home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.visual.basic      MS Visual Basic discussions, NOT dot-net      10,840 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 9,575 of 10,840   
   Jew to Iain Bishop   
   Re: Object Model Problem (1/2)   
   21 Jun 05 00:00:56   
   
   From: jet@aloha.net   
      
   On Mon, 02 May 2005 23:30:25 GMT, "Iain Bishop"  wrote:   
      
   >I'm trying to model objects for the following problem:   
   >   
   >A building site contains assemblies, each of which can contain other   
   >assemblies and/or materials.   
   >   
   >I have modelled this using a Site class, Assembly class, and Material class   
   >as follows...   
   >   
   >Site Class (clsSite):   
   >Option Explicit   
   >'General Details   
   >Public ProjectNumber As String   
   >Public SiteWBSCode As String   
   >Public SiteType As String   
   >Public LastUpdateFirstName As String   
   >Public LastUpdateSurname As String   
   >Public LastUpdateDate As Date   
   >Public TotalPriceOfAllMaterials As Double   
   >Public GeneralNotes As String   
   >'Contents of Site   
   >Public SiteAssemblies As clsAssemblies 'a collection class of clsAssembly   
   >Public SiteMaterials As clsMaterials 'a collection class of clsMaterial   
   >   
   >Assembly Class (clsAssembly):   
   >Option Explicit   
   >'General Details   
   >Public ID As Long   
   >Public QuantityRequested As Integer   
   >Public QuantityIssued As Integer   
   >'Contents   
   >Public AssemblyAssemblies As clsAssemblies 'a collection class of   
   >clsAssembly   
   >Public AssemblyMaterials As clsMaterials 'a collection class of clsMaterial   
   >   
   >Material Class (clsMaterial)   
   >Option Explicit   
   >'General Details   
   >Public InventoryCode As String   
   >Public Rate As Double   
   >Public QuantityRequested As Integer   
   >Public QuantityIssued As Integer   
   >Public TotalPrice As Double   
   >Public DateAmended As Date   
   >   
   >My questions are:   
   >1. Have I modelled the problem correctly?   
      
   The replies you receievd so far sound very good. An exploded Bill   
   Of Material / Product Structure generally has the financial standard   
   costs and labor hours regenerated at the end of every month, so I   
   see no reason why you cannot save some CPU time by *NOT* making your   
   subtotals methods instead of properties: the End Of Month Closing   
   routines will perform all the necessary calculations and update the   
   properties.   
      
   For example: the PRMS mid-frame application that runs on the AS/400   
   has standard labor, standard labor costs, material costs, and the   
   like as properties (values). At the end of every financial month the   
   Month End Close / Cost Build programs are run, and new values for   
   components and sub-assemblies are generated. This generally means   
   the financial module includes in the database the next/future costing   
   values, and historical values. The database also contains actual labor   
   hours, actual labor costs, actual material costs, etc., so that one   
   may forecast future costs.   
      
   > 2. There is the potential for an infinite hierarchy of Assemblies -   
   > is this ok?   
      
   Infinite is bad; finite is good. :-)   
      
   You must add a check that looks to see if an assembly's newly-added   
   component part is not the assembly itself, and (if the component   
   is a sub-assembly) check to see if any of the newly-added component   
   parts include the parent part. This is actually very easy to do.   
      
   A section of code from my Product Structure modual (changing my   
   news reader's word-wrap to 700 characters):   
      
   Private Sub txtParent_LostFocus()   
       Dim FindPN As String, sSQL As String, nodX As Node, TheDesc As String,   
   TheUM As String   
      
       FindPN = UCase$(Trim(txtParent.Text))   
       txtParent.Text = FindPN: ' A fuction that looks at the Product Master to   
   see if a part number exists   
      
       If FindPN = "" Then Exit Sub   
      
       MousePointer = 11   
       DoEvents   
      
       Dim de As Boolean   
       If ServerLocation = "" Then   
           de = DoesPNExist(FindPN, TheDesc, TheUM)   
       Else   
           de = DF.DoesPNExist(FindPN, TheDesc, TheUM): '   Internet server, use   
   Business Object   
       End If   
      
       If de = True Then   
           lblDesc.Caption = TheDesc   
      
           TreeView1.Nodes.Clear   
           Set nodX = TreeView1.Nodes.Add()   
           nodX.Expanded = True   
           nodX.Text = FindPN   
           nodX.Image = 1   
           nodX.SelectedImage = 3   
           nodX.Key = FindPN   
           nodX.Tag = 0   
           List1.AddItem nodX.Text   
           List2.AddItem nodX.Text   
      
           If ServerLocation = "" Then   
               Set Adodc1.Recordset = GetSMP("SELECT * FROM ProductStructure   
   WHERE Parent = '" & FindPN & "';")   
           Else   
               Set Adodc1.Recordset = DF.GetSMP("SELECT * FROM ProductStructure   
   WHERE Parent = '" & FindPN & "';"): '   database is on web server   
           End If   
      
           Do Until Adodc1.Recordset.EOF   
               Set nodX = TreeView1.Nodes.Add(1, tvwChild)   
               nodX.Text = Adodc1.Recordset!Child   
               nodX.Image = 2   
               nodX.Key = Adodc1.Recordset!Child   
               nodX.Parent = Adodc1.Recordset!Parent   
               nodX.SelectedImage = 3   
               nodX.Tag = 1   
               List1.AddItem "   " & nodX.Text   
               List2.AddItem "SELECT * FROM ProductStructure WHERE Parent = '" &   
   FindPN & "' AND Child = '" & nodX.Text & "';"   
               Adodc1.Recordset.MoveNext   
           Loop   
           DoEvents   
           PopulateSubAssemblies   
       Else   
           lblDesc.Caption = "The parent assembly does not exist in the product   
   master."   
       End If   
       MousePointer = 0   
       DoEvents   
   End Sub   
      
   Private Sub PopulateSubAssemblies()   
       Dim nodX As Node, Child As String, Parent As String, Level As Long   
       Dim LookIndex As Long, LastKey As String, tl As Long, i As Long   
       Dim lBox As Long   
      
       LookIndex = 1   
      
       Do   
           LookIndex = LookIndex + 1   
           Parent = TreeView1.Nodes(LookIndex).Text   
           Level = TreeView1.Nodes(LookIndex).Tag   
           For i = 0 To List1.ListCount - 1   
               If Trim(List1.List(i)) = Parent Then   
                   lBox = i   
                   Exit For   
               End If   
           Next   
      
           If ServerLocation = "" Then   
               Set Adodc1.Recordset = GetSMP("SELECT * FROM ProductStructure   
   WHERE Parent = '" & Parent & "' ORDER BY Child;")   
           Else   
               Set Adodc1.Recordset = DF.GetSMP("SELECT * FROM ProductStructure   
   WHERE Parent = '" & Parent & "' ORDER BY Child;"): '    SMPBO   
           End If   
      
           If Adodc1.Recordset.EOF = False Then   
      
               TreeView1.Nodes(LookIndex).Image = 1   
               TreeView1.Nodes(LookIndex).Expanded = True   
      
               Adodc1.Recordset.MoveFirst   
      
               Do While Adodc1.Recordset.EOF = False   
                   Child = Adodc1.Recordset!Child   
                   Set nodX = TreeView1.Nodes.Add(Parent, tvwChild, , Child, 2, 3)   
                   nodX.Tag = Level + 1   
                   List1.AddItem String$((Level + 1) * 3, " ") & nodX.Text, lBox   
   + 1   
                   List2.AddItem "SELECT * FROM ProductStructure WHERE Parent =   
   '" & Parent & "' AND Child = '" & nodX.Text & "';", lBox + 1   
      
                   Adodc1.Recordset.MoveNext   
               Loop   
           End If   
           If LookIndex = TreeView1.Nodes.Count Then Exit Do   
       Loop   
       btnReport.Enabled = True   
   End Sub   
      
   What my program does is first check to see if the database is   
   local, or if it is on a web server. It then checks to see if   
   the part number is in the Product Master; if it is, it checks   
   to see if it is an assembly: if it is not in the Product Structure,   
   it is assumed to be a component and not an assembly.   
      
   If the part number is in the Product Structure, it is an assembly.   
      
   [continued in next message]   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca