701 lines
24 KiB
ObjectPascal
701 lines
24 KiB
ObjectPascal
|
|
unit U_JGSXCKOutPut;
|
|||
|
|
|
|||
|
|
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
|
|||
|
|
TfrmJGSXCKOutPut = 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;
|
|||
|
|
v1CRType: TcxGridDBColumn;
|
|||
|
|
v1Column13: TcxGridDBColumn;
|
|||
|
|
v1Column14: TcxGridDBColumn;
|
|||
|
|
v2Column1: TcxGridDBColumn;
|
|||
|
|
v1Column8: TcxGridDBColumn;
|
|||
|
|
v1Column11: TcxGridDBColumn;
|
|||
|
|
v1Column9: TcxGridDBColumn;
|
|||
|
|
v2Column6: TcxGridDBColumn;
|
|||
|
|
v1Column3: TcxGridDBColumn;
|
|||
|
|
v1Note: TcxGridDBColumn;
|
|||
|
|
cxGrid2Level1: TcxGridLevel;
|
|||
|
|
v1Column5: TcxGridDBColumn;
|
|||
|
|
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);
|
|||
|
|
procedure v1Column11PropertiesButtonClick(Sender: TObject;
|
|||
|
|
AButtonIndex: Integer);
|
|||
|
|
procedure v1Column5PropertiesButtonClick(Sender: TObject;
|
|||
|
|
AButtonIndex: Integer);
|
|||
|
|
procedure Tv1MouseDown(Sender: TObject; Button: TMouseButton;
|
|||
|
|
Shift: TShiftState; X, Y: Integer);
|
|||
|
|
private
|
|||
|
|
{ Private declarations }
|
|||
|
|
function SaveCKData():Boolean;
|
|||
|
|
function YFData():Boolean;
|
|||
|
|
public
|
|||
|
|
{ Public declarations }
|
|||
|
|
FBCId:String;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
var
|
|||
|
|
frmJGSXCKOutPut: TfrmJGSXCKOutPut;
|
|||
|
|
|
|||
|
|
implementation
|
|||
|
|
uses
|
|||
|
|
U_DataLink,U_RTFun,U_ClothContractListHZCX,U_ZDYHelp,U_SXCKKCSelList,
|
|||
|
|
U_GYSSelList, U_ZdyAttachGYS, U_ProductOrderListSel, U_JGSXCKKCSelList;
|
|||
|
|
|
|||
|
|
{$R *.dfm}
|
|||
|
|
|
|||
|
|
function TfrmJGSXCKOutPut.YFData():Boolean;
|
|||
|
|
var
|
|||
|
|
CRID,YFID,Price,PriceUnit,OrderUnit,FComTaiTou:String;
|
|||
|
|
begin
|
|||
|
|
Result:=False;
|
|||
|
|
with ADOQueryTemp do
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
sql.Clear;
|
|||
|
|
sql.Add('select ComTaiTou from Cloth_Main where Mainid='''+Trim(CDS_Sub.fieldbyname('SCMainIdCK').AsString)+'''');
|
|||
|
|
Open;
|
|||
|
|
end;
|
|||
|
|
FComTaiTou:=Trim(ADOQueryTemp.fieldbyname('ComTaiTou').AsString);
|
|||
|
|
with ADOQueryTemp do
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
SQL.Clear;
|
|||
|
|
sql.Add('select * from YF_Money_KC where FactoryName='''+Trim(CDS_Sub.fieldbyname('ToFactoryName').AsString)+'''');
|
|||
|
|
Open;
|
|||
|
|
end;
|
|||
|
|
if ADOQueryTemp.IsEmpty=False then
|
|||
|
|
begin
|
|||
|
|
CRID:=ADOQueryTemp.fieldbyname('CRID').AsString;
|
|||
|
|
end else
|
|||
|
|
begin
|
|||
|
|
with ADOQueryCmd do
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
sql.Clear;
|
|||
|
|
sql.Add('Update YF_Money_CRID set CRID=CRID+1');
|
|||
|
|
sql.Add('select * from YF_Money_CRID ');
|
|||
|
|
Open;
|
|||
|
|
end;
|
|||
|
|
CRID:=ADOQueryCmd.fieldbyname('CRID').AsString;
|
|||
|
|
with ADOQueryCmd do
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
SQL.Clear;
|
|||
|
|
sql.Add('select * from YF_Money_KC where 1<>1');
|
|||
|
|
Open;
|
|||
|
|
end;
|
|||
|
|
with ADOQueryCmd do
|
|||
|
|
begin
|
|||
|
|
Append;
|
|||
|
|
FieldByName('CRID').Value:=StrToInt(CRID);
|
|||
|
|
FieldByName('FactoryName').Value:=Trim(CDS_Sub.fieldbyname('ToFactoryName').AsString);
|
|||
|
|
FieldByName('ZdyStr1').Value:='Ӧ<><D3A6><EFBFBD><EFBFBD>';
|
|||
|
|
Post;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
with ADOQueryTemp do
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
sql.Clear;
|
|||
|
|
sql.Add('select * from YF_Money_CR where FactoryName='''+Trim(CDS_Sub.fieldbyname('ToFactoryName').AsString)+'''');
|
|||
|
|
sql.Add(' and YFTypeId='''+Trim(CDS_Sub.fieldbyname('SPID').AsString)+'''');
|
|||
|
|
Open;
|
|||
|
|
end;
|
|||
|
|
if ADOQueryTemp.IsEmpty then
|
|||
|
|
begin
|
|||
|
|
if GetLSNo(ADOQueryCmd,YFID,'CS','YF_Money_CR',3,1)=False then
|
|||
|
|
begin
|
|||
|
|
Application.MessageBox('ȡ<><C8A1>ƷӦ<C6B7><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>!','<27><>ʾ',0);
|
|||
|
|
Exit;
|
|||
|
|
end;
|
|||
|
|
with ADOQueryCmd do
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
sql.Clear;
|
|||
|
|
sql.Add('select * from YF_Money_CR where 1<>1');
|
|||
|
|
Open;
|
|||
|
|
end;
|
|||
|
|
with ADOQueryCmd do
|
|||
|
|
begin
|
|||
|
|
Append;
|
|||
|
|
FieldByName('YFID').Value:=Trim(YFID);
|
|||
|
|
FieldByName('YFTypeId').Value:=Trim(CDS_Sub.fieldbyname('SPID').AsString);
|
|||
|
|
FieldByName('CRID').Value:=StrToInt(CRID);
|
|||
|
|
FieldByName('Filler').Value:=Trim(DName);
|
|||
|
|
FieldByName('status').Value:='0';
|
|||
|
|
FieldByName('CRType').Value:='Ӧ<>տ<EFBFBD><D5BF>Ǽ<EFBFBD>';
|
|||
|
|
FieldByName('CRFlag').Value:='Ӧ<><D3A6><EFBFBD><EFBFBD>';
|
|||
|
|
FieldByName('QtyFlag').Value:=1;
|
|||
|
|
FieldByName('FactoryName').Value:=Trim(CDS_Sub.fieldbyname('ToFactoryName').AsString);
|
|||
|
|
FieldByName('CRTime').Value:=Trim(FormatDateTime('yyyy-MM-dd',now));
|
|||
|
|
FieldByName('YFType').Value:='<27>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>';
|
|||
|
|
FieldByName('Huilv').Value:=1;
|
|||
|
|
FieldByName('BZType').Value:='<27><>';
|
|||
|
|
FieldByName('QtyUnit').Value:=Trim(CDS_Sub.FieldByName('QtyUnit').asstring);
|
|||
|
|
FieldByName('ComTaiTou').Value:=Trim(FComTaiTou);
|
|||
|
|
FieldByName('YFName').Value:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>۽<EFBFBD><DBBD><EFBFBD>';
|
|||
|
|
FieldByName('MainId').Value:=Trim(CDS_Sub.fieldbyname('SCMainidCK').AsString);
|
|||
|
|
Post;
|
|||
|
|
end;
|
|||
|
|
end else
|
|||
|
|
begin
|
|||
|
|
YFID:=Trim(ADOQueryTemp.fieldbyname('YFID').AsString);
|
|||
|
|
end;
|
|||
|
|
with ADOQueryCmd do
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
sql.Clear;
|
|||
|
|
sql.Add('update YF_Money_CR Set Qty=(select isnull(Sum(Qty),0) from CK_SXPB_CR ');
|
|||
|
|
sql.Add(' where SPID=YF_Money_CR.YFTypeId)');
|
|||
|
|
sql.Add(' where YFTypeId='''+Trim(CDS_Sub.fieldbyname('SPID').AsString)+'''');
|
|||
|
|
ExecSQL;
|
|||
|
|
end;
|
|||
|
|
with ADOQueryTemp do
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
sql.Clear;
|
|||
|
|
sql.Add('select * from YF_Money_CR where YFId='''+Trim(YFID)+'''');
|
|||
|
|
Open;
|
|||
|
|
end;
|
|||
|
|
if ADOQueryTemp.FieldByName('Qty').Value=0 then
|
|||
|
|
begin
|
|||
|
|
with ADOQueryCmd do
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
sql.Clear;
|
|||
|
|
sql.Add('delete from YF_Money_CR where YFID='''+Trim(YFID)+'''');
|
|||
|
|
ExecSQL;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
with ADOQueryTemp do
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
sql.Clear;
|
|||
|
|
sql.Add('select * from YF_Money_CR where CRId='+CRID);
|
|||
|
|
Open;
|
|||
|
|
end;
|
|||
|
|
if ADOQueryTemp.IsEmpty then
|
|||
|
|
begin
|
|||
|
|
with ADOQueryCmd do
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
sql.Clear;
|
|||
|
|
sql.Add('delete from YF_Money_KC where CRId='+CRID);
|
|||
|
|
ExecSQL;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
Result:=True;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmJGSXCKOutPut.FormClose(Sender: TObject;
|
|||
|
|
var Action: TCloseAction);
|
|||
|
|
begin
|
|||
|
|
Action:=caFree;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmJGSXCKOutPut.TBAddClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
try
|
|||
|
|
frmJGSXCKKCSelList:=TfrmJGSXCKKCSelList.Create(Application);
|
|||
|
|
with frmJGSXCKKCSelList do
|
|||
|
|
begin
|
|||
|
|
ToolButton1.Visible:=True;
|
|||
|
|
if ShowModal=1 then
|
|||
|
|
begin
|
|||
|
|
CDS_Main.DisableControls;
|
|||
|
|
with CDS_Main do
|
|||
|
|
begin
|
|||
|
|
First;
|
|||
|
|
while not eof do
|
|||
|
|
begin
|
|||
|
|
if CDS_Main.FieldByName('Ssel').AsBoolean=true then
|
|||
|
|
begin
|
|||
|
|
with Self.CDS_Sub do
|
|||
|
|
begin
|
|||
|
|
Append;
|
|||
|
|
FieldByName('CRTime').Value:=SGetServerDate10(ADOQueryTemp);
|
|||
|
|
FieldByName('ORDMainIdRK').Value:=Trim(frmJGSXCKKCSelList.CDS_Main.fieldbyname('ORDMainIdRK').AsString);
|
|||
|
|
FieldByName('ORDSubIdRK').Value:=Trim(frmJGSXCKKCSelList.CDS_Main.fieldbyname('ORDSubIdRK').AsString);
|
|||
|
|
FieldByName('SCMainIdRK').Value:=Trim(frmJGSXCKKCSelList.CDS_Main.fieldbyname('SCMainIdRK').AsString);
|
|||
|
|
FieldByName('SCSubIdRK').Value:=Trim(frmJGSXCKKCSelList.CDS_Main.fieldbyname('SCSubIdRK').AsString);
|
|||
|
|
FieldByName('QCOrderNo').Value:=frmJGSXCKKCSelList.CDS_Main.fieldbyname('OrderNo').Value;
|
|||
|
|
FieldByName('FactoryName').Value:=frmJGSXCKKCSelList.CDS_Main.fieldbyname('FactoryName').Value;
|
|||
|
|
FieldByName('FactoryNo').Value:=frmJGSXCKKCSelList.CDS_Main.fieldbyname('FactoryNo').Value;
|
|||
|
|
FieldByName('SPName').Value:=frmJGSXCKKCSelList.CDS_Main.fieldbyname('SPName').Value;
|
|||
|
|
FieldByName('SPCode').Value:=frmJGSXCKKCSelList.CDS_Main.fieldbyname('SPCode').Value;
|
|||
|
|
FieldByName('SPSpec').Value:=frmJGSXCKKCSelList.CDS_Main.fieldbyname('SPSpec').Value;
|
|||
|
|
FieldByName('SPCF').Value:=frmJGSXCKKCSelList.CDS_Main.fieldbyname('SPCF').Value;
|
|||
|
|
FieldByName('SPMF').Value:=frmJGSXCKKCSelList.CDS_Main.fieldbyname('SPMF').Value;
|
|||
|
|
FieldByName('SPKZ').Value:=frmJGSXCKKCSelList.CDS_Main.fieldbyname('SPKZ').Value;
|
|||
|
|
FieldByName('FromFactoryName').Value:=frmJGSXCKKCSelList.CDS_Main.fieldbyname('ToFactoryName').Value;
|
|||
|
|
FieldByName('FromFactoryNo').Value:=frmJGSXCKKCSelList.CDS_Main.fieldbyname('ToFactoryNo').Value;
|
|||
|
|
//FieldByName('ToFactoryName').Value:=frmJGSXCKKCSelList.CDS_Main.fieldbyname('ToFactoryName').Value;
|
|||
|
|
//FieldByName('ToFactoryNo').Value:=frmJGSXCKKCSelList.CDS_Main.fieldbyname('ToFactoryNo').Value;
|
|||
|
|
FieldByName('QtyUnit').Value:=frmJGSXCKKCSelList.CDS_Main.fieldbyname('QtyUnit').Value;
|
|||
|
|
FieldByName('PiQty').Value:=frmJGSXCKKCSelList.CDS_Main.fieldbyname('MXKCPiQty').Value;
|
|||
|
|
FieldByName('Qty').Value:=frmJGSXCKKCSelList.CDS_Main.fieldbyname('MXKCQty').Value;
|
|||
|
|
FieldByName('FZSPID').Value:=frmJGSXCKKCSelList.CDS_Main.fieldbyname('SPID').Value;
|
|||
|
|
post;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
next;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
frmJGSXCKKCSelList.CDS_Main.EnableControls;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
finally
|
|||
|
|
frmJGSXCKKCSelList.Free;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TfrmJGSXCKOutPut.SaveCKData():Boolean;
|
|||
|
|
var
|
|||
|
|
FCRID,Maxno,FSPID,MaxPYNo,FPYID:string;
|
|||
|
|
begin
|
|||
|
|
try
|
|||
|
|
ADOQueryCmd.Connection.BeginTrans;
|
|||
|
|
CDS_Sub.DisableControls;
|
|||
|
|
with CDS_Sub do
|
|||
|
|
begin
|
|||
|
|
First;
|
|||
|
|
while not eof do
|
|||
|
|
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;
|
|||
|
|
FSPID:=Trim(ADOQueryTemp.fieldbyname('SPID').AsString);
|
|||
|
|
if Trim(FSPID)='' then
|
|||
|
|
begin
|
|||
|
|
if GetLSNo(ADOQueryCmd,Maxno,'PC','CK_SXPB_CR',3,1)=False then
|
|||
|
|
begin
|
|||
|
|
Result:=False;
|
|||
|
|
ADOQueryCmd.Connection.RollbackTrans;
|
|||
|
|
Application.MessageBox('ȡ<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>!','<27><>ʾ',0);
|
|||
|
|
Exit;
|
|||
|
|
end;
|
|||
|
|
end else
|
|||
|
|
begin
|
|||
|
|
Maxno:=Trim(FSPID);
|
|||
|
|
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(FSPID)='' then
|
|||
|
|
begin
|
|||
|
|
Append;
|
|||
|
|
end else
|
|||
|
|
begin
|
|||
|
|
Edit;
|
|||
|
|
end;
|
|||
|
|
FieldByName('SPID').Value:=Trim(Maxno);
|
|||
|
|
FieldByName('OrdMainIdRK').Value:=Trim(CDS_Sub.fieldbyname('OrdMainIdRK').AsString);
|
|||
|
|
FieldByName('OrdSubidRK').Value:=Trim(CDS_Sub.fieldbyname('OrdSubidRK').AsString);
|
|||
|
|
FieldByName('ORDMainIdCK').Value:=Trim(CDS_Sub.fieldbyname('ORDMainIdCK').AsString);
|
|||
|
|
FieldByName('ORDSubIdCK').Value:=Trim(CDS_Sub.fieldbyname('ORDSubIdCK').AsString);
|
|||
|
|
FieldByName('FZSPID').Value:=Trim(CDS_Sub.fieldbyname('FZSPID').AsString);
|
|||
|
|
FieldByName('FactoryNo').Value:=Trim(CDS_Sub.fieldbyname('FactoryNo').AsString);
|
|||
|
|
FieldByName('FromFactoryNo').Value:=Trim(CDS_Sub.fieldbyname('FromFactoryNo').AsString);
|
|||
|
|
FieldByName('ToFactoryNo').Value:=Trim(CDS_Sub.fieldbyname('ToFactoryNo').AsString);
|
|||
|
|
FieldByName('CPID').Value:=Trim(CDS_Sub.fieldbyname('CPID').AsString);
|
|||
|
|
FieldByName('CRFlag').Value:='<27><><EFBFBD><EFBFBD>';
|
|||
|
|
FieldByName('CRQtyFlag').Value:=-1;
|
|||
|
|
RTSetSaveDataCDS(ADOQueryCmd,Tv1,CDS_Sub,'CK_SXPB_CR',2);
|
|||
|
|
FieldByName('CKName').Value:='<27><><EFBFBD><EFBFBD>';
|
|||
|
|
if Trim(CDS_Sub.fieldbyname('CRType').AsString)='ƽ<>Ƴ<EFBFBD><C6B3><EFBFBD>' then
|
|||
|
|
begin
|
|||
|
|
FieldByName('PYID').Value:=Trim(Maxno);
|
|||
|
|
end;
|
|||
|
|
if Trim(FSPID)='' then
|
|||
|
|
FieldByName('Filler').Value:=Trim(DName)
|
|||
|
|
else
|
|||
|
|
begin
|
|||
|
|
FieldByName('Editer').Value:=Trim(DName);
|
|||
|
|
FieldByName('EditTime').Value:=SGetServerDate(ADOQueryTemp);
|
|||
|
|
end;
|
|||
|
|
Post;
|
|||
|
|
end;
|
|||
|
|
with ADOQueryCmd do
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
sql.Clear;
|
|||
|
|
sql.Add('Update CK_SXPB_CR Set MXKCQty=(select sum(isnull(Qty,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('MXKCQty').Value<0 then
|
|||
|
|
begin
|
|||
|
|
CDS_Sub.DisableControls;
|
|||
|
|
ADOQueryCmd.Connection.RollbackTrans;
|
|||
|
|
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڿ<EFBFBD><DABF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܱ<EFBFBD><DCB1><EFBFBD>!','<27><>ʾ',0);
|
|||
|
|
Exit;
|
|||
|
|
end;
|
|||
|
|
if Trim(CDS_Sub.fieldbyname('CRType').AsString)='ƽ<>Ƴ<EFBFBD><C6B3><EFBFBD>' then
|
|||
|
|
begin
|
|||
|
|
with ADOQueryTemp do
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
sql.Clear;
|
|||
|
|
sql.Add('select * from CK_SXPB_CR where PYID='''+Trim(Maxno)+'''');
|
|||
|
|
sql.Add(' and isnull(CRType,'''')=''ƽ<><C6BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'' ');
|
|||
|
|
Open;
|
|||
|
|
end;
|
|||
|
|
FPYID:=Trim(ADOQueryTemp.fieldbyname('SPID').AsString);
|
|||
|
|
if Trim(FPYID)='' then
|
|||
|
|
begin
|
|||
|
|
if GetLSNo(ADOQueryCmd,MaxPYNo,'YR','CK_SXPB_CR',3,1)=False then
|
|||
|
|
begin
|
|||
|
|
Result:=False;
|
|||
|
|
ADOQueryCmd.Connection.RollbackTrans;
|
|||
|
|
Application.MessageBox('ȡ<><C8A1><EFBFBD><EFBFBD>ƽ<EFBFBD><C6BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>!','<27><>ʾ',0);
|
|||
|
|
Exit;
|
|||
|
|
end;
|
|||
|
|
end else
|
|||
|
|
begin
|
|||
|
|
MaxPYNo:=Trim(FPYID);
|
|||
|
|
end;
|
|||
|
|
with ADOQueryCmd do
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
sql.Clear;
|
|||
|
|
sql.Add('select * from CK_SXPB_CR where SPID='''+Trim(MaxPYNo)+'''');
|
|||
|
|
Open;
|
|||
|
|
end;
|
|||
|
|
with ADOQueryCmd do
|
|||
|
|
begin
|
|||
|
|
if Trim(FPYID)='' then
|
|||
|
|
begin
|
|||
|
|
Append;
|
|||
|
|
end else
|
|||
|
|
begin
|
|||
|
|
Edit;
|
|||
|
|
end;
|
|||
|
|
FieldByName('SPID').Value:=Trim(MaxPYNo);
|
|||
|
|
FieldByName('ORDMainIdRK').Value:=Trim(CDS_Sub.fieldbyname('ORDMainIdCK').AsString);
|
|||
|
|
FieldByName('ORDSubIdRK').Value:=Trim(CDS_Sub.fieldbyname('ORDSubIdCK').AsString);
|
|||
|
|
{FieldByName('ORDMainIdCK').Value:=Trim(CDS_Sub.fieldbyname('ORDMainIdCK').AsString);
|
|||
|
|
FieldByName('ORDSubIdCK').Value:=Trim(CDS_Sub.fieldbyname('ORDSubIdCK').AsString);}
|
|||
|
|
FieldByName('FZSPID').Value:=Trim(MaxPYNo);
|
|||
|
|
FieldByName('FactoryNo').Value:=Trim(CDS_Sub.fieldbyname('FactoryNo').AsString);
|
|||
|
|
FieldByName('FromFactoryNo').Value:=Trim(CDS_Sub.fieldbyname('FromFactoryNo').AsString);
|
|||
|
|
FieldByName('ToFactoryNo').Value:=Trim(CDS_Sub.fieldbyname('ToFactoryNo').AsString);
|
|||
|
|
//FieldByName('CRID').Value:=CDS_Sub.fieldbyname('CRID').Value;
|
|||
|
|
FieldByName('CRFlag').Value:='<27><><EFBFBD><EFBFBD>';
|
|||
|
|
FieldByName('CRQtyFlag').Value:=1;
|
|||
|
|
RTSetSaveDataCDS(ADOQueryCmd,Tv1,CDS_Sub,'CK_SXPB_CR',2);
|
|||
|
|
FieldByName('CKName').Value:='<27><><EFBFBD><EFBFBD>';
|
|||
|
|
FieldByName('CRType').Value:='ƽ<><C6BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
|
|||
|
|
FieldByName('PYID').Value:=Trim(Maxno);
|
|||
|
|
if Trim(FPYID)='' then
|
|||
|
|
FieldByName('Filler').Value:=Trim(DName)
|
|||
|
|
else
|
|||
|
|
begin
|
|||
|
|
FieldByName('Editer').Value:=Trim(DName);
|
|||
|
|
FieldByName('EditTime').Value:=SGetServerDate(ADOQueryTemp);
|
|||
|
|
end;
|
|||
|
|
Post;
|
|||
|
|
end;
|
|||
|
|
with ADOQueryCmd do
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
sql.Clear;
|
|||
|
|
sql.Add('Update CK_SXPB_CR Set MXKCQty=(select sum(isnull(Qty,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(MaxPYNo)+'''');
|
|||
|
|
ExecSQL;
|
|||
|
|
end;
|
|||
|
|
with ADOQueryTemp do
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
sql.Clear;
|
|||
|
|
sql.Add('select * from CK_SXPB_CR where SPID='''+Trim(MaxPYNo)+'''');
|
|||
|
|
Open;
|
|||
|
|
end;
|
|||
|
|
if ADOQueryTemp.FieldByName('MXKCQty').Value<0 then
|
|||
|
|
begin
|
|||
|
|
CDS_Sub.DisableControls;
|
|||
|
|
ADOQueryCmd.Connection.RollbackTrans;
|
|||
|
|
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڿ<EFBFBD><DABF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܱ<EFBFBD><DCB1><EFBFBD>!','<27><>ʾ',0);
|
|||
|
|
Exit;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
Edit;
|
|||
|
|
FieldByName('SPID').Value:=Trim(Maxno);
|
|||
|
|
Post;
|
|||
|
|
{if Trim(CDS_Sub.fieldbyname('CRType').AsString)='<27><><EFBFBD>۳<EFBFBD><DBB3><EFBFBD>' then
|
|||
|
|
begin
|
|||
|
|
YFData();
|
|||
|
|
end;}
|
|||
|
|
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 TfrmJGSXCKOutPut.TBCloseClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
WriteCxGrid('<27><><EFBFBD>ϳ<EFBFBD><CFB3><EFBFBD><EFBFBD>Ǽ<EFBFBD>PMD',Tv1,'<27><><EFBFBD>ϲֿ<CFB2>');
|
|||
|
|
Close;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmJGSXCKOutPut.FormShow(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
ReadCxGrid('<27><><EFBFBD>ϳ<EFBFBD><CFB3><EFBFBD><EFBFBD>Ǽ<EFBFBD>PMD',Tv1,'<27><><EFBFBD>ϲֿ<CFB2>');
|
|||
|
|
with ADOQueryTemp do
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
sql.Clear;
|
|||
|
|
sql.Add(' select A.* ');
|
|||
|
|
sql.Add(' ,OrderNo=(select OrderNo from JYOrder_Main JM where JM.MainId=A.OrdMainIdRK )');
|
|||
|
|
sql.Add(' ,OrderNoCK=(select OrderNo from JYOrder_Main JM where JM.MainId=A.OrdMainIdCK )');
|
|||
|
|
sql.Add(' ,PRTColorNo=(select PRTColorNo from JYOrder_Sub JM where JM.SubId=A.OrdSubIdCK )');
|
|||
|
|
sql.Add(' ,PRTColor=(select PRTColor from JYOrder_Sub JM where JM.SubId=A.OrdSubIdCK )');
|
|||
|
|
sql.Add(' ,PRTHX=(select PRTHX from JYOrder_Sub JM where JM.SubId=A.OrdSubIdCK )');
|
|||
|
|
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 TfrmJGSXCKOutPut.TBDelClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
if CDS_Sub.IsEmpty then Exit;
|
|||
|
|
if Trim(CDS_Sub.fieldbyname('SPID').AsString)<>'' then
|
|||
|
|
begin
|
|||
|
|
with ADOQueryTemp do
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
sql.Clear;
|
|||
|
|
sql.Add('select * from CK_SXPB_CR where FZSPID=');
|
|||
|
|
sql.Add('(select SPID from CK_SXPB_CR where PYID='''+Trim(CDS_Sub.fieldbyname('SPID').AsString)+'''');
|
|||
|
|
sql.Add(' and isnull(CRType,'''')=''ƽ<><C6BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'')');
|
|||
|
|
sql.Add(' and CRQtyFlag=-1');
|
|||
|
|
Open;
|
|||
|
|
end;
|
|||
|
|
if ADOQueryTemp.IsEmpty=False then
|
|||
|
|
begin
|
|||
|
|
Application.MessageBox('<27><><EFBFBD>г<EFBFBD><D0B3><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE>!','<27><>ʾ',0);
|
|||
|
|
Exit;
|
|||
|
|
end;
|
|||
|
|
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(',MXKCQty=(select sum(isnull(Qty,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;
|
|||
|
|
ADOQueryCmd.Connection.CommitTrans;
|
|||
|
|
except
|
|||
|
|
ADOQueryCmd.Connection.RollbackTrans;
|
|||
|
|
Application.MessageBox('ɾ<><C9BE><EFBFBD>쳣!','<27><>ʾ',0);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
end;
|
|||
|
|
CDS_Sub.Delete;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmJGSXCKOutPut.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('CRType',null,[])=True then
|
|||
|
|
begin
|
|||
|
|
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ͳ<EFBFBD><CDB2><EFBFBD>Ϊ<EFBFBD><CEAA>!','<27><>ʾ',0);
|
|||
|
|
Exit;
|
|||
|
|
end;
|
|||
|
|
{if CDS_Sub.Locate('ToFactoryName',null,[])=True then
|
|||
|
|
begin
|
|||
|
|
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ӹ<EFBFBD><D3B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>!','<27><>ʾ',0);
|
|||
|
|
Exit;
|
|||
|
|
end; }
|
|||
|
|
if CDS_Sub.Locate('Qty',null,[])=True then
|
|||
|
|
begin
|
|||
|
|
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>!','<27><>ʾ',0);
|
|||
|
|
Exit;
|
|||
|
|
end;
|
|||
|
|
if CDS_Sub.Locate('PiQty',null,[])=True then
|
|||
|
|
begin
|
|||
|
|
Application.MessageBox('ƥ<><C6A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>!','<27><>ʾ',0);
|
|||
|
|
Exit;
|
|||
|
|
end;
|
|||
|
|
if CDS_Sub.Locate('CRType;CKOrderNo',VarArrayOf(['<27>ӹ<EFBFBD><D3B9><EFBFBD><EFBFBD><EFBFBD>',Null]),[loPartialKey])=True then
|
|||
|
|
begin
|
|||
|
|
Application.MessageBox('<27>ӹ<EFBFBD><D3B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ų<EFBFBD><C5B2><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 TfrmJGSXCKOutPut.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;
|
|||
|
|
|
|||
|
|
procedure TfrmJGSXCKOutPut.v1Column11PropertiesButtonClick(Sender: TObject;
|
|||
|
|
AButtonIndex: Integer);
|
|||
|
|
begin
|
|||
|
|
try
|
|||
|
|
frmZdyAttachGYS:=TfrmZdyAttachGYS.Create(Application);
|
|||
|
|
with frmZdyAttachGYS do
|
|||
|
|
begin
|
|||
|
|
if ShowModal=1 then
|
|||
|
|
begin
|
|||
|
|
with Self.CDS_Sub do
|
|||
|
|
begin
|
|||
|
|
edit;
|
|||
|
|
FieldByName('ToFactoryNo').Value:=Trim(frmZdyAttachGYS.CDS_HZ.fieldbyname('ZdyCode').AsString) ;
|
|||
|
|
FieldByName('ToFactoryName').Value:=Trim(frmZdyAttachGYS.CDS_HZ.fieldbyname('ZdyName').AsString);
|
|||
|
|
//Post;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
finally
|
|||
|
|
frmZdyAttachGYS.Free;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmJGSXCKOutPut.v1Column5PropertiesButtonClick(Sender: TObject;
|
|||
|
|
AButtonIndex: Integer);
|
|||
|
|
begin
|
|||
|
|
try
|
|||
|
|
frmProductOrderListSel:=TfrmProductOrderListSel.Create(Application);
|
|||
|
|
with frmProductOrderListSel do
|
|||
|
|
begin
|
|||
|
|
if ShowModal=1 then
|
|||
|
|
begin
|
|||
|
|
with Self.CDS_Sub do
|
|||
|
|
begin
|
|||
|
|
Edit;
|
|||
|
|
FieldByName('ORDMainIdCK').Value:=Trim(frmProductOrderListSel.Order_Main.fieldbyname('MainId').AsString);
|
|||
|
|
FieldByName('ORDSubIdCK').Value:=Trim(frmProductOrderListSel.Order_Main.fieldbyname('SubId').AsString);
|
|||
|
|
FieldByName('CKorderNo').Value:=Trim(frmProductOrderListSel.Order_Main.fieldbyname('OrderNo').AsString);
|
|||
|
|
//if Self.CDS_Sub.fieldbyname('ToFactoryName').AsString='' then
|
|||
|
|
//FieldByName('ToFactoryName').Value:=Trim(frmProductOrderListSel.Order_Main.fieldbyname('CustomerNoName').AsString);
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
finally
|
|||
|
|
frmProductOrderListSel.Free;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmJGSXCKOutPut.Tv1MouseDown(Sender: TObject;
|
|||
|
|
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
|
|||
|
|
var
|
|||
|
|
FFSPID:String;
|
|||
|
|
begin
|
|||
|
|
if CDS_Sub.IsEmpty then Exit;
|
|||
|
|
if Trim(CDS_Sub.fieldbyname('SPID').AsString)<>'' then
|
|||
|
|
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;
|
|||
|
|
FFSPID:=Trim(ADOQueryTemp.fieldbyname('SPID').AsString);
|
|||
|
|
if Trim(FFSPID)<>'' then
|
|||
|
|
begin
|
|||
|
|
v1CRType.Options.Editing:=False;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
end.
|