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

📄 htyj.pas

📁 2004090611144625767.rar 资源名称:通用工资管理
💻 PAS
字号:
unit htyj;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, Grids, DBGrids, Db;

type
  Thtyjb = class(TForm)
    DataSource1: TDataSource;
    DBGrid1: TDBGrid;
    Button1: TButton;
    Button2: TButton;
    procedure FormShow(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
      DataCol: Integer; Column: TColumn; State: TGridDrawState);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  htyjb: Thtyjb;

implementation

uses datamodule;

{$R *.DFM}

procedure Thtyjb.FormShow(Sender: TObject);
var
month_str,htgnstr,last_time:string;
i_mod:integer;  //月数
begin
htgnstr:='select *from htgn';
with datamodule1.htgns do
begin
close;
sql.clear;
sql.add(htgnstr);
prepare;
open;
end;
datamodule1.htgns.close;
datamodule1.htgns.open;
datasource1.DataSet.close;
datasource1.dataset.open;
while not datamodule1.htgns.eof do
begin
month_str:=formatdatetime('mm',datamodule1.htgns.fieldbyname('a_date').asdatetime);
month_str:=floattostr(strtofloat(month_str)+datamodule1.htgns.fieldbyname('a_htys').asfloat);
if strtoint(month_str)>12 then
begin
i_mod:=strtoint(month_str) mod 12;//佘几年
last_time:=formatdatetime('yyyy',datamodule1.htgns.fieldbyname('a_date').asdatetime);
last_time:=floattostr(strtoint(last_time)+(strtoint(month_str)-i_mod)/12);
if ((i_mod=2) and (strtofloat(formatdatetime('d',datamodule1.htgns.fieldbyname('a_date').asdatetime))>=29)) or ((i_mod in [2,4,6,9,11]) and (strtofloat(formatdatetime('d',datamodule1.htgns.fieldbyname('a_date').asdatetime))>=30)) then
//合同下限
last_time:=last_time+'-'+inttostr(i_mod)+'-28'
else
last_time:=last_time+'-'+inttostr(i_mod)+'-'+formatdatetime('d',datamodule1.htgns.fieldbyname('a_date').asdatetime);
end
else
begin
last_time:=trim(formatdatetime('yyyy',datamodule1.htgns.fieldbyname('a_date').asdatetime));
last_time:=last_time+'-'+trim(floattostr(strtofloat(formatdatetime('mm',datamodule1.htgns.fieldbyname('a_date').asdatetime))+datamodule1.htgns.fieldbyname('a_htys').asfloat));
i_mod:=strtofloat(formatdatetime('mm',datamodule1.htgns.fieldbyname('a_date').asdatetime))+datamodule1.htgns.fieldbyname('a_htys').value;
if ((i_mod=2) and (strtofloat(formatdatetime('d',datamodule1.htgns.fieldbyname('a_date').asdatetime))>=29)) or ((i_mod in [2,4,6,9,11]) and (strtofloat(formatdatetime('d',datamodule1.htgns.fieldbyname('a_date').asdatetime))>=30))then
begin
last_time:=last_time+'-28';
end
else
last_time:=last_time+'-'+trim(formatdatetime('d',datamodule1.htgns.fieldbyname('a_date').asdatetime));
end;
if strtodate(last_time)<=date-61 then
 begin
  datamodule1.htgns.edit;
  datamodule1.htgns.fieldbyname('a_shhj').asboolean:=true;
  datamodule1.htgns.post;
  end
  else
  begin
  datamodule1.htgns.edit;
  datamodule1.htgns.fieldbyname('a_shhj').asboolean:=false;
  datamodule1.htgns.post;
  end;
datamodule1.htgns.next;
end;//.eof的循环
datamodule1.htgns.close;
datamodule1.htgns.open;
datasource1.dataset.close;
datasource1.dataset.open;
htgnstr:='select *from htgn where a_shhj=true';
with datamodule1.htgns do
begin
close;
sql.Clear;
sql.Add(htgnstr);
prepare;
open;
end;
datasource1.dataset.Close;
datasource1.dataset.open;

end;

procedure Thtyjb.Button1Click(Sender: TObject);
begin
self.close;
end;

procedure Thtyjb.Button2Click(Sender: TObject);
var
yggbstr:string;
begin
if application.messagebox('你确定要中止此员工的合同并删除此员工档案吗?','程序执行确认',mb_yesno+mb_defbutton2+mb_iconstop+mb_applmodal)=idyes then
begin
yggbstr:='select *from yggb where a_number='+''''+datamodule1.htgns.fieldbyname('a_number').asstring+'''';
yggbstr:=yggbstr+' and a_name='+''''+datamodule1.htgns.fieldbyname('a_name').asstring+'''';
with datamodule1.yggb do
begin
close;
sql.clear;
sql.add(yggbstr);
prepare;
open;
end;
datamodule1.yggb.Delete;
datamodule1.htgns.Delete;
showmessage('删除成功!');
end;

end;

procedure Thtyjb.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
  DataCol: Integer; Column: TColumn; State: TGridDrawState);
var
 lastcolor: TColor;
begin
 with (Sender as TDBGrid) do
 begin
   lastcolor := clred;

   case DataSource.DataSet.RecNo mod 2 of
     1: lastcolor := $00F5FEFD;
     0: lastcolor := clwhite;
   end;

   if gdSelected in State then
     lastcolor := clred;      //选中行背景为绿色

   Canvas.Brush.Color := lastcolor;
   DefaultDrawDataCell(Rect, Column.Field, State);
 end;
end;

procedure Thtyjb.FormClose(Sender: TObject; var Action: TCloseAction);
begin
self.release;
end;

end.

⌨️ 快捷键说明

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