Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Problem with data binding in Grid class
Message
De
26/02/2013 13:38:37
Alp Berker
Defense Finance and Accounting Services
Indianapolis, Indiana, États-Unis
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Programmation Orientée Object
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01566955
Message ID:
01566962
Vues:
52
Sure, here is the code
Define Class UIController As Custom
   Add Object ReportCollection As Collection
   oForm = ""
   Descriptn = .F.

   Procedure Init()
      This.ReportCollection.Add(Createobject('AgingReport'), 'AgingReport')
      This.ReportCollection.Add(Createobject('CollDisb'), 'CollDisb')
      This.ReportCollection.Add(Createobject('NetDisbursement'), 'NetDisbursement')
      This.ReportCollection.Add(Createobject('TransactionLayer'), 'TransactionLayer')
   Endproc

   Procedure setFormRef(oForm)
*      oForm.AddObject('grdDetail', 'grdDetail')
      This.oForm = oForm
   Endproc

   Procedure BuildGrid()
      This.oForm.grdDetail.BuildGrid(This.oForm)
      This.oForm.grdDetail.Refresh
   Endproc
EndDefine

Define Class DetailColumn As Column
   Service = ""
   HdrText = ""
   strArmy = "Service = 'ARMY'"
   strTreas = "Service = 'TREA'"
   strTotal = "Service = 'Total'"
   strNavy = "Service = 'NAVY'"
   strUSAF = "Service = 'USAF'"
   strOSD = "Service = 'OSD'"
   intCol = 0
   Alignment = 6

   Procedure Init(intNumber)
      With This
         .intCol = intNumber
         .Header1.Caption = Iif(.intCol = 1, "Reporting"  + Chr(13) + Chr(10) + "ALC", ;
            IIF(.intCol = 2, "Treasury"  + Chr(13) + Chr(10) + Chr(40)+ "GWA" + Chr(41), ;
            IIF(.intCol = 3, "Month Year", Iif(intCol = 4, "Aging" + Chr(13) + Chr(10) + "Days", ;
            IIF(.intCol = 5, "Limit", Iif(intCol = 6, "Status", Iif(intCol = 7, "Description", ;
            IIF(.intCol = 8, "Point of Contact", Iif(.intCol = 9, "Contact" + Chr(13) + Chr(10) + "Date", "Action Taken")))))))))
         .Header1.Refresh
      Endwith
   Endproc
   Procedure setAlignment()
      This.Alignment = Iif(This.intCol = 2, 1, 9)
   Endproc

   Procedure setWidth()
      With This
         .Width = Iif(Inlist(.intCol, 4, 5, 6),75, Iif(Inlist(.intCol, 7), 65, Iif(.intCol = 1, 100, Iif(.intCol = 2, 125, Iif(.intCol <> 8, 100, 175)))))
      Endwith
   Endproc

   Procedure setName(strRecordSource)
      This.Name = Field(This.intCol, strRecordSource)
   Endproc

   Procedure SetDynamicBackColor()
      This.DynamicBackColor = "Iif(&this.strArmy, Rgb(0,128,128), Iif(&this.strNavy, Rgb(0,64,128), ;
         Iif(&this.strUSAF, Rgb(0,128,255), Iif(&this.strTreas, Rgb(0,128,64), Iif(&this.strOSD, ;
         Rgb(222,254,180), Rgb(255,255,255))))))"
   Endproc

   Procedure SetDynamicForeColor()
      This.DynamicForeColor = "Iif(&this.strArmy, Rgb(255,255,0), Iif(InList(Service, 'NAVY', 'USAF'), ;
         Rgb(255,255,255), Iif(&this.strTreas, Rgb(255,254,230), Rgb(0,0,0))))"
   Endproc

   Procedure settextFormat(strFormat)
      This.text1.Format = strFormat
   Endproc

   Procedure setEnabled(blnEnabled)
      This.Enabled = blnEnabled
   Endproc

   Procedure SetControlEnabled(blnEnabled)
      With This
         mobjCurrentControl = '.' + .CurrentControl + '.Enabled'
         &mobjCurrentControl = blnEnabled
      Endwith
   Endproc

   Procedure SetBackgroundAttributes()
      With This
         mobjDisabledBackColor = '.' + .CurrentControl + '.DisabledBackColor'
         mobjBackColor = '.' + .CurrentControl + '.BackColor'
         Store Iif(&.strArmy, Rgb(0,128,128), Iif(&.strNavy, Rgb(0,64,128), Iif(&.strUSAF, Rgb(0,128,255), Iif(&.strTreas, Rgb(0,128,64), ;
            Iif(&.strOSD, Rgb(222,254,180), Rgb(255,255,255)))))) To &mobjDisabledBackColor, &mobjBackColor
      Endwith
   Endproc

   Procedure SetForegroundAttributes()
      With This
         mobjDisabledForeColor = '.' + .CurrentControl + '.DisabledForeColor'
         mobjForeColor = '.' + .CurrentControl + '.ForeColor'
         Store Iif(&.strArmy, Rgb(255,255,0), Iif(Inlist(Service, 'NAVY', 'USAF'), Rgb(255,255,255), Iif(&.strTreas, Rgb(255,254,230), Rgb(0,0,0)))) ;
            To &mobjDisabledForeColor, &mobjForeColor
      Endwith
   Endproc

   Procedure AddObject2Column()
      With This
         Do Case
            Case .intCol = 6
               If Type('oCol.cmbActive') <> 'O'
                  .AddObject("cmbActive", "COMBOBOX")
               Endif
               .CurrentControl = "cmbActive"
               .ControlSource = "dtlRecon1.ActiveVar"
               .cmbActive.RowSource = "ThisForm.cntRecon"
               .cmbActive.RowSourceType = 10
            Case .intCol = 1
               If Type('oCol.cmbService') <> 'O'
                  .AddObject("cmbService", "COMBOBOX")
               Endif
               .CurrentControl = "cmbService"
               .ControlSource = "dtlRecon1.Service"
               .cmbService.RowSource = "ServiceTypes.Service"
               .cmbService.RowSourceType = 6
            Case Inlist(.intCol, 3, 9)
               If Type('oCol.dtpPicker') <> 'O'
                  .AddObject('dtpPicker', Iif(intCol = 3, 'dtPicker', 'dtPickerCT'), 'MSComCtl2.DTPicker.2')
               Endif
               Store .F. To .dtpPicker.Visible, .dtpPicker.Enabled
               .CurrentControl = "Text1"
            Case .intCol = 2
*               .text1.Format = "@RK"
               .text1.InputMask = "$$$,$$$,$$$,999,999.99"
            Case intCol = 10
               .text1.ToolTipText = Alltrim(dtlRecon1.ActnTkn)
            Case intCol = 7
               .text1.ToolTipText = Alltrim(dtlRecon1.Descriptn)
         Endcase
         mobjBackStyle = '.' + oCol.CurrentControl + '.backstyle'
         mobjBorderStyle = '.' + oCol.CurrentControl + '.borderstyle'
         mobjName = '.' + oCol.CurrentControl + '.name'
         If Lower(&mobjName) = "cmb"
            Store 0 To &mobjBorderStyle
            *&mobjBackStyle
         Endif
      Endwith
   Endproc
Enddefine

Define Class grdDetail As Grid
   ColumnCount = 0
   DeleteMark = .F.
   Height = 348
   HighlightRow = .F.
   Left = 5
   RecordMark = .T.
   RecordSource = "dtlRecon1"
   RecordSourceType = 1
   Top = 254
   Width = 1009
   Name = "grdDetail"
   Visible = .T.

   Procedure Init()
      For intCol = 1 To 10
         This.AddObject('Column' + Alltrim(Str(intCol)), 'DetailColumn', intCol)
      Endfor
   Endproc

   Procedure BuildGrid(oForm)
*   SET STEP ON
      This.ColumnCount = 0
      For intCol = 1 To 10
         This.AddObject('Column' + Alltrim(Str(intCol)), 'DetailColumn', intCol)
      Endfor

      For Each oCol In This.Columns
         oCol.setAlignment()
         oCol.setWidth()
         oCol.setName(This.RecordSource)
         oCol.settextFormat("@KR!")
         oCol.setEnabled(oForm.Editing Or oForm.Adding)
         oCol.AddObject2Column()
         oCol.SetBackgroundAttributes()
         oCol.SetForegroundAttributes()
         oCol.SetControlEnabled(oForm.Editing Or oForm.Adding)
         oCol.SetDynamicBackColor()
         oCol.SetDynamicForeColor()
         oCol.Sparse = .F.
         oCol.Visible = .T.
      Endfor
   Endproc

Enddefine
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform