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

📄 cwa500_02.pas.svn-base

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

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Bas100_01, StdCtrls, ExtCtrls, Db, Buttons, wwdbdatetimepicker,
  Mask, ADODB, wwdbedit, Menus, dxCntner, dxEditor, dxExEdtr, dxEdLib;

type
  TCwa500_02Form = class(TBas100_01Form)
    lblType: TLabel;
    cbType: TComboBox;
    lblDept: TLabel;
    lblEmpID: TLabel;
    lblEmpTo: TLabel;
    lblDate: TLabel;
    lblDateTo: TLabel;
    Bevel1: TBevel;
    dtFromDate: TwwDBDateTimePicker;
    dtToDate: TwwDBDateTimePicker;
    bbtnOk: TBitBtn;
    bbtnExit: TBitBtn;
    cbDepart: TComboBox;
    lblTime: TLabel;
    lblTimeTo: TLabel;
    edtValue: TwwDBEdit;
    lblValue: TLabel;
    lblUnit: TLabel;
    edtFromEmpID: TEdit;
    SpeedButton1: TSpeedButton;
    edtToEmpID: TEdit;
    SpeedButton2: TSpeedButton;
    qryHrm100: TADOQuery;
    qryHrm150: TADOQuery;
    qryHrm150H150_001: TAutoIncField;
    qryHrm150H150_002: TStringField;
    qryHrm150H150_003: TStringField;
    ADOQuery1: TADOQuery;
    edtFromTime: TdxTimeEdit;
    edtToTime: TdxTimeEdit;
    procedure FormCreate(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure bbtnOkClick(Sender: TObject);
    procedure bbtnExitClick(Sender: TObject);
    procedure cbTypeChange(Sender: TObject);
    procedure SpeedButton1Click(Sender: TObject);
    procedure SpeedButton2Click(Sender: TObject);
    procedure edtFromEmpIDKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure edtToEmpIDKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure edtToTimeExit(Sender: TObject);
    procedure edtValueKeyPress(Sender: TObject; var Key: Char);
  private
    procedure SetInterface;
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Cwa500_02Form: TCwa500_02Form;

implementation

uses SYSDATA, CommFun, HwSelData;

{$R *.DFM}

function GetTimeValue(ATime:array of string;ATimeValue:array of Integer;var AFromTime,AToTime:string):Integer;
var
  AValue:Integer;
  Time01,Time02:Integer;
begin
  //起始时间
  if AFromTime<=ATime[1] then
  begin
    AFromTime:=ATime[1];
    Time01:=0;
  end else
  if AFromTime<=ATime[2] then
  begin
    AFromTime:=AFromTime;
    AValue:=StrToInt(copy(AFromTime,1,2))*60+StrToInt(copy(AFromTime,4,2));
    Time01:=AValue-ATimeValue[1];
  end else
  if AFromTime<=ATime[3] then
  begin
    AFromTime:=ATime[3];
    Time01:=ATimeValue[2]-ATimeValue[1];
  end else
  if AFromTime<=ATime[4] then
  begin
    AFromTime:=AFromTime;
    AValue:=StrToInt(copy(AFromTime,1,2))*60+StrToInt(copy(AFromTime,4,2));
    Time01:=AValue-ATimeValue[3]+ATimeValue[2]-ATimeValue[1];
  end else
  if AFromTime<=ATime[5] then
  begin
    AFromTime:=ATime[5];
    Time01:=ATimeValue[4]-ATimeValue[3]+ATimeValue[2]-ATimeValue[1];
  end else
  if AFromTime<=ATime[6] then
  begin
    AFromTime:=AFromTime;
    AValue:=StrToInt(copy(AFromTime,1,2))*60+StrToInt(copy(AFromTime,4,2));
    Time01:=AValue-ATimeValue[5]+ATimeValue[4]-ATimeValue[3]+ATimeValue[2]-ATimeValue[1];
  end else
  begin
    if ATimeValue[6]<>0 then AFromTime:=ATime[6]
    else if ATimeValue[4]<>0 then AFromTime:=ATime[4]
    else if ATimeValue[2]<>0 then AFromTime:=ATime[2];
    Time01:=ATimeValue[2]-ATimeValue[1]+ATimeValue[4]-ATimeValue[3]+ATimeValue[6]-ATimeValue[5];
  end;

  //结束时间
  if AToTime<=ATime[1] then
  begin
    AToTime:=ATime[1];
    Time02:=0;
  end else
  if AToTime<=ATime[2] then
  begin
    AToTime:=AToTime;
    AValue:=StrToInt(copy(AToTime,1,2))*60+StrToInt(copy(AToTime,4,2));
    Time02:=AValue-ATimeValue[1];
  end else
  if AToTime<=ATime[3] then
  begin
    AToTime:=ATime[3];
    Time02:=ATimeValue[2]-ATimeValue[1];
  end else
  if AToTime<=ATime[4] then
  begin
    AToTime:=AToTime;
    AValue:=StrToInt(copy(AToTime,1,2))*60+StrToInt(copy(AToTime,4,2));
    Time02:=AValue-ATimeValue[3]+ATimeValue[2]-ATimeValue[1];
  end else
  if AToTime<=ATime[5] then
  begin
    AToTime:=ATime[5];
    Time02:=ATimeValue[4]-ATimeValue[3]+ATimeValue[2]-ATimeValue[1];
  end else
  if AToTime<=ATime[6] then
  begin
    AToTime:=AToTime;
    AValue:=StrToInt(copy(AToTime,1,2))*60+StrToInt(copy(AToTime,4,2));
    Time02:=AValue-ATimeValue[5]+ATimeValue[4]-ATimeValue[3]+ATimeValue[2]-ATimeValue[1];
  end else
  begin
    if ATimeValue[6]<>0 then AToTime:=ATime[6]
    else if ATimeValue[4]<>0 then AToTime:=ATime[4]
    else if ATimeValue[2]<>0 then AToTime:=ATime[2];
    Time02:=ATimeValue[2]-ATimeValue[1]+ATimeValue[4]-ATimeValue[3]+ATimeValue[6]-ATimeValue[5];
  end;
  Result:=Time02-Time01;
end;

function GetTypeTime(AEmpNo:Integer;ADate:TDateTime;var AFromTime, AToTime:string):Double;
var
  ATime:array [1..6] of String;
  ATimeValue:array [1..6] of Integer;
begin
  //取员工班别的时间
  SYSDM.qryQuery.Close;
  SYSDM.qryQuery.SQL.Clear;
  SYSDM.qryQuery.SQL.Add('select C120_004,C120_005,C120_006,C120_007,C120_008,C120_009,C120_010');
  SYSDM.qryQuery.SQL.Add('from CWA120 where C120_001='+IntToStr(AEmpNo)+' and C120_003='+GetDateString(ADate));
  SYSDM.qryQuery.Open;
  ATime[1]:=SYSDM.qryQuery.Fields[0].Value;
  ATime[2]:=SYSDM.qryQuery.Fields[1].Value;
  ATime[3]:=SYSDM.qryQuery.Fields[2].Value;
  ATime[4]:=SYSDM.qryQuery.Fields[3].Value;
  ATime[5]:=SYSDM.qryQuery.Fields[4].Value;
  ATime[6]:=SYSDM.qryQuery.Fields[5].Value;
  ATimeValue[1]:=StrToInt(copy(ATime[1],1,2))*60+StrToInt(copy(ATime[1],4,2));
  ATimeValue[2]:=StrToInt(copy(ATime[2],1,2))*60+StrToInt(copy(ATime[2],4,2));
  ATimeValue[3]:=StrToInt(copy(ATime[3],1,2))*60+StrToInt(copy(ATime[3],4,2));
  ATimeValue[4]:=StrToInt(copy(ATime[4],1,2))*60+StrToInt(copy(ATime[4],4,2));
  ATimeValue[5]:=StrToInt(copy(ATime[5],1,2))*60+StrToInt(copy(ATime[5],4,2));
  ATimeValue[6]:=StrToInt(copy(ATime[6],1,2))*60+StrToInt(copy(ATime[6],4,2));
  if AFromTime='' then
  begin
    if ATimeValue[1]<>0 then AFromTime:=ATime[1]
    else if ATimeValue[3]<>0 then AFromTime:=ATime[3]
    else if ATimeValue[5]<>0 then AFromTime:=ATime[5];
  end;
  if AToTime='' then
  begin
    if ATimeValue[6]<>0 then AToTime:=ATime[6]
    else if ATimeValue[4]<>0 then AToTime:=ATime[4]
    else if ATimeValue[2]<>0 then AToTime:=ATime[2];
  end;
  Result:=GetTimeValue(ATime,ATimeValue,AFromTime,AToTime);
end;

procedure TCwa500_02Form.SetInterface;
begin
  Caption:=GetDBString('CWA50002001');  //成批录入
  lblType.Caption:=GetDBString('CWA50002002');  //事务类型
  lblDept.Caption:=GetDBString('CWA50002003');  //部门编号
  lblEmpID.Caption:=GetDBString('CWA50002004');  //员工编号
  lblEmpTo.Caption:=GetDBString('CWA50002005');  //至
  lblDate.Caption:=GetDBString('CWA50002006');  //日期范围
  lblDateTo.Caption:=GetDBString('CWA50002005');  //至
  lblTime.Caption:=GetDBString('CWA50002007');  //时间范围
  lblTimeTo.Caption:=GetDBString('CWA50002005');  //至
  lblValue.Caption:=GetDBString('CWA50002008');  //事务数值
  lblUnit.Caption:=GetDBString('CWA50002009');  //分钟
  bbtnOk.Caption:=GetDBString('CWA50002010');  //确定(&O)
  bbtnExit.Caption:=GetDBString('CWA50002011');  //退出(&X)
end;

procedure TCwa500_02Form.FormCreate(Sender: TObject);
var
  ADate:TDateTime;
begin
  inherited;
  //事务类型
  cbType.Clear;
  SYSDM.qryQuery.Close;
  SYSDM.qryQuery.SQL.Clear;
  SYSDM.qryQuery.SQL.Add('select C150_003 from CWA150 where C150_004=0 and C150_008='+GetBoolean(True));
  SYSDM.qryQuery.Open;
  while not SYSDM.qryQuery.Eof do
  begin
    cbType.Items.Add(SYSDM.qryQuery.Fields[0].AsString);
    SYSDM.qryQuery.Next;
  end;
  cbType.ItemIndex:=0;
  cbTypeChange(cbType);

  //部门资料
  cbDepart.Items.Clear;
  cbDepart.Items.Add(GetDBString('COM00004007'));  //所有部门
  qryHrm100.Close;
  qryHrm100.Open;
  while not qryHrm100.Eof do
  begin
    cbDepart.Items.Add(qryHrm100.FieldByName('H100_002').AsString);
    qryHrm100.Next;
  end;
  cbDepart.ItemIndex:=0;

  GetLocaleInfo(LOCALE_SYSTEM_DEFAULT, LOCALE_SSHORTDATE, ASystemDate, SizeOf(ASystemDate));
  ADate:=StrToDate(FormatDateTime(ASystemDate,GetServerDate));
  dtFromDate.Date:=ADate;
  dtToDate.Date:=ADate;
  //设置界面信息
  SetInterface;
end;

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

function GetDateTime(ATypeNo,AUnitNo,AEmpNo,AHours:Integer;AFromDate,AToDate:TDateTime;var AFromTime,AToTime:string;AFlag:Boolean):Double;
var
  ADate:TDateTime;
  ATime:Double;
begin
  Result:=0;
  ADate:=AFromDate;
  while ADate<=AToDate do
  begin
    //大于起始日期 小于结束日期
    if (ADate>AFromDate) and (ADate<AToDate) then
    begin
      AFromTime:='';
      AToTime:='';
    end;
    //结束日期
    if ADate=AToDate then
    begin
      AFromTime:='';
      AToTime:=AToTime;
    end;
    //起始日期
    if ADate=AFromDate then
    begin
      AFromTime:=AFromTime;
      AToTime:='';
    end;
    if ATypeNo=4 then   //事务类型=请假则自动计算时间
    begin
      ATime:=GetTypeTime(AEmpNo,ADate,AFromTime,AToTime);
      case AUnitNo of  //0=分钟,1=小时,2=天,3=次,4=月,5=年,6=元
        0:ATime:=ATime;
        1:ATime:=ATime/60;
        2:ATime:=ATime/60/AHours;
        3:ATime:=ATime;
      end;
    end else

⌨️ 快捷键说明

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