⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 photoopunit.pas

📁 jvcl driver development envionment
💻 PAS
📖 第 1 页 / 共 2 页
字号:
procedure TPhotoOpMain.NextDateButtonClick(Sender: TObject);
begin
  JvTFDays1.NextDate;
end;

procedure TPhotoOpMain.GotoDatePickerChange(Sender: TObject);
begin
  // GotoDatePicker.OnCloseUp should also point to this handler
  JvTFDays1.GotoDate(GotoDatePicker.Date);
  JvTFWeeks1.DisplayDate := GotoDatePicker.Date;
  JvTFWeeks1.DisplayDate := GotoDatePicker.Date;
end;

procedure TPhotoOpMain.GotoDatePickerUserInput(Sender: TObject;
  const UserString: String; var DateAndTime: TDateTime;
  var AllowChange: Boolean);
begin
  AllowChange := True;
  GotoDatePicker.OnChange(nil);
end;

procedure TPhotoOpMain.TimeIncComboChange(Sender: TObject);
begin
  Case TimeIncCombo.ItemIndex of
     0 : JvTFDays1.Granularity := 60;
     1 : JvTFDays1.Granularity := 30;
     2 : JvTFDays1.Granularity := 20;
     3 : JvTFDays1.Granularity := 15;
     4 : JvTFDays1.Granularity := 12;
     5 : JvTFDays1.Granularity := 10;
     6 : JvTFDays1.Granularity := 6;
     7 : JvTFDays1.Granularity := 5;
     8 : JvTFDays1.Granularity := 4;
     9 : JvTFDays1.Granularity := 3;
    10 : JvTFDays1.Granularity := 2;
    11 : JvTFDays1.Granularity := 1;
  End;
end;

procedure TPhotoOpMain.NewApptButtonClick(Sender: TObject);
begin
  // Simply open the EditAppt window.  The Appt var of the
  // EditAppt form will already be nil (which indicates
  // that the appoinment is being created).
  ApptEdit.ShowModal;
end;

procedure TPhotoOpMain.EditApptButtonClick(Sender: TObject);
begin
  If Assigned(JvTFDays1.SelAppt) Then
    Begin
      // Set EditAppt's Appt var to the selected appointment to
      // indicate that the appointment should be edited.
      ApptEdit.Appt := JvTFDays1.SelAppt;
      ApptEdit.ShowModal;
    End
  Else
    MessageDlg('Please select an appointment to edit.', mtInformation,
               [mbOK], 0);
end;

procedure TPhotoOpMain.DeleteApptButtonClick(Sender: TObject);
var
  Appt : TJvTFAppt;
  dbDel : Boolean;
  SelSchedName : String;
begin
  // This routine employs a simple business that asks the user what to
  // do in the case where the user is attempting to delete a shared appt.
  // NOTE:  This is NOT required.  You are completely free to implement
  // any business rules you see fit.

  // Another shortcut to save typing
  Appt := JvTFDays1.SelAppt;

  If Assigned(Appt) Then
    Begin
      dbDel := True;
      If Appt.Shared Then
        If MessageDlg('This appointment is shared with other schedules.' + #13#10 +
                      'Do you want to delete the appointment from ' +
                      'all schedules?' + #13#10#13#10 +
                      'Choose ''No'' to delete the appointment from the ' +
                      'selected schedule only.' + #13#10 +
                      'Choose ''All'' to delete the appointment from all schedules.',
                      mtConfirmation, [mbNo, mbAll], 0) = mrNo Then
          Begin
            // Don't delete the appointment, but remove it from the schedule
            // of the selected resource.
            dbDel := False;

            With JvTFDays1 do
              Begin
                SelSchedName := '';
                If ValidSelection and Cols[SelStart.X].Connected Then
                  SelSchedName := Cols[SelStart.X].Schedule.SchedName;
              End;

            If SelSchedName <> '' Then
              Appt.RemoveSchedule(SelSchedName)
            Else
              MessageDlg('No schedule is selected.' + #13#10 +
                         'Could not remove appointment from schedule.',
                         mtInformation, [mbOK], 0);
          End;

      If dbDel Then
        If MessageDlg('Are you sure you want to delete the selected appointment?',
                      mtConfirmation, [mbYes, mbNo], 0) = mrYes Then
          // Delete the appointment (removes it from the db)
          // Note: Could substitute Appt.Delete; for the line below
          JvTFDays1.ScheduleManager.dbDeleteAppt(JvTFDays1.SelAppt);
    End
  Else
    MessageDlg('Please select an appointment to delete.',
               mtInformation, [mbOK], 0);
end;

procedure TPhotoOpMain.JvTFDays1DateChanging(Sender: TObject;
  var NewDate: TDate);
begin
  // Make sure all appts are posted before moving on.
  JvTFDays1.ScheduleManager.PostAppts;
end;

procedure TPhotoOpMain.JvTFDays1DateChanged(Sender: TObject);
begin
  // Synchronize the tool bar
  With JvTFDays1.Template do
    If ActiveTemplate = agtLinear Then
      GotoDatePicker.Date := LinearStartDate
    Else
      GotoDatePicker.Date := CompDate;
end;

procedure TPhotoOpMain.JvTFDays1GranularityChanged(Sender: TObject);
begin
  // Update the TimeIncCombo when the granularity is changed.
  //  (This can be done by <Ctrl> + <Insert> and <Ctrl> + <Delete>)
  Case JvTFDays1.Granularity of
    60 : TimeIncCombo.ItemIndex := 0;
    30 : TimeIncCombo.ItemIndex := 1;
    20 : TimeIncCombo.ItemIndex := 2;
    15 : TimeIncCombo.ItemIndex := 3;
    12 : TimeIncCombo.ItemIndex := 4;
    10 : TimeIncCombo.ItemIndex := 5;
     6 : TimeIncCombo.ItemIndex := 6;
     5 : TimeIncCombo.ItemIndex := 7;
     4 : TimeIncCombo.ItemIndex := 8;
     3 : TimeIncCombo.ItemIndex := 9;
     2 : TimeIncCombo.ItemIndex := 10;
  Else
    TimeIncCombo.ItemIndex := 11;
  End;
end;

procedure TPhotoOpMain.JvTFDays1DblClick(Sender: TObject);
begin
  With JvTFDays1 do
    If ValidSelection Then
      If Assigned(SelAppt) Then
        EditApptButtonClick(nil)
      Else
        NewApptButtonClick(nil);
end;

procedure TPhotoOpMain.FormShow(Sender: TObject);
var
  ResName : String;
begin
  // Initialize the date
  //GotoDatePicker.Date := Date;
  GotoDatePicker.Date := EncodeDate(2002, 1, 1);

  // Initialize the granularity
  TimeIncCombo.ItemIndex := 1; // 30 mins

  // Initialize the mode
  ModeCombo.ItemIndex := 0; // Single mode
  DaysCombo.ItemIndex := 6; // One day

  // Populate the resource related controls
  With SchedulesQuery do
    try
      Open;
      First;
      While not EOF do
        Begin
          ResName := SchedulesQuery.FieldByName('SchedName').AsString;
          ResourceCombo.Items.Add(ResName);
          VisibleResources.ResourcesCheckList.Items.Add(ResName);
          Share.ResourcesCheckList.Items.Add(ResName);
          Next;
        End;
      Close;
    except
      on E:EDBEngineError do
      begin
        ShowMessageFmt('%s:'#13#10'Try moving the database to a shorter path.',[E.Message]);
        Application.Terminate;
        Exit;
      end;
    end;

  // Initialize the resource related controls
  ResourceCombo.ItemIndex := 0;
  VisibleResources.ResourcesCheckList.Checked[0] := True;

  // Initialize the comparative template
  JvTFDays1.Template.CompNames.Add(VisibleResources.ResourcesCheckList.Items[0]);

  // Now run the events to synchronize JvTFDays, etc.
  ResourceComboChange(nil);
  DaysComboChange(nil);
  ModeComboChange(nil);
  GotoDatePicker.Date := EncodeDate(2002, 1, 1);
  GotoDatePickerChange(nil);
  TimeIncComboChange(nil);
end;

procedure TPhotoOpMain.PrintButtonClick(Sender: TObject);
begin
  With JvTFDaysPrinter1 do
    Begin
      // "Copy" the display properties from the JvTFDays control
      SetProperties(JvTFDays1);
      // Set gridline color to black for sharp display on printed page
      GridLineColor := clBlack;
      // print 48 rows on each page
      PageLayout.RowsPerPage := 48;
      // fit all the columns onto one page wide
      PageLayout.ColsPerPage := 0;
      // "Copy" the schedules from the JvTFDays control
      Cols.Assign(JvTFDays1.Cols);
      PrintProgress.Show;
      Application.ProcessMessages;
      // print the document
      PrintDirect;
      PrintProgress.Close;
    End;
end;

procedure TPhotoOpMain.JvTFDaysPrinter1ApptProgress(Sender: TObject;
  Current, Total: Integer);
begin
  If Current > Total Then
    Total := Current;
  PrintProgress.Label2.Caption := 'Processing appointment ' + IntToStr(Current) +
                                  ' of ' + IntToStr(Total) + ' (estimated)';
  PrintProgress.ProgressBar1.Max := Total;
  PrintProgress.ProgressBar1.Position := Current;
end;

procedure TPhotoOpMain.JvTFDaysPrinter1AssembleProgress(Sender: TObject;
  Current, Total: Integer);
begin
  PrintProgress.Label2.Caption := 'Assembling page ' + IntToStr(Current) +
                                  ' of ' + IntToStr(Total); 
  PrintProgress.ProgressBar1.Max := Total;
  PrintProgress.ProgressBar1.Position := Current;
end;

procedure TPhotoOpMain.JvTFDaysPrinter1PrintProgress(Sender: TObject;
  Current, Total: Integer);
begin
  PrintProgress.Label2.Caption := 'Printing page ' + IntToStr(Current) +
                                  ' of ' + IntToStr(Total);
  PrintProgress.ProgressBar1.Max := Total;
  PrintProgress.ProgressBar1.Position := Current;
end;

procedure TPhotoOpMain.utfScheduleManager1LoadBatch(Sender: TObject;
  BatchName: String; BatchStartDate, BatchEndDate: TDate);
var
  Appt : TJvTFAppt;
  NewAppt : Boolean;
begin
  With NeedApptsQuery do
    Begin
      // Set the query parameters so the query will return
      // all appointments for the given resource that fall
      // on the given date.
      ParamByName('D1').AsDate := BatchStartDate;
      ParamByName('D2').AsDate := BatchEndDate;
      ParamByName('SchedName').AsString := BatchName;

      // Next, loop through the returned records to add the data
      Open;
      First;
      While not EOF do
        Begin
          // Request an appointment object from the server
          utfScheduleManager1.RequestAppt(FieldByName('ApptID').AsString,
            Appt, NewAppt);

          // If it is a newly loaded appt we want to set its properties
          If NewAppt Then
            Begin
              Appt.SetStartEnd(FieldByName('StartDate').AsDateTime,
                               FieldByName('StartTime').AsDateTime,
                               FieldByName('EndDate').AsDateTime,
                               FieldByName('EndTime').AsDateTime);
              Appt.Description := FieldByName('Description').AsString;
              Appt.AlarmEnabled := FieldByName('AlarmEnabled').AsBoolean;
              Appt.AlarmAdvance := FieldByName('AlarmAdvance').AsInteger;

              // Now manage the Appt --> Schedule(s) relationship
              With ApptSchedulesQuery do
                Begin
                  ParamByName('ApptID').AsString := Appt.ID;
                  Open;
                  First;
                  While not EOF do
                    Begin
                      Appt.AddSchedule(FieldByName('SchedName').AsString);
                      Next;
                    End;
                  Close; // ApptSchedulesQuery
                End;
            End;
          Next; // NeedApptsQuery record
        End;
      Close;  // NeedApptsQuery
    End;
end;

procedure TPhotoOpMain.FormCreate(Sender: TObject);
var
   DataPath: string;
begin
   DataPath := '..\examples\JvTimeFramework\PhotoOp\Data\';
   dbUTF.Params.Add('PATH=' + DataPath);
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -