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

📄 cwa120_02.pas.svn-base

📁 这是一个功能齐全的,代码完整的ERP企业信息管理系统,现在上传和大家分享
💻 SVN-BASE
字号:
unit Cwa120_02;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Bas100_01, StdCtrls, wwdbdatetimepicker, Mask, Buttons, ExtCtrls, DBCtrls, Db,
  ADODB, dxdbtrel, Menus, ComCtrls;

type
  TCwa120_02Form = class(TBas100_01Form)
    Label1: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    wwDBDateTimePicker1: TwwDBDateTimePicker;
    wwDBDateTimePicker2: TwwDBDateTimePicker;
    Bevel1: TBevel;
    bbtnOk: TBitBtn;
    bbtnExit: TBitBtn;
    cbDept: TComboBox;
    ComboBox3: TComboBox;
    Edit1: TEdit;
    SpeedButton1: TSpeedButton;
    Edit2: TEdit;
    SpeedButton2: TSpeedButton;
    dsHrm100: TDataSource;
    qryHrm100: TADOQuery;
    qryHrm150: TADOQuery;
    qryHrm150H150_001: TAutoIncField;
    qryHrm150H150_002: TStringField;
    qryHrm150H150_003: TStringField;
    procedure FormCreate(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure bbtnOkClick(Sender: TObject);
    procedure bbtnExitClick(Sender: TObject);
    procedure SpeedButton1Click(Sender: TObject);
    procedure SpeedButton2Click(Sender: TObject);
  private
    procedure SetBanBei;
    procedure SetInterface;
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Cwa120_02Form: TCwa120_02Form;

implementation

uses SYSDATA, CommFun, Wait, HwSelData;

{$R *.DFM}

procedure TCwa120_02Form.SetBanBei;
var
  ABanBei,ADepartID,AFromEmpID,AToEmpID:string;
  AFromDate,AToDate:TDate;
begin
  ADepartID:=trim(cbDept.Text);
  AFromEmpID:=trim(Edit1.Text);
  AToEmpID:=trim(Edit2.Text);
  AFromDate:=wwDBDateTimePicker1.Date;
  AToDate:=wwDBDateTimePicker2.Date;
  ABanBei:=trim(ComboBox3.Text);

  if cbDept.ItemIndex=0 then  //所有部门
  begin
    //删除旧资料
    SYSDM.qryQuery.Close;
    SYSDM.qryQuery.SQL.Clear;
    SYSDM.qryQuery.SQL.Add('delete from CWA120 where C120_003>='+GetDateString(AFromDate)+' and C120_003<='+GetDateString(AToDate));
    if (AFromEmpID<>'') and (AToEmpID<>'') then
      SYSDM.qryQuery.SQL.Add(' and C120_001 in (select H150_001 from HRM150 where H150_002>='+''''+AFromEmpID+''''+' and H150_002<='+''''+AToEmpID+''''+')');
    SYSDM.qryQuery.ExecSQL;

    SYSDM.qryQuery.Close;
    SYSDM.qryQuery.SQL.Clear;
    SYSDM.qryQuery.SQL.Add('insert into CWA120(C120_001, C120_002, C120_003, C120_004, C120_005,');
    SYSDM.qryQuery.SQL.Add('  C120_006, C120_007, C120_008, C120_009, C120_010, C120_011, C120_012, C120_013, C120_014)');
    SYSDM.qryQuery.SQL.Add('select A.H150_001, B.C110_001, C.C100_001, B.C110_004,');
    SYSDM.qryQuery.SQL.Add('  B.C110_005, B.C110_006, B.C110_007, B.C110_008, B.C110_009, '+GetBoolean(False)+', '+GetBoolean(False)+', B.C110_011, B.C110_012, B.C110_013');
    SYSDM.qryQuery.SQL.Add('from HRM150 A, CWA110 B, CWA100 C');
    SYSDM.qryQuery.SQL.Add('where B.C110_003='+''''+ABanBei+'''');
    SYSDM.qryQuery.SQL.Add(' and C.C100_001>='+GetDateString(AFromDate)+' and C.C100_001<='+GetDateString(AToDate));
    if (AFromEmpID<>'') and (AToEmpID<>'') then
      SYSDM.qryQuery.SQL.Add(' and A.H150_002>='+''''+AFromEmpID+''''+' and A.H150_002<='+''''+AToEmpID+'''');
    SYSDM.qryQuery.ExecSQL;
  end else
  begin
    //删除旧资料
    SYSDM.qryQuery.Close;
    SYSDM.qryQuery.SQL.Clear;
    SYSDM.qryQuery.SQL.Add('delete from CWA120 where C120_003>='+GetDateString(AFromDate)+' and C120_003<='+GetDateString(AToDate));
    SYSDM.qryQuery.SQL.Add(' and (select H150_005 from HRM150 where H150_001=C120_001)='+''''+ADepartID+'''');
    if (AFromEmpID<>'') and (AToEmpID<>'') then
      SYSDM.qryQuery.SQL.Add(' and C120_001 in (select H150_001 from HRM150 where H150_002>='+''''+AFromEmpID+''''+' and H150_002<='+''''+AToEmpID+''''+')');
    SYSDM.qryQuery.ExecSQL;

    SYSDM.qryQuery.Close;
    SYSDM.qryQuery.SQL.Clear;
    SYSDM.qryQuery.SQL.Add('insert into CWA120(C120_001, C120_002, C120_003, C120_004, C120_005,');
    SYSDM.qryQuery.SQL.Add('C120_006, C120_007, C120_008, C120_009, C120_010, C120_011, C120_012, C120_013, C120_014)');
    SYSDM.qryQuery.SQL.Add('select A.H150_001, B.C110_001, C.C100_001, B.C110_004,');
    SYSDM.qryQuery.SQL.Add('B.C110_005, B.C110_006, B.C110_007, B.C110_008, B.C110_009, '+GetBoolean(False)+', '+GetBoolean(False)+', B.C110_011, B.C110_012, B.C110_013');
    SYSDM.qryQuery.SQL.Add('from HRM150 A, CWA110 B, CWA100 C');
    SYSDM.qryQuery.SQL.Add('where B.C110_003='+''''+ABanBei+'''');
    SYSDM.qryQuery.SQL.Add(' and C.C100_001>='+GetDateString(AFromDate)+' and C.C100_001<='+GetDateString(AToDate));
    SYSDM.qryQuery.SQL.Add('and A.H150_005='+''''+ADepartID+'''');
    if (AFromEmpID<>'') and (AToEmpID<>'') then
      SYSDM.qryQuery.SQL.Add(' and A.H150_002>='+''''+AFromEmpID+''''+' and A.H150_002<='+''''+AToEmpID+'''');
    SYSDM.qryQuery.ExecSQL;
  end;

  //将公休天,假期的上下班时间改为""
  //类型('1'=工作日,'2'=全天公休,'3'=国定假日,'4'=下午公休半天,'5'=上午公休半天)
  SYSDM.qryQuery.Close;
  SYSDM.qryQuery.SQL.Clear;
  SYSDM.qryQuery.SQL.Add('update CWA120 set C120_004='''', C120_005='''', C120_006='''',');
  SYSDM.qryQuery.SQL.Add('C120_007='''', C120_008='''', C120_009='''', C120_012=-1, C120_013=-1, C120_014=-1');
  SYSDM.qryQuery.SQL.Add('where exists(select 1 from CWA100 where C100_001=C120_003 and C100_002 in (2,3))');
  SYSDM.qryQuery.ExecSQL;

  //将半天公休的上下班时间改为""
  SYSDM.qryQuery.Close;
  SYSDM.qryQuery.SQL.Clear;
  SYSDM.qryQuery.SQL.Add('update CWA120 set C120_006='''', C120_007='''', C120_008='''', C120_009='''', C120_013=-1, C120_014=-1');
  SYSDM.qryQuery.SQL.Add('where exists(select 1 from CWA100 where C100_001=C120_003 and C100_002 in (4))');
  SYSDM.qryQuery.ExecSQL;

  SYSDM.qryQuery.Close;
  SYSDM.qryQuery.SQL.Clear;
  SYSDM.qryQuery.SQL.Add('update CWA120 set C120_004='''', C120_005='''', C120_008='''', C120_009='''', C120_012=-1, C120_014=-1');
  SYSDM.qryQuery.SQL.Add('where exists(select 1 from CWA100 where C100_001=C120_003 and C100_002 in (5))');
  SYSDM.qryQuery.ExecSQL;
end;

procedure TCwa120_02Form.SetInterface;
begin
  Caption:=GetDBString('CWA12002001');  //员工班次设置
  Label1.Caption:=GetDBString('CWA12002002');  //部门编号
  Label3.Caption:=GetDBString('CWA12002003');  //员工编号
  Label4.Caption:=GetDBString('CWA12002006');  //至
  Label5.Caption:=GetDBString('CWA12002004');  //日期
  Label6.Caption:=GetDBString('CWA12002006');  //至
  Label7.Caption:=GetDBString('CWA12002005');  //班次
  bbtnOk.Caption:=GetDBString('CWA12002007');  //确定(&O)
  bbtnExit.Caption:=GetDBString('CWA12002008');  //退出(&X)
end;

procedure TCwa120_02Form.FormCreate(Sender: TObject);
begin
  inherited;
  //设置界面信息
  SetInterface;

  //部门资料
  cbDept.Items.Clear;
  cbDept.Items.Add(GetDBString('COM00004007'));  //所有部门
  qryHrm100.Close;
  qryHrm100.Open;
  while not qryHrm100.Eof do
  begin
    cbDept.Items.Add(qryHrm100.FieldByName('H100_002').AsString);
    qryHrm100.Next;
  end;
  cbDept.ItemIndex:=0;
  //班次资料
  ComboBox3.Items.Clear;
  SYSDM.qryQuery.Close;
  SYSDM.qryQuery.SQL.Clear;
  SYSDM.qryQuery.SQL.Add('select C110_003 from CWA110');
  SYSDM.qryQuery.Open;
  while not SYSDM.qryQuery.Eof do
  begin
    ComboBox3.Items.Add(SYSDM.qryQuery.Fields[0].AsString);
    SYSDM.qryQuery.Next;
  end;

  qryHrm150.Open;
  wwDBDateTimePicker1.Date:=GetMonthFirstDate(Date);
  wwDBDateTimePicker2.Date:=GetMonthEndDate(Date);
end;

procedure TCwa120_02Form.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  inherited;
  qryHrm150.Close;
end;

procedure TCwa120_02Form.bbtnOkClick(Sender: TObject);
var
  ABanBei,ADepartID,AFromEmpID,AToEmpID:string;
  AFromDate,AToDate:TDate;
begin
  inherited;
//确定
  ADepartID:=trim(cbDept.Text);
  AFromEmpID:=trim(Edit1.Text);
  AToEmpID:=trim(Edit2.Text);
  AFromDate:=wwDBDateTimePicker1.Date;
  AToDate:=wwDBDateTimePicker2.Date;
  ABanBei:=trim(ComboBox3.Text);
  if (wwDBDateTimePicker1.Text='') and (wwDBDateTimePicker2.Text='') then
  begin
    ShowMsg('UMS10000213');  //日期范围不能为空
    wwDBDateTimePicker1.SetFocus;
    Abort;
  end;
  if AFromEmpID>AToEmpID then
  begin
    ShowMsg('UMS10000060');  //起始员工编号大于截止员工编号
    Edit1.SetFocus;
    Abort;
  end;
  if AFromDate>AToDate then
  begin
    ShowMsg('UMS10000044');  //起始日期不能大于结束日期
    wwDBDateTimePicker1.SetFocus;
    Abort;
  end;
  if ABanBei='' then
  begin
    ShowMsg('UMS10000061');  //班次不能为空
    ComboBox3.SetFocus;
    Abort;
  end;
  SYSDM.qryQuery.Close;
  SYSDM.qryQuery.SQL.Clear;
  SYSDM.qryQuery.SQL.Add('select 1 from CWA100 where C100_001>='+GetDateString(AFromDate)+' and C100_001<='+GetDateString(AToDate));
  SYSDM.qryQuery.Open;
  if SYSDM.qryQuery.IsEmpty then
  begin
    ShowMsg('UMS10000062');  //工作日历为空,请先设置工作日历
    Abort;
  end;

  WaitForm.Show;     
  WaitForm.Update;
  try
    SetBanBei;
  except
    WaitForm.Close;
    ShowMsg(GetDBString('UMS10000063')+#13+SYSDM.ADOC.Errors[0].Description+#13+SYSDM.qryQuery.SQL.Text,1);  //员工班别设置失败
    Abort;
  end;
  WaitForm.Close;
  ShowMsg('UMS10000064');  //员工班别设置成功
  Close;
end;

procedure TCwa120_02Form.bbtnExitClick(Sender: TObject);
begin
  inherited;
//退出
  Close;
end;

procedure TCwa120_02Form.SpeedButton1Click(Sender: TObject);
begin
  inherited;
//员工编号查询1
  if not Edit1.Focused then Edit1.SetFocus;
  HwSelDataForm:=THwSelDataForm.Create(Application);
  HwSelDataForm.OpenSelData(qryHrm150,nil);
  if HwSelDataForm.ShowModal=1 then
  begin
    Edit1.Text:=qryHrm150.FieldByName('H150_002').AsString;
  end;
end;

procedure TCwa120_02Form.SpeedButton2Click(Sender: TObject);
begin
  inherited;
//员工编号查询2
  if not Edit2.Focused then Edit2.SetFocus;
  HwSelDataForm:=THwSelDataForm.Create(Application);
  HwSelDataForm.OpenSelData(qryHrm150,nil);
  if HwSelDataForm.ShowModal=1 then
  begin
    Edit2.Text:=qryHrm150.FieldByName('H150_002').AsString;
  end;
end;

initialization
  RegisterClass(TCwa120_02Form);

finalization
  UnRegisterClass(TCwa120_02Form);

end.

⌨️ 快捷键说明

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