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

📄 unit_servicebooking.pas

📁 用delphi开发的美容院管理系统
💻 PAS
📖 第 1 页 / 共 2 页
字号:
  finally
    try
       dmod.Database.Commit ;
    except
       dmod.Database.Rollback ;
       MessageBox(handle,'操作失败,请重试!','提示',mb_ok+mb_iconinformation);
       result := false;
    end;
  end;
end;
{********************************************}
procedure Tfrm_servicebooking.sbtn_closeClick(Sender: TObject);
begin
  close;
end;

procedure Tfrm_servicebooking.FormClose(Sender: TObject;
  var Action: TCloseAction);
var
  i:integer;
begin
  if pagecontrol1.ActivePage = sht_content then
  if sbtn_append.Enabled then
  begin
    if edt_Bookingno.Enabled then
    begin
      i := MessageBox(handle,'在窗口关闭的同时,你要保存操作的数据吗?','询问',mb_yesnocancel+mb_iconquestion);
      if i=6 then
      begin
        if SaveBookingInfo then i:=7 else i:=2;
      end;
      if i=2 then
      begin
        action := canone;
        exit;
      end;
    end;
  end;
  action := cafree;
  frm_servicebooking:=nil;
end;

procedure Tfrm_servicebooking.cbb_EmpNoExit(Sender: TObject);
begin
  if cbb_EmpNo.Text ='' then exit;
  
  with dmod.qrydata do
  begin
    close;
    SQL.Text :='select emp_name from employee where emp_no='+#39+trim(cbb_EmpNo.Text)+#39;
    Open;
    if not eof then
    begin
      edt_EmpName.Text := FieldByname('emp_name').AsString ;
    end;
  end;
end;

procedure Tfrm_servicebooking.edt_CusNoExit(Sender: TObject);
begin
  {if edt_CusNo.Text ='' then exit;

  with dmod.qrydata do
  begin
    close;
    SQL.Text :='select * from customercard where cus_no='+#39+trim(edt_CusNo.Text)+#39;
    Open;
    if eof then
    begin
      MessageBox(self.handle,'该顾客还未办理任何顾客卡,请先予以办理!','提示',mb_ok+mb_iconinformation);
      edt_CusNo.SetFocus ;
      exit;
    end;

    close;
    SQL.Text :='select cus_name,type_name,total_cost,cost_score from customer,customertype,customercard '+
               ' where customer.cus_no=customercard.cus_no and customer.cus_type=customertype.type_id and Customer.cus_no='+#39+trim(edt_CusNo.Text)+#39;
    Open;
    if not eof then
    begin
      edt_CusName.Text := FieldByname('cus_name').AsString ;
      edt_CusType.Text  := FieldByname('type_name').AsString ;
      edt_TotalCost.Text := FieldByName('total_cost').AsString ;
      edt_CostScore.Text:= FieldByName('cost_score').AsString ;
    end else
    begin
      MessageBox(self.handle,'该客户编号不存在,请重试!','提示',mb_ok+mb_iconinformation);
      edt_CusNo.SetFocus ;
    end;
  end; }
end;

procedure Tfrm_servicebooking.sg_BookingSelectCell(Sender: TObject; ACol,
  ARow: Integer; var CanSelect: Boolean);
begin
  if ARow = sg_Booking.RowCount - 1 then
    CanSelect:= false
  else
  begin
    sbtn_back.Enabled := true;
    sbtn_front.Enabled := true;
    if ARow = sg_Booking.RowCount - 2 then sbtn_back.Enabled := false;
    if ARow = 1 then sbtn_front.Enabled := false;
    CanSelect := true;
  end;
end;

procedure Tfrm_servicebooking.sht_ContentShow(Sender: TObject);
begin
  PageIndex := 1;
  if not AppendOrEdit then
  begin
    if sg_Booking.Cells[0,sg_Booking.Row]<>'' then GetBookingInfo;
    MakeEnabled(false);
  end;
end;

procedure Tfrm_servicebooking.sht_ListShow(Sender: TObject);
begin
  PageIndex:=0;
  if not sbtn_append.Enabled then exit;
  sbtn_delete.Enabled := true;
  sbtn_save.Enabled := false;
end;

procedure Tfrm_servicebooking.PageControl1Changing(Sender: TObject;
  var AllowChange: Boolean);
var
  i:integer;
begin
  AllowChange := true;
  if not sbtn_append.Enabled then exit;
  if PageIndex=1 then
  begin
    if edt_BookingNo.Enabled then
    begin
      AppendOrEdit := false;
      i := MessageBox(handle,'你要保存操作的数据吗?','询问',mb_yesnocancel+mb_iconquestion);
      if i=6 then //
      begin
        sbtn_saveClick(nil);
        if not DoChange then i:=2;
      end;
      if i=7 then MakeEnabled(true);
      if i=2 then AllowChange:=true;
    end;
  end else if (sg_Booking.Cells [0,sg_Booking.Row]='') and not AppendOrEdit then AllowChange:=true;
end;

procedure Tfrm_servicebooking.sbtn_appendClick(Sender: TObject);
var
  i : integer;
  temp : string;
begin
  if pagecontrol1.ActivePage = sht_content then  //to determine whethter sht_content is shown
  if (not AppendOrEdit) and edt_Bookingno.Enabled then  //to determine status of Edit and Components' Enabled
  begin
    i := MessageBox(handle,'你要保存操作的数据吗?','询问',mb_yesnocancel+mb_iconquestion);
    if i=6 then //select yes
    if not SaveBookingInfo then i:=2;
    if i=2 then exit;
  end;

  AppendOrEdit := true;
  pagecontrol1.ActivePage := sht_content;
  MakeEnabled(true);
  ClearBookingInfo;
  temp:=GetDateString('DBMeirong');
  temp:=copy(temp,1,4)+copy(temp,6,2)+copy(temp,9,2);
  edt_Bookingno.Text :=GetNo('DBMeirong','CustomerServiceBooking','','','booking_no',temp,2); 
end;

procedure Tfrm_servicebooking.sbtn_editClick(Sender: TObject);
var
   i:integer;
begin
  if pagecontrol1.ActivePage = sht_content then
   if AppendOrEdit and edt_BookingNo.Enabled then
   begin
     i := MessageBox(handle,'你要保存操作的数据吗?','询问',mb_yesnocancel+mb_iconquestion);
     if i=6 then
     if not SaveBookingInfo then i:=2;
     if i=2 then exit;
   end;
   if sg_Booking.Cells[0,sg_Booking.Row]='' then exit;
   if pagecontrol1.ActivePage <> sht_content then pagecontrol1.ActivePage := sht_content;
   if AppendOrEdit then GetBookingInfo;
   AppendOrEdit := false;
   MakeEnabled(true);
   edt_Bookingno.Enabled := false;
end;

procedure Tfrm_servicebooking.sbtn_saveClick(Sender: TObject);
var
  i : integer;
  temp : string;
begin
  if not SaveBookingInfo then exit;

  if AppendOrEdit then
  begin
    StringGridInsert(sg_Booking);
    i:=1;
  end else i:=sg_Booking.Row ;
   
  with sg_Booking do
  begin
    Cells[0,i] := trim(edt_BookingNo.Text );
    //Cells[1,i] := trim(edt_CusNo.Text );
    Cells[1,i] := trim(cbb_CusName.Text );
    Cells[2,i] := DateToString(dtp_BookingDate.Date);
    Cells[3,i] := trim(cbb_Empno.Text );
    cells[4,i] := trim(edt_EmpName.Text );
    cells[5,i] := mm_BookingContent.Text ;
  end;

  if AppendOrEdit then
  begin
    ClearBookingInfo;
    temp := GetDateString('DBMeirong');
    temp := copy(temp,1,4) + copy(temp,6,2) + copy(temp,9,2);
    edt_Bookingno.Text := GetNo('DBMeirong','CustomerServiceBooking','','','booking_no',temp,2);
    if sg_Booking.RowCount > 3 then sbtn_back.Enabled := true;
  end else MakeEnabled(false);
