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

📄 cwa100_02.pas.svn-base

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

interface

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

type
  TCwa100_02Form = class(TBas100_01Form)
    Label1: TLabel;
    Label2: TLabel;
    wwDBDateTimePicker1: TwwDBDateTimePicker;
    wwDBDateTimePicker2: TwwDBDateTimePicker;
    Bevel1: TBevel;
    bbtnOk: TBitBtn;
    bbtnExit: TBitBtn;
    ComboBox1: TComboBox;
    ComboBox2: TComboBox;
    Label5: TLabel;
    Label6: TLabel;
    wwDBDateTimePicker4: TwwDBDateTimePicker;
    wwDBDateTimePicker3: TwwDBDateTimePicker;
    RadioButton1: TRadioButton;
    RadioButton2: TRadioButton;
    ADOQuery1: TADOQuery;
    procedure FormCreate(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure bbtnOkClick(Sender: TObject);
    procedure bbtnExitClick(Sender: TObject);
  private
    procedure SetWorkCalendar;
    procedure SetInterface;
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Cwa100_02Form: TCwa100_02Form;

implementation

uses CommFun, SYSDATA, Wait;

{$R *.DFM}

procedure TCwa100_02Form.SetWorkCalendar;
var
  AFlag,AType,AWeek,AWeekID:Integer;
  ADate,AFromDate,AToDate:TDate;
begin
  AFlag:=0;
  if RadioButton1.Checked then AFlag:=1  //每周
  else if RadioButton2.Checked then AFlag:=2;  //隔周
  AType:=ComboBox2.ItemIndex+1;  //1=工作日,2=全天公休,3=国定假日,4=下午公休半天,5=上午公休半天
  AFromDate:=wwDBDateTimePicker1.Date;
  AToDate:=wwDBDateTimePicker2.Date;

  SYSDM.qryQuery.Close;
  SYSDM.qryQuery.SQL.Clear;
  SYSDM.qryQuery.SQL.Add('delete from CWA100 where C100_001>='+GetDateString(AFromDate)+' and C100_001<='+GetDateString(AToDate));
  SYSDM.qryQuery.ExecSQL;

  AWeekID:=ComboBox1.ItemIndex;
  ADate:=AFromDate;
  while ADate<=AToDate do
  begin
    AWeek:=DayOfWeek(ADate)-1;
    SYSDM.qryQuery.Close;
    SYSDM.qryQuery.SQL.Clear;
    SYSDM.qryQuery.SQL.Add('select * from CWA100 where C100_001='+GetDateString(ADate));
    SYSDM.qryQuery.Open;
    if SYSDM.qryQuery.IsEmpty then
    begin
      ADOQuery1.Close;
      ADOQuery1.SQL.Clear;
      ADOQuery1.SQL.Add('select top 1 * from CWA100 order by C100_001 desc');
      ADOQuery1.Open;
      ADOQuery1.Append;
      ADOQuery1.FieldByName('C100_001').Value:=ADate;
      ADOQuery1.FieldByName('C100_002').Value:=1;
      ADOQuery1.FieldByName('C100_003').Value:=AWeek;
      ADOQuery1.FieldByName('C100_004').Value:='';
      ADOQuery1.Post;
    end;
    ADate:=ADate+1
  end;

  if AFlag=1 then	//1=每周,2=隔周
  begin
    SYSDM.qryQuery.Close;
    SYSDM.qryQuery.SQL.Clear;
    SYSDM.qryQuery.SQL.Add('update CWA100 set C100_002='+IntToStr(AType)+' where C100_001>='+GetDateString(AFromDate)+' and C100_001<='+GetDateString(AToDate)+' and C100_003='+IntToStr(AWeekID));
    SYSDM.qryQuery.ExecSQL;
  end else		//2=隔周
  begin
    //设置双周为公体日
    SYSDM.qryQuery.Close;
    SYSDM.qryQuery.SQL.Clear;
    case ADataBase of  //0=Access, 1=SQL Server
      0:SYSDM.qryQuery.SQL.Add('update CWA100 set C100_002='+IntToStr(AType)+' where C100_001>='+GetDateString(AFromDate)+' and C100_001<='+GetDateString(AToDate)+' and (datepart(''ww'',C100_001) mod 2)=0 and C100_003='+IntToStr(AWeekID));
      1:SYSDM.qryQuery.SQL.Add('update CWA100 set C100_002='+IntToStr(AType)+' where C100_001>='+GetDateString(AFromDate)+' and C100_001<='+GetDateString(AToDate)+' and (datepart(ww,C100_001) % 2)=0 and C100_003='+IntToStr(AWeekID));
    end;
    SYSDM.qryQuery.ExecSQL;
  end;

  //设定国定假日
  if (wwDBDateTimePicker3.Text<>'') and (wwDBDateTimePicker4.Text<>'') then
  begin
    SYSDM.qryQuery.Close;
    SYSDM.qryQuery.SQL.Clear;
    SYSDM.qryQuery.SQL.Add('update CWA100 set C100_002=''3'' where C100_001>='+GetDateString(wwDBDateTimePicker3.Date)+' and C100_001<='+GetDateString(wwDBDateTimePicker4.Date));
    SYSDM.qryQuery.ExecSQL;
  end;
end;

procedure TCwa100_02Form.SetInterface;
begin
  Caption:=GetDBString('CWA10002001');  //设置
  Label1.Caption:=GetDBString('CWA10002002');  //日期范围
  Label2.Caption:=GetDBString('CWA10002003');  //至
  Label5.Caption:=GetDBString('CWA10002004');  //国定假日
  Label6.Caption:=GetDBString('CWA10002003');  //至
  RadioButton1.Caption:=GetDBString('CWA10002005');  //每周
  RadioButton2.Caption:=GetDBString('CWA10002006');  //隔周
  bbtnOk.Caption:=GetDBString('CWA10002007');  //确定(&O)
  bbtnExit.Caption:=GetDBString('CWA10002008');  //退出(&X)
end;

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

  ComboBox1.Items.Clear;
  ComboBox1.Items.Add(GetDBString('CWA10001020'));  //星期日
  ComboBox1.Items.Add(GetDBString('CWA10001021'));  //星期一
  ComboBox1.Items.Add(GetDBString('CWA10001022'));  //星期二
  ComboBox1.Items.Add(GetDBString('CWA10001023'));  //星期三
  ComboBox1.Items.Add(GetDBString('CWA10001024'));  //星期四
  ComboBox1.Items.Add(GetDBString('CWA10001025'));  //星期五
  ComboBox1.Items.Add(GetDBString('CWA10001026'));  //星期六
  ComboBox1.ItemIndex:=0;

  ComboBox2.Items.Clear;
  ComboBox2.Items.Add(GetDBString('CWA10001027'));  //工作日
  ComboBox2.Items.Add(GetDBString('CWA10001028'));  //全天公休
  ComboBox2.Items.Add(GetDBString('CWA10001029'));  //国定假日
  ComboBox2.Items.Add(GetDBString('CWA10001030'));  //下午公休半天
  ComboBox2.Items.Add(GetDBString('CWA10001031'));  //上午公休半天
  ComboBox2.ItemIndex:=1;

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

procedure TCwa100_02Form.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  inherited;
//
end;

procedure TCwa100_02Form.bbtnOkClick(Sender: TObject);
begin
  inherited;
//确定
  if wwDBDateTimePicker1.Date>wwDBDateTimePicker2.Date then
  begin
    ShowMsg('UMS10000198');  //日期范围起始日期必须小于或等于结束日期
    wwDBDateTimePicker1.SetFocus;
    Abort;
  end;
  if wwDBDateTimePicker3.Date>wwDBDateTimePicker4.Date then
  begin
    ShowMsg('UMS10000204');  //国定假日起始日期必须小于或等于结束日期
    wwDBDateTimePicker3.SetFocus;
    Abort;
  end;
  try
    Screen.Cursor:=crHourGlass;
    WaitForm.Show;
    WaitForm.Update;
    SetWorkCalendar;
  except
    WaitForm.Close;
    Screen.Cursor:=crDefault;
    ShowMsg(GetDBString('UMS10000057')+#13+SYSDM.ADOC.Errors[0].Description,1);  //工作日历设置失败
    Abort;
  end;
  WaitForm.Close;
  Screen.Cursor:=crDefault;
  ShowMsg('UMS10000058');  //工作日历设置成功
  Close;
end;

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

initialization
  RegisterClass(TCwa100_02Form);

finalization
  UnRegisterClass(TCwa100_02Form);

end.

⌨️ 快捷键说明

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