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

📄 unit_serviceextra.pas

📁 管理软件/可以用于有会员积分管理的场所,支持会员卡管理
💻 PAS
📖 第 1 页 / 共 2 页
字号:
unit Unit_ServiceExtra;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, ComCtrls, Buttons, StdCtrls, Grids, Menus;

type
  Tfrm_serviceitemextra = class(TForm)
    PageControl1: TPageControl;
    sht_same: TTabSheet;
    sht_specific: TTabSheet;
    Panel1: TPanel;
    sbtn_front: TSpeedButton;
    sbtn_back: TSpeedButton;
    sbtn_close: TSpeedButton;
    Splitter1: TSplitter;
    GroupBox1: TGroupBox;
    Label1: TLabel;
    Splitter2: TSplitter;
    StatusBar1: TStatusBar;
    Panel2: TPanel;
    sg_same: TStringGrid;
    Panel3: TPanel;
    RadioGroup1: TRadioGroup;
    Label2: TLabel;
    edt_Tcnumber1: TEdit;
    sbtn_sure1: TSpeedButton;
    sbtn_save: TSpeedButton;
    Panel4: TPanel;
    sg_specific: TStringGrid;
    Panel5: TPanel;
    RadioGroup2: TRadioGroup;
    Label3: TLabel;
    edt_Tcnumber2: TEdit;
    sbtn_sure2: TSpeedButton;
    sbtn_Reconfig: TSpeedButton;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    Label8: TLabel;
    Label9: TLabel;
    Label10: TLabel;
    Label11: TLabel;
    Label12: TLabel;
    sg_Employee: TStringGrid;
    Label13: TLabel;
    procedure sbtn_closeClick(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure sg_sameSelectCell(Sender: TObject; ACol, ARow: Integer;
      var CanSelect: Boolean);
    procedure sbtn_backClick(Sender: TObject);
    procedure sbtn_frontClick(Sender: TObject);
    procedure sbtn_sure1Click(Sender: TObject);
    procedure sg_sameClick(Sender: TObject);
    procedure sbtn_saveClick(Sender: TObject);
    procedure sbtn_sure2Click(Sender: TObject);
    procedure sg_EmployeeClick(Sender: TObject);
    procedure PageControl1Changing(Sender: TObject;
      var AllowChange: Boolean);
    procedure sbtn_ReconfigClick(Sender: TObject);
    procedure sg_specificSelectCell(Sender: TObject; ACol, ARow: Integer;
      var CanSelect: Boolean);
    procedure sg_EmployeeSelectCell(Sender: TObject; ACol, ARow: Integer;
      var CanSelect: Boolean);
  private
    { Private declarations }
    isSameConfig,isConfig:boolean;

    procedure InitialServiceExtra;
    procedure SearchSpecificServiceExtra(temp:string);
    procedure SearchEmployeeInfo;
    procedure SaveSameServiceExtra;
    procedure SaveSpecificServiceExtra(temp:string);
  public
    { Public declarations }
    procedure ServiceExtra_ref;
  end;

var
  frm_serviceitemextra: Tfrm_serviceitemextra;

implementation
  uses unit_DataModule,unit_TotalPublic,PublicFunOrPro;
  
{$R *.dfm}
{***************************************************}
procedure Tfrm_serviceitemextra.ServiceExtra_ref ;
begin

  pagecontrol1.ActivePage := sht_same;
  
  with sg_Same do
  begin
    cells[0,0]:='服务编号';
    cells[1,0]:='服务名称';
    cells[2,0]:='服务价格';
    cells[3,0]:='提成方法';
    cells[4,0]:='提成数目';
  end;

  with sg_specific do
  begin
    cells[0,0]:='服务编号';
    cells[1,0]:='服务名称';
    cells[2,0]:='服务价格';
    cells[3,0]:='提成方法';
    cells[4,0]:='提成数目';
  end;

  with sg_Employee do
  begin
    cells[0,0]:='员工编号';
    cells[1,0]:='员工姓名';
  end;

  InitialServiceExtra;
  SearchEmployeeInfo;
end;

procedure Tfrm_serviceitemextra.SearchEmployeeInfo ;
var
  i:integer;
begin
  with dmod.qrydata do
  begin
    Close;
    SQL.Text :='select emp_no,emp_name from employee order by emp_no';
    Open;
    i:=1;
    while not eof do
    begin
      sg_Employee.Cells[0,i]:=FieldByName('emp_no').AsString ;
      sg_Employee.Cells[1,i]:=FieldByName('emp_name').AsString ;
      inc(i);
      next;
    end;
  end;
  if i<>1 then sg_Employee.RowCount :=i+1;
end;

procedure Tfrm_serviceitemextra.InitialServiceExtra ;
var
  i:integer;
begin
  with dmod.qrydata do
  begin
    Close;
    SQL.Text :='select count(*) as count from serviceextra';
    Open;
    if FieldByName('count').AsInteger =0 then //如果没有设置服务提成
    begin
      Close;
      SQL.Text :='select item_id,item_name,item_price from serviceitem order by item_id';
      Open;
      i:=1;
      while not eof do
      begin
        sg_same.Cells[0,i]:=FieldByName('item_id').AsString ;
        sg_same.Cells[1,i]:=FieldByName('item_name').AsString ;
        sg_same.Cells[2,i]:=FloatToStr(FieldByName('item_price').AsFloat) ;

        inc(i);
        next;
      end;
      StatusBar1.Panels[0].Text :='友好提示:你还没有进行服务提成设置';
      sbtn_reconfig.Enabled := false;
      isConfig:=false;
    end else if FieldByName('count').AsInteger >0 then  //如果已经设置服务提成
    begin
      Close;
      SQL.Text :='select distinct conf_type from serviceextra';
      Open;
      if FieldByName('conf_type').AsString ='0' then  //如果进行统一设置
      begin
        pagecontrol1.ActivePage := sht_same;
        Close;
        SQL.Text :='select e.item_id,item_name,item_price,tc_type,tc_value from serviceitem i,serviceextra e '+
                   ' where i.item_id=e.item_id';
        Open;
        i:=1;
        while not eof do
        begin
          sg_same.Cells[0,i]:=FieldByName('item_id').AsString ;
          sg_same.Cells[1,i]:=FieldByName('item_name').AsString ;
          sg_same.Cells[2,i]:=FloatToStr(FieldByName('item_price').AsFloat) ;
          if FieldByName('tc_type').AsString='0' then
            sg_same.Cells[3,i]:='固定提成'
          else
            sg_same.Cells[3,i]:='按百分比' ;
          sg_same.Cells[4,i]:=FloatToStr(FieldByName('tc_value').AsFloat) ;

          inc(i);
          next;
        end;
        StatusBar1.Panels[0].Text :='友好提示:服务提成按统一方法设置';
        isSameConfig:=true;
      end else if FieldByName('conf_type').AsString ='1' then   //如果进行分别设置
      begin
        pagecontrol1.ActivePage := sht_specific;
        StatusBar1.Panels[0].Text :='友好提示:服务提成按分别方法设置';
        isSameConfig:=false;
      end;
    isConfig:=true;
    sbtn_reconfig.Enabled := true;
    end;

  end;
  if i<>1 then sg_same.RowCount :=i+1;
end;

procedure Tfrm_serviceitemextra.SearchSpecificServiceExtra(temp:string) ;
var
  i:integer;
begin
  StringGridClear(sg_specific);
  with dmod.qrydata do
  begin
    Close;
    SQL.Text :='select e.item_id,item_name,item_price,tc_type,tc_value from serviceextra e,serviceitem i '+
               ' where e.item_id=i.item_id and emp_no='+#39+temp+#39;
    Open;
    i:=1;
    if not eof then
    begin
      while not eof do
      begin
        sg_specific.Cells[0,i]:=FieldByName('item_id').AsString ;
        sg_specific.Cells[1,i]:=FieldByName('item_name').AsString ;
        sg_specific.Cells[2,i]:=FieldByName('item_price').AsString ;
        if FieldByName('tc_type').AsString='0' then
          sg_specific.Cells[3,i]:='固定提成'
        else if FieldByName('tc_type').AsString='1' then
          sg_specific.Cells[3,i]:='按百分比';
        sg_specific.Cells[4,i]:=FloatToStr(FieldByName('tc_value').AsFloat) ;
        inc(i);
        next;
      end;
    end else begin
      Close;
      SQL.Text :='select item_id,item_name,item_price from serviceitem order by item_id';
      Open;
      i:=1;
      while not eof do
      begin
        sg_specific.cells[0,i]:=FieldByName('item_id').AsString ;
        sg_specific.cells[1,i]:=FieldByName('item_name').AsString ;
        sg_specific.cells[2,i]:=FloatToStr(FieldByName('item_price').AsFloat) ;
        inc(i);
        next;
      end;
    end;
  end;
  if i<>1 then sg_specific.RowCount :=i+1;
end;

procedure Tfrm_serviceitemextra.SaveSameServiceExtra ;
var
  i:integer;
begin
    if pagecontrol1.ActivePage <> sht_same then
    begin
      MessageBox(handle,'你已经对服务提成采用统一设置,分别设置保存不予处理!','提示',mb_ok+mb_iconinformation);
      exit;
    end;
    for i:=1 to sg_Same.RowCount-2 do
    begin
      if (sg_Same.cells[3,i]='') or (sg_Same.cells[4,i]='') then
      begin
        MessageBox(handle,'服务提成设置不完全,请重试!','提示',mb_ok+mb_iconinformation);
        exit;
      end;
    end;

    try
      dmod.Database.StartTransaction ;
      with dmod.qrydata do
      begin
        Close;
        SQL.Text :='delete from serviceextra';
        ExecSQL;

        for i:=1 to sg_same.RowCount-2 do
        begin
          Close;
          SQL.Text :='insert into serviceextra(item_id,emp_no,tc_type,tc_value,conf_type) '+
                   ' values(:itemid,:empno,:tctype,:tcvalue,:conftype)';
          ParamByName('itemid').AsString :=sg_same.Cells[0,i];
          ParamByName('empno').AsString :='';
          if sg_same.Cells[3,i]='固定提成' then
            ParamByName('tctype').AsString :='0'
          else if sg_same.cells[3,i]='按百分比' then
            ParamByName('tctype').AsString :='1';
          ParamByName('tcvalue').AsFloat :=StrToFloat(sg_same.Cells[4,i]);
          ParamByName('conftype').AsString :='0';
          ExecSQL;
        end;

      end;
    finally
      try
        dmod.Database.Commit ;
        MessageBox(handle,'服务提成按统一设置保存完成!','提示',mb_ok+mb_iconinformation);
      except
        dmod.Database.Rollback ;
        MessageBox(handle,'服务提成按统一设置保存失败,请重试!','提示',mb_ok+mb_iconinformation);
      end;
    end;
end;

procedure Tfrm_serviceitemextra.SaveSpecificServiceExtra(temp:string) ;
var
  i:integer;
begin
  if pagecontrol1.ActivePage <> sht_specific then

⌨️ 快捷键说明

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