?? u_form_checkstandard.pas
字號:
unit U_Form_CheckStandard;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, EasyGrid, StdCtrls, ComCtrls, ButtonExCtl, ImgList, DB, ADODB;
type
TForm_CheckStandard = class(TForm)
GroupBox1: TGroupBox;
GroupBox2: TGroupBox;
GroupBox3: TGroupBox;
Tree: TTreeView;
Edit1: TEdit;
Grid1: TEasyGrid;
Add: TButtonExCtl;
Edit: TButtonExCtl;
Del: TButtonExCtl;
Find: TButtonExCtl;
Print: TButtonExCtl;
ImageList1: TImageList;
ImageList2: TImageList;
ADOQuery1: TADOQuery;
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
procedure FormShow(Sender: TObject);
procedure AddClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure TreeDblClick(Sender: TObject);
procedure EditClick(Sender: TObject);
procedure Grid1DblClick(Sender: TObject);
procedure DelClick(Sender: TObject);
procedure PrintClick(Sender: TObject);
procedure Grid1KeyPress(Sender: TObject; var Key: Char);
procedure FindClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form_CheckStandard: TForm_CheckStandard;
implementation
uses U_Form_MainMenu,uAdoSet,uGlobal,U_Form_CheckSetup,U_Form_CheckStandardFind;
{$R *.dfm}
procedure TForm_CheckStandard.FormCloseQuery(Sender: TObject;
var CanClose: Boolean);
begin
EnableWindow(Form_MainMenu.Handle,true);
CanClose:=true;
end;
procedure TForm_CheckStandard.FormShow(Sender: TObject);
var
i:integer;
begin
grid1.Cells[1,1].ForeText:='ID';
grid1.ColWidths[1]:=40;
grid1.Cells[2,1].ForeText:='年';
grid1.ColWidths[2]:=40;
grid1.Cells[3,1].ForeText:='月';
grid1.ColWidths[3]:=40;
grid1.Cells[4,1].ForeText:='序號';
grid1.ColWidths[4]:=40;
grid1.Cells[5,1].ForeText:='考核部門';
grid1.ColWidths[5]:=100;
grid1.Cells[6,1].ForeText:='被考核部門';
grid1.ColWidths[6]:=100;
grid1.Cells[7,1].ForeText:='考核標準';
grid1.ColWidths[7]:=80;
for i:=1 to grid1.ColCount-1 do
begin
grid1.Cells[i,1].Color:=rgb(0,143,247);
grid1.Cells[i,1].FontColor:=rgb(255,255,255);
end;///
end;
procedure TForm_CheckStandard.AddClick(Sender: TObject);
begin
isCHKAdd:=1;
Exit_Flag:=1;
var_Form_CHKID:=trim(edit1.text);
if Form_CheckSetup=nil then
begin
EnableWindow(Form_CheckStandard.Handle,false);
Form_CheckSetup:=TForm_CheckSetup.Create(Application);
Form_CheckSetup.Show;
end
else
begin
EnableWindow(Form_CheckStandard.Handle,false);
Form_CheckSetup.Show;
end;////
end;
procedure TForm_CheckStandard.FormCreate(Sender: TObject);
var
param:TStringList;
strSql:string;
begin
param:=TStringList.Create;
param.clear;
tree.Items.Clear;
tree.Items.AddChild(nil,'部門名稱');
setDBFlag('HRManage');
strSql:='Select Distinct CHK_CheckDept From HRCheckStandard';
FillCtrlParam(AdoQuery1,strSql,param,tree,'CHK_CheckDept');
////Tree.Items[0].Item[0].Selected:=true;
end;
procedure TForm_CheckStandard.TreeDblClick(Sender: TObject);
var
param:TStringList;
strSql:string;
i:integer;
_Year:string;
_Month:string;
begin
//////得到當前系統日期//////////
_year:=copy(trim(formatDateTime('yyyy-mm-dd',now)),1,4);
_Month:=copy(trim(formatDateTime('yyyy-mm-dd',now)),6,2);
/////////
Edit1.Text:=Tree.Selected.Text;
param:=TStringList.Create;
setDBFlag('HRManage');
param.clear;
param.Add(trim(edit1.text));
param.Add('0');
param.Add(trim(_Year));
param.Add(_Month);
strSql:='Select sID,CHK_Year,CHK_Month,CHK_OrderID,CHK_CheckDept,CHK_ByCheckDept,CHK_Standard From HRCheckStandard Where CHK_CheckDept=:s1 and isCanCel=:s2 and CHK_Year=:s3 and CHK_Month=:s4 Order By CHK_OrderID';
BindToGrid(AdoQuery1,strSql,param,grid1);
end;
procedure TForm_CheckStandard.EditClick(Sender: TObject);
var
i:integer;
begin
isCHKAdd:=2;
Exit_Flag:=1;
/////得到數據/////////////////
for i:=1 to grid1.ColCount-1 do
begin
var_Form_CHK[i-1]:=trim(grid1.cells[i,grid1.row].ForeText);
end;
//////////////////////////////
if Form_CheckSetup=nil then
begin
EnableWindow(Form_CheckStandard.Handle,false);
Form_CheckSetup:=TForm_CheckSetup.Create(Application);
Form_CheckSetup.Show;
end
else
begin
EnableWindow(Form_CheckStandard.Handle,false);
Form_CheckSetup.Show;
end;////
end;
procedure TForm_CheckStandard.Grid1DblClick(Sender: TObject);
var
i:integer;
begin
isCHKAdd:=2;
Exit_Flag:=1;
/////得到數據/////////////////
for i:=1 to grid1.ColCount-1 do
begin
var_Form_CHK[i-1]:=trim(grid1.cells[i,grid1.row].ForeText);
end;
//////////////////////////////
if Form_CheckSetup=nil then
begin
EnableWindow(Form_CheckStandard.Handle,false);
Form_CheckSetup:=TForm_CheckSetup.Create(Application);
Form_CheckSetup.Show;
end
else
begin
EnableWindow(Form_CheckStandard.Handle,false);
Form_CheckSetup.Show;
end;////
end;
procedure TForm_CheckStandard.DelClick(Sender: TObject);
var
param:TStringList;
strSql:string;
begin
param:=TStringList.Create;
param.clear;
if Application.MessageBox('確定是否刪除當前記錄?','系統提示',MB_YesNo+MB_IconInformation)=id_yes then
begin
setDbFlag('HRManage');
param.Add('1');
param.Add(trim(grid1.cells[1,grid1.row].foretext));
strSql:='Update HRCheckStandard SET isCancel=:s1 Where sID=:s2';
DelRecord(AdoQuery1,strSql,param);
param.clear;
param.Add(trim(edit1.text));
param.Add('0');
strSql:='Select sID,CHK_Year,CHK_Month,CHK_OrderID,CHK_CheckDept,CHK_ByCheckDept,CHK_Standard From HRCheckStandard Where CHK_CheckDept=:s1 and isCanCel=:s2 Order By CHK_OrderID';
BindToGrid(AdoQuery1,strSql,param,grid1);
end;///
end;
procedure TForm_CheckStandard.PrintClick(Sender: TObject);
var
param:TStringList;
strSql:string;
i:integer;
begin
param:=TStringList.Create;
for i:=2 to grid1.RowCount-2 do
begin
param.Clear;
end;////
end;
procedure TForm_CheckStandard.Grid1KeyPress(Sender: TObject;
var Key: Char);
begin
if key=#13 then
begin
if grid1.col=7 then
begin
grid1.RowCount:=grid1.RowCount+1;
end;///
end;///
end;
procedure TForm_CheckStandard.FindClick(Sender: TObject);
begin
if Form_CheckStandardFind=nil then
begin
EnableWindow(Form_CheckStandard.Handle,false);
Form_CheckStandardFind:=TForm_CheckStandardFind.Create(Application);
Form_CheckStandardFind.Show;
end
else
begin
EnableWindow(Form_CheckStandard.Handle,false);
Form_CheckStandardFind.Show;
end;///
end;
end.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -