?? u_form_checktotal.pas
字號:
unit U_Form_CheckTotal;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, EasyGrid, DB, ADODB;
type
TForm_CheckTotal = class(TForm)
GroupBox1: TGroupBox;
Label6: TLabel;
Label5: TLabel;
ComboBox4: TComboBox;
ComboBox3: TComboBox;
Button1: TButton;
Button2: TButton;
Button3: TButton;
GroupBox2: TGroupBox;
Grid1: TEasyGrid;
ADOQuery1: TADOQuery;
procedure Button3Click(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form_CheckTotal: TForm_CheckTotal;
implementation
uses U_Form_MainMenu,uGlobal,uAdoSet;
{$R *.dfm}
procedure TForm_CheckTotal.Button3Click(Sender: TObject);
begin
EnableWindow(Form_MainMenu.Handle,true);
Close;
end;
procedure TForm_CheckTotal.FormCloseQuery(Sender: TObject;
var CanClose: Boolean);
begin
EnableWindow(Form_MainMenu.Handle,true);
CanClose:=true;
end;
procedure TForm_CheckTotal.FormCreate(Sender: TObject);
var
i:integer;
param:TStringList;
strSql:string;
begin
combobox3.Items.Clear;
for i:=2006 to 2040 do
begin
combobox3.Items.Add(trim(intToStr(i)));
end;///
combobox4.Items.Clear;
for i:=1 to 12 do
begin
if i<10 then
begin
combobox4.Items.Add('0'+trim(intToStr(i)));
end
else
combobox4.Items.Add(trim(intToStr(i)));
end;///
///////////////////////
param:=TStringList.Create;
/////得到烈數 ///////////////
setDbFlag('HRManage');
///////////////////////////
end;
procedure TForm_CheckTotal.Button1Click(Sender: TObject);
var
param:TStringList;
strSql:string;
i,j:integer;
_ColCount:integer;
_FieldList:TStringList;
_ByCheckDept:TStringList;////
_DeptInfo:Array[1..20] of Double;
begin
param:=TStringList.Create;
_FieldList:=TStringList.Create;
_ByCheckDept:=TStringList.Create;
_ByCheckDept.clear;
_FieldList.Clear;
param.Clear;
setDbFlag('HRManage');
param.Add(trim(combobox3.text));
param.Add(trim(combobox4.text));
strSql:='Select Distinct CHK_CheckDept From HRCheckStandard Where CHK_Year=:s1 and CHK_Month=:s2';
//showmessage(inttostr(getRecordCount(AdoQuery1,strSql,param)));
grid1.ColCount:=getRecordCount(AdoQuery1,strSql,param)*2+3;
////設置標題寬度////////////////////////////////
grid1.ColWidths[1]:=100;
grid1.RowHeights[1]:=40;
grid1.RowHeights[2]:=40;
grid1.SetMerges(rect(1,1,1,2));
grid1.Cells[1,1].ForeText:='部門名稱';
for i:=2 to grid1.ColCount-2 do
begin
grid1.ColWidths[i]:=50;
end;///
_ColCount:=strToInt(trim(formatFloat('##0',(grid1.ColCount-2)/2)));
for i:=2 to _ColCount do
begin
grid1.SetMerges(rect((i-1)*2,1,(i-1)*2+1,1));
grid1.Cells[(i-1)*2,1].ForeText:='dffdgfdg';
end;///
param.Clear;
setDbFlag('HRManage');
param.Add(trim(combobox3.text));
param.Add(trim(combobox4.text));
strSql:='Select Distinct CHK_CheckDept From HRCheckStandard Where CHK_Year=:s1 and CHK_Month=:s2';
_FieldList:=getFieldList(AdoQuery1,strSql,param,'CHK_CheckDept');
///showmessage(inttostr(_FieldList.Count));
for i:=0 to _FieldList.Count-1 do
begin
grid1.Cells[(i+1)*2,1].ForeText:=trim(_FieldList[i]);
grid1.Cells[(i+1)*2,2].ForeText:='標準分';
grid1.Cells[(i+1)*2+1,2].ForeText:='實得分'+_LETTER[I+1];
end;
/////顯示部門名稱////////////////////////////////////////////
param.Clear;
param.Add('人力資源部');
strSql:='Select CHK_ByCheckDept From HRCheckStandard Where CHK_CheckDept=:s1';
_ByCheckDept:=getFieldList(AdoQuery1,strSql,param,'CHK_ByCheckDept');
grid1.RowCount:=_ByCheckDept.Count+3;
for i:=3 to grid1.RowCount-1 do
begin
grid1.cells[1,i].ForeText:=trim(_ByCheckDept[i-3]);
end;
///////查詢數據//////////////////////////////////////////////
for j:=2 to _ColCount do
begin
for i:=3 to grid1.RowCount-1 do
begin
with AdoQuery1 do
begin
ConnectionString:='Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=HRManage;Data Source=NTSERVER';
Close;
Sql.clear;
strSql:='Select * From HRCheckMark Where CHM_Year=:s1 and CHM_Month=:s2 and CHM_CheckDept=:s3 and CHM_ByCheckDept=:s4';
Sql.Add(strSql);
parameters.ParamByName('s1').Value:=trim(Combobox3.text);
parameters.ParamByName('s2').Value:=trim(Combobox4.text);
parameters.ParamByName('s3').Value:=trim(grid1.cells[(j-1)*2,1].foretext);
parameters.ParamByName('s4').Value:=trim(grid1.cells[1,i].foretext);
prepared;
open;
if recordcount<>0 then
begin
////顯示標準得分//////////////////////////
if not FieldByName('CHM_Mark').IsNull then
begin
grid1.Cells[(j-1)*2,i].ForeText:=trim(FieldByName('CHM_Mark').AsString);
end
else
grid1.Cells[(j-1)*2,i].ForeText:='/';
////實際得分///////////////////////////////
if not FieldByName('CHM_RealMark').IsNull then
begin
grid1.Cells[(j-1)*2+1,i].ForeText:=trim(FieldByName('CHM_RealMark').AsString);
end
else
grid1.Cells[(j-1)*2+1,i].ForeText:='/';
end////
else
begin
grid1.Cells[(j-1)*2,i].ForeText:='/';
grid1.Cells[(j-1)*2+1,i].ForeText:='/';
end;///
end;///with
end;////i
end;///j
/////計算最后一行合計(A+B+C+D....+H)=最后得分/////////////////
grid1.SetMerges(rect(grid1.ColCount-1,1,grid1.ColCount-1,2));
grid1.Cells[grid1.ColCount-1,1].ForeText:='評分合計'+#13#10+'(A+B+C+D+..H)';
////計算合計/////////////////////////////////////////////////
for i:=1 to 20 do
begin
_DeptInfo[i]:=0;
end;
for j:=3 to grid1.RowCount-1 do
begin
_DeptInfo[j-2]:=0;
for i:=2 to _ColCount do
begin
if trim(grid1.Cells[(i-1)*2+1,j].foretext)<>'/' then
begin
_DeptInfo[j-2]:=_DeptInfo[j-2]+ strToFloat(trim(grid1.Cells[(i-1)*2+1,j].foretext));
end
else
begin
_DeptInfo[j-2]:=_DeptInfo[j-2]+0;
end;///
end;///i
grid1.Cells[grid1.ColCount-1,j].ForeText:=formatFloat('##0.00',_DeptInfo[j-2]);
end;////j
/////////////////////////////////////////////////////////////
grid1.Refresh;
end;
procedure TForm_CheckTotal.Button2Click(Sender: TObject);
begin
grid1.Preview;
end;
end.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -