292 lines
8.1 KiB
ObjectPascal
292 lines
8.1 KiB
ObjectPascal
unit U_StopWorkList;
|
||
|
||
interface
|
||
|
||
uses
|
||
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
||
Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData,
|
||
cxDataStorage, cxEdit, DB, cxDBData, cxCalendar, cxTimeEdit,
|
||
cxButtonEdit, cxGridLevel, cxGridCustomTableView, cxGridTableView,
|
||
cxGridDBTableView, cxClasses, cxControls, cxGridCustomView, cxGrid,
|
||
StdCtrls, ComCtrls, ExtCtrls, ToolWin, ADODB, DBClient,
|
||
cxGridCustomPopupMenu, cxGridPopupMenu, cxGridBandedTableView,
|
||
cxGridDBBandedTableView, cxDropDownEdit;
|
||
|
||
type
|
||
TfrmStopWorkList = class(TForm)
|
||
ToolBar1: TToolBar;
|
||
TBRafresh: TToolButton;
|
||
TBDel: TToolButton;
|
||
TBClose: TToolButton;
|
||
Panel1: TPanel;
|
||
Label1: TLabel;
|
||
Label3: TLabel;
|
||
Label5: TLabel;
|
||
BegDate: TDateTimePicker;
|
||
EndDate: TDateTimePicker;
|
||
cxGrid5: TcxGrid;
|
||
cxGridLevel4: TcxGridLevel;
|
||
ToolButton1: TToolButton;
|
||
ToolButton2: TToolButton;
|
||
Label4: TLabel;
|
||
DataSource1: TDataSource;
|
||
cxGridPopupMenu1: TcxGridPopupMenu;
|
||
CDS_Main: TClientDataSet;
|
||
ADOTemp: TADOQuery;
|
||
ADOCmd: TADOQuery;
|
||
ADOQuery1: TADOQuery;
|
||
Tv1: TcxGridDBBandedTableView;
|
||
v1Column1: TcxGridDBBandedColumn;
|
||
v1Column2: TcxGridDBBandedColumn;
|
||
v1Column3: TcxGridDBBandedColumn;
|
||
v1Column5: TcxGridDBBandedColumn;
|
||
v1Column7: TcxGridDBBandedColumn;
|
||
v1Column8: TcxGridDBBandedColumn;
|
||
cxStyleRepository1: TcxStyleRepository;
|
||
cxStyle1: TcxStyle;
|
||
cxStyle2: TcxStyle;
|
||
cxStyle3: TcxStyle;
|
||
cxStyle4: TcxStyle;
|
||
SWPersonBZ: TComboBox;
|
||
SWPerson: TComboBox;
|
||
SWReason: TComboBox;
|
||
ADOQueryMain: TADOQuery;
|
||
ToolButton3: TToolButton;
|
||
ToolButton4: TToolButton;
|
||
procedure FormDestroy(Sender: TObject);
|
||
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
||
procedure FormCreate(Sender: TObject);
|
||
procedure FormShow(Sender: TObject);
|
||
procedure ToolButton1Click(Sender: TObject);
|
||
procedure v1Column7PropertiesButtonClick(Sender: TObject;
|
||
AButtonIndex: Integer);
|
||
procedure TBCloseClick(Sender: TObject);
|
||
procedure ToolButton2Click(Sender: TObject);
|
||
procedure TBDelClick(Sender: TObject);
|
||
procedure SWPersonBZChange(Sender: TObject);
|
||
procedure TBRafreshClick(Sender: TObject);
|
||
procedure ToolButton3Click(Sender: TObject);
|
||
procedure ToolButton4Click(Sender: TObject);
|
||
private
|
||
{ Private declarations }
|
||
procedure ComboxData(v1Column310:TcxGridDBBandedColumn;ii:Integer);
|
||
procedure InitGrid();
|
||
public
|
||
{ Public declarations }
|
||
end;
|
||
|
||
var
|
||
frmStopWorkList: TfrmStopWorkList;
|
||
|
||
implementation
|
||
uses
|
||
U_DataLink,U_Fun,U_ZDYHelp;
|
||
|
||
{$R *.dfm}
|
||
|
||
procedure TfrmStopWorkList.FormDestroy(Sender: TObject);
|
||
begin
|
||
frmStopWorkList:=nil;
|
||
end;
|
||
|
||
procedure TfrmStopWorkList.FormClose(Sender: TObject;
|
||
var Action: TCloseAction);
|
||
begin
|
||
Action:=caFree;
|
||
end;
|
||
|
||
procedure TfrmStopWorkList.FormCreate(Sender: TObject);
|
||
begin
|
||
cxGrid5.Align:=alClient;
|
||
|
||
end;
|
||
|
||
procedure TfrmStopWorkList.FormShow(Sender: TObject);
|
||
|
||
begin
|
||
EndDate.DateTime:=SGetServerDate(ADOQuery1);
|
||
BegDate.DateTime:=EndDate.DateTime-7;
|
||
ReadCxBandedGrid('ͣ<><CDA3><EFBFBD><EFBFBD>¼',Tv1,'<27>IJ<DEB7><C4B2><EFBFBD><EFBFBD><EFBFBD>');
|
||
InitGrid();
|
||
|
||
end;
|
||
procedure TfrmStopWorkList.InitGrid();
|
||
var
|
||
sql:string;
|
||
begin
|
||
try
|
||
ADOQueryMain.DisableControls;
|
||
with ADOQueryMain do
|
||
begin
|
||
Filtered:=False;
|
||
Close;
|
||
sql.Clear;
|
||
SQL.Add('select SWDate10=(Convert(varchar(10),A.SWBegTime,120)), A.* from WFB_StopWorkList A where SWBegTime>=:begdate and SWBegTime<:enddate');
|
||
Parameters.ParamByName('begdate').Value:=FormatDateTime('yyyy-MM-dd',BegDate.DateTime);
|
||
Parameters.ParamByName('enddate').Value:=FormatDateTime('yyyy-MM-dd',enddate.DateTime+1);
|
||
Open;
|
||
end;
|
||
SCreateCDS20(ADOQueryMain,CDS_Main);
|
||
SInitCDSData20(ADOQueryMain,CDS_Main);
|
||
finally
|
||
ADOQueryMain.EnableControls;
|
||
end;
|
||
sql:='select distinct(SWPersonBZ) Name from WFB_StopWorkList where SWBegTime>='''+Trim(FormatDateTime('yyyy-MM-dd',BegDate.DateTime))+''''
|
||
+'and SWBegTime<'''+Trim(FormatDateTime('yyyy-MM-dd',EndDate.DateTime+1))+'''';
|
||
SInitComBoxBySql(ADOTemp,SWPersonBZ,False,sql);
|
||
sql:='select distinct(SWPerson) Name from WFB_StopWorkList where SWBegTime>='''+Trim(FormatDateTime('yyyy-MM-dd',BegDate.DateTime))+''''
|
||
+'and SWBegTime<'''+Trim(FormatDateTime('yyyy-MM-dd',EndDate.DateTime+1))+'''';
|
||
SInitComBoxBySql(ADOTemp,SWPerson,False,sql);
|
||
sql:='select distinct(SWReason) Name from WFB_StopWorkList where SWBegTime>='''+Trim(FormatDateTime('yyyy-MM-dd',BegDate.DateTime))+''''
|
||
+'and SWBegTime<'''+Trim(FormatDateTime('yyyy-MM-dd',EndDate.DateTime+1))+'''';
|
||
SInitComBoxBySql(ADOTemp,SWReason,False,sql);
|
||
end;
|
||
procedure TfrmStopWorkList.ComboxData(v1Column310:TcxGridDBBandedColumn;ii:Integer);
|
||
var
|
||
i:Integer;
|
||
j:string;
|
||
begin
|
||
(v1Column310.Properties as TcxComboBoxProperties).Items.Clear;
|
||
for i:=0 to ii do
|
||
begin
|
||
if i<10 then
|
||
j:='0'+trim(IntToStr(i))
|
||
else
|
||
j:=Trim(IntToStr(i));
|
||
(v1Column310.Properties as TcxComboBoxProperties).Items.Add(Trim(j));
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmStopWorkList.ToolButton1Click(Sender: TObject);
|
||
begin
|
||
with CDS_Main do
|
||
begin
|
||
Append;
|
||
FieldByName('SWDate').Value:=SGetServerDate(ADOTemp);
|
||
FieldByName('SWPerson').Value:=Trim(DName);
|
||
with ADOQuery1 do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select * from SY_User where UserId='''+Trim(DCode)+'''');
|
||
Open;
|
||
end;
|
||
FieldByName('SWPersonBZ').Value:=Trim(ADOQuery1.fieldbyname('UDept').AsString);
|
||
Post;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmStopWorkList.v1Column7PropertiesButtonClick(Sender: TObject;
|
||
AButtonIndex: Integer);
|
||
begin
|
||
try
|
||
frmZDYHelp:=TfrmZDYHelp.Create(Application);
|
||
with frmZDYHelp do
|
||
begin
|
||
flag:='SWReason';
|
||
flagname:='ͣ<><CDA3>ԭ<EFBFBD><D4AD>';
|
||
if ShowModal=1 then
|
||
begin
|
||
Self.CDS_Main.Edit;
|
||
Self.CDS_Main.FieldByName('SWReason').Value:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString)
|
||
end;
|
||
end;
|
||
finally
|
||
frmZDYHelp.Free;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmStopWorkList.TBCloseClick(Sender: TObject);
|
||
begin
|
||
Close;
|
||
WriteCxBandedGrid('ͣ<><CDA3><EFBFBD><EFBFBD>¼',Tv1,'<27>IJ<DEB7><C4B2><EFBFBD><EFBFBD><EFBFBD>');
|
||
end;
|
||
|
||
procedure TfrmStopWorkList.ToolButton2Click(Sender: TObject);
|
||
var
|
||
maxno:string;
|
||
begin
|
||
BegDate.SetFocus;
|
||
if CDS_Main.IsEmpty then Exit;
|
||
try
|
||
ADOCmd.Connection.BeginTrans;
|
||
with ADOCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('Update WFB_StopWorkList Set SWReason='''+Trim(CDS_Main.fieldbyname('SWReason').AsString)+'''');
|
||
sql.Add(' where SWID='''+Trim(CDS_Main.fieldbyname('SWID').AsString)+'''');
|
||
ExecSQL;
|
||
end;
|
||
ADOCmd.Connection.CommitTrans;
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD>','<27><>ʾ',0);
|
||
Exit;
|
||
except
|
||
ADOCmd.Connection.RollbackTrans;
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmStopWorkList.TBDelClick(Sender: TObject);
|
||
begin
|
||
if Trim(CDS_Main.fieldbyname('SWID').AsString)<>'' then
|
||
begin
|
||
if Trim(DCode)<>'ADMIN' then
|
||
begin
|
||
if Trim(DName)<>Trim(CDS_Main.fieldbyname('SWPerson').AsString) then
|
||
begin
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE><EFBFBD><EFBFBD><EFBFBD>˼<EFBFBD>¼<EFBFBD><C2BC>','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
end;
|
||
if Application.MessageBox('ȷ<><C8B7>Ҫɾ<D2AA><C9BE><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD>','<27><>ʾ',32+4)<>IDYES then Exit;
|
||
with ADOCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('delete WFB_StopWorkList where SWID='''+Trim(CDS_Main.fieldbyname('SWID').AsString)+'''');
|
||
ExecSQL;
|
||
end;
|
||
end;
|
||
CDS_Main.Delete;
|
||
end;
|
||
|
||
procedure TfrmStopWorkList.SWPersonBZChange(Sender: TObject);
|
||
begin
|
||
SDofilter(ADOQueryMain,SGetFilters(Panel1,1,2));
|
||
SCreateCDS20(ADOQueryMain,CDS_Main);
|
||
SInitCDSData20(ADOQueryMain,CDS_Main);
|
||
end;
|
||
|
||
procedure TfrmStopWorkList.TBRafreshClick(Sender: TObject);
|
||
begin
|
||
BegDate.SetFocus;
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmStopWorkList.ToolButton3Click(Sender: TObject);
|
||
begin
|
||
if CDS_Main.IsEmpty then Exit;
|
||
TcxGridToExcel('ͣ<><CDA3><EFBFBD><EFBFBD>¼',cxGrid5);
|
||
end;
|
||
|
||
procedure TfrmStopWorkList.ToolButton4Click(Sender: TObject);
|
||
begin
|
||
try
|
||
frmZDYHelp:=TfrmZDYHelp.Create(Application);
|
||
with frmZDYHelp do
|
||
begin
|
||
flag:='SWReason';
|
||
flagname:='ͣ<><CDA3>ԭ<EFBFBD><D4AD>';
|
||
if ShowModal=1 then
|
||
begin
|
||
end;
|
||
end;
|
||
finally
|
||
frmZDYHelp.Free;
|
||
end;
|
||
end;
|
||
|
||
end.
|