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

📄 winygjilu.pas

📁 考勤管理 考勤管理 考勤管理
💻 PAS
字号:
unit WinYGjilu;
//****************************************************************
//*公司名:华夏数码有限公司
//*系统名:考勤管理系统
//*程序名:WinYGjilu
//*
//*--------------------------------------------------------------
//*  [年月日]     [制造者]
//*--------------------------------------------------------------
//*  2005/12/29    徐二芳
//*
//****************************************************************
interface

uses
  System.Drawing, System.Collections, System.ComponentModel,
  System.Windows.Forms, System.Data,clsmain,borland.Vcl.SysUtils,system.Data.OleDb, 
  System.Resources;

type
  TWinYGjilu = class(System.Windows.Forms.Form)
  {$REGION 'Designer Managed Code'}
  strict private
    /// <summary>
    /// Required designer variable.
    /// </summary>
    components: System.ComponentModel.IContainer;
    GroupBox1: System.Windows.Forms.GroupBox;
    Label1: System.Windows.Forms.Label;
    dtpdangqian: System.Windows.Forms.DateTimePicker;
    Label2: System.Windows.Forms.Label;
    txtname: System.Windows.Forms.TextBox;
    Label4: System.Windows.Forms.Label;
    txtbumen: System.Windows.Forms.TextBox;
    butup: System.Windows.Forms.Button;
    butdown: System.Windows.Forms.Button;
    Timer1: System.Windows.Forms.Timer;
    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    procedure InitializeComponent;

    procedure TWinYGjilu_Load(sender: System.Object; e: System.EventArgs);
    procedure butup_Click(sender: System.Object; e: System.EventArgs);
    procedure TWinYGjilu_Closed(sender: System.Object; e: System.EventArgs);


    procedure butdown_Click(sender: System.Object; e: System.EventArgs);
    procedure txtbumen_TextChanged(sender: System.Object; e: System.EventArgs);

  {$ENDREGION}
  strict protected
    /// <summary>
    /// Clean up any resources being used.
    /// </summary>
    procedure Dispose(Disposing: Boolean); override;
  private

    { Private Declarations }
  public

   procedure RefreshEnabled;

    constructor Create;

  end;

  [assembly: RuntimeRequiredAttribute(TypeOf(TWinYGjilu))]

implementation


{$REGION 'Windows Form Designer generated code'}
/// <summary>
/// Required method for Designer support -- do not modify
/// the contents of this method with the code editor.
/// </summary>
procedure TWinYGjilu.InitializeComponent;
var
  resources: System.Resources.ResourceManager;
begin
  Self.components := System.ComponentModel.Container.Create;
  resources := System.Resources.ResourceManager.Create(TypeOf(TWinYGjilu));
  Self.GroupBox1 := System.Windows.Forms.GroupBox.Create;
  Self.txtbumen := System.Windows.Forms.TextBox.Create;
  Self.Label4 := System.Windows.Forms.Label.Create;
  Self.txtname := System.Windows.Forms.TextBox.Create;
  Self.Label2 := System.Windows.Forms.Label.Create;
  Self.dtpdangqian := System.Windows.Forms.DateTimePicker.Create;
  Self.Label1 := System.Windows.Forms.Label.Create;
  Self.butup := System.Windows.Forms.Button.Create;
  Self.butdown := System.Windows.Forms.Button.Create;
  Self.Timer1 := System.Windows.Forms.Timer.Create(Self.components);
  Self.GroupBox1.SuspendLayout;
  Self.SuspendLayout;
  // 
  // GroupBox1
  // 
  Self.GroupBox1.Controls.Add(Self.txtbumen);
  Self.GroupBox1.Controls.Add(Self.Label4);
  Self.GroupBox1.Controls.Add(Self.txtname);
  Self.GroupBox1.Controls.Add(Self.Label2);
  Self.GroupBox1.Controls.Add(Self.dtpdangqian);
  Self.GroupBox1.Controls.Add(Self.Label1);
  Self.GroupBox1.Location := System.Drawing.Point.Create(40, 16);
  Self.GroupBox1.Name := 'GroupBox1';
  Self.GroupBox1.Size := System.Drawing.Size.Create(264, 136);
  Self.GroupBox1.TabIndex := 0;
  Self.GroupBox1.TabStop := False;
  Self.GroupBox1.Text := ' ';
  // 
  // txtbumen
  // 
  Self.txtbumen.Enabled := False;
  Self.txtbumen.Location := System.Drawing.Point.Create(80, 96);
  Self.txtbumen.Name := 'txtbumen';
  Self.txtbumen.Size := System.Drawing.Size.Create(160, 21);
  Self.txtbumen.TabIndex := 8;
  Self.txtbumen.Text := ' ';
  Include(Self.txtbumen.TextChanged, Self.txtbumen_TextChanged);
  // 
  // Label4
  // 
  Self.Label4.Location := System.Drawing.Point.Create(24, 96);
  Self.Label4.Name := 'Label4';
  Self.Label4.TabIndex := 6;
  Self.Label4.Text := '您所在部';
  // 
  // txtname
  // 
  Self.txtname.Enabled := False;
  Self.txtname.Location := System.Drawing.Point.Create(80, 56);
  Self.txtname.Name := 'txtname';
  Self.txtname.Size := System.Drawing.Size.Create(160, 21);
  Self.txtname.TabIndex := 4;
  Self.txtname.Text := ' ';
  // 
  // Label2
  // 
  Self.Label2.Location := System.Drawing.Point.Create(24, 64);
  Self.Label2.Name := 'Label2';
  Self.Label2.TabIndex := 2;
  Self.Label2.Text := '您的姓名';
  // 
  // dtpdangqian
  // 
  Self.dtpdangqian.CustomFormat := 'yyyy-MM-dd HH:m ddd';
  Self.dtpdangqian.Enabled := False;
  Self.dtpdangqian.Format := System.Windows.Forms.DateTimePickerFormat.Custom;
  Self.dtpdangqian.Location := System.Drawing.Point.Create(80, 24);
  Self.dtpdangqian.Name := 'dtpdangqian';
  Self.dtpdangqian.Size := System.Drawing.Size.Create(160, 21);
  Self.dtpdangqian.TabIndex := 1;
  // 
  // Label1
  // 
  Self.Label1.Location := System.Drawing.Point.Create(24, 32);
  Self.Label1.Name := 'Label1';
  Self.Label1.Size := System.Drawing.Size.Create(112, 16);
  Self.Label1.TabIndex := 0;
  Self.Label1.Text := '当前时间';
  // 
  // butup
  // 
  Self.butup.Location := System.Drawing.Point.Create(64, 192);
  Self.butup.Name := 'butup';
  Self.butup.Size := System.Drawing.Size.Create(75, 40);
  Self.butup.TabIndex := 1;
  Self.butup.Text := '上  班';
  Include(Self.butup.Click, Self.butup_Click);

  // 
  // butdown
  // 
  Self.butdown.Location := System.Drawing.Point.Create(168, 192);
  Self.butdown.Name := 'butdown';
  Self.butdown.Size := System.Drawing.Size.Create(75, 40);
  Self.butdown.TabIndex := 2;
  Self.butdown.Text := '下  班';
  Include(Self.butdown.Click, Self.butdown_Click);
 
  //
  // Timer1
  // 
  Self.Timer1.Enabled := True;

  //
  // TWinYGjilu
  // 
  Self.AutoScaleBaseSize := System.Drawing.Size.Create(6, 14);
  Self.ClientSize := System.Drawing.Size.Create(336, 261);
  Self.Controls.Add(Self.butdown);
  Self.Controls.Add(Self.butup);
  Self.Controls.Add(Self.GroupBox1);
  Self.Icon := (System.Drawing.Icon(resources.GetObject('$this.Icon')));
  Self.Name := 'TWinYGjilu';
  Self.Text := '员工记录';
  Include(Self.Load, Self.TWinYGjilu_Load);
  Include(Self.Closed, Self.TWinYGjilu_Closed);
  Self.GroupBox1.ResumeLayout(False);
  Self.ResumeLayout(False);
end;
{$ENDREGION}

procedure TWinYGjilu.Dispose(Disposing: Boolean);
begin
  if Disposing then
  begin
    if Components <> nil then
      Components.Dispose();
  end;
  inherited Dispose(Disposing);
end;

constructor TWinYGjilu.Create;
begin
  inherited Create;
  //
  // Required for Windows Form Designer support
  //
  InitializeComponent;
  //
  // TODO: Add any constructor code after InitializeComponent call
  //
end;

procedure TWinYGjilu.txtbumen_TextChanged(sender: System.Object; e: System.EventArgs);
begin
  
end;





//****************************************************************
//*  窗体加载 [Load]
//*
//*  [参数]
//*      1:系统参数
//*      2:系统参数
//*  [返回]
//*      无
//****************************************************************
procedure TWinYGjilu.TWinYGjilu_Load(sender: System.Object; e: System.EventArgs);
begin
 try
    //设置控件初始可用状态
    RefreshEnabled();
  except
    on ex:Exception do
    begin
      messagebox.Show('TWinYGjilu_Load : (' + ex.message + ') ' , '考勤管理系统');
    end;
  end;
end;
//****************************************************************
//*  窗体卸载 [closed]
//*
//*  [参数]
//*      1:系统参数
//*      2:系统参数
//*  [返回]
//*      无
//****************************************************************
procedure TWinYGjilu.TWinYGjilu_Closed(sender: System.Object; e: System.EventArgs);
begin
  try
    application.Exit;
  except
  on ex:exception do
    begin
       messagebox.Show('TWinYGjilu.TWinYGjilu_Closed:('+ex.Message+')','考勤管理系统');
    end;
  end;
end;
//****************************************************************
//*   butup_Click
//*
//*  [参数]
//*      1:系统参数
//*      2:系统参数
//*  [返回]
//*      无
//****************************************************************
procedure TWinYGjilu.butup_Click(sender: System.Object; e: System.EventArgs);
var
  w_SQL:String;
  w_Dtpdangqian:String;
  w_TUpWorkTime:String;
  w_ChiDao:String;
begin
  try
    //设置当前光标为忙等待状态
    self.Cursor:=cursors.WaitCursor;
    w_Dtpdangqian:=Dtpdangqian.Text.trim;

    w_SQL :='';
    w_SQL := w_SQL + ' SELECT *';
    w_SQL := w_SQL + ' From 工作时间表';

    MyDs :=dataset.Create;
    MyDs:=clsmain.TClass1.Create.Cmn_Ado_Select (w_SQL);

    If MyDs.Tables[0].Rows.Count <> 0 Then
    begin
       w_TUpWorkTime:=clsmain.TClass1.Create.getItemValueS(MyDs, 0, '上班时间').ToString;
      if copy(w_Dtpdangqian,17,5)>  w_TUpWorkTime then
      begin
        w_ChiDao:='迟到';
      end
      else
      begin
        w_ChiDao:='';
      end;

    end;

    w_SQL := '';
    w_SQL := w_SQL + ' UPDATE 员工出勤表 SET';
    w_SQL := w_SQL + ' 上班时间=right('''+w_Dtpdangqian+''',5),';
    w_SQL := w_SQL + ' 迟到='''+w_ChiDao+'''';
    w_SQL := w_SQL + ' WHERE 员工编号='''+ clsMain.YGpass + '''';
    w_SQL := w_SQL + ' And 日期=left('''+w_Dtpdangqian+''',10)';

    clsmain.TClass1.Create.BeginTrans();            //开始事务
    clsmain.TClass1.Create.Cmn_Ado_Execute(w_SQL);  //执行SQL语句
    clsmain.TClass1.Create.Commit();                //提交事务

    ButUp.Enabled:=false;
    ButDown.Enabled:=true;
    //设置当前光标为默认状态
    self.Cursor := Cursors.Default;
  except
    on ex:Exception do
    begin
      //事务回滚
      clsmain.TClass1.Create.Rollback();
      //设置当前光标为默认状态
      self.Cursor := Cursors.Default;
      messagebox.Show('TWinYGjilu.butup_Click : (' + ex.message + ') ' , '考勤管理系统');
    end;
  end;
end;
//****************************************************************
//*   butdown_Click
//*
//*  [参数]
//*      1:系统参数
//*      2:系统参数                  
//*  [返回]
//*      无                         
//****************************************************************
procedure TWinYGjilu.butdown_Click(sender: System.Object; e: System.EventArgs);
var
  w_SQL:String;
  w_Dtpdangqian:String;
  w_TDownWorkTime:String;
  w_ZaoTui:String;
begin
  try
    //设置当前光标为忙等待状态
    self.Cursor:=cursors.WaitCursor;
    w_Dtpdangqian:=Dtpdangqian.Text.trim;

    w_SQL :='';
    w_SQL := w_SQL + ' SELECT *';
    w_SQL := w_SQL + ' From 工作时间表';

    MyDs :=dataset.Create;
    MyDs:=clsmain.TClass1.Create.Cmn_Ado_Select (w_SQL);

    If MyDs.Tables[0].Rows.Count <> 0 Then
    begin
      w_TDownWorkTime:=clsmain.TClass1.Create.getItemValueS(MyDs, 0, '下班时间').ToString;

      if copy(w_Dtpdangqian,17,5)< w_TDownWorkTime then
      begin
        w_ZaoTui:='早退';
      end
      else
      begin
        w_ZaoTui:='';
      end;

    end;

    w_SQL := '';
    w_SQL := w_SQL + ' UPDATE 员工出勤表 SET';
    w_SQL := w_SQL + ' 下班时间=right('''+w_Dtpdangqian+''',5),';
    w_SQL := w_SQL + ' 早退='''+w_ZaoTui+'''';
    w_SQL := w_SQL + ' WHERE 员工编号='''+ clsMain.YGpass + '''';
    w_SQL := w_SQL + ' And 日期=left('''+w_Dtpdangqian+''',10)';

    clsmain.TClass1.Create.BeginTrans();            //开始事务
    clsmain.TClass1.Create.Cmn_Ado_Execute(w_SQL);  //执行SQL语句
    clsmain.TClass1.Create.Commit();                //提交事务

    ButDown.Enabled:=false;
    //设置当前光标为默认状态
    self.Cursor := Cursors.Default;
  except
    on ex:Exception do
    begin
      //事务回滚
      clsmain.TClass1.Create.Rollback();
      //设置当前光标为默认状态
      self.Cursor := Cursors.Default;
      messagebox.Show('TWinYGjilu.ButDown_Click : (' + ex.message + ') ' , '考勤管理系统');
    end;
  end;
end;

//****************************************************************
//*  TWinKaoQinRecord_KeyDown
//*
//*  [参数]
//*      1:系统参数
//*      2:系统参数
//*  [返回]
//*      无
//****************************************************************
procedure TWinYGjilu.RefreshEnabled;
var
  w_SQL:String;
  w_Dtpdangqian:String;
  w_UpWorkTime:String;
  w_DownWorkTime:String;
begin
  try
    w_Dtpdangqian:=Dtpdangqian.Text.trim;

    w_SQL := '';
    w_SQL := w_SQL + ' SELECT *';
    w_SQL := w_SQL + ' From 员工出勤表';
    w_SQL := w_SQL + ' WHERE 员工编号='''+ clsMain.YGpass + '''';
    w_SQL := w_SQL + ' And 日期=left('''+w_Dtpdangqian+''',10)';

    MyDs :=dataset.Create;
    //执行SQL语句并把记录集返回
    MyDs:=clsmain.TClass1.Create.Cmn_Ado_Select (w_SQL);

    If MyDs.Tables[0].Rows.Count <>0 Then
    begin
      TxtBuMen.text:=clsmain.TClass1.Create.getItemValueS(MyDs, 0, '部门名称').ToString;
      TxtName.text:=clsmain.TClass1.Create.getItemValueS(MyDs, 0, '姓名').ToString;
      w_UpWorkTime:=clsmain.TClass1.Create.getItemValueS(MyDs, 0, '上班时间').ToString;
      w_DownWorkTime:=clsmain.TClass1.Create.getItemValueS(MyDs, 0, '下班时间').ToString;
    end;

    if w_UpWorkTime='00:00' then
    begin
      ButUp.Enabled :=true;
      ButDown.Enabled :=false;
    end
    else
    begin
      if w_DownWorkTime<>'00:00' then
      begin
        ButUp.Enabled :=false;
        ButDown.Enabled :=false;
        messagebox.Show('您已经添加完今天的考勤信息,祝您一路顺风!', '考勤管理系统');
      end
      else
      begin
        ButUp.Enabled :=false;
        ButDown.Enabled :=true;
      end;
    end;

  except
    on ex:Exception do
    begin
      messagebox.Show('TWinKaoQinRecord.RefreshEnabled : (' + ex.message + ') ' , '考勤管理系统');
    end;
  end;
end;



end.

⌨️ 快捷键说明

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