unit U_WorkDeptList_DK;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ComCtrls, ToolWin, cxStyles, cxCustomData, cxGraphics, cxFilter,
  cxData, cxDataStorage, cxEdit, DB, cxDBData, cxTextEdit, cxCalendar,
  cxGridLevel, cxGridCustomTableView, cxGridTableView, cxGridDBTableView,
  cxClasses, cxControls, cxGridCustomView, cxGrid, ADODB, DBClient,
  cxButtonEdit, cxPC, StdCtrls, ExtCtrls, ExtDlgs, IdBaseComponent,
  IdComponent, IdTCPConnection, IdTCPClient, IdFTP,jpeg, IniFiles,
  DelphiTwain, Buttons,MMSystem;

type
  TFrmWorkDeptList_DK = class(TForm)
    cxGrid1: TcxGrid;
    Tv1: TcxGridDBTableView;
    v1DKDate: TcxGridDBColumn;
    v1YGName: TcxGridDBColumn;
    cxGrid1Level1: TcxGridLevel;
    Order_Main: TClientDataSet;
    ADOQueryMain: TADOQuery;
    DataSource1: TDataSource;
    ADOQueryDel: TADOQuery;
    Panel1: TPanel;
    Label1: TLabel;
    YGID: TEdit;
    Button1: TButton;
    OpenPictureDialog1: TOpenPictureDialog;
    IdFTP1: TIdFTP;
    adoqueryImage: TADOQuery;
    ADOQuery1: TADOQuery;
    SaveDialog1: TSavePictureDialog;
    Label3: TLabel;
    filltime: TDateTimePicker;
    CheckBox1: TCheckBox;
    v1SXBstatus: TcxGridDBColumn;
    procedure FormShow(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormDestroy(Sender: TObject);
    procedure YGIDKeyPress(Sender: TObject; var Key: Char);
    procedure Button1Click(Sender: TObject);
    procedure Image1MouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure FormCreate(Sender: TObject);
  private
    hWndC : THandle;
    CapturingAVI : bool;
    { Private declarations }
    ClickPos: TPoint;
    SelectedSource, PicLeft, PicTop, PicWidth, PicHeight: Integer;
    procedure initGrid();
    { Private declarations }
  public
    canshu1:string;
    { Public declarations }
  end;

var
  FrmWorkDeptList_DK: TFrmWorkDeptList_DK;

implementation

uses U_ZDYHelp,U_RTfun,U_DataLink,U_WorkDeptList_DKPZ;

{$R *.dfm}

procedure TFrmWorkDeptList_DK.initGrid();
begin
  with ADOQueryMain do
  begin
    close;
    sql.Clear;
    sql.Add('select * from OA_YG_KQ ');
    sql.add('where convert(varchar(10),DKDate,120)=convert(varchar(10),getdate(),120)');
    open;
  end;
  SCreateCDS20(ADOQueryMain,Order_Main);
  SInitCDSData20(ADOQueryMain,Order_Main);
end;

procedure TFrmWorkDeptList_DK.FormShow(Sender: TObject);
begin
  ReadCxGrid('打卡',Tv1,'费用报销管理');
  with ADOQueryMain do
  begin
    close;
    sql.Clear;
    sql.Add('select * from OA_YG_KQ ');
    sql.Add('where convert(varchar(10),DKDate,120)=convert(varchar(10),getdate(),120)');
    sql.Add(' and isnull(SXBStatus,'''')='''+trim(canshu1)+'''');
    open;
  end;
  SCreateCDS20(ADOQueryMain,Order_Main);
  SInitCDSData20(ADOQueryMain,Order_Main);
  if canshu1='上班' then
  begin
    Label1.Caption:='上班扫描';
    label3.Caption:='上班日期';
  end
  else
  begin
    Label1.Caption:='下班扫描';
    label3.Caption:='下班日期';
  end;
  YGID.SetFocus;
end;

procedure TFrmWorkDeptList_DK.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  Action:=caFree;
end;

procedure TFrmWorkDeptList_DK.FormDestroy(Sender: TObject);
begin
  FrmWorkDeptList_DK:=nil;
end;

procedure TFrmWorkDeptList_DK.YGIDKeyPress(Sender: TObject; var Key: Char);
var maxno:string;
begin
  if Key=#13 then
  begin
    YGID.Enabled:=false;
    if canshu1='上班' then
    begin
      if FormatDateTime('HH',SGetServerDateTime(ADOQuery1))>'12' then
      begin
        if application.MessageBox('已超过中午12点,确定要上班打卡吗','提示',1)=2 then exit;
      end;
    end;
    if canshu1='下班' then
    begin
      if FormatDateTime('HH',SGetServerDateTime(ADOQuery1))<'12' then
      begin
        if application.MessageBox('未超过中午12点,确定要下班打卡吗','提示',1)=2 then exit;
      end;
    end;
    with ADOQueryDel do
    begin
      Close;
      sql.Clear;
      sql.Add('select * from OA_YG_DangAn ');
      sql.Add('where YGID='''+Trim(YGID.Text)+'''');
      open;
    end;
    if ADOQueryDel.IsEmpty then
    begin
      PlaySound('SMCW.wav', 0, SND_FILENAME or SND_ASYNC);
      YGID.Enabled:=true;
      YGID.Text:='';
      Exit;
    end;
    FrmWorkDeptList_DKPZ:=TFrmWorkDeptList_DKPZ.Create(self);
    with FrmWorkDeptList_DKPZ do
    begin
      FYGID:=trim(self.YGID.Text);
      IFSXB:=Trim(canshu1);
      if CheckBox1.Checked=false then
      begin
        IFZT:='0';
      end
      else
      IFZT:='1';
      if ShowModal=1 then
      begin
        Self.YGID.Text:='';
        self.YGID.Enabled:=true;
        Self.YGID.SetFocus;
        with Self.ADOQueryMain do
        begin
          close;
          sql.Clear;
          sql.Add('select * from OA_YG_KQ ');
          sql.Add('where convert(varchar(10),DKDate,120)=convert(varchar(10),getdate(),120)');
          sql.Add(' and isnull(SXBStatus,'''')='''+trim(canshu1)+'''');
          open;
        end;
        SCreateCDS20(Self.ADOQueryMain,Self.Order_Main);
        SInitCDSData20(Self.ADOQueryMain,Self.Order_Main);
      end;
      free;
    end;
  end;
end;

procedure TFrmWorkDeptList_DK.Button1Click(Sender: TObject);
begin
  WriteCxGrid('打卡',Tv1,'费用报销管理');
  close;
end;

procedure TFrmWorkDeptList_DK.Image1MouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  ClickPos.x := X;
  ClickPos.y := Y;
end;

procedure TFrmWorkDeptList_DK.FormCreate(Sender: TObject);
begin
  filltime.Date:=SGetServerDate(ADOQueryDel);
  canshu1:=trim(DParameters1);
end;

end.
