478 lines
13 KiB
ObjectPascal
478 lines
13 KiB
ObjectPascal
unit U_CaiGouSQList;
|
||
|
||
interface
|
||
|
||
uses
|
||
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
||
Dialogs, StdCtrls, ExtCtrls, ComCtrls, ToolWin, cxStyles, cxCustomData,
|
||
cxGraphics, cxFilter, cxData, cxDataStorage, cxEdit, DB, cxDBData, ADODB,
|
||
cxGridCustomPopupMenu, cxGridPopupMenu, cxGridLevel, cxClasses,
|
||
cxControls, cxGridCustomView, cxGridCustomTableView, cxGridTableView,
|
||
cxGridDBTableView, cxGrid, DBClient, cxCalendar, cxButtonEdit, cxSplitter,
|
||
RM_Common, RM_Class, RM_e_Xls, RM_Dataset, RM_System, RM_GridReport,
|
||
cxTextEdit, cxPC, cxDropDownEdit, cxCheckBox;
|
||
|
||
type
|
||
TfrmCaiGouSQList = class(TForm)
|
||
ToolBar1: TToolBar;
|
||
TBRafresh: TToolButton;
|
||
TBAdd: TToolButton;
|
||
TBEdit: TToolButton;
|
||
TBDel: TToolButton;
|
||
TBClose: TToolButton;
|
||
cxGridPopupMenu1: TcxGridPopupMenu;
|
||
ADOQueryCmd: TADOQuery;
|
||
ADOQueryMain: TADOQuery;
|
||
ADOQueryTemp: TADOQuery;
|
||
DataSource1: TDataSource;
|
||
TBExport: TToolButton;
|
||
Order_Main: TClientDataSet;
|
||
Panel1: TPanel;
|
||
Label1: TLabel;
|
||
Label2: TLabel;
|
||
BegDate: TDateTimePicker;
|
||
EndDate: TDateTimePicker;
|
||
TBFind: TToolButton;
|
||
SPName: TEdit;
|
||
Label4: TLabel;
|
||
SQPerson: TEdit;
|
||
Label5: TLabel;
|
||
TBSS: TToolButton;
|
||
TBSSCX: TToolButton;
|
||
cxTabControl1: TcxTabControl;
|
||
Label3: TLabel;
|
||
Label6: TLabel;
|
||
PinPai: TEdit;
|
||
FactoryName: TEdit;
|
||
Label7: TLabel;
|
||
ConNo: TEdit;
|
||
cxGrid1: TcxGrid;
|
||
Tv1: TcxGridDBTableView;
|
||
v1SSel: TcxGridDBColumn;
|
||
v1Column7: TcxGridDBColumn;
|
||
v1Column6: TcxGridDBColumn;
|
||
v1Column12: TcxGridDBColumn;
|
||
v1Column13: TcxGridDBColumn;
|
||
v1Column5: TcxGridDBColumn;
|
||
v1Column14: TcxGridDBColumn;
|
||
v1Column15: TcxGridDBColumn;
|
||
v1Column16: TcxGridDBColumn;
|
||
v1Column17: TcxGridDBColumn;
|
||
v1Column1: TcxGridDBColumn;
|
||
v1Column2: TcxGridDBColumn;
|
||
v1Column4: TcxGridDBColumn;
|
||
v1Column18: TcxGridDBColumn;
|
||
v1Column19: TcxGridDBColumn;
|
||
v1Column20: TcxGridDBColumn;
|
||
v1Column3: TcxGridDBColumn;
|
||
v1Column11: TcxGridDBColumn;
|
||
v1Column10: TcxGridDBColumn;
|
||
v1Column8: TcxGridDBColumn;
|
||
v1Column9: TcxGridDBColumn;
|
||
cxGrid1Level1: TcxGridLevel;
|
||
ToolButton1: TToolButton;
|
||
CDS_PRT: TClientDataSet;
|
||
RMDBPRT: TRMDBDataSet;
|
||
RM1: TRMGridReport;
|
||
v1Column21: TcxGridDBColumn;
|
||
v1Column22: TcxGridDBColumn;
|
||
v1Column23: TcxGridDBColumn;
|
||
v1Column24: TcxGridDBColumn;
|
||
v1Column25: TcxGridDBColumn;
|
||
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
||
procedure TBCloseClick(Sender: TObject);
|
||
procedure TBEditClick(Sender: TObject);
|
||
procedure TBDelClick(Sender: TObject);
|
||
procedure TBExportClick(Sender: TObject);
|
||
procedure TBRafreshClick(Sender: TObject);
|
||
procedure TBAddClick(Sender: TObject);
|
||
procedure FormShow(Sender: TObject);
|
||
procedure cxPageControl1Change(Sender: TObject);
|
||
procedure ToolButton3Click(Sender: TObject);
|
||
procedure cxTabControl1Change(Sender: TObject);
|
||
procedure TBFindClick(Sender: TObject);
|
||
procedure TBSSClick(Sender: TObject);
|
||
procedure TBSSCXClick(Sender: TObject);
|
||
procedure FormDestroy(Sender: TObject);
|
||
procedure ToolButton1Click(Sender: TObject);
|
||
private
|
||
|
||
canshu1,canshu2,ChildFlag:string;
|
||
procedure InitGrid();
|
||
procedure InitForm();
|
||
function DelData():Boolean;
|
||
{ Private declarations }
|
||
public
|
||
|
||
{ Public declarations }
|
||
end;
|
||
|
||
//var
|
||
// frmCaiGouSQList: TfrmCaiGouSQList;
|
||
|
||
implementation
|
||
uses
|
||
U_DataLink,U_RTFun,U_CaiGouSQInPut,U_ModuleNote;
|
||
|
||
{$R *.dfm}
|
||
|
||
procedure TfrmCaiGouSQList.FormClose(Sender: TObject;
|
||
var Action: TCloseAction);
|
||
begin
|
||
application:=mainapplication;
|
||
Action:=caFree;
|
||
end;
|
||
|
||
procedure TfrmCaiGouSQList.TBCloseClick(Sender: TObject);
|
||
begin
|
||
Close;
|
||
WriteCxGrid(Self.Caption,Tv1,'<27>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
||
end;
|
||
|
||
procedure TfrmCaiGouSQList.InitGrid();
|
||
begin
|
||
BegDate.SetFocus;
|
||
try
|
||
ADOQueryMain.DisableControls;
|
||
with ADOQueryMain do
|
||
begin
|
||
Filtered:=False;
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add(' select A.* ');
|
||
SQL.Add(' from CaiGou_SQ A where SQType=''ɴ<><C9B4>'' ');
|
||
if Trim(canshu1)='¼<><C2BC>' then
|
||
begin
|
||
sql.Add(' and Filler='''+Trim(DName)+'''');
|
||
end;
|
||
if Trim(canshu1)<>'<27><>ѯ' then
|
||
begin
|
||
if cxTabControl1.TabIndex=0 then
|
||
begin
|
||
sql.Add(' and isnull(SChkStatus,'''')='''' ');
|
||
end else
|
||
if cxTabControl1.TabIndex=1 then
|
||
begin
|
||
sql.Add(' and isnull(SChkStatus,'''')<>'''' and isnull(ChkStatus,'''')='''' ');
|
||
end else
|
||
if cxTabControl1.TabIndex=2 then
|
||
begin
|
||
sql.Add(' and isnull(ChkStatus,'''')<>'''' ');
|
||
end;
|
||
if cxTabControl1.TabIndex<>0 then
|
||
begin
|
||
sql.Add(' and A.SQDate>='''+Trim(FormatDateTime('yyyy-MM-dd',BegDate.Date))+'''');
|
||
sql.Add(' and A.SQDate<'''+Trim(FormatDateTime('yyyy-MM-dd',EndDate.Date+1))+'''');
|
||
end;
|
||
end else
|
||
begin
|
||
sql.Add(' and A.SQDate>='''+Trim(FormatDateTime('yyyy-MM-dd',BegDate.Date))+'''');
|
||
sql.Add(' and A.SQDate<'''+Trim(FormatDateTime('yyyy-MM-dd',EndDate.Date+1))+'''');
|
||
sql.Add(' and isnull(Chker,'''')<>'''' ');
|
||
end;
|
||
sql.Add(' order by SQDate desc');
|
||
Open;
|
||
end;
|
||
SCreateCDS20(ADOQueryMain,Order_Main);
|
||
SInitCDSData20(ADOQueryMain,Order_Main);
|
||
finally
|
||
ADOQueryMain.EnableControls;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmCaiGouSQList.InitForm();
|
||
begin
|
||
if Self.Caption='ɴ<>߲ɹ<DFB2><C9B9>ӹ<EFBFBD><D3B9><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC>' then
|
||
begin
|
||
canshu1:='¼<><C2BC>';
|
||
end else
|
||
if Self.Caption='ɴ<>߲ɹ<DFB2><C9B9>ӹ<EFBFBD><D3B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȩ<EFBFBD><C8A8>' then
|
||
begin
|
||
canshu1:='<27><>Ȩ<EFBFBD><C8A8>';
|
||
end else
|
||
if Self.Caption='ɴ<>߲ɹ<DFB2><C9B9>ӹ<EFBFBD><D3B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯ' then
|
||
begin
|
||
canshu1:='<27><>ѯ';
|
||
end;
|
||
if canshu1='<27><>ѯ' then
|
||
begin
|
||
TBAdd.Visible:=False;TBEdit.Visible:=False;TBDel.Visible:=False;
|
||
TBSS.Visible:=False;TBSSCX.Visible:=False;cxTabControl1.Visible:=False;
|
||
end;
|
||
EndDate.Date:=SGetServerDate(ADOQueryTemp);
|
||
BegDate.Date:=EndDate.Date-7;
|
||
ReadCxGrid(Self.Caption,Tv1,'<27>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
||
if Trim(canshu1)='<27><>ѯ' then
|
||
begin
|
||
v1SSel.Visible:=False;
|
||
v1SSel.Hidden:=True;
|
||
end;
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmCaiGouSQList.TBEditClick(Sender: TObject);
|
||
begin
|
||
if Order_Main.IsEmpty then Exit;
|
||
if cxTabControl1.TabIndex<>0 then Exit;
|
||
{if Self.Caption<>'ɴ<>߲ɹ<DFB2><C9B9>ӹ<EFBFBD><D3B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȩ<EFBFBD><C8A8>' then
|
||
begin
|
||
if cxTabControl1.TabIndex<>0 then Exit;
|
||
end;}
|
||
try
|
||
frmCaiGouSQInPut:=TfrmCaiGouSQInPut.Create(Application);
|
||
with frmCaiGouSQInPut do
|
||
begin
|
||
PState:=1;
|
||
FMainId:=Trim(Self.Order_Main.fieldbyname('SQID').AsString);
|
||
frmCaiGouSQInPut.ToolButton3.Visible:=False;
|
||
frmCaiGouSQInPut.ToolButton4.Visible:=False;
|
||
FSQType:=Trim(Self.canshu2);
|
||
{if Self.Caption='ɴ<>߲ɹ<DFB2><C9B9>ӹ<EFBFBD><D3B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȩ<EFBFBD><C8A8>' then
|
||
begin
|
||
ZFormName:='<27><><EFBFBD><EFBFBD>';
|
||
end; }
|
||
|
||
if ShowModal=1 then
|
||
begin
|
||
|
||
end;
|
||
end;
|
||
finally
|
||
frmCaiGouSQInPut.Free;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmCaiGouSQList.TBDelClick(Sender: TObject);
|
||
begin
|
||
if Order_Main.IsEmpty then Exit;
|
||
if cxTabControl1.TabIndex<>0 then Exit;
|
||
if Application.MessageBox('ȷ<><C8B7>Ҫɾ<D2AA><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>','<27><>ʾ',32+4)<>IDYES then Exit;
|
||
if DelData() then
|
||
begin
|
||
Order_Main.Delete;
|
||
end;
|
||
end;
|
||
|
||
function TfrmCaiGouSQList.DelData():Boolean;
|
||
begin
|
||
try
|
||
Result:=false;
|
||
ADOQueryCmd.Connection.BeginTrans;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('delete CaiGou_SQ where SQId='''+Trim(Order_Main.fieldbyname('SQId').AsString)+'''');
|
||
ExecSQL;
|
||
end;
|
||
ADOQueryCmd.Connection.CommitTrans;
|
||
Result:=True;
|
||
except
|
||
ADOQueryCmd.Connection.RollbackTrans;
|
||
Result:=False;
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE><EFBFBD>쳣<EFBFBD><ECB3A3>','<27><>ʾ',0);
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmCaiGouSQList.TBExportClick(Sender: TObject);
|
||
begin
|
||
if Order_Main.IsEmpty then Exit;
|
||
TcxGridToExcel('ɴ<>߲ɹ<DFB2><C9B9>ӹ<EFBFBD><D3B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>',cxGrid1);
|
||
end;
|
||
|
||
procedure TfrmCaiGouSQList.TBRafreshClick(Sender: TObject);
|
||
begin
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmCaiGouSQList.TBAddClick(Sender: TObject);
|
||
begin
|
||
try
|
||
frmCaiGouSQInPut:=TfrmCaiGouSQInPut.Create(Application);
|
||
with frmCaiGouSQInPut do
|
||
begin
|
||
PState:=0;
|
||
FMainId:='';
|
||
FSQType:=Trim(Self.canshu2);
|
||
frmCaiGouSQInPut.Canshu1:=Trim(Self.canshu1);
|
||
if ShowModal=1 then
|
||
begin
|
||
|
||
end;
|
||
end;
|
||
finally
|
||
frmCaiGouSQInPut.Free;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmCaiGouSQList.FormShow(Sender: TObject);
|
||
begin
|
||
InitForm();
|
||
end;
|
||
|
||
procedure TfrmCaiGouSQList.cxPageControl1Change(Sender: TObject);
|
||
begin
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmCaiGouSQList.ToolButton3Click(Sender: TObject);
|
||
begin
|
||
try
|
||
frmModuleNote:=TfrmModuleNote.Create(Application);
|
||
with frmModuleNote do
|
||
begin
|
||
flag:='<27>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ǽ<EFBFBD>';
|
||
if ShowModal=1 then
|
||
begin
|
||
|
||
end;
|
||
end;
|
||
finally
|
||
frmModuleNote.Free;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmCaiGouSQList.cxTabControl1Change(Sender: TObject);
|
||
begin
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmCaiGouSQList.TBFindClick(Sender: TObject);
|
||
begin
|
||
if ADOQueryMain.Active=False then Exit;
|
||
SDofilter(ADOQueryMain,SGetFilters(Panel1,1,2));
|
||
SCreateCDS20(ADOQueryMain,Order_Main);
|
||
SInitCDSData20(ADOQueryMain,Order_Main);
|
||
end;
|
||
|
||
procedure TfrmCaiGouSQList.TBSSClick(Sender: TObject);
|
||
begin
|
||
if cxTabControl1.TabIndex<>0 then Exit;
|
||
if Order_Main.IsEmpty then Exit;
|
||
if Order_Main.Locate('SSel',True,[])=False then
|
||
begin
|
||
Application.MessageBox('û<><C3BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
if Application.MessageBox('ȷ<><C8B7>Ҫִ<D2AA>д˲<D0B4><CBB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>','<27><>ʾ',32+4)<>IDYES then Exit;
|
||
try
|
||
ADOQueryCmd.Connection.BeginTrans;
|
||
Order_Main.DisableControls;
|
||
with Order_Main do
|
||
begin
|
||
First;
|
||
while Locate('SSel',True,[])=True do
|
||
begin
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('UPdate CaiGou_SQ Set SChkStatus=''<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'',SChktime=getdate(),SChker='''+Trim(DName)+'''');
|
||
sql.Add(' where SQID='''+Trim(Order_Main.fieldbyname('SQID').AsString)+'''');
|
||
ExecSQL;
|
||
end;
|
||
Order_Main.Delete;
|
||
end;
|
||
end;
|
||
Order_Main.EnableControls;
|
||
ADOQueryCmd.Connection.CommitTrans;
|
||
except
|
||
Order_Main.EnableControls;
|
||
ADOQueryCmd.Connection.RollbackTrans;
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>쳣!','<27><>ʾ',0);
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmCaiGouSQList.TBSSCXClick(Sender: TObject);
|
||
begin
|
||
if cxTabControl1.TabIndex<>1 then Exit;
|
||
if Order_Main.IsEmpty then Exit;
|
||
if Order_Main.Locate('SSel',True,[])=False then
|
||
begin
|
||
Application.MessageBox('û<><C3BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
if Application.MessageBox('ȷ<><C8B7>Ҫִ<D2AA>д˲<D0B4><CBB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>','<27><>ʾ',32+4)<>IDYES then Exit;
|
||
try
|
||
ADOQueryCmd.Connection.BeginTrans;
|
||
Order_Main.DisableControls;
|
||
with Order_Main do
|
||
begin
|
||
First;
|
||
while Locate('SSel',True,[])=True do
|
||
begin
|
||
with ADOQueryTemp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select * from CaiGou_SQ ');
|
||
sql.Add(' where SQID='''+Trim(Order_Main.fieldbyname('SQID').AsString)+'''');
|
||
Open;
|
||
end;
|
||
if Trim(ADOQueryTemp.fieldbyname('ChkStatus').AsString)='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>' then
|
||
begin
|
||
Order_Main.EnableControls;
|
||
ADOQueryCmd.Connection.RollbackTrans;
|
||
InitGrid();
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><CBB5><EFBFBD><EFBFBD>ݲ<EFBFBD><DDB2>ܳ<EFBFBD><DCB3><EFBFBD>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('UPdate CaiGou_SQ Set SChkStatus=Null,SChktime=getdate(),SChker='''+Trim(DName)+'''');
|
||
sql.Add(' where SQID='''+Trim(Order_Main.fieldbyname('SQID').AsString)+'''');
|
||
ExecSQL;
|
||
end;
|
||
Order_Main.Delete;
|
||
end;
|
||
end;
|
||
Order_Main.EnableControls;
|
||
ADOQueryCmd.Connection.CommitTrans;
|
||
except
|
||
Order_Main.EnableControls;
|
||
ADOQueryCmd.Connection.RollbackTrans;
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>쳣!','<27><>ʾ',0);
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmCaiGouSQList.FormDestroy(Sender: TObject);
|
||
begin
|
||
//frmCaiGouSQList:=nil;
|
||
end;
|
||
|
||
procedure TfrmCaiGouSQList.ToolButton1Click(Sender: TObject);
|
||
var
|
||
fPrintFile,FPBName:string;
|
||
begin
|
||
if Order_Main.IsEmpty then Exit;
|
||
if cxTabControl1.TabIndex<>2 then Exit;
|
||
fPrintFile:= ExtractFilePath(Application.ExeName) + 'Report\ԭ<>ϲɹ<CFB2><C9B9><EFBFBD>.rmf' ;
|
||
with ADOQueryTemp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add(' select A.* ');
|
||
sql.Add(',KHConNo=(select KHConNo from JYOrderCon_Main C where C.MainId=isnull(B.ConMainId,''''))');
|
||
SQL.Add(' from CaiGou_SQ A ');
|
||
sql.Add(' left join Cloth_Main B on A.ConNo=B.ConNo');
|
||
sql.add(' where isnull(A.chker,'''')<>'''' and A.SQType=''ɴ<><C9B4>''');
|
||
SQL.Add(' and A.SQID='''+Trim(Order_Main.fieldbyname('SQID').AsString)+'''');
|
||
Open;
|
||
end;
|
||
SCreateCDS20(ADOQueryTemp,CDS_PRT);
|
||
SInitCDSData20(ADOQueryTemp,CDS_PRT);
|
||
if FileExists(fPrintFile) then
|
||
begin
|
||
RM1.LoadFromFile(fPrintFile);
|
||
RM1.ShowReport;
|
||
end else
|
||
begin
|
||
Application.MessageBox(PChar('û<><C3BB><EFBFBD><EFBFBD>'+ExtractFilePath(Application.ExeName)+'Report\ԭ<>ϲɹ<CFB2><C9B9><EFBFBD>.rmf'),'<27><>ʾ',0);
|
||
end;
|
||
end;
|
||
|
||
|
||
end.
|