?? htyj.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 + -