if not file('IndesignMode')
   msgbox('Run ContaX.prg to start this application!')
   return

endif

SET CuaEnter OFF

EXTERN CINT LockWindowUpdate(CINT) user32
EXTERN CINT UpdateWindow(CINT) user32

shell(false)
** END HEADER -- do not remove this line
//
// Generated on 02/04/2000
//
parameter bModal
local f
f = new SchedulerForm()
if (bModal)
   f.mdi = false // ensure not MDI
   f.readModal()
else
   f.open()
endif

class SchedulerForm of FORM
   set procedure to TOGGLEBUTTON.CC additive
   set procedure to sched.dmd additive
   set procedure to :FormControls:calendar.cc additive
   set procedure to SCHEDULECOLUMN.CC additive
   with (this)
      canClose = class::FORM_CANCLOSE
      open = class::FORM_OPEN
      readModal = class::FORM_READMODAL
      metric = 6	// Pixels
      height = 535
      left = 0
      top = 0
      width = 796
      text = "ContaX Calendar"
      background = "filename :Images:CtxBackground.GIF"
      mdi = false
      menuFile = "Scheduler.mnu"
   endwith


   this.DATAMOD1 = new SCHEDDATAMODULE()
   this.DATAMOD1.parent = this
   with (this.DATAMOD1)
      left = 412
      top = -11
   endwith


   this.IMAGE3 = new IMAGE(this)
   with (this.IMAGE3)
      height = 217
      left = 207
      top = 281
      width = 578
      borderStyle = 2	// Lowered
   endwith


   this.IMAGE2 = new IMAGE(this)
   with (this.IMAGE2)
      height = 217
      left = 10
      top = 281
      width = 190
      borderStyle = 2	// Lowered
   endwith


   this.NOTEBOOK1 = new NOTEBOOK(this)
   with (this.NOTEBOOK1)
      canSelChange = class::NOTEBOOK1_CANSELCHANGE
      height = 264
      left = 10
      top = 10
      width = 777
      fontSize = 9
      dataSource = 'ARRAY {"Office View","Personal View"}'
   endwith


   this.NOTEBOOK1.EMPLOYEENAMEFIELD = new ENTRYFIELD(this.NOTEBOOK1)
   with (this.NOTEBOOK1.EMPLOYEENAMEFIELD)
      when = {||False}
      height = 15
      left = 508
      top = 3
      width = 184
      function = "J"
      colorNormal = "gray/silver"
      tabStop = false
      fontSize = 9
      value = "Entryfield1"
      pageno = 2
      borderStyle = 3	// None
   endwith


   this.NOTEBOOK1.TEXT1 = new TEXT(this.NOTEBOOK1)
   with (this.NOTEBOOK1.TEXT1)
      height = 20
      left = 8
      top = 31
      width = 57
      colorNormal = "black/silver"
      alignVertical = 1	// Middle
      alignHorizontal = 1	// Center
      fontSize = 8
      text = "Employee  "
      borderStyle = 1	// Raised
   endwith


   this.NOTEBOOK1.SCHEDCOL1 = new SCHEDCOL(this.NOTEBOOK1)
   with (this.NOTEBOOK1.SCHEDCOL1)
      left = 73
      top = 29
   endwith


   this.NOTEBOOK1.SCHEDCOL2 = new SCHEDCOL(this.NOTEBOOK1)
   with (this.NOTEBOOK1.SCHEDCOL2)
      left = 297
      top = 29
   endwith

   this.NOTEBOOK1.SCHEDCOL3 = new SCHEDCOL(this.NOTEBOOK1)
   with (this.NOTEBOOK1.SCHEDCOL3)
      left = 521
      top = 29
   endwith

   this.NOTEBOOK1.GRID2 = new GRID(this.NOTEBOOK1)
   with (this.NOTEBOOK1.GRID2)
      dataLink = form.datamod1.appoints1.rowset
      columns["COLUMN1"] = new GRIDCOLUMN(form.NOTEBOOK1.GRID2)
      columns["COLUMN1"].dataLink = form.datamod1.appoints1.rowset.fields["time"]
      columns["COLUMN1"].editorType = 1	// EntryField
      columns["COLUMN1"].width = 50
      columns["COLUMN2"] = new GRIDCOLUMN(form.NOTEBOOK1.GRID2)
      columns["COLUMN2"].dataLink = form.datamod1.appoints1.rowset.fields["type"]
      columns["COLUMN2"].editorType = 1	// EntryField
      columns["COLUMN2"].width = 70
      columns["COLUMN3"] = new GRIDCOLUMN(form.NOTEBOOK1.GRID2)
      columns["COLUMN3"].dataLink = form.datamod1.appoints1.rowset.fields["units"]
      columns["COLUMN3"].editorType = 3	// SpinBox
      columns["COLUMN3"].width = 40
      columns["COLUMN4"] = new GRIDCOLUMN(form.NOTEBOOK1.GRID2)
      columns["COLUMN4"].dataLink = form.datamod1.appoints1.rowset.fields["with whom"]
      columns["COLUMN4"].editorType = 1	// EntryField
      columns["COLUMN4"].width = 200
      columns["COLUMN5"] = new GRIDCOLUMN(form.NOTEBOOK1.GRID2)
      columns["COLUMN5"].dataLink = form.datamod1.appoints1.rowset.fields["where"]
      columns["COLUMN5"].editorType = 1	// EntryField
      columns["COLUMN5"].width = 200
      columns["COLUMN6"] = new GRIDCOLUMN(form.NOTEBOOK1.GRID2)
      columns["COLUMN6"].dataLink = form.datamod1.appoints1.rowset.fields["employee"]
      columns["COLUMN6"].editorType = 1	// EntryField
      columns["COLUMN6"].width = 200

      with (columns["COLUMN1"].editorControl)
         colorNormal = "white/gray"
         fontSize = 9
      endwith


      with (columns["COLUMN1"].headingControl)
         fontSize = 9
         fontBold = false
         value = "time"
      endwith


      with (columns["COLUMN2"].editorControl)
         fontSize = 9
      endwith


      with (columns["COLUMN2"].headingControl)
         fontSize = 9
         fontBold = false
         value = "type"
      endwith


      with (columns["COLUMN3"].editorControl)
         rangeMax = 100
         rangeMin = 1
      endwith


      with (columns["COLUMN3"].headingControl)
         fontSize = 9
         fontBold = false
         value = "Units"
      endwith


      with (columns["COLUMN4"].editorControl)
         fontSize = 9
      endwith


      with (columns["COLUMN4"].headingControl)
         fontSize = 9
         fontBold = false
         value = "With Whom"
      endwith


      with (columns["COLUMN5"].editorControl)
         fontSize = 9
      endwith


      with (columns["COLUMN5"].headingControl)
         fontSize = 9
         fontBold = false
         value = "Where"
      endwith


      with (columns["COLUMN6"].editorControl)
         fontSize = 9
      endwith


      with (columns["COLUMN6"].headingControl)
         fontSize = 9
         fontBold = false
         value = "You"
      endwith


      bgColor = "white"
      cellHeight = 18
      hasVScrollHintText = false
      allowEditing = false
      allowAddRows = false
      pageno = 2
      height = 219
      left = 9
      top = 33
      width = 752
   endwith


   this.NOTEBOOK1.DATEFIELD = new ENTRYFIELD(this.NOTEBOOK1)
   with (this.NOTEBOOK1.DATEFIELD)
      when = {||False}
      height = 15
      left = 705
      top = 3
      width = 69
      picture = "99/99/9999"
      function = "D"
      colorNormal = "gray/silver"
      tabStop = false
      fontSize = 9
      value = {  /  /    }
      maxLength = 10
      pageno = 2
      borderStyle = 3	// None
   endwith


   this.NOTEBOOK1.TIMEGRID = new GRID(this.NOTEBOOK1)
   with (this.NOTEBOOK1.TIMEGRID)
      onOpen = {;form.datamod1.schedtemp1.rowset.first()}
      dataLink = form.datamod1.schedtemp1.rowset
      columns["COLUMN1"] = new GRIDCOLUMN(form.NOTEBOOK1.TIMEGRID)
      columns["COLUMN1"].dataLink = form.datamod1.schedtemp1.rowset.fields["time"]
      columns["COLUMN1"].editorType = 1	// EntryField
      columns["COLUMN1"].width = 70

      with (columns["COLUMN1"].editorControl)
         colorNormal = "white/gray"
         fontSize = 8
      endwith


      with (columns["COLUMN1"].headingControl)
         fontSize = 8
         fontBold = false
         value = "Time"
      endwith


      bgColor = "gray"
      cellHeight = 17
      hasIndicator = false
      hasVScrollHintText = false
      rowSelect = true
      allowEditing = false
      allowAddRows = false
      hScrollBar = 0	// Off
      vScrollBar = 0	// Off
      enabled = false
      borderStyle = 2	// Lowered
      height = 183
      left = 8
      top = 71
      width = 57
   endwith


   this.NOTEBOOK1.UPONEPAGEARROW = new PUSHBUTTON(this.NOTEBOOK1)
   with (this.NOTEBOOK1.UPONEPAGEARROW)
      onClick = class::UPONEPAGEARROW_ONCLICK
      height = 62
      left = 742
      top = 98
      width = 23
      text = ""
      upBitmap = "FILENAME :Images:uparrow.gif"
   endwith


   this.NOTEBOOK1.DOWNONEPAGEARROW = new PUSHBUTTON(this.NOTEBOOK1)
   with (this.NOTEBOOK1.DOWNONEPAGEARROW)
      onClick = class::DOWNONEPAGEARROW_ONCLICK
      height = 62
      left = 742
      top = 163
      width = 23
      text = ""
      upBitmap = "FILENAME :Images:downarrow.gif"
   endwith


   this.NOTEBOOK1.UPONEARROW = new PUSHBUTTON(this.NOTEBOOK1)
   with (this.NOTEBOOK1.UPONEARROW)
      onClick = class::UPONEARROW_ONCLICK
      height = 24
      left = 742
      top = 72
      width = 23
      text = ""
      upBitmap = "FILENAME :Images:uparrow.gif"
   endwith


   this.NOTEBOOK1.DOWNONEARROW = new PUSHBUTTON(this.NOTEBOOK1)
   with (this.NOTEBOOK1.DOWNONEARROW)
      onClick = class::DOWNONEARROW_ONCLICK
      height = 24
      left = 742
      top = 228
      width = 23
      text = ""
      upBitmap = "FILENAME :Images:downarrow.gif"
   endwith


   this.TEXTTIME1 = new TEXT(this)
   with (this.TEXTTIME1)
      height = 19
      left = 219
      top = 319
      width = 29
      colorNormal = "black/silver"
      transparent = true
      fontSize = 9
      text = "Time"
   endwith


   this.TEXTDATE1 = new TEXT(this)
   with (this.TEXTDATE1)
      height = 14
      left = 219
      top = 296
      width = 51
      colorNormal = "black/silver"
      transparent = true
      fontSize = 9
      text = "Date"
   endwith


   this.TEXTSALESPERSON1 = new TEXT(this)
   with (this.TEXTSALESPERSON1)
      height = 22
      left = 219
      top = 341
      width = 71
      colorNormal = "black/silver"
      transparent = true
      fontSize = 9
      text = "You"
   endwith


   this.TEXTDESCRIP1 = new TEXT(this)
   with (this.TEXTDESCRIP1)
      height = 14
      left = 219
      top = 409
      width = 70
      colorNormal = "black/silver"
      transparent = true
      fontSize = 9
      text = "Description"
   endwith


   this.DATEFIELD = new SPINBOX(this)
   with (this.DATEFIELD)
      dataLink = form.datamod1.appoints1.rowset.fields["date"]
      height = 18
      left = 290
      top = 295
      width = 94
      colorHighLight = "black/0xc2e7f8"
      rangeMax = {05/08/2000}
      rangeMin = {01/29/2000}
      fontSize = 9
   endwith


   this.TIMEFIELD = new HICOMBO(this)
   with (this.TIMEFIELD)
      dataLink = form.datamod1.appoints1.rowset.fields["time"]
      height = 20
      left = 290
      top = 316
      width = 74
      fontSize = 9
      dataSource = form.datamod1.timelookup1.rowset.fields["time"]
      style = 1	// DropDown
      dropDownHeight = 132
   endwith


   this.UNITSFIELD = new SPINBOX(this)
   with (this.UNITSFIELD)
      dataLink = form.datamod1.appoints1.rowset.fields["units"]
      height = 18
      left = 406
      top = 317
      width = 48
      colorHighLight = "black/0xc2e7f8"
      rangeMax = 100
      rangeMin = 1
      fontSize = 9
      rangeRequired = true
   endwith


   this.EMPLOYEECOMBO = new HICOMBO(this)
   with (this.EMPLOYEECOMBO)
      dataLink = form.datamod1.appoints1.rowset.fields["employee"]
      height = 20
      left = 290
      top = 338
      width = 207
      fontSize = 9
      dataSource = form.datamod1.employees1.rowset.fields["name"]
      style = 1	// DropDown
      dropDownHeight = 132
   endwith


   this.WHEREFIELD = new ENTRYFIELD(this)
   with (this.WHEREFIELD)
      dataLink = form.datamod1.appoints1.rowset.fields["where"]
      height = 19
      left = 290
      top = 361
      width = 225
      colorNormal = "black/white"
      colorHighLight = "black/0xc2e7f8"
      fontSize = 9
      borderStyle = 7	// Client
   endwith


   this.WITHWHOMFIELD = new ENTRYFIELD(this)
   with (this.WITHWHOMFIELD)
      dataLink = form.datamod1.appoints1.rowset.fields["with whom"]
      height = 19
      left = 290
      top = 384
      width = 225
      colorNormal = "black/white"
      colorHighLight = "black/0xc2e7f8"
      fontSize = 9
      borderStyle = 7	// Client
   endwith


   this.EDITORDESCRIP1 = new HIEDITOR(this)
   with (this.EDITORDESCRIP1)
      height = 84
      left = 289
      top = 406
      width = 228
      colorNormal = "black/white"
      fontSize = 9
      dataLink = form.datamod1.appoints1.rowset.fields["descrip"]
   endwith


   this.FIRSTNAMEFIELD = new ENTRYFIELD(this)
   with (this.FIRSTNAMEFIELD)
      when = {||false}
      dataLink = form.datamod1.contacts1.rowset.fields["firstname"]
      height = 18
      left = 575
      top = 301
      width = 77
      colorNormal = "0x5d5d5d/0xe0e0e0"
      colorHighLight = "black/0xc2e7f8"
      fontSize = 9
      borderStyle = 7	// Client
   endwith


   this.COMPANYFIELD = new ENTRYFIELD(this)
   with (this.COMPANYFIELD)
      when = {||false}
      dataLink = form.datamod1.contacts1.rowset.fields["company"]
      height = 18
      left = 575
      top = 330
      width = 199
      colorNormal = "0x5d5d5d/0xe0e0e0"
      colorHighLight = "black/0xc2e7f8"
      fontSize = 9
      borderStyle = 7	// Client
   endwith


   this.STREETADDRESSFIELD = new ENTRYFIELD(this)
   with (this.STREETADDRESSFIELD)
      when = {||false}
      dataLink = form.datamod1.contacts1.rowset.fields["address1"]
      height = 18
      left = 575
      top = 360
      width = 199
      colorNormal = "0x5d5d5d/0xe0e0e0"
      colorHighLight = "black/0xc2e7f8"
      fontSize = 9
      borderStyle = 7	// Client
   endwith


   this.ENTRYFIELD11 = new ENTRYFIELD(this)
   with (this.ENTRYFIELD11)
      when = {||False}
      dataLink = form.datamod1.contacts1.rowset.fields["state"]
      height = 18
      left = 677
      top = 390
      width = 24
      colorNormal = "0x5d5d5d/0xe0e0e0"
      colorHighLight = "black/0xc2e7f8"
      fontSize = 9
      borderStyle = 7	// Client
   endwith


   this.ENTRYFIELD12 = new ENTRYFIELD(this)
   with (this.ENTRYFIELD12)
      when = {||false}
      dataLink = form.datamod1.contacts1.rowset.fields["zip"]
      height = 18
      left = 707
      top = 390
      width = 67
      colorNormal = "0x5d5d5d/0xe0e0e0"
      colorHighLight = "black/0xc2e7f8"
      fontSize = 9
      borderStyle = 7	// Client
   endwith


   this.ENTRYFIELD13 = new ENTRYFIELD(this)
   with (this.ENTRYFIELD13)
      when = {||False}
      dataLink = form.datamod1.contacts1.rowset.fields["email"]
      height = 18
      left = 575
      top = 420
      width = 201
      colorNormal = "0x5d5d5d/0xe0e0e0"
      colorHighLight = "black/0xc2e7f8"
      fontSize = 9
      borderStyle = 7	// Client
   endwith


   this.ENTRYFIELD2 = new ENTRYFIELD(this)
   with (this.ENTRYFIELD2)
      when = {||false}
      dataLink = form.datamod1.contacts1.rowset.fields["phone1"]
      height = 18
      left = 646
      top = 450
      width = 83
      picture = "999-999-9999"
      function = "@R"
      colorNormal = "0x5d5d5d/0xe0e0e0"
      colorHighLight = "black/0xc2e7f8"
      fontSize = 9
   endwith


   this.ENTRYFIELD3 = new ENTRYFIELD(this)
   with (this.ENTRYFIELD3)
      when = {||false}
      dataLink = form.datamod1.contacts1.rowset.fields["phone2"]
      height = 18
      left = 646
      top = 470
      width = 83
      picture = "999-999-9999"
      function = "@R"
      colorNormal = "0x5d5d5d/0xe0e0e0"
      colorHighLight = "black/0xc2e7f8"
      fontSize = 9
   endwith


   this.ADDADDRESSBUTTON = new PUSHBUTTON(this)
   with (this.ADDADDRESSBUTTON)
      onClick = class::ADDADDRESSBUTTON_ONCLICK
      height = 40
      left = 734
      top = 449
      width = 43
      text = ""
      upBitmap = "filename :Images:Addressb.bmp"
      fontSize = 9
   endwith


   this.LASTNAMEFIELD = new ENTRYFIELD(this)
   with (this.LASTNAMEFIELD)
      when = {||False}
      dataLink = form.datamod1.contacts1.rowset.fields["lastname"]
      height = 18
      left = 660
      top = 301
      width = 115
      colorNormal = "0x5d5d5d/0xe0e0e0"
      colorHighLight = "black/0xc2e7f8"
      fontSize = 9
      borderStyle = 7	// Client
   endwith


   this.TEXT1 = new TEXT(this)
   with (this.TEXT1)
      height = 13
      left = 578
      top = 288
      width = 85
      colorNormal = "gray/silver"
      transparent = true
      fontSize = 8
      text = "Name (first, last)"
   endwith


   this.ENTRYFIELD6 = new ENTRYFIELD(this)
   with (this.ENTRYFIELD6)
      when = {||False}
      dataLink = form.datamod1.contacts1.rowset.fields["city"]
      height = 18
      left = 575
      top = 390
      width = 95
      colorNormal = "0x5d5d5d/0xe0e0e0"
      colorHighLight = "black/0xc2e7f8"
      fontSize = 9
      borderStyle = 7	// Client
   endwith


   this.TEXT7 = new TEXT(this)
   with (this.TEXT7)
      height = 13
      left = 578
      top = 317
      width = 85
      colorNormal = "gray/silver"
      transparent = true
      fontSize = 8
      text = "Company"
   endwith


   this.TEXT2 = new TEXT(this)
   with (this.TEXT2)
      height = 13
      left = 578
      top = 347
      width = 85
      colorNormal = "gray/silver"
      transparent = true
      fontSize = 8
      text = "Street Address"
   endwith


   this.CALENDAR1 = new CALENDAR(this)
   with (this.CALENDAR1)
      left = 19
      top = 291
      width = 176
      height = 158
   endwith

   this.TEXT5 = new TEXT(this)
   with (this.TEXT5)
      height = 13
      left = 578
      top = 377
      width = 85
      colorNormal = "gray/silver"
      transparent = true
      fontSize = 8
      text = "City, State, Zip"
   endwith


   this.TEXT3 = new TEXT(this)
   with (this.TEXT3)
      height = 18
      left = 219
      top = 363
      width = 51
      colorNormal = "black/silver"
      transparent = true
      fontSize = 9
      text = "Where"
   endwith


   this.TEXT6 = new TEXT(this)
   with (this.TEXT6)
      height = 13
      left = 579
      top = 407
      width = 85
      colorNormal = "gray/silver"
      transparent = true
      fontSize = 8
      text = "eMail"
   endwith


   this.TEXT4 = new TEXT(this)
   with (this.TEXT4)
      height = 15
      left = 219
      top = 386
      width = 69
      colorNormal = "black/silver"
      transparent = true
      fontSize = 9
      text = "With Whom"
   endwith


   this.TEXT8 = new TEXT(this)
   with (this.TEXT8)
      height = 11
      left = 579
      top = 437
      width = 85
      colorNormal = "gray/silver"
      transparent = true
      fontSize = 8
      text = "Phones"
   endwith


   this.IMAGE1 = new IMAGE(this)
   with (this.IMAGE1)
      height = 27
      left = 47
      top = 456
      width = 110
      dataSource = "FILENAME LogoOnlySm.gif"
      alignment = 4	// True Size
      borderStyle = 3	// None
   endwith


   this.TOGGLEBUTTONS1 = new TOGGLEBUTTONS(this)
   with (this.TOGGLEBUTTONS1)
      left = 525
      top = 291
      width = 44
      height = 200
   endwith

   this.TEXT9 = new TEXT(this)
   with (this.TEXT9)
      height = 19
      left = 370
      top = 319
      width = 35
      colorNormal = "black/silver"
      transparent = true
      fontSize = 9
      text = "Units"
   endwith


   this.INTERVALTEXT = new TEXT(this)
   with (this.INTERVALTEXT)
      height = 19
      left = 460
      top = 319
      width = 61
      colorNormal = "black/silver"
      transparent = true
      fontSize = 9
      text = "( 15 mins)"
   endwith


   this.TASKTYPEFIELD = new ENTRYFIELD(this)
   with (this.TASKTYPEFIELD)
      dataLink = form.datamod1.appoints1.rowset.fields["type"]
      visible = false
      enabled = false
      height = 22
      left = 298
      top = 506
      width = 56
   endwith


   this.ENTRYFIELD1 = new ENTRYFIELD(this)
   with (this.ENTRYFIELD1)
      when = {||false}
      dataLink = form.datamod1.contacts1.rowset.fields["phone1type"]
      height = 18
      left = 575
      top = 450
      width = 63
      colorNormal = "0x5d5d5d/0xe0e0e0"
      colorHighLight = "black/0xc2e7f8"
      fontSize = 9
      borderStyle = 7	// Client
   endwith


   this.ENTRYFIELD4 = new ENTRYFIELD(this)
   with (this.ENTRYFIELD4)
      when = {||false}
      dataLink = form.datamod1.contacts1.rowset.fields["phone2type"]
      height = 18
      left = 575
      top = 470
      width = 63
      colorNormal = "0x5d5d5d/0xe0e0e0"
      colorHighLight = "black/0xc2e7f8"
      fontSize = 9
      borderStyle = 7	// Client
   endwith


   this.CONTACTKEYFIELD = new ENTRYFIELD(this)
   with (this.CONTACTKEYFIELD)
      dataLink = form.datamod1.appoints1.rowset.fields["contactkey"]
      visible = false
      enabled = false
      height = 22
      left = 434
      top = 504
      width = 56
   endwith


   this.rowset = this.datamod1.appoints1.rowset

   function editorControl_onGotFocus
     
      return

   function form_canClose
      if form.Datamod1.Appoints1.rowset.modified
         msgbox('Appointment has been added or changed! '+chr(13)+;
                'Save or abandon before closing!','Changes Pending',16)
         return false
      endif

      form.mainbar.detach(form)

      ////// Remove all circular references before attempting to close!
      ////// If not, you will not clean up your resources.
      form.notebook1.schedcol1.unregister()
      form.notebook1.schedcol2.unregister()
      form.notebook1.schedcol3.unregister()
      form.calendar1.unregister()
      form.dataMod1.unregister()

      return true

   ////// Override both Open and ReadModal to do initializations
   function FORM_Open
      class::Init()
      return super::Open()

   function FORM_ReadModal
      class::init()
      return super::ReadModal()

   function Init
      ////// Attach toolbar
      if type('this.mainbar') # 'O'
         set procedure to maintool.cc additive
         this.mainbar = new  mainToolBar()
         this.mainbar.attach(this)

         ///// Assign event handlers to the toolbar events
         this.mainbar.newButton.onClick = class::newButton_OnClick
         this.mainbar.saveButton.onClick = class::saveButton_OnClick
         this.mainbar.abandonButton.onClick = class::abandonButton_OnClick
         this.mainbar.deleteButton.onClick = class::deleteButton_OnClick
      endif

      this.notebook1.timeGrid.setFocus() // causes row highlight to appear

      ///// Register scheduler Column Objects
      class::register()

      ////// register form controls with Calendar
      ///// Register dateFields with calendar
      this.calendar1.registerOwners(form)
      ///// Register field with taskbar
      this.toggleButtons1.registerField(form.taskTypeField)
      
      ///// Register taskbar with appoints1 rowset
      this.dataMod1.registerTaskbar(form.ToggleButtons1)

      if type('_app.interval') = 'N'
         this.IntervalText.text = '('+str(_app.interval,2)+' Mins)'
      endif

      return true

   /////// Matches appointment to scheduler current column
   function MATCHBUTTON_onClick
      form.timefield.value = form.DataMod1.schedTemp1.rowset.fields["Time"].value
      form.datefield.value = form.oCurrentSchedCol.date
      form.employeeField.value = form.CurrentSchedCol.employeeCombo.value
      return

   function NOTEBOOK1_canSelChange(nNewSel)
      ////// Change Appoints.dbf indexes, ranges and findkey() as user
      ////// toggles between office view (columns) and personal view (Grid)

      if this.cursel = 1 and nNewSel = 2
         ////// Set employee name on page two to match the employee
         ////// on the currently selected scheduler column
         // pad employee  to 24 chars
         this.datefield.value = this.parent.oCurrentSchedcol.date
         cEmployee = substr(form.oCurrentSchedCol.employeeCombo.value + space(24),1,24)

         this.employeeNameField.value = trim(cEmployee)
         this.parent.datamod1.appoints1.rowset.indexName = 'DateSlotEmployee'
         this.parent.dataMod1.appoints1.rowset.setRange(dtos(this.datefield.value)+cEmployee)
        
         this.parent.datamod1.appoints1.rowset.first()
   

      elseif this.cursel = 2 and nNewSel = 1 

         ////// Go back to appt on current selected column

         cCol = form.oCurrentSchedCol.cSeqNumber
         with (form.dataMod1.appoints1)
             rowset.indexName = 'Key'
             rowset.first()
         endwith
         form.dataMod1.schedTemp1.rowset.onNavigate()


      endif

      return true

      ////// Create new Appointment
   function newButton_onClick
      this.parent.form.datamod1.Appoints1.rowset.clearRange()
      this.parent.form.datamod1.Appoints1.rowset.beginAppend()

      // Set default values
      this.parent.form.datefield.value = ;
         this.parent.form.oCurrentSchedCol.date
      this.parent.form.timeField.value = ;
         this.parent.form.dataMod1.SchedTemp1.rowset.fields["Time"].value
      this.parent.form.employeeCombo.value = ;
         this.parent.form.oCurrentSchedCol.employeeCombo.value
      this.parent.form.unitsfield.value = 2
          
      this.parent.form.dateField.setFocus()

      this.parent.form.calendar1.registerFields(this.parent.form.timeField)
      return

   function AbandonButton_OnClick
    
      this.parent.form.dataMod1.Appoints1.rowset.abandon()

      ////// unregister time field, now follows datalink
      this.parent.form.calendar1.unRegister(this.parent.form.timeField)

      return true

 function ADDADDRESSBUTTON_onClick

      ///// create new address book form object
      set proc to AddressBook.wfm additive
      f = new AddressBookForm()
      f.mdi = false
      f.readModal()

      if f.apply
        nKey = f.applyKey

         with (form.dataMod1.Contacts1)

            ////// Query rowset to get changes/adds
            requery() 

            ///// Delink Contacts1 from Appoints1
            rowset.masterFields = null
            rowset.indexName = 'ContactKey'
            rowset.first()

            ////// Find the new/changed entry (the apply)
            rowset.findKey(nKey)

            ////// If there is a valid appointment row current
            if not parent.Appoints1.rowset.endOfSet

               ///// Update appoints1 (parent) with key for new entry
               parent.Appoints1.rowset.fields["ContactKey"].value = nKey

            endif

            ////// Re-establish parent/child link
            rowset.masterRowset = parent.appoints1.rowset
            rowset.masterFields = 'ContactKey'
            rowset.first()

         endwith
 
         ////// If both parent and child exist
         if (not form.datamod1.contacts1.rowset.endOfSet) and ;
            (not form.dataMod1.appoints1.rowset.endOfSet) and ;
            (not form.dataMod1.schedTemp1.rowset.endOfSet)
                  ////// Update data-entry field if empty
            form.WithWhomField.value = ;
            form.dataMod1.Contacts1.rowset.fields["fullname"].value
            form.enableForNew(false)
         endif

      endif

      f.release()  //clean up
      f = null
      return

      ///// create new address book form object
      set proc to AddressBook.wfm additive
      f = new AddressBookForm()
      f.mdi = false
      f.readModal()

      if f.apply
         nKey = f.applyKey

         with (form.dataMod1)

            Contacts1.requery() // get changes
            Contacts1.rowset.indexName = 'ContactKey'
            Contacts1.rowset.findkey(nKey)

         endwith

         form.ContactkeyField.value = ;
              form.dataMod1.Contacts1.rowset.fields["ContactKey"].value

         form.WithWhomField.value = ;
              form.dataMod1.Contacts1.rowset.fields["Fullname"].value
      endif

      f.release()  //clean up
      f = null
      return

   function DeleteButton_OnClick
     
      
      with (this.parent.form.dataMod1.appoints1)
         ////// Check to see if sitting on valid rwo
         if rowset.endOfSet
            return false
         endif
          
         ////// if so, store key data and delete row
         cEmployee = rowset.fields["Employee"].value
         dDate = rowset.fields["date"].value
         if not msgbox('Delete this apppointment. Are you sure?','Delete',36) = 6
            return false
         endif
         rowset.delete()
      endwith

      ////// reload schedule columns as needed only
      this.parent.form.conditionalReload(dDate,cEmployee)
      return

   function SaveButton_OnClick
      if this.parent.form.dataMod1.Appoints1.rowset.endOfSet
         return false
      endif

      // Validate fields
      if empty(this.parent.form.dateField.value)
         msgbox('Date is required!','Missing Data',16)
         return false

      elseif empty(this.parent.form.togglebuttons1.getTask())
         msgbox('Task must be selected','Missing Data',16)
         return false

      elseif empty(this.parent.form.timefield.value)
         msgbox('Time must be selected','Missing Data',16)
         return false

      elseif empty(this.parent.form.unitsfield.value)
         msgbox('Units cannot be 0 or less!','Invalid Data',16)
         return false
 
      endif


      ////// Do lookup to get slot from time
      qT = new query()
      qT.database = this.parent.form.dataMod1.Contax1
      qT.sql = 'Select * from "schedtemp.dbf"'
      qT.active = true
      qT.rowset.indexName = 'Time'

      if not qT.rowset.findKey(this.parent.form.timefield.value)
         ////// this is just insurance  in case slots were changed
         nSlot = this.parent.form.dataMod1.schedTemp1.rowset.fields["Slot"].value
      else
         nSlot = qT.rowset.fields["Slot"].value
      endif

      qT.active = false // clean up lookup
      qT = null
     

      // save values to table
      with (this.parent.form.datamod1.appoints1)
         rowset.fields["Slot"].value = nSlot
         rowset.fields["Type"].value = this.parent.form.toggleButtons1.getTask()
         dDate = rowset.fields["Date"].value
         cEmployee = trim(rowset.fields["employee"].value)
         nKey = rowset.fields["Key"].value
         rowset.save()

      endwith
    
      with (this.parent.form)
         oCurrentSchedCol.EmployeeCombo.value = cEmployee
         oCurrentSchedCol.date = dDate
         // reload scheduler column for all
         conditionalReload('All')
      endwith


      return true

   function UPONEARROW_onClick
      with (form.datamod1.schedtemp1)
         if not (rowset.endOfset or  rowset.atFirst())
            rowset.next(-1)
            rowset.refreshControls()
         endif
      endwith
      return

   function UPONEPAGEARROW_onClick
      ////// Scrolls grids up one page
      private n

      form.dataDisplay(false)
 
      with (form.datamod1.schedtemp1)
         if not rowset.atFirst()
    
            ///// Next(-9) won't work as Grid tries to compensate for
            ///// beginning of set
            for n = 1 to 9
               if rowset.atFirst()
                  exit
               endif
               rowset.next(-1)
            next
         endif

      endwith
      form.dataDisplay(true)

      return

  function DOWNONEARROW_onClick
      with (form.datamod1.schedtemp1)
         if not rowset.endOfSet
            rowset.next()
            rowset.refreshControls()
         endif
      endwith
      return

   function DOWNONEPAGEARROW_onClick
      form.DataDisplay(false)
      form.dataMod1.appoints1.rowset.notifyControls = false
      with (form.datamod1.schedtemp1)
         for i = 1 to 9
             if rowset.endOfSet or rowset.atLast()
                exit
             endif
             rowset.next() 
         next

      endwith
      form.dataDisplay(true)
      return

   ////// Method:    dataDisplay ///////////////////////////////
   ////// Purpose:   Turns screen refresh on and off for faster
   //////            scrolling of data in Scheduler Columns ////
   function dataDisplay(lOn)


      form.dataMod1.appoints1.rowset.notifyControls = lOn
      form.dataMod1.contacts1.rowset.notifyControls = lOn
      if lOn
         with (form.dataMod1)
            Appoints1.rowset.refreshControls()
            Contacts1.rowset.refreshControls()
            bm = schedTemp1.rowset.bookmark()
            schedTemp1.rowset.goto(bm)
            schedTemp1.rowset.refreshControls()
         endwith
         lockWindowUpdate(0)
         h = form.hWnd
         updateWindow(h)
      else
         ////// Lock window display because Editor is
         ////// not respecting notifyControls = false
         h = form.hWnd
         lockWindowUpdate(h)
      endif

   function OKBUTTON_onClick
      form.close()
      return

   /////// Method: Register /////////////////////////////////////////
   ////// This gets called from calling app in overridden ReadModal()
   ////// or Open().It registers all the appointment columns with 
   ////// each other and the calendar and sets defaults and datalinks
   function Register
      
        
      with (form.notebook1)

         cEmployee = iif(type('_app.UserID') = 'C',_app.UserID,;
                  form.dataMod1.employees1.rowset.fields["Name"].value)

         ///// Register each scheduling column to make it aware of
         ///// external objects it needs to interact with
         SchedCol1.Register(1,;
                   schedCol2,;
                   schedCol3,;
                   form.calendar1)


         ///// Set datalinks to rowsets used by schedcolumns
         SchedCol1.DataLink(form.datamod1.schedTemp1.rowset,;
                   form.datamod1.schedTemp1.appoints1)

         
         SchedCol1.employeeCombo.value = cEmployee
         SchedCol1.setdate(date()) // Includes a load



         ////// Repeat for each column
         SchedCol2.Register(2,;
                   schedCol1,;
                   schedCol3,;
                   form.calendar1)


         SchedCol2.DataLink(form.datamod1.schedTemp1.rowset,;
                   form.datamod1.schedTemp1.appoints1)


         
         SchedCol2.employeeCombo.value = cEmployee
         SchedCol2.setDate(date()+1) 


         SchedCol3.Register(3,;
                   schedCol1,;
                   schedCol2,;
                   form.calendar1)

         SchedCol3.DataLink(form.datamod1.schedTemp1.rowset,;
                   form.datamod1.schedTemp1.appoints1)
       
         SchedCol3.employeeCombo.value = cEmployee
         SchedCol3.setDate(date()+2)


      endwith
      // force an on-Navigate row move
      bm = form.dataMod1.SchedTemp1.rowset.bookMark()
      form.dataMod1.SchedTemp1.rowset.goto(bm)

      // give focus to opening column
      form.notebook1.schedCol1.container_onGotFocus()

      /////// Method:   SetDate(dDate) //////////////////////////////////
      /////// Purpose:  Responds to call from calendar //////////////////
      /////// Note:     Only updates if notebook cursel = 2 (personal veiw)
      function setDate(dDate)
      if this.notebook1.cursel = 2
         this.notebook1.dateField.value = dDate
         this.dataMod1.appoints1.rowset.indexName = 'DateSlotEmployee'
         this.dataMod1.appoints1.rowset.setRange(dtos(this.notebook1.datefield.value)+;
            this.notebook1.employeeNameField.value)
         this.datamod1.appoints1.rowset.first()

      endif

   ////// Function   ConditionalReload /////////////////////////////////////\
   ////// Purpose:   Redisplay schedule columns only as needed /////////////
   ////// Param:     dDate and cEmployee used to match to SchedCol to determine
   //////            if reloading is necessary
   function conditionalReload(dDate,cEmployee)
      xDate = dDate // private for type() function
      bDoAll = type('xDate') = 'C' and xDate = 'All'

          
      //// if all matches
      if bDoAll or (this.notebook1.schedCol1.date = dDate and ;
         this.notebook1.schedCol1.employeeCombo.value = trim(cEmployee))
         this.notebook1.schedCol1.load()
      endif

            //// if all matches
      if bDoAll or (this.notebook1.schedCol2.date = dDate and ;
         this.notebook1.schedCol2.employeeCombo.value = trim(cEmployee))
         this.notebook1.schedCol2.load()
      endif

            //// if all matches
      if bDoAll or (this.notebook1.schedCol3.date = dDate and ;
         this.notebook1.schedCol3.employeeCombo.value = trim(cEmployee))
         this.notebook1.schedCol3.load()
      endif

      return true

   function enableForNew(bEnable)

      ////// disable container controls
      form.notebook1.schedCol1.enable(bEnable)
      form.notebook1.schedCol2.enable(bEnable)
      form.notebook1.schedCol3.enable(bEnable)
      form.calendar1.enable(bEnable)
      ///// Turn these off for new or edit, on for save/abandon
      form.mainbar.newbutton.enabled = (bEnable)
      form.mainbar.deletebutton.enabled = (bEnable)

      ////// freeze page changes on notebook
      if bEnable
         form.notebook1.canSelChange = class::notebook1_canSelChange
      else
         form.notebook1.canSelChange = {||false}
      endif
  
      ////// freeze grid on page 2 of notebook
      form.notebook1.grid2.enabled = bEnable

      return true
endclass
////// Class HiEditor  adds ColorHighlight to Editor controls
class HiEditor(formObj) OF EDITOR(formObj)  Custom
with (this)
  ongotfocus = {;this.colornormal = "black/0xc2e7f8"}
  onLostFocus = {;this.colornormal = "black/White"}
endwith
Endclass

////// Class HiCombo   adds ColorHighlight to Combobox controls
class HiCombo(formObj) of Combobox(formObj) Custom
with (this)
  ongotfocus = {;this.colornormal = "black/0xc2e7f8"}
  onLostFocus = {;this.colornormal = "black/White"}
endwith
Endclass