end;

procedure Tfrm_servicebooking.sbtn_deleteClick(Sender: TObject);
begin
  if sg_Booking.cells[0,sg_Booking.Row]='' then exit;
  if MessageBox(handle,'你确定要删除该客户预约信息吗?','询问',mb_yesno+mb_iconquestion)<> IDYes then exit;
  with dmod.qrydata do
  begin
    close;
    SQL.Text := 'delete from CustomerServiceBooking where booking_no='+#39+sg_Booking.Cells[0,sg_Booking.Row]+#39;
    ExecSQL;
  end;
  StringGridDelete(sg_Booking,sg_Booking.Row);
  if sg_Booking.Row = sg_Booking.RowCount - 1 then
  begin
    if sg_Booking.RowCount > 2 then
      sg_Booking.Row := sg_Booking.Row - 1
    else
      sbtn_back.Enabled := false;
  end;
  if sg_Booking.Row = 1 then sbtn_front.Enabled := false;
  if sg_Booking.Row = sg_Booking.RowCount - 2 then sbtn_back.Enabled := false;
end;

procedure Tfrm_servicebooking.sbtn_backClick(Sender: TObject);
var
  i:integer;
begin
  if pagecontrol1.ActivePage = sht_content then
  if edt_Bookingno.Enabled  then
  if sbtn_append.Enabled  then
  begin
     i := MessageBox(handle,'你要保存操作的数据吗?','询问',mb_yesnocancel+mb_iconquestion);
     if i=6 then  //select yes
     if not SaveBookingInfo then i:=2; //if save error
     if i=2 then exit;
  end;
  if sg_Booking.Row > sg_Booking.RowCount-2 then
  begin
     sbtn_back.Enabled := false;
     exit;
  end;
  sbtn_front.Enabled := true;
  sg_Booking.Row := sg_Booking.Row+1;
  if pagecontrol1.ActivePage = sht_content then
  begin
     GetBookingInfo();
     MakeEnabled(false);
  end;
end;

procedure Tfrm_servicebooking.sbtn_frontClick(Sender: TObject);
var
  i:integer;
begin
  if pagecontrol1.ActivePage = sht_content then
  if edt_Bookingno.Enabled then
  if sbtn_append.Enabled then
  begin
     i := MessageBox(handle,'你要保存操作的数据吗?','询问',mb_yesnocancel+mb_iconquestion);
     if i=6 then
     if not SaveBookingInfo then i:=2;
     if i=2 then exit;
  end;

  if sg_Booking.Row=1 then
  begin
    sbtn_front.Enabled := false;
    exit;
  end;

  sbtn_back.Enabled := true;
  sg_Booking.Row := sg_Booking.Row-1;

  if pagecontrol1.ActivePage = sht_content then
  begin
    GetBookingInfo();
    MakeEnabled(false);
  end;
end;

procedure Tfrm_servicebooking.FormResize(Sender: TObject);
begin
  StringGridAutoSize(sg_Booking);
end;

procedure Tfrm_servicebooking.FormKeyPress(Sender: TObject; var Key: Char);
var
   temp,temp1:boolean;
begin
   temp := false;
   temp1:= true;

   if (key=#13) and sbtn_save.Enabled then
   begin
     temp := true;
     if (ActiveControl is TMemo) then
     if TMemo(ActiveControl).Name = 'mm_BookingRemark' then temp1:=false;
   end;

   if temp then
   begin
     if temp1 then
     begin
       key:=#0;
       perform(WM_NEXTDLGCTL,0,0)
     end else if sbtn_save.Enabled then sbtn_saveClick(nil);
   end;
end;

procedure Tfrm_servicebooking.sbtn_printClick(Sender: TObject);
begin
  DoreportServiceBooking;
end;

end.

⌨️ 快捷键说明

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