?? cllrsh.pas
字號:
DataModule1.ClientDataSet25.Open;
DataModule1.ClientDataSet25.EnableControls;
help.Caption:=' 查詢完畢!';
except
DataModule1.clientdataset25.EnableControls;
showmessage('數據庫沒有打開!');
end;
end;
procedure TFrmcllrsh.DBGrid5TitleClick(Column: TColumn);
var i : integer;
begin
for i:= 1 to DBGrid5.Columns.Count do
begin
//恢復所有標題字體為默認
DBGrid5.Columns[i-1].Title.Font.Color := clBlue;
DBGrid5.Columns[i-1].Title.Font.Style := [];
end;
if DataModule1.ClientDataSet25.IndexFieldNames<>(Column.FieldName) then //判斷原排序方式
begin
DataModule1.ClientDataSet25.IndexFieldNames:= Column.FieldName;
Column.Title.Font.Color := clRed; //改變標題行字體為紅色,表示當前的排序方式為升序
Column.Title.Font.Style := [fsBold];
end;
end;
procedure TFrmcllrsh.DBGrid5DrawColumnCell(Sender: TObject;
const Rect: TRect; DataCol: Integer; Column: TColumn;
State: TGridDrawState);
begin
if DataModule1.ClientDataSet25.FieldByName('shbj').AsInteger=1 then
begin
dbgrid5.Canvas.Font.Color:=clred;
dbgrid5.Canvas.Brush.Color:=clyellow;
end
else
begin
dbgrid5.Canvas.Font.Color:=clblue;
dbgrid5.Canvas.Brush.Color:=clwhite;
end;
dbgrid5.DefaultDrawColumnCell(rect,datacol,column,state);
if ((State = [gdSelected]) or (State = [gdSelected, gdFocused])) then
begin
DBGrid5.Canvas.Brush.Color:=clred;
DBGrid5.Canvas.Font.Color:=clWhite;
DBGrid5.DefaultDrawColumnCell(Rect, datacol,column, State);
end;
end;
procedure TFrmcllrsh.bshClick(Sender: TObject);
var
relation,cx,dx,sqlstr:string;
begin
if not DataModule1.ClientDataSet25.Active then exit;
if DataModule1.ClientDataSet25.RecordCount<1 then exit;
relation:=' = ''';
cx:='';
dx:= ' ''';
try
DataModule1.ClientDataSet25.Edit;
if DataModule1.ClientDataSet25.FieldByName('shbj').AsInteger=0 then
begin
sqlstr:='update dbo.cllrb set shy'+relation+form1.StatusBar1.Panels[4].Text+dx+' ,shbj'+relation+'1'+dx+' ,shsj'+relation+datetimetostr(Date)+dx;
sqlstr:=sqlstr+' where (clh' +relation+cx+DataModule1.ClientDataSet25.FieldByName('clh').AsString+cx+''')';
DataModule1.ClientDataSet25.CommandText:=sqlstr;
DataModule1.ClientDataSet25.Execute;
DataModule1.ClientDataSet25.ApplyUpdates(-1);
DataModule1.ClientDataSet25.DisableControls;
DataModule1.ClientDataSet25.Close;
DataModule1.ClientDataSet25.CommandText:=commandstringq;
DataModule1.ClientDataSet25.Open;
DataModule1.ClientDataSet25.EnableControls;
help.Caption:= '數據審核成功!';
end;
except
DataModule1.clientdataset25.EnableControls;
help.Caption:= '數據審核失敗!';
end;
end;
procedure TFrmcllrsh.bquerysClick(Sender: TObject);
var
commandtring1,relation,cx:string;
begin
relation:=' like ''';
cx:='%';
commandstring:='select * from dbo.cllrb';
commandtring1:='select * from dbo.cllrb';
try
if (trim(qddh.Text)<>'') and (cddh.Checked) then
begin
relation:=' like ''';
cx:='%';
if commandstring=commandtring1 then
begin
commandstring:=commandstring+' where (dbo.cllrb.ddh'+relation+cx+trim(qddh.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.cllrb.ddh'+relation+cx+trim(qddh.Text)+cx+''')';
end;
end
else
begin
qddh.Text:='';
end;
if (trim(qclh.Text)<>'') and (cclh.Checked) then
begin
relation:=' like ''';
cx:='%';
if commandstring=commandtring1 then
begin
commandstring:=commandstring+' where (dbo.cllrb.clh'+relation+cx+trim(qclh.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.cllrb.clh'+relation+cx+trim(qclh.Text)+cx+''')';
end;
end
else
begin
qclh.Text:='';
end;
if cqq.Checked then
begin
if commandstring=commandtring1 then
begin
relation:=' >= ''';
cx:='';
commandstring:=commandstring+' where (dbo.cllrb.rq'+ relation+FormatDateTime('yyyy-mm-dd',qq.Date)+cx+''')';
end
else
begin
relation:=' >= ''';
cx:='';
commandstring:=commandstring+' and (dbo.cllrb.rq'+ relation+FormatDateTime('yyyy-mm-dd',qq.Date)+cx+''')';
end;
end;
if czq.Checked then
begin
if commandstring=commandtring1 then
begin
relation:=' < ''';
cx:='';
commandstring:=commandstring+' where (dbo.cllrb.rq'+ relation+FormatDateTime('yyyy-mm-dd',zq.Date+1)+cx+''')';
end
else
begin
relation:=' < ''';
cx:='';
commandstring:=commandstring+' and (dbo.cllrb.rq'+ relation+FormatDateTime('yyyy-mm-dd',zq.Date+1)+cx+''')';
end;
end;
if (trim(qgh.Text)<>'') and (cgh.Checked) then
begin
relation:=' like ''';
cx:='%';
if commandstring=commandtring1 then
begin
commandstring:=commandstring+' where (dbo.cllrb.gh'+relation+cx+trim(qgh.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.cllrb.gh'+relation+cx+trim(qgh.Text)+cx+''')';
end;
end
else
begin
qgh.Text:='';
end;
if (trim(qfb.Text)<>'') and (cfb.Checked) then
begin
relation:=' like ''';
cx:='%';
if commandstring=commandtring1 then
begin
commandstring:=commandstring+' where (dbo.cllrb.fb'+relation+cx+trim(qfb.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.cllrb.fb'+relation+cx+trim(qfb.Text)+cx+''')';
end;
end
else
begin
qfb.Text:='';
end;
if (trim(qfz.Text)<>'') and (cfz.Checked) then
begin
relation:=' like ''';
cx:='%';
if commandstring=commandtring1 then
begin
commandstring:=commandstring+' where (dbo.cllrb.fz'+relation+cx+trim(qfz.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.cllrb.fz'+relation+cx+trim(qfz.Text)+cx+''')';
end;
end
else
begin
qfz.Text:='';
end;
if (trim(qyg.Text)<>'') and (cyg.Checked) then
begin
relation:=' like ''';
cx:='%';
if commandstring=commandtring1 then
begin
commandstring:=commandstring+' where (dbo.cllrb.yg'+relation+cx+trim(qyg.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.cllrb.yg'+relation+cx+trim(qyg.Text)+cx+''')';
end;
end
else
begin
qyg.Text:='';
end;
if (trim(qbh.Text)<>'') and (cbh.Checked) then
begin
relation:=' like ''';
cx:='%';
if commandstring=commandtring1 then
begin
commandstring:=commandstring+' where (dbo.cllrb.bh'+relation+cx+trim(qbh.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.cllrb.bh'+relation+cx+trim(qbh.Text)+cx+''')';
end;
end
else
begin
qbh.Text:='';
end;
if (trim(qys.Text)<>'') and (cys.Checked) then
begin
relation:=' like ''';
cx:='%';
if commandstring=commandtring1 then
begin
commandstring:=commandstring+' where (dbo.cllrb.ys'+relation+cx+trim(qys.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.cllrb.ys'+relation+cx+trim(qys.Text)+cx+''')';
end;
end
else
begin
qys.Text:='';
end;
if (trim(qcm.Text)<>'') and (ccm.Checked) then
begin
relation:=' like ''';
cx:='%';
if commandstring=commandtring1 then
begin
commandstring:=commandstring+' where (dbo.cllrb.cm'+relation+cx+trim(qcm.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.cllrb.cm'+relation+cx+trim(qcm.Text)+cx+''')';
end;
end
else
begin
qcm.Text:='';
end;
if (trim(qsl.Text)<>'') and (csl.Checked) then
begin
relation:=' like ''';
cx:='%';
if commandstring=commandtring1 then
begin
commandstring:=commandstring+' where (dbo.cllrb.sl'+relation+cx+trim(qsl.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.cllrb.sl'+relation+cx+trim(qsl.Text)+cx+''')';
end;
end
else
begin
qsl.Text:='';
end;
if (trim(qgxmc.Text)<>'') and (cgxmc.Checked) then
begin
relation:=' like ''';
cx:='%';
if commandstring=commandtring1 then
begin
commandstring:=commandstring+' where (dbo.cllrb.gxmc'+relation+cx+trim(qgxmc.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.cllrb.gxmc'+relation+cx+trim(qgxmc.Text)+cx+''')';
end;
end
else
begin
qgxmc.Text:='';
end;
if (trim(qdj.Text)<>'') and (cdj.Checked) then
begin
relation:=' like ''';
cx:='%';
if commandstring=commandtring1 then
begin
commandstring:=commandstring+' where (dbo.cllrb.dj'+relation+cx+trim(qdj.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.cllrb.dj'+relation+cx+trim(qdj.Text)+cx+''')';
end;
end
else
begin
qdj.Text:='';
end;
if (trim(qxs.Text)<>'') and (cxs.Checked) then
begin
relation:=' like ''';
cx:='%';
if commandstring=commandtring1 then
begin
commandstring:=commandstring+' where (dbo.cllrb.xs'+relation+cx+trim(qxs.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.cllrb.xs'+relation+cx+trim(qxs.Text)+cx+''')';
end;
end
else
begin
qxs.Text:='';
end;
if (trim(qcz.Text)<>'') and (ccz.Checked) then
begin
relation:=' like ''';
cx:='%';
if commandstring=commandtring1 then
begin
commandstring:=commandstring+' where (dbo.cllrb.cz'+relation+cx+trim(qcz.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.cllrb.cz'+relation+cx+trim(qcz.Text)+cx+''')';
end;
end
else
begin
qcz.Text:='';
end;
if (trim(qbz.Text)<>'') and (cbz.Checked) then
begin
relation:=' like ''';
cx:='%';
if commandstring=commandtring1 then
begin
commandstring:=commandstring+' where (dbo.cllrb.bz'+relation+cx+trim(qbz.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.cllrb.bz'+relation+cx+trim(qbz.Text)+cx+''')';
end;
end
else
begin
qbz.Text:='';
end;
if (trim(qczy.Text)<>'') and (cczy.Checked) then
begin
relation:=' like ''';
cx:='%';
if commandstring=commandtring1 then
begin
commandstring:=commandstring+' where (dbo.cllrb.czy'+relation+cx+trim(qczy.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.cllrb.czy'+relation+cx+trim(qczy.Text)+cx+''')';
end;
end
else
begin
qczy.Text:='';
end;
if commandstring=commandtring1 then
begin
relation:=' = ''';
cx:='';
commandstring:=commandstring+' where (dbo.cllrb.shbj'+relation+cx+'1'+cx+''')';
end
else
begin
relation:=' = ''';
cx:='';
commandstring:=commandstring+' and (dbo.cllrb.shbj'+relation+cx+'1'+cx+''')';
end;
commandstring:=commandstring+' order by ddh,clh';
commandstringq:=commandstring;
DataModule1.ClientDataSet25.DisableControls;
DataModule1.ClientDataSet25.Close;
DataModule1.ClientDataSet25.CommandText:=commandstring;
DataModule1.ClientDataSet25.Open;
DataModule1.ClientDataSet25.EnableControls;
help.Caption:=' 查詢完畢!';
except
DataModule1.clientdataset25.EnableControls;
showmessage('數據庫沒有打開!');
end;
end;
procedure TFrmcllrsh.bfsClick(Sender: TObject);
var
relation,cx,dx,sqlstr:string;
begin
if not DataModule1.ClientDataSet25.Active then exit;
if DataModule1.ClientDataSet25.RecordCount<1 then exit;
relation:=' = ''';
cx:='';
dx:= ' ''';
try
DataModule1.ClientDataSet25.Edit;
if DataModule1.ClientDataSet25.FieldByName('shbj').AsInteger=1 then
begin
sqlstr:='update dbo.cllrb set shy'+relation+form1.StatusBar1.Panels[4].Text+dx+' ,shbj'+relation+'0'+dx+' ,shsj'+relation+datetimetostr(Date)+dx;
sqlstr:=sqlstr+' where (clh' +relation+cx+DataModule1.ClientDataSet25.FieldByName('clh').AsString+cx+''')';
DataModule1.ClientDataSet25.CommandText:=sqlstr;
DataModule1.ClientDataSet25.Execute;
DataModule1.ClientDataSet25.ApplyUpdates(-1);
DataModule1.ClientDataSet25.DisableControls;
DataModule1.ClientDataSet25.Close;
DataModule1.ClientDataSet25.CommandText:=commandstringq;
DataModule1.ClientDataSet25.Open;
DataModule1.ClientDataSet25.EnableControls;
help.Caption:= '數據審核成功!';
end;
except
DataModule1.clientdataset25.EnableControls;
help.Caption:= '數據審核失敗!';
end;
end;
procedure TFrmcllrsh.bprintcClick(Sender: TObject);
var
excelname: string;
begin
if not DataModule1.ClientDataSet25.Active then exit;
if not form1.excel then
begin
showmessage('您還未獲得管理員的授權!請您與管理員聯系獲取授權!');
exit;
end;
if DataModule1.ClientDataSet25.RecordCount<1 then exit;
opendialog1.Filter:='Excel 文件 (*.xls) │*.xls';
if opendialog1.Execute then excelname:=opendialog1.FileName;
if length(excelname)>0 then writetoexcel(DataModule1.ClientDataSet25,excelname,'員工產量信息報表');
exit;
end;
end.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -