D7wmguihua/坯布码单待检(PBMDDJ.dll)/U_ContractCGJGChkList.pas
DESKTOP-E401PHE\Administrator b4b5840f18 1
2025-01-18 16:22:10 +08:00

516 lines
15 KiB
ObjectPascal
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

unit U_ContractCGJGChkList;
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, IdBaseComponent, IdComponent, IdTCPConnection,
IdTCPClient, IdFTP,ShellAPI, cxCheckBox,jpeg,IniFiles;
type
TfrmContractCGJGChkList = class(TForm)
ToolBar1: TToolBar;
TBRafresh: TToolButton;
TBFind: TToolButton;
TBPrint: TToolButton;
TBClose: TToolButton;
Panel1: TPanel;
BegDate: TDateTimePicker;
EndDate: TDateTimePicker;
Label1: TLabel;
Label2: TLabel;
cxGridPopupMenu1: TcxGridPopupMenu;
ADOQueryCmd: TADOQuery;
ADOQueryMain: TADOQuery;
ADOQueryTemp: TADOQuery;
DataSource1: TDataSource;
Label3: TLabel;
ConNo: TEdit;
Label5: TLabel;
C_CodeName: TEdit;
Order_Main: TClientDataSet;
Label4: TLabel;
FactoryNoName: TEdit;
RM1: TRMGridReport;
RMDBMain: TRMDBDataSet;
RMXLSExport1: TRMXLSExport;
CDS_PRT: TClientDataSet;
cxGrid1: TcxGrid;
Tv1: TcxGridDBTableView;
v1OrderNo: TcxGridDBColumn;
v1Column2: TcxGridDBColumn;
v1DeliveryDate: TcxGridDBColumn;
v1Column5: TcxGridDBColumn;
v1FactoryNo1Name: TcxGridDBColumn;
v1PRTSpec: TcxGridDBColumn;
v1Qty1: TcxGridDBColumn;
v1PRTOrderQty: TcxGridDBColumn;
v1OrderUnit: TcxGridDBColumn;
v1Column1: TcxGridDBColumn;
v1PRTQty: TcxGridDBColumn;
v1Column4: TcxGridDBColumn;
cxGrid1Level1: TcxGridLevel;
v1Column3: TcxGridDBColumn;
ConType: TComboBox;
Label14: TLabel;
ToolButton2: TToolButton;
v1Column6: TcxGridDBColumn;
v1Column7: TcxGridDBColumn;
v1Column8: TcxGridDBColumn;
v1Column9: TcxGridDBColumn;
ToolButton3: TToolButton;
ODPat: TOpenDialog;
IdFTP1: TIdFTP;
SaveDialog1: TSaveDialog;
v1Column14: TcxGridDBColumn;
v1Column15: TcxGridDBColumn;
TBChkNO: TToolButton;
TBChkOk: TToolButton;
v1Column16: TcxGridDBColumn;
v1Column17: TcxGridDBColumn;
ToolButton8: TToolButton;
cxTabControl1: TcxTabControl;
v1Column10: TcxGridDBColumn;
v1Column11: TcxGridDBColumn;
ComboBox1: TComboBox;
ToolButton1: TToolButton;
Panel2: TPanel;
Label6: TLabel;
ChkNote: TEdit;
v1Column12: TcxGridDBColumn;
v1Column13: TcxGridDBColumn;
procedure FormDestroy(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure TBCloseClick(Sender: TObject);
procedure TBFindClick(Sender: TObject);
procedure TBPrintClick(Sender: TObject);
procedure TBRafreshClick(Sender: TObject);
procedure ConNoChange(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure conPress(Sender: TObject; var Key: Char);
procedure ToolButton2Click(Sender: TObject);
procedure ToolButton3Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure TBChkOkClick(Sender: TObject);
procedure TBChkNOClick(Sender: TObject);
procedure cxTabControl1Change(Sender: TObject);
procedure ToolButton8Click(Sender: TObject);
procedure ToolButton1Click(Sender: TObject);
private
FInt,PFInt:Integer;
canshu1:string;
lstPat: TStringList;
AJpeg: TJPEGImage;
procedure InitGrid();
procedure InitForm();
function DelData():Boolean;
procedure ReadINIFile10();
{ Private declarations }
public
{ Public declarations }
end;
var
frmContractCGJGChkList: TfrmContractCGJGChkList;
implementation
uses
U_DataLink,U_RTFun,U_ClothContractInPutSXMX,U_ZDYHelp
{U_ClothContractInPutSX,
U_ProductOrderList,U_ZDYHelp,
,U_ClothContractInPutHZ,U_ClothContractInPutPB}, U_ModuleNote;
{$R *.dfm}
procedure TfrmContractCGJGChkList.FormDestroy(Sender: TObject);
begin
frmContractCGJGChkList:=nil;
end;
procedure TfrmContractCGJGChkList.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
Action:=caFree;
end;
procedure TfrmContractCGJGChkList.TBCloseClick(Sender: TObject);
var
FPath:String;
begin
Close;
WriteCxGrid('<27>ɹ<EFBFBD><C9B9>ӹ<EFBFBD><D3B9><EFBFBD>ͬChk',Tv1,'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD>');
end;
procedure TfrmContractCGJGChkList.InitGrid();
begin
try
ADOQueryMain.DisableControls;
with ADOQueryMain do
begin
Filtered:=False;
Close;
sql.Clear;
sql.Add('select A.*,B.*,Money=B.C_Qty*B.Price from Contract_Main A inner join Contract_Sub B on A.MainId=B.MainId ');
sql.Add(' where isnull(SSPerson,'''')<>'''' ');
if cxTabControl1.TabIndex=0 then
begin
sql.Add(' and isnull(Chker,'''')='''' ');
end else
begin
sql.Add(' and A.FillTime>='''+Trim(FormatDateTime('yyyy-MM-dd',BegDate.DateTime))+'''');
sql.Add(' and A.FillTime<'''+Trim(FormatDateTime('yyyy-MM-dd',EndDate.DateTime+1))+'''');
if cxTabControl1.TabIndex<>3 then
begin
sql.Add(' and isnull(Chker,'''')<>'''' ');
if cxTabControl1.TabIndex=1 then
begin
sql.Add(' and isnull(ChkStatus,'''')=''<27><><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8>'' ');
end else
if cxTabControl1.TabIndex=2 then
begin
sql.Add(' and isnull(ChkStatus,'''')=''<27><><EFBFBD>˲<EFBFBD>ͨ<EFBFBD><CDA8>'' ');
end;
end;
end;
Open;
end;
SCreateCDS20(ADOQueryMain,Order_Main);
SInitCDSData20(ADOQueryMain,Order_Main);
finally
ADOQueryMain.EnableControls;
end;
end;
procedure TfrmContractCGJGChkList.InitForm();
var
FSJ:string;
begin
ReadCxGrid('<27>ɹ<EFBFBD><C9B9>ӹ<EFBFBD><D3B9><EFBFBD>ͬChk',Tv1,'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD>');
EndDate.DateTime:=SGetServerDate10(ADOQueryTemp);
BegDate.DateTime:=EndDate.DateTime-30;
FSJ:='select ZdyName Name,ZdyName Code from KH_Zdy where TYpe=''JGGX'' and ZdyName not like ''%<25>ؼ<EFBFBD>%'' ';
SInitComBoxBySql(ADOQueryTemp,ConType,False,Fsj);
end;
procedure TfrmContractCGJGChkList.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;
function TfrmContractCGJGChkList.DelData():Boolean;
begin
try
Result:=false;
ADOQueryCmd.Connection.BeginTrans;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('delete Contract_Sub where SubId='''+Trim(Order_Main.fieldbyname('SubId').AsString)+'''');
ExecSQL;
end;
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add('select * from Contract_Sub where MainId='''+Trim(Order_Main.fieldbyname('MainId').AsString)+'''');
Open;
end;
if ADOQueryTemp.IsEmpty then
begin
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('delete Contract_Main where MainId='''+Trim(Order_Main.fieldbyname('MainId').AsString)+'''');
ExecSQL;
end;
end;
if Trim(Order_Main.fieldbyname('SubId').AsString)='' then
begin
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('delete Contract_Main where MainId='''+Trim(Order_Main.fieldbyname('MainId').AsString)+'''');
ExecSQL;
end;
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 TfrmContractCGJGChkList.TBPrintClick(Sender: TObject);
var
fPrintFile,FConNoM,RPTName:string;
begin
if Order_Main.IsEmpty then Exit;
if Trim(ComboBox1.Text)='' then
begin
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʋ<EFBFBD><C6B2><EFBFBD>Ϊ<EFBFBD><CEAA>!','<27><>ʾ',0);
Exit;
end;
RPTName:='Report\'+Trim(ComboBox1.Text)+'.rmf';
// fPrintFile:= ExtractFilePath(Application.ExeName) + 'Report\<5C>ɹ<EFBFBD><C9B9>ӹ<EFBFBD><D3B9><EFBFBD>ͬ.rmf' ;
fPrintFile:= ExtractFilePath(Application.ExeName) +RPTName;
with ADOQueryTemp do
begin
Filtered:=False;
Close;
sql.Clear;
sql.Add('select A.*,B.*,Money=B.C_Qty*B.Price,C.*,D.KHName,D.ZKTelNo,D.ZKFax,D.ZKAddress ');
sql.Add(' ,C.ZdyName,C.ZdyStr1,C.ZdyStr2,C.ZdyStr3,C.ZdyStr4');
sql.Add(' from Contract_Main A inner join Contract_Sub B on A.MainId=B.MainId');
sql.Add(' left join KH_Zdy C on A.CompanyName=C.ZdyName and C.Type=''GSTT'' ');
sql.Add(' left join ZH_KH_Info D on A.FactoryNo=D.ZKID');
sql.Add(' where A.Mainid='''+Trim(Order_Main.fieldbyname('MainId').AsString)+'''');
Open;
end;
SCreateCDS20(ADOQueryTemp,CDS_PRT);
SInitCDSData20(ADOQueryTemp,CDS_PRT);
if FileExists(fPrintFile) then
begin
//RMVariables['begindate']:=begindate.DateTime;
//RMVariables['enddate']:=enddate.DateTime;
//RMVariables['printtime']:=Now;
//RMVariables['printer']:=Trim(gUserName);
RM1.LoadFromFile(fPrintFile);
RM1.ShowReport;
end else
begin
Application.MessageBox(PChar(<><C3BB><EFBFBD><EFBFBD>'+ExtractFilePath(Application.ExeName)+RPTName),'<27><>ʾ',0);
end;
end;
procedure TfrmContractCGJGChkList.TBRafreshClick(Sender: TObject);
begin
InitGrid();
end;
procedure TfrmContractCGJGChkList.ConNoChange(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 TfrmContractCGJGChkList.FormShow(Sender: TObject);
begin
InitForm();
end;
procedure TfrmContractCGJGChkList.conPress(Sender: TObject;
var Key: Char);
begin
if Key=#13 then
begin
if Length(Trim(ConNo.Text))<3 then Exit;
try
ADOQueryMain.DisableControls;
with ADOQueryMain do
begin
Filtered:=False;
Close;
sql.Clear;
sql.Add('select A.*,B.*,Money=B.C_Qty*B.Price from Contract_Main A inner join Contract_Sub B on A.MainId=B.MainId ');
sql.Add(' where A.ConNo like '''+'%'+Trim(ConNo.text)+'%'+'''');
sql.Add(' and isnull(SSPerson,'''')<>'''' ');
if cxTabControl1.TabIndex=0 then
begin
sql.Add(' and isnull(Chker,'''')='''' ');
end else
begin
if cxTabControl1.TabIndex<>3 then
begin
sql.Add(' and isnull(Chker,'''')<>'''' ');
if cxTabControl1.TabIndex=1 then
begin
sql.Add(' and isnull(ChkStatus,'''')=''<27><><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8>'' ');
end else
if cxTabControl1.TabIndex=2 then
begin
sql.Add(' and isnull(ChkStatus,'''')=''<27><><EFBFBD>˲<EFBFBD>ͨ<EFBFBD><CDA8>'' ');
end;
end;
end;
Open;
end;
SCreateCDS20(ADOQueryMain,Order_Main);
SInitCDSData20(ADOQueryMain,Order_Main);
finally
ADOQueryMain.EnableControls;
end;
end;
end;
procedure TfrmContractCGJGChkList.ToolButton2Click(Sender: TObject);
begin
try
frmClothContractInPutSXMX:=TfrmClothContractInPutSXMX.Create(Application);
with frmClothContractInPutSXMX do
begin
PState:=1;
FMainId:=Trim(Self.Order_Main.fieldbyname('MainId').AsString);
FConNo:=Trim(Self.Order_Main.fieldbyname('ConNo').AsString);
TBSave.Visible:=False;
ToolBar2.Visible:=False;
if ShowModal=1 then
begin
end;
end;
finally
frmClothContractInPutSXMX.Free;
end;
end;
procedure TfrmContractCGJGChkList.ToolButton3Click(Sender: TObject);
begin
try
frmModuleNote:=TfrmModuleNote.Create(Application);
with frmModuleNote do
begin
flag:='<27>ɹ<EFBFBD><C9B9>ӹ<EFBFBD><D3B9><EFBFBD>ͬ';
if ShowModal=1 then
begin
end;
end;
finally
frmModuleNote.Free;
end;
end;
procedure TfrmContractCGJGChkList.FormCreate(Sender: TObject);
begin
canshu1:=Trim(DParameters1);
cxTabControl1.TabIndex:=0;
end;
procedure TfrmContractCGJGChkList.ReadINIFile10();
var
programIni:Tinifile; //<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>
FileName:string;
begin
FileName:=ExtractFilePath(Paramstr(0))+'SYSTEMSET.INI';
programIni:=Tinifile.create(FileName);
server:=programIni.ReadString('SERVER','<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ','127.0.0.1');
programIni.Free;
end;
procedure TfrmContractCGJGChkList.TBChkOkClick(Sender: TObject);
begin
if cxTabControl1.TabIndex<>0 then Exit;
if Order_Main.IsEmpty then Exit;
if Application.MessageBox(<><C8B7>Ҫִ<D2AA>д˲<D0B4><CBB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>','<27><>ʾ',32+4)<>IDYES then Exit;
with ADOQueryCmd do
begin
Close;
sql.Clear;
SQL.Add('Update Contract_Main Set ChkStatus=''<27><><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8>'',Chker='''+Trim(DName)+'''');
sql.Add(',ChkTIme=getdate() where MainId='''+Trim(Order_Main.fieldbyname('MainId').AsString)+'''');
ExecSQL;
end;
Order_Main.Delete;
end;
procedure TfrmContractCGJGChkList.TBChkNOClick(Sender: TObject);
begin
if cxTabControl1.TabIndex=0 then Exit;
if cxTabControl1.TabIndex=3 then Exit;
if Order_Main.IsEmpty then Exit;
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add('select * from Contract_Main where MainId='''+Trim(Order_Main.fieldbyname('MainId').AsString)+'''');
sql.Add(' and isnull(PChker,'''')<>'''' ');
Open;
end;
if ADOQueryTemp.IsEmpty=False then
begin
Application.MessageBox('<27>Ѿ<EFBFBD><D1BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܳ<EFBFBD><DCB3><EFBFBD>!','<27><>ʾ',0);
Exit;
end;
if Application.MessageBox(<><C8B7>Ҫִ<D2AA><D6B4><EFBFBD><EFBFBD><EFBFBD>˳<EFBFBD><CBB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>','<27><>ʾ',32+4)<>IDYES then Exit;
with ADOQueryCmd do
begin
Close;
sql.Clear;
SQL.Add('Update Contract_Main Set ChkStatus=NUll,Chker=NUll,ChkNote=Null ');
sql.Add(',ChkTIme=Null where MainId='''+Trim(Order_Main.fieldbyname('MainId').AsString)+'''');
ExecSQL;
end;
Order_Main.Delete;
end;
procedure TfrmContractCGJGChkList.cxTabControl1Change(Sender: TObject);
begin
InitGrid();
end;
procedure TfrmContractCGJGChkList.ToolButton8Click(Sender: TObject);
begin
if Order_Main.IsEmpty then Exit;
TcxGridToExcel('<27>ɹ<EFBFBD><C9B9>ӹ<EFBFBD><D3B9><EFBFBD>ͬ',cxGrid1);
end;
procedure TfrmContractCGJGChkList.ToolButton1Click(Sender: TObject);
begin
if cxTabControl1.TabIndex>1 then Exit;
if Order_Main.IsEmpty then Exit;
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add('select * from Contract_Main where MainId='''+Trim(Order_Main.fieldbyname('MainId').AsString)+'''');
sql.Add(' and isnull(PChker,'''')<>'''' ');
Open;
end;
if ADOQueryTemp.IsEmpty=False then
begin
Application.MessageBox('<27>Ѿ<EFBFBD><D1BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˲<EFBFBD>ͨ<EFBFBD><CDA8>','<27><>ʾ',0);
Exit;
end;
if Trim(ChkNote.Text)='' then
begin
Application.MessageBox('<27><><EFBFBD>˱<EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>!','<27><>ʾ',0);
Exit;
end;
if Application.MessageBox(<><C8B7>Ҫ<EFBFBD><D2AA><EFBFBD>˲<EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>','<27><>ʾ',32+4)<>IDYES then Exit;
with ADOQueryCmd do
begin
Close;
sql.Clear;
SQL.Add('Update Contract_Main Set ChkStatus=''<27><><EFBFBD>˲<EFBFBD>ͨ<EFBFBD><CDA8>'',Chker='''+Trim(DName)+'''');
sql.Add(',ChkTime=getdate(),ChkNote='''+Trim(ChkNote.Text)+'''');
sql.add(' where MainId='''+Trim(Order_Main.fieldbyname('MainId').AsString)+'''');
ExecSQL;
end;
//ChkNote.Text:='';
Order_Main.Delete;
end;
end.