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

355 lines
12 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_SXCKTHPut;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData,
cxDataStorage, cxEdit, DB, cxDBData, cxCalendar, cxDropDownEdit,
ComCtrls, ToolWin, cxGridLevel, cxGridCustomTableView, cxGridTableView,
cxGridDBTableView, cxClasses, cxControls, cxGridCustomView, cxGrid,
cxGridCustomPopupMenu, cxGridPopupMenu, ADODB, DBClient, cxButtonEdit,
cxTextEdit, cxSpinEdit;
type
TfrmSXCKTHPut = class(TForm)
ToolBar1: TToolBar;
TBAdd: TToolButton;
TBDel: TToolButton;
TBSave: TToolButton;
TBClose: TToolButton;
DataSource3: TDataSource;
CDS_Sub: TClientDataSet;
ADOQueryCmd: TADOQuery;
ADOQueryMain: TADOQuery;
ADOQueryTemp: TADOQuery;
cxGridPopupMenu2: TcxGridPopupMenu;
cxGrid2: TcxGrid;
Tv1: TcxGridDBTableView;
v1Column6: TcxGridDBColumn;
v1Column2: TcxGridDBColumn;
v2Column3: TcxGridDBColumn;
v2Column1: TcxGridDBColumn;
v1Column7: TcxGridDBColumn;
v1Column8: TcxGridDBColumn;
v1Column1: TcxGridDBColumn;
v1Column14: TcxGridDBColumn;
v1Column5: TcxGridDBColumn;
v1Column9: TcxGridDBColumn;
v2Column6: TcxGridDBColumn;
v1Column12: TcxGridDBColumn;
cxGrid2Level1: TcxGridLevel;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure TBAddClick(Sender: TObject);
procedure TBCloseClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure TBDelClick(Sender: TObject);
procedure TBSaveClick(Sender: TObject);
procedure v1Column1PropertiesButtonClick(Sender: TObject;
AButtonIndex: Integer);
private
{ Private declarations }
function SaveCKData():Boolean;
public
{ Public declarations }
FBCId:String;
end;
var
frmSXCKTHPut: TfrmSXCKTHPut;
implementation
uses
U_DataLink,U_RTFun,U_ClothContractListHZCX,U_ZDYHelp,U_SXCKKCSelList;
{$R *.dfm}
procedure TfrmSXCKTHPut.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
Action:=caFree;
end;
procedure TfrmSXCKTHPut.TBAddClick(Sender: TObject);
begin
try
frmSXCKKCSelList:=TfrmSXCKKCSelList.Create(Application);
with frmSXCKKCSelList do
begin
if ShowModal=1 then
begin
with Self.CDS_Sub do
begin
Append;
FieldByName('CRTime').Value:=Trim(FormatDateTime('yyyy-MM-dd',Now));
FieldByName('CGMainId').Value:=frmSXCKKCSelList.CDS_Main.fieldbyname('CGMainId').Value;
FieldByName('CGSubId').Value:=frmSXCKKCSelList.CDS_Main.fieldbyname('CGSubId').Value;
FieldByName('FactoryName').Value:=frmSXCKKCSelList.CDS_Main.fieldbyname('FactoryName').Value;
FieldByName('FactoryNo').Value:=frmSXCKKCSelList.CDS_Main.fieldbyname('FactoryNo').Value;
FieldByName('SPName').Value:=frmSXCKKCSelList.CDS_Main.fieldbyname('SPName').Value;
FieldByName('BatchNo').Value:=frmSXCKKCSelList.CDS_Main.fieldbyname('BatchNo').Value;
FieldByName('KuWei').Value:=frmSXCKKCSelList.CDS_Main.fieldbyname('KuWei').Value;
FieldByName('SPCF').Value:=frmSXCKKCSelList.CDS_Main.fieldbyname('SPCF').Value;
FieldByName('ShaZhi').Value:=frmSXCKKCSelList.CDS_Main.fieldbyname('ShaZhi').Value;
FieldByName('SeBie').Value:=frmSXCKKCSelList.CDS_Main.fieldbyname('SeBie').Value;
FieldByName('PiQty').Value:=frmSXCKKCSelList.CDS_Main.fieldbyname('MXKCPiQty').Value;
FieldByName('KgQty').Value:=frmSXCKKCSelList.CDS_Main.fieldbyname('MXKCKgQty').Value;
FieldByName('CRID').Value:=frmSXCKKCSelList.CDS_Main.fieldbyname('CRID').Value;
FieldByName('FZSPID').Value:=frmSXCKKCSelList.CDS_Main.fieldbyname('SPID').Value;
FieldByName('Price').Value:=frmSXCKKCSelList.CDS_Main.fieldbyname('Price').Value;
end;
end;
end;
finally
frmSXCKKCSelList.Free;
end;
end;
function TfrmSXCKTHPut.SaveCKData():Boolean;
var
FCRID,Maxno:string;
begin
try
ADOQueryCmd.Connection.BeginTrans;
CDS_Sub.DisableControls;
with CDS_Sub do
begin
First;
while not eof do
begin
if Trim(CDS_Sub.fieldbyname('SPID').AsString)='' then
begin
if GetLSNo(ADOQueryCmd,Maxno,'ST','CK_SXPB_CR',3,1)=False then
begin
Result:=False;
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox('ȡɴ<C8A1><C9B4><EFBFBD>˻<EFBFBD><CBBB><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>!','<27><>ʾ',0);
Exit;
end;
end else
begin
Maxno:=Trim(CDS_Sub.fieldbyname('SPID').AsString);
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('select * from CK_SXPB_CR where SPID='''+Trim(Maxno)+'''');
Open;
end;
with ADOQueryCmd do
begin
if Trim(CDS_Sub.fieldbyname('SPID').AsString)='' then
begin
Append;
end else
begin
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add('select * from CK_SXPB_CR where SPID='''+Trim(CDS_Sub.fieldbyname('SPID').AsString)+'''');
Open;
end;
if ADOQueryTemp.IsEmpty=False then Edit else Append;
end;
FieldByName('SPID').Value:=Trim(Maxno);
FieldByName('CGMainId').Value:=Trim(CDS_Sub.fieldbyname('CGMainId').AsString);
FieldByName('CGSubId').Value:=Trim(CDS_Sub.fieldbyname('CGSubId').AsString);
FieldByName('FZSPID').Value:=Trim(CDS_Sub.fieldbyname('FZSPID').AsString);
FieldByName('FactoryNo').Value:=Trim(CDS_Sub.fieldbyname('FactoryNo').AsString);
FieldByName('Price').Value:=CDS_Sub.fieldbyname('Price').Value;
FieldByName('CRID').Value:=CDS_Sub.fieldbyname('CRID').Value;
FieldByName('CRFlag').Value:='<27><><EFBFBD><EFBFBD>';
FieldByName('CRQtyFlag').Value:=-1;
FieldByName('CRType').Value:='<27>˻<EFBFBD>';
FieldByName('CKName').Value:=<><C9B4>';
RTSetSaveDataCDS(ADOQueryCmd,Tv1,CDS_Sub,'CK_SXPB_CR',2);
if Trim(CDS_Sub.fieldbyname('SPID').AsString)='' then
FieldByName('Filler').Value:=Trim(DName)
else
begin
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add('select * from CK_SXPB_CR where SPID='''+Trim(CDS_Sub.fieldbyname('SPID').AsString)+'''');
Open;
end;
if ADOQueryTemp.IsEmpty=False then
begin
FieldByName('Editer').Value:=Trim(DName);
FieldByName('EditTime').Value:=SGetServerDate(ADOQueryTemp);
end else
begin
FieldByName('Filler').Value:=Trim(DName);
end;
end;
Post;
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('Update CK_SXPB_KC Set KCKGQty=(select sum(KGQty*CRQtyFlag) from CK_SXPB_CR A where A.CRID=CK_SXPB_KC.CRID)');
sql.Add(',KCPiQty=(select sum(isnull(PiQty,0)*CRQtyFlag) from CK_SXPB_CR A where A.CRID=CK_SXPB_KC.CRID)');
sql.Add(' where CRID='+CDS_Sub.fieldbyname('CRID').AsString);
ExecSQL;
end;
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add('select * from CK_SXPB_KC where CRID='+Trim(CDS_Sub.fieldbyname('CRID').AsString));
Open;
end;
if ADOQueryTemp.FieldByName('KCKGQty').Value<0 then
begin
CDS_Sub.DisableControls;
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox('<27>˻<EFBFBD><CBBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڿ<EFBFBD><DABF><EFBFBD><E6B9AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܱ<EFBFBD><DCB1><EFBFBD>!','<27><>ʾ',0);
Exit;
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('Update CK_SXPB_CR Set MXKCKgQty=(select sum(isnull(KGQty,0)*CRQtyFlag) from CK_SXPB_CR A where A.FZSPID=CK_SXPB_CR.SPID)');
sql.Add(',MXKCPiQty=(select sum(isnull(PiQty,0)*CRQtyFlag) from CK_SXPB_CR A where A.FZSPID=CK_SXPB_CR.SPID)');
sql.Add(' where SPID='''+Trim(CDS_Sub.fieldbyname('FZSPID').AsString)+'''');
ExecSQL;
end;
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add('select * from CK_SXPB_CR where SPID='''+Trim(CDS_Sub.fieldbyname('FZSPID').AsString)+'''');
Open;
end;
if ADOQueryTemp.FieldByName('MXKCKGQty').Value<0 then
begin
CDS_Sub.DisableControls;
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox('<27>˻<EFBFBD><CBBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڿ<EFBFBD><DABF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܱ<EFBFBD><DCB1><EFBFBD>!','<27><>ʾ',0);
Exit;
end;
Edit;
FieldByName('SPID').Value:=Trim(Maxno);
Post;
Next;
end;
end;
CDS_Sub.EnableControls;
ADOQueryCmd.Connection.CommitTrans;
Result:=True;
except
Result:=False;
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>쳣!','<27><>ʾ',0);
end;
end;
procedure TfrmSXCKTHPut.TBCloseClick(Sender: TObject);
begin
WriteCxGrid(<><C9B4><EFBFBD>˻<EFBFBD><CBBB>Ǽ<EFBFBD>',Tv1,<>ֿ߲<DFB2>');
Close;
end;
procedure TfrmSXCKTHPut.FormShow(Sender: TObject);
begin
ReadCxGrid(<><C9B4><EFBFBD>˻<EFBFBD><CBBB>Ǽ<EFBFBD>',Tv1,<>ֿ߲<DFB2>');
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add(' select A.* ');
//sql.Add(' ,ConNo=(select ConNo from Contract_Main CM where CM.MainId=A.CGMainId )');
sql.Add(' from CK_SXPB_CR A');
sql.Add(' where SPID='''+Trim(FBCId)+'''');
Open;
end;
SCreateCDS20(ADOQueryTemp,CDS_Sub);
SInitCDSData20(ADOQueryTemp,CDS_Sub);
end;
procedure TfrmSXCKTHPut.TBDelClick(Sender: TObject);
begin
if CDS_Sub.IsEmpty then Exit;
if Trim(CDS_Sub.fieldbyname('SPID').AsString)<>'' then
begin
if Application.MessageBox(<><C8B7>Ҫɾ<D2AA><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>','<27><>ʾ',32+4)<>IDYES then Exit;
try
ADOQueryCmd.Connection.BeginTrans;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add(' delete CK_SXPB_CR where SPID='''+Trim(CDS_Sub.fieldbyname('SPID').AsString)+'''');
sql.Add('Update CK_SXPB_CR Set MXKCKgQty=(select sum(isnull(KGQty,0)*CRQtyFlag) from CK_SXPB_CR A where A.FZSPID=CK_SXPB_CR.SPID)');
sql.Add(',MXKCPiQty=(select sum(isnull(PiQty,0)*CRQtyFlag) from CK_SXPB_CR A where A.FZSPID=CK_SXPB_CR.SPID)');
sql.Add(' where SPID='''+Trim(CDS_Sub.fieldbyname('FZSPID').AsString)+'''');
sql.Add('Update CK_SXPB_KC Set KCKGQty=(select sum(KGQty*CRQtyFlag) from CK_SXPB_CR A where A.CRID=CK_SXPB_KC.CRID)');
sql.Add(',KCPiQty=(select sum(PiQty*CRQtyFlag) from CK_SXPB_CR A where A.CRID=CK_SXPB_KC.CRID)');
sql.Add(' where CRID='+Trim(CDS_Sub.fieldbyname('CRID').AsString));
ExecSQL;
end;
ADOQueryCmd.Connection.CommitTrans;
except
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox(<><C9BE><EFBFBD>쳣!','<27><>ʾ',0);
end;
end;
CDS_Sub.Delete;
end;
procedure TfrmSXCKTHPut.TBSaveClick(Sender: TObject);
begin
if CDS_Sub.IsEmpty then Exit;
if CDS_Sub.Locate('CRTime',null,[])=True then
begin
Application.MessageBox('<27><><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><E4B2BB>Ϊ<EFBFBD><CEAA>!','<27><>ʾ',0);
Exit;
end;
if CDS_Sub.Locate('KGQty',null,[])=True then
begin
Application.MessageBox('<27><><EFBFBD>ز<EFBFBD><D8B2><EFBFBD>Ϊ<EFBFBD><CEAA>!','<27><>ʾ',0);
Exit;
end;
if SaveCKData() then
begin
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>!','<27><>ʾ',0);
//ModalResult:=1;
Exit;
end;
end;
procedure TfrmSXCKTHPut.v1Column1PropertiesButtonClick(Sender: TObject;
AButtonIndex: Integer);
begin
try
frmClothContractListHZCX:=TfrmClothContractListHZCX.Create(Application);
with frmClothContractListHZCX do
begin
if ShowModal=1 then
begin
with Self.CDS_Sub do
begin
Edit;
FieldByName('CGConNo').Value:=Trim(frmClothContractListHZCX.Order_Main.fieldbyname('ConNo').AsString);
FieldByName('CGConMainId').Value:=Trim(frmClothContractListHZCX.Order_Main.fieldbyname('MainId').AsString);
FieldByName('CGConSubId').Value:=Trim(frmClothContractListHZCX.Order_Main.fieldbyname('SubId').AsString);
FieldByName('FactoryName').Value:=Trim(frmClothContractListHZCX.Order_Main.fieldbyname('FactoryNoName').AsString);
FieldByName('SXName').Value:=Trim(frmClothContractListHZCX.Order_Main.fieldbyname('C_CodeName').AsString);
//Post;
end;
end;
end;
finally
frmClothContractListHZCX.Free;
end;
end;
end.