1226 lines
44 KiB
ObjectPascal
1226 lines
44 KiB
ObjectPascal
unit U_ClothContractListLL;
|
||
|
||
interface
|
||
|
||
uses
|
||
Windows, Messages, strutils,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, cxDropDownEdit, cxCheckBox;
|
||
|
||
type
|
||
TfrmClothContractListLL = class(TForm)
|
||
ToolBar1: TToolBar;
|
||
TBRafresh: TToolButton;
|
||
TBFind: 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;
|
||
C_Spec: TEdit;
|
||
ToolButton2: TToolButton;
|
||
ToolButton3: TToolButton;
|
||
ToolButton4: TToolButton;
|
||
ClientDataSet3: TClientDataSet;
|
||
DataSource2: TDataSource;
|
||
DataSource3: TDataSource;
|
||
ClientDataSet2: TClientDataSet;
|
||
ToolButton5: TToolButton;
|
||
RM1: TRMGridReport;
|
||
RMDBMain: TRMDBDataSet;
|
||
RMXLSExport1: TRMXLSExport;
|
||
Panel2: TPanel;
|
||
cxGrid3: TcxGrid;
|
||
Tv3: TcxGridDBTableView;
|
||
v3Column6: TcxGridDBColumn;
|
||
v3Column3: TcxGridDBColumn;
|
||
v3Column2: TcxGridDBColumn;
|
||
v3Column4: TcxGridDBColumn;
|
||
v3Column5: TcxGridDBColumn;
|
||
v3Column7: TcxGridDBColumn;
|
||
v3Column8: TcxGridDBColumn;
|
||
cxGridLevel1: TcxGridLevel;
|
||
cxSplitter1: TcxSplitter;
|
||
cxGrid1: TcxGrid;
|
||
Tv1: TcxGridDBTableView;
|
||
v1OrderNo: TcxGridDBColumn;
|
||
v1Column2: TcxGridDBColumn;
|
||
v1FactoryNo1Name: TcxGridDBColumn;
|
||
v1PRTSpec: TcxGridDBColumn;
|
||
v1PRTMF: TcxGridDBColumn;
|
||
v1PRTKZ: TcxGridDBColumn;
|
||
v1OrderUnit: TcxGridDBColumn;
|
||
v1Column4: TcxGridDBColumn;
|
||
cxGrid1Level1: TcxGridLevel;
|
||
v1Column3: TcxGridDBColumn;
|
||
ToolBar2: TToolBar;
|
||
ToolButton8: TToolButton;
|
||
ToolButton9: TToolButton;
|
||
ToolButton11: TToolButton;
|
||
v1Column5: TcxGridDBColumn;
|
||
cxGridPopupMenu2: TcxGridPopupMenu;
|
||
Label6: TLabel;
|
||
FactoryNoName: TEdit;
|
||
Label7: TLabel;
|
||
FirstName: TEdit;
|
||
v3Column1: TcxGridDBColumn;
|
||
v3Column9: TcxGridDBColumn;
|
||
v1Column6: TcxGridDBColumn;
|
||
v1Column7: TcxGridDBColumn;
|
||
v1Column8: TcxGridDBColumn;
|
||
v3Column10: TcxGridDBColumn;
|
||
v3Column11: TcxGridDBColumn;
|
||
v3ToName: TcxGridDBColumn;
|
||
v3gangNO: TcxGridDBColumn;
|
||
v3Column12: TcxGridDBColumn;
|
||
v3Column13: TcxGridDBColumn;
|
||
v3JGType: TcxGridDBColumn;
|
||
procedure FormDestroy(Sender: TObject);
|
||
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
||
procedure TBCloseClick(Sender: TObject);
|
||
procedure TBFindClick(Sender: TObject);
|
||
procedure TBRafreshClick(Sender: TObject);
|
||
procedure ConNoChange(Sender: TObject);
|
||
procedure FormShow(Sender: TObject);
|
||
procedure ToolButton2Click(Sender: TObject);
|
||
procedure Tv2MouseDown(Sender: TObject; Button: TMouseButton;
|
||
Shift: TShiftState; X, Y: Integer);
|
||
procedure Tv2CellClick(Sender: TcxCustomGridTableView;
|
||
ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
|
||
AShift: TShiftState; var AHandled: Boolean);
|
||
procedure ToolButton5Click(Sender: TObject);
|
||
procedure ToolButton3Click(Sender: TObject);
|
||
procedure v2Column3PropertiesButtonClick(Sender: TObject;
|
||
AButtonIndex: Integer);
|
||
procedure v3Column2PropertiesEditValueChanged(Sender: TObject);
|
||
procedure j(Sender: TcxCustomGridTableView;
|
||
ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
|
||
AShift: TShiftState; var AHandled: Boolean);
|
||
procedure ConNoKeyPress(Sender: TObject; var Key: Char);
|
||
procedure v3ToNamePropertiesButtonClick(Sender: TObject;
|
||
AButtonIndex: Integer);
|
||
procedure v3Column13PropertiesButtonClick(Sender: TObject;
|
||
AButtonIndex: Integer);
|
||
procedure v3Column13PropertiesEditValueChanged(Sender: TObject);
|
||
private
|
||
FInt,PFInt:Integer;
|
||
procedure InitGrid();
|
||
procedure InitForm();
|
||
function DelData():Boolean;
|
||
function YFData(fMainID,FsubID:string):Boolean;
|
||
{ Private declarations }
|
||
public
|
||
{ Public declarations }
|
||
end;
|
||
|
||
var
|
||
frmClothContractListLL: TfrmClothContractListLL;
|
||
|
||
implementation
|
||
uses
|
||
U_DataLink,U_ClothContractInPut,U_Fun,U_ProductOrderListSel,U_ZDYHelp;
|
||
|
||
{$R *.dfm}
|
||
|
||
procedure TfrmClothContractListLL.FormDestroy(Sender: TObject);
|
||
begin
|
||
frmClothContractListLL:=nil;
|
||
end;
|
||
|
||
procedure TfrmClothContractListLL.FormClose(Sender: TObject;
|
||
var Action: TCloseAction);
|
||
begin
|
||
Action:=caFree;
|
||
end;
|
||
|
||
procedure TfrmClothContractListLL.TBCloseClick(Sender: TObject);
|
||
begin
|
||
Close;
|
||
WriteCxGrid('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD>ll1',Tv1,'ָʾ<D6B8><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
||
WriteCxGrid('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD>llr1',Tv3,'ָʾ<D6B8><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
||
end;
|
||
|
||
procedure TfrmClothContractListLL.InitGrid();
|
||
begin
|
||
try
|
||
ADOQueryMain.DisableControls;
|
||
{ with ADOQueryMain do
|
||
begin
|
||
Filtered:=False;
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select AA.*,ClothPS=DHPS-TPPSHZ,ClothQty=DHQty-TPQtyHZ, ');
|
||
SQL.Add('BCPPS=TPPSHZ-HCPS,BCPQty=FBCPQty-HCQty,');
|
||
SQL.Add('KCPS=DHPS-HCPS,KCQty=DHQty-TPQtyHZ+FBCPQty-HCQty');
|
||
SQL.Add(' from (select A.*,B.ConNo,C.C_CodeName,B.FactoryNoName,C.C_Spec,C.MFQty,C.KZQty, ');
|
||
sql.Add('HCPS=(select isnull(Sum(HCPS),0) from Contract_Cloth_LL MM where MM.DHID=A.DHID),');
|
||
sql.Add('HCQty=(select isnull(Sum(HCQty),0) from Contract_Cloth_LL MM where MM.DHID=A.DHID),');
|
||
sql.Add('FBCPQty=(select isnull(Sum(YZQty2),0) from Contract_Cloth_LLMx MM where MM.DHID=A.DHID) ');
|
||
sql.Add(' from Contract_Cloth_DH A inner join Contract_Main B on A.Mainid=B.Mainid');
|
||
sql.Add('inner join Contract_Sub C on A.Subid=C.Subid');
|
||
//sql.Add(' where exists (select * from Contract_Sub_MX SM where SM.SubId=A.SubId and SM.RKPlace=A.FirstName)');
|
||
SQL.Add(' )AA where exists(select * from Contract_Main BB where BB.MainId=AA.MainId and ');
|
||
sql.Add(' BB.FillTime>=:begdate and Filltime<:enddate )');
|
||
|
||
Parameters.ParamByName('begdate').Value:=BegDate.Date;
|
||
Parameters.ParamByName('enddate').Value:=EndDate.Date+1;
|
||
Open;
|
||
end; }
|
||
with ADOQueryMain do
|
||
begin
|
||
Filtered:=False;
|
||
Close;
|
||
sql.Clear;
|
||
Filtered:=False;
|
||
sql.Add('EXEC P_SELECT_PbKC ');
|
||
SQL.Add('@begdate='''+formatdateTime('yyyy-MM-dd',begdate.Date)+'''');
|
||
SQL.Add(',@enddate='''+formatdateTime('yyyy-MM-dd',enddate.Date+1)+'''');
|
||
Open;
|
||
end;
|
||
SCreateCDS20(ADOQueryMain,Order_Main);
|
||
SInitCDSData20(ADOQueryMain,Order_Main);
|
||
finally
|
||
ADOQueryMain.EnableControls;
|
||
end;
|
||
|
||
if Order_Main.IsEmpty then exit;
|
||
with ADOQueryTemp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
SQL.Add('select A.* ');
|
||
SQL.Add('from Contract_Cloth_LLMx A ');
|
||
sql.Add('where A.mainid='''+Trim(Order_Main.fieldbyname('mainid').AsString)+'''');
|
||
sql.Add('and A.subid='''+Trim(Order_Main.fieldbyname('subid').AsString)+'''');
|
||
//ShowMessage(SQL.Text);
|
||
Open;
|
||
end;
|
||
ClientDataSet3.EnableControls;
|
||
SCreateCDS20(ADOQueryTemp,ClientDataSet3);
|
||
SInitCDSData20(ADOQueryTemp,ClientDataSet3);
|
||
end;
|
||
|
||
procedure TfrmClothContractListLL.InitForm();
|
||
begin
|
||
|
||
ReadCxGrid('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD>ll1',Tv1,'ָʾ<D6B8><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
||
ReadCxGrid('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD>llr1',Tv3,'ָʾ<D6B8><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
||
EndDate.DateTime:=SGetServerDateTime(ADOQueryTemp);
|
||
BegDate.DateTime:=EndDate.DateTime-30;
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmClothContractListLL.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 TfrmClothContractListLL.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 TfrmClothContractListLL.TBRafreshClick(Sender: TObject);
|
||
begin
|
||
InitGrid();
|
||
TBFind.Click ;
|
||
|
||
end;
|
||
|
||
procedure TfrmClothContractListLL.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 TfrmClothContractListLL.FormShow(Sender: TObject);
|
||
begin
|
||
InitForm();
|
||
end;
|
||
|
||
procedure TfrmClothContractListLL.ToolButton2Click(Sender: TObject);
|
||
var
|
||
Mdate:TdateTime;
|
||
fToNo,fToName:string;
|
||
begin
|
||
if Order_Main.IsEmpty then Exit;
|
||
if not ClientDataSet3.IsEmpty then
|
||
begin
|
||
ClientDataSet3.Last;
|
||
Mdate:= ClientDataSet3.fieldbyname('TPDate').AsDateTime;
|
||
fToNo:= ClientDataSet3.fieldbyname('ToNo').AsString;
|
||
fToName:= ClientDataSet3.fieldbyname('ToName').AsString;
|
||
end
|
||
else
|
||
begin
|
||
Mdate:= date();
|
||
end;
|
||
Self.ClientDataSet3.Append;
|
||
Self.ClientDataSet3.FieldByName('TPDate').Value:=formatdateTime('yyyy-MM-dd',Mdate);
|
||
Self.ClientDataSet3.FieldByName('ToNo').Value:=Trim(fToNo);
|
||
Self.ClientDataSet3.FieldByName('ToName').Value:=Trim(fToName);
|
||
Self.ClientDataSet3.FieldByName('JGType').Value:='<27><><EFBFBD><EFBFBD><EFBFBD>ӹ<EFBFBD>';
|
||
|
||
Self.ClientDataSet3.FieldByName('mainid').Value:=Trim(Order_Main.fieldbyname('mainID').AsString);
|
||
Self.ClientDataSet3.FieldByName('subid').Value:=Trim(Order_Main.fieldbyname('SubId').AsString);
|
||
self.ClientDataSet3.FieldByName('Qty2').Value:=0;
|
||
// Self.ClientDataSet3.FieldByName('OrderNo').Value:=Trim(frmProductOrderListSel.Order_Main.fieldbyname('OrderNo').AsString);
|
||
{ Self.ClientDataSet3.FieldByName('MPRTCodeName').Value:=Trim(frmProductOrderListSel.Order_Main.fieldbyname('MPRTCodeName').AsString);
|
||
Self.ClientDataSet3.FieldByName('MPRTSpec').Value:=Trim(frmProductOrderListSel.Order_Main.fieldbyname('MPRTSpec').AsString);
|
||
Self.ClientDataSet3.FieldByName('PRTColor').Value:=Trim(frmProductOrderListSel.Order_Main.fieldbyname('PRTColor').AsString);}
|
||
Self.ClientDataSet3.FieldByName('TPUnit').Value:=Self.Order_Main.FieldByName('C_Unit').Value;
|
||
Self.ClientDataSet3.Post;
|
||
tv3.Controller.EditingController.ShowEdit();
|
||
{ begin
|
||
try
|
||
frmProductOrderListSel:=TfrmProductOrderListSel.Create(Application);
|
||
with frmProductOrderListSel do
|
||
begin
|
||
OrderNoM.Text:=Trim(self.Order_Main.fieldbyname('ConNo').AsString);
|
||
if ShowModal=1 then
|
||
begin
|
||
with frmProductOrderListSel.Order_Main do
|
||
begin
|
||
frmProductOrderListSel.Order_Main.First;
|
||
while not frmProductOrderListSel.Order_Main.Eof do
|
||
begin
|
||
if frmProductOrderListSel.Order_Main.FieldByName('SSel').AsBoolean=True then
|
||
begin
|
||
with Self.ClientDataSet3 do
|
||
begin
|
||
Self.ClientDataSet3.Append;
|
||
Self.ClientDataSet3.FieldByName('OrdSubId').Value:=Trim(frmProductOrderListSel.Order_Main.fieldbyname('SubId').AsString);
|
||
Self.ClientDataSet3.FieldByName('OrderNo').Value:=Trim(frmProductOrderListSel.Order_Main.fieldbyname('OrderNo').AsString);
|
||
Self.ClientDataSet3.FieldByName('MPRTCodeName').Value:=Trim(frmProductOrderListSel.Order_Main.fieldbyname('MPRTCodeName').AsString);
|
||
Self.ClientDataSet3.FieldByName('MPRTSpec').Value:=Trim(frmProductOrderListSel.Order_Main.fieldbyname('MPRTSpec').AsString);
|
||
Self.ClientDataSet3.FieldByName('PRTColor').Value:=Trim(frmProductOrderListSel.Order_Main.fieldbyname('PRTColor').AsString);
|
||
Self.ClientDataSet3.FieldByName('TPUnit').Value:=Self.Order_Main.FieldByName('DHUnit').Value;
|
||
end;
|
||
end;
|
||
frmProductOrderListSel.Order_Main.Next;
|
||
end;
|
||
end;
|
||
end;
|
||
end;
|
||
finally
|
||
frmProductOrderListSel.Free;
|
||
end;
|
||
end; }
|
||
end;
|
||
|
||
procedure TfrmClothContractListLL.Tv2MouseDown(Sender: TObject;
|
||
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
|
||
begin
|
||
FInt:=2;
|
||
end;
|
||
|
||
procedure TfrmClothContractListLL.Tv2CellClick(
|
||
Sender: TcxCustomGridTableView;
|
||
ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
|
||
AShift: TShiftState; var AHandled: Boolean);
|
||
begin
|
||
with ADOQueryTemp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
SQL.Add('select A.*,C.MPRTSpec,B.PRTColor,C.MPRTCodeName,C.OrderNo ,');
|
||
sql.Add('C_Unit=(select Top 1 C_Unit from Contract_Sub AA,Contract_Sub_Mx BB where AA.SubId=BB.SubId and BB.MXid=A.Mxid)');
|
||
SQL.Add(' from Contract_Sub_MxTo A inner join JYOrder_Sub B on A.OrdSubId=B.SubId ');
|
||
SQL.Add(' inner join JYOrder_Main C on C.MainId=B.MainId ');
|
||
sql.Add('where A.MxId='''+Trim(ClientDataSet2.fieldbyname('MxId').AsString)+'''');
|
||
Open;
|
||
end;
|
||
ClientDataSet3.EnableControls;
|
||
SCreateCDS20(ADOQueryTemp,ClientDataSet3);
|
||
SInitCDSData20(ADOQueryTemp,ClientDataSet3);
|
||
end;
|
||
|
||
procedure TfrmClothContractListLL.ToolButton5Click(Sender: TObject);
|
||
var
|
||
maxno,LLIdx,dhID,FDW:string;
|
||
begin
|
||
if ClientDataSet3.IsEmpty then Exit;
|
||
ToolBar1.SetFocus;
|
||
{ if ClientDataSet3.Locate('OrderNo',null,[]) then
|
||
begin
|
||
Application.MessageBox('ָ<><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ų<EFBFBD><C5B2><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>','<27><>ʾ',0);
|
||
Exit;
|
||
end; }
|
||
if ClientDataSet3.Locate('JGType',null,[]) then
|
||
begin
|
||
Application.MessageBox('<27><><EFBFBD>Ͳ<EFBFBD><CDB2><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
{ if ClientDataSet3.Locate('ToName',null,[]) then
|
||
begin
|
||
Application.MessageBox('<27>ӹ<EFBFBD><D3B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>','<27><>ʾ',0);
|
||
Exit;
|
||
end; }
|
||
if ClientDataSet3.Locate('TPPS',null,[]) then
|
||
begin
|
||
Application.MessageBox('ƥ<><C6A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
if ClientDataSet3.Locate('TPQty',null,[]) then
|
||
begin
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
if ClientDataSet3.Locate('Qty2',null,[]) then
|
||
begin
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EEB2BB>Ϊ<EFBFBD>գ<EFBFBD>','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
{ if ClientDataSet3.Locate('TPUnit',null,[]) then
|
||
begin
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>','<27><>ʾ',0);
|
||
Exit;
|
||
end; }
|
||
ClientDataSet3.DisableControls;
|
||
with ClientDataSet3 do
|
||
begin
|
||
First;
|
||
while not Eof do
|
||
begin
|
||
if Trim(FDW)='' then
|
||
begin
|
||
FDW:=Trim(ClientDataSet3.fieldbyname('TPUnit').AsString);
|
||
end;
|
||
if FDW<>Trim(ClientDataSet3.fieldbyname('TPUnit').AsString) then
|
||
begin
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>һ<EFBFBD><D2BB>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
Next;
|
||
end;
|
||
end;
|
||
ClientDataSet3.EnableControls;
|
||
{ if Trim(Order_Main.fieldbyname('DHUnit').AsString)='M' then
|
||
begin
|
||
if ClientDataSet3.Locate('TPUnit','Kg',[]) then
|
||
begin
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λΪM,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>ΪKg<4B><67>','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
end; }
|
||
BegDate.SetFocus;
|
||
try
|
||
ADOQueryCmd.Connection.BeginTrans;
|
||
//<2F><><EFBFBD><EFBFBD>ȥ<EFBFBD><C8A5><EFBFBD><EFBFBD>
|
||
with ClientDataSet3 do
|
||
begin
|
||
First;
|
||
while not eof do
|
||
begin
|
||
if Trim(ClientDataSet3.fieldbyname('MXId').AsString)='' then
|
||
begin
|
||
if GetLSNo(ADOQueryCmd,maxno,'MX','Contract_Cloth_LLMx',4,1)=False then
|
||
begin
|
||
ADOQueryCmd.Connection.RollbackTrans;
|
||
Application.MessageBox('ȡȥ<C8A1><C8A5><EFBFBD><EFBFBD>ˮ<EFBFBD><CBAE>ʧ<EFBFBD>ܣ<EFBFBD>','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
end else
|
||
begin
|
||
maxno:=Trim(ClientDataSet3.fieldbyname('MXId').AsString);
|
||
end;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select * from Contract_Cloth_LLMx where MXId='''+Trim(ClientDataSet3.fieldbyname('MXId').AsString)+'''');
|
||
Open;
|
||
end;
|
||
with ADOQueryCmd do
|
||
begin
|
||
if Trim(ClientDataSet3.fieldbyname('MXId').AsString)='' then
|
||
Append
|
||
else
|
||
Edit;
|
||
FieldByName('MainId').Value:=Trim(Order_Main.fieldbyname('MainId').AsString);
|
||
FieldByName('SubId').Value:=Trim(Order_Main.fieldbyname('SubId').AsString);
|
||
FieldByName('DHId').Value:=Trim(Order_Main.fieldbyname('SubId').AsString);
|
||
// FieldByName('DHId').Value:=Trim(maxno);
|
||
FieldByName('MXId').Value:=Trim(maxno);
|
||
// FieldByName('OrdSubId').Value:=Trim(maxno);
|
||
FieldByName('OrdSubId').Value:=Trim(Order_Main.fieldbyname('SubId').AsString);
|
||
FieldByName('TPDate').Value:=ClientDataSet3.fieldbyname('TPDate').Value;
|
||
FieldByName('TPPerson').Value:=ClientDataSet3.fieldbyname('TPPerson').Value;
|
||
FieldByName('TPNote').Value:=ClientDataSet3.fieldbyname('TPNote').Value;
|
||
FieldByName('ToNo').Value:=ClientDataSet3.fieldbyname('ToNo').Value;
|
||
FieldByName('ToName').Value:=ClientDataSet3.fieldbyname('ToName').Value;
|
||
FieldByName('gangNO').Value:=trim(ClientDataSet3.fieldbyname('gangNO').AsString);
|
||
FieldByName('BCgangNO').Value:=trim(ClientDataSet3.fieldbyname('BCgangNO').AsString);
|
||
FieldByName('C_Color').Value:=trim(ClientDataSet3.fieldbyname('C_Color').AsString);
|
||
FieldByName('JGType').Value:=trim(ClientDataSet3.fieldbyname('JGType').AsString);
|
||
|
||
if Trim(ClientDataSet3.fieldbyname('MXId').AsString)<>'' then
|
||
begin
|
||
if Trim(ADOQueryCmd.fieldbyname('TPUnit').AsString)<>Trim(ClientDataSet3.fieldbyname('TPUnit').AsString) then
|
||
begin
|
||
with ADOQueryTemp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select * from Contract_Cloth_LL A where A.DHIDHelp in(');
|
||
sql.Add('select LLID from Contract_Cloth_LL B where B.LLID='''+Trim(ClientDataSet3.fieldbyname('MXID').AsString)+''')');
|
||
// sql.Add(' and OrdSubId='''+Trim(ClientDataSet3.fieldbyname('OrdSubId').AsString)+''' and JXJGFlag=1)');
|
||
Open;
|
||
end;
|
||
if ADOQueryTemp.IsEmpty=False then
|
||
begin
|
||
ADOQueryCmd.Connection.RollbackTrans;
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ӹ<EFBFBD><D3B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><DEB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
end;
|
||
end;
|
||
if Trim(ClientDataSet3.fieldbyname('MXId').AsString)<>'' then
|
||
begin
|
||
if Trim(ADOQueryCmd.fieldbyname('TPUnit').AsString)<>Trim(ClientDataSet3.fieldbyname('TPUnit').AsString) then
|
||
begin
|
||
with ADOQueryTemp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select * from JYOrder_Sub_AnPai A where SubId='''+Trim(ClientDataSet3.fieldbyname('OrdSubId').AsString)+'''');
|
||
Open;
|
||
end;
|
||
if ADOQueryTemp.IsEmpty=False then
|
||
begin
|
||
ADOQueryCmd.Connection.RollbackTrans;
|
||
Application.MessageBox('<27>ѻزֲ<D8B2><D6B2><EFBFBD><EFBFBD><EFBFBD><DEB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
end;
|
||
end;
|
||
|
||
FieldByName('TPUnit').Value:=ClientDataSet3.fieldbyname('TPUnit').Value;
|
||
{ FieldByName('TPPS').Value:=ClientDataSet3.fieldbyname('TPPS').AsFloat;
|
||
FieldByName('TPQty').Value:=ClientDataSet3.fieldbyname('TPQty').AsFloat;
|
||
FieldByName('Qty1').Value:=ClientDataSet3.fieldbyname('Qty1').AsFloat;
|
||
FieldByName('Qty2').Value:=ClientDataSet3.fieldbyname('Qty2').AsFloat;
|
||
FieldByName('Qty3').Value:=ClientDataSet3.fieldbyname('Qty3').AsFloat;
|
||
FieldByName('TPQty').Value:=ClientDataSet3.fieldbyname('TPQty').AsFloat;
|
||
FieldByName('JGPrice').Value:=ClientDataSet3.fieldbyname('JGPrice').AsFloat;
|
||
FieldByName('GangFee').Value:=ClientDataSet3.fieldbyname('GangFee').AsFloat; }
|
||
if Trim(ClientDataSet3.fieldbyname('TPQty').AsString)<>'' then
|
||
FieldByName('TPQty').Value:=ClientDataSet3.fieldbyname('TPQty').Value
|
||
else
|
||
FieldByName('TPQty').Value:=0;
|
||
if Trim(ClientDataSet3.fieldbyname('JGPrice').AsString)<>'' then
|
||
FieldByName('JGPrice').Value:=ClientDataSet3.fieldbyname('JGPrice').Value
|
||
else
|
||
FieldByName('JGPrice').Value:=0;
|
||
if Trim(ClientDataSet3.fieldbyname('GangFee').AsString)<>'' then
|
||
FieldByName('GangFee').Value:=ClientDataSet3.fieldbyname('GangFee').Value
|
||
else
|
||
FieldByName('GangFee').Value:=0;
|
||
if Trim(ClientDataSet3.fieldbyname('TPPS').AsString)<>'' then
|
||
FieldByName('TPPS').Value:=ClientDataSet3.fieldbyname('TPPS').Value
|
||
else
|
||
FieldByName('TPPS').Value:=0;
|
||
if Trim(ClientDataSet3.fieldbyname('Qty1').AsString)<>'' then
|
||
FieldByName('Qty1').Value:=ClientDataSet3.fieldbyname('Qty1').Value
|
||
else
|
||
FieldByName('Qty1').Value:=0;
|
||
if Trim(ClientDataSet3.fieldbyname('Qty2').AsString)<>'' then
|
||
FieldByName('Qty2').Value:=ClientDataSet3.fieldbyname('Qty2').Value
|
||
else
|
||
FieldByName('Qty2').Value:=0;
|
||
if Trim(ClientDataSet3.fieldbyname('Qty3').AsString)<>'' then
|
||
FieldByName('Qty3').Value:=ClientDataSet3.fieldbyname('Qty3').Value
|
||
else
|
||
FieldByName('Qty3').Value:=0;
|
||
if Trim(ClientDataSet3.fieldbyname('TPUnit').AsString)='Kg' then
|
||
begin
|
||
FieldByName('TPMQty').Value:=ClientDataSet3.fieldbyname('TPQty').Value*1.00*1000
|
||
/(Order_Main.fieldbyname('MFQty').Value*1.00/100*Order_Main.fieldbyname('KZQty').Value);
|
||
end else
|
||
begin
|
||
FieldByName('TPMQty').Value:=ClientDataSet3.fieldbyname('TPQty').Value;
|
||
end;
|
||
if Trim(ClientDataSet3.fieldbyname('TPUnit').AsString)='Kg' then
|
||
begin
|
||
FieldByName('MQty2').Value:=ClientDataSet3.fieldbyname('Qty2').Value*1.00*1000
|
||
/(Order_Main.fieldbyname('MFQty').Value*1.00/100*Order_Main.fieldbyname('KZQty').Value);
|
||
end else
|
||
begin
|
||
FieldByName('MQty2').Value:=ClientDataSet3.fieldbyname('Qty2').Value;
|
||
end;
|
||
if Trim(ClientDataSet3.FieldByName('TPUnit').AsString)=Trim(Order_Main.FieldByName('C_Unit').AsString) then
|
||
begin
|
||
FieldByName('TPYZQty').Value:=ClientDataSet3.fieldbyname('TPQty').Value;
|
||
end else
|
||
begin
|
||
if Trim(ClientDataSet3.FieldByName('TPUnit').AsString)='M' then
|
||
begin
|
||
FieldByName('TPYZQty').Value:=ClientDataSet3.fieldbyname('TPQty').Value
|
||
*Order_Main.fieldbyname('MFQty').Value*1.00/100
|
||
*Order_Main.fieldbyname('KZQty').Value*1.00/1000;
|
||
end;
|
||
end;
|
||
if Trim(ClientDataSet3.FieldByName('TPUnit').AsString)=Trim(Order_Main.FieldByName('C_Unit').AsString) then
|
||
begin
|
||
FieldByName('YZQty2').Value:=ClientDataSet3.fieldbyname('Qty2').Value;
|
||
end else
|
||
begin
|
||
if Trim(ClientDataSet3.FieldByName('TPUnit').AsString)='M' then
|
||
begin
|
||
FieldByName('YZQty2').Value:=ClientDataSet3.fieldbyname('Qty2').Value
|
||
*Order_Main.fieldbyname('MFQty').Value*1.00/100
|
||
*Order_Main.fieldbyname('KZQty').Value*1.00/1000;
|
||
end;
|
||
end;
|
||
Post;
|
||
end;
|
||
with ClientDataSet3 do
|
||
begin
|
||
Edit;
|
||
FieldByName('MXId').Value:=Trim(maxno);
|
||
Post;
|
||
end;
|
||
with ADOQueryTemp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select * from Contract_Cloth_LL where LLID='''+Trim(ClientDataSet3.fieldbyname('MXId').AsString)+'''');
|
||
// sql.Add(' and OrdSubId='''+Trim(ClientDataSet3.fieldbyname('OrdSubId').AsString)+'''');
|
||
Open;
|
||
end;
|
||
if ADOQueryTemp.IsEmpty then
|
||
begin
|
||
{ with ADOQueryTemp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select isnull(Max(LLIdx),0) LLIdx from Contract_Cloth_LL ');
|
||
Open;
|
||
end;
|
||
LLIdx:=IntToStr(ADOQueryTemp.fieldbyname('LLIdx').AsInteger+1); }
|
||
{if GetLSNo(ADOQueryCmd,dhID,'LL','Contract_Cloth_LL',4,1)=False then
|
||
begin
|
||
ADOQueryCmd.Connection.RollbackTrans;
|
||
Application.MessageBox('ȡȥ<C8A1><C8A5><EFBFBD><EFBFBD>ˮ<EFBFBD><CBAE>ʧ<EFBFBD>ܣ<EFBFBD>','<27><>ʾ',0);
|
||
Exit;
|
||
end; }
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select * from Contract_Cloth_LL where 1<>1');
|
||
Open;
|
||
end;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Append;
|
||
FieldByName('LLID').Value:=trim(maxNo);
|
||
// FieldByName('DHID').Value:=tirm(maxNo);
|
||
FieldByName('DHID').Value:=Trim(Order_Main.fieldbyname('subID').AsString);
|
||
FieldByName('FirstNo').Value:=Trim(ClientDataSet3.fieldbyname('ToNo').AsString);
|
||
FieldByName('FirstName').Value:=Trim(ClientDataSet3.fieldbyname('ToName').AsString);
|
||
FieldByName('OrdSubId').Value:=Trim(Order_Main.fieldbyname('subID').AsString);
|
||
FieldByName('TPUnit').Value:=Trim(ClientDataSet3.fieldbyname('TPUnit').AsString);
|
||
// FieldByName('LLIdx').Value:=LLIdx;
|
||
FieldByName('LLIdx').Value:=1;
|
||
Post;
|
||
end;
|
||
|
||
end else
|
||
begin
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('Update Contract_Cloth_LL Set LLIdx=1,TPUnit='''+Trim(ClientDataSet3.fieldbyname('TPUnit').AsString)+'''');
|
||
sql.Add(' where LLID='''+Trim(ADOQueryTemp.fieldbyname('LLID').AsString)+'''');
|
||
ExecSQL;
|
||
end;
|
||
end;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('UPdate Contract_Cloth_LL Set TPPS=(select isnull(sum(TPPS),0) from Contract_Cloth_LLMX A where A.MXID=Contract_Cloth_LL.LLID');
|
||
SQL.Add(' and A.OrdSubId=Contract_Cloth_LL.OrdSubId)');
|
||
if Trim(ClientDataSet3.FieldByName('TPUnit').AsString)=Trim(Order_Main.FieldByName('C_Unit').AsString) then
|
||
begin
|
||
sql.Add(',TPQty=(select Sum(TPQty) from Contract_Cloth_LLMx A where A.MXID=Contract_Cloth_LL.LLID');
|
||
SQL.Add(' and A.OrdSubId=Contract_Cloth_LL.OrdSubId)');
|
||
end else
|
||
begin
|
||
if Trim(ClientDataSet3.FieldByName('TPUnit').AsString)='M' then
|
||
begin
|
||
SQL.Add(',TPQty=(select sum(TPQty*(MFQty/100)*(KZQty/1000)) from Contract_Cloth_LLMx A ');
|
||
sql.Add(' inner join Contract_Sub B on A.SubId=B.SubId where A.DHID=Contract_Cloth_LL.LLID');
|
||
SQL.Add(' and A.OrdSubId=Contract_Cloth_LL.OrdSubId)');
|
||
end;
|
||
end;
|
||
if Trim(ClientDataSet3.FieldByName('TPUnit').AsString)=Trim(Order_Main.FieldByName('C_Unit').AsString) then
|
||
begin
|
||
sql.Add(',BCPQty=(select Sum(Qty2) from Contract_Cloth_LLMx A where A.MXID=Contract_Cloth_LL.LLID');
|
||
SQL.Add(' and A.OrdSubId=Contract_Cloth_LL.OrdSubId)');
|
||
end else
|
||
begin
|
||
if Trim(ClientDataSet3.FieldByName('TPUnit').AsString)='M' then
|
||
begin
|
||
SQL.Add(',BCPQty=(select sum(A.Qty2*(MFQty/100)*(KZQty/1000)) from Contract_Cloth_LLMx A ');
|
||
sql.Add(' inner join Contract_Sub B on A.SubId=B.SubId where A.MXID=Contract_Cloth_LL.LLID');
|
||
SQL.Add(' and A.OrdSubId=Contract_Cloth_LL.OrdSubId)');
|
||
end;
|
||
end;
|
||
sql.Add(', TPMQty=(select isnull(sum(TPMQty),0) from Contract_Cloth_LLMX A where A.MXID=Contract_Cloth_LL.LLID');
|
||
SQL.Add(' and A.OrdSubId=Contract_Cloth_LL.OrdSubId)');
|
||
sql.Add(', BCPMQty=(select isnull(sum(MQty2),0) from Contract_Cloth_LLMX A where A.MXID=Contract_Cloth_LL.LLID');
|
||
SQL.Add(' and A.OrdSubId=Contract_Cloth_LL.OrdSubId)');
|
||
sql.Add('where LLID='''+Trim(ClientDataSet3.fieldbyname('MXID').AsString)+'''');
|
||
// SQL.Add(' and OrdSubId='''+Trim(ClientDataSet3.fieldbyname('OrdSubid').AsString)+'''');
|
||
ExecSQL;
|
||
end;
|
||
|
||
|
||
Next;
|
||
end;
|
||
end;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('delete Contract_Cloth_LL where not exists(');
|
||
sql.Add(' select * from Contract_Cloth_LLMX LM where LM.MXID=Contract_Cloth_LL.LLID ');
|
||
sql.Add(' and LM.OrdSubId=Contract_Cloth_LL.OrdSubId )');
|
||
sql.Add(' and LLID='''+Trim(ClientDataSet3.fieldbyname('MXID').AsString)+'''');
|
||
sql.Add(' and isnull(DHIDHelp,'''')='''' ');
|
||
ExecSQL;
|
||
end;
|
||
|
||
if not YFData(Order_Main.fieldbyname('MainID').AsString,Order_Main.fieldbyname('subID').AsString) then
|
||
begin
|
||
ADOQueryCmd.Connection.RollbackTrans;
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>˻<EFBFBD><CBBB>쳣!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
ADOQueryCmd.Connection.CommitTrans;
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD>','<27><>ʾ',0);
|
||
ClientDataSet3.EnableControls;
|
||
except
|
||
ADOQueryCmd.Connection.RollbackTrans;
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>쳣<EFBFBD><ECB3A3>','<27><>ʾ',0);
|
||
end;
|
||
end;
|
||
|
||
function TfrmClothContractListLL.YFData(fMainID,FsubID:string):Boolean;
|
||
var
|
||
CRID,OrdMainId,YFID,FComTaiTou,FCRID,FFactoryName:String;
|
||
begin
|
||
Result:=False;
|
||
try
|
||
with ADOQueryTemp do
|
||
begin
|
||
Close;
|
||
SQL.Clear;
|
||
sql.Add('select * from YF_Money_KC where FactoryName='''+Trim(Order_Main.fieldbyName('FactoryNoName').asstring)+'''');
|
||
Open;
|
||
end;
|
||
if not ADOQueryTemp.IsEmpty 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 ');
|
||
sql.add('where CRID='+quotedstr(trim(CRID)));
|
||
Open;
|
||
end;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Append;
|
||
FieldByName('CRID').Value:=StrToInt(CRID);
|
||
FieldByName('FactoryName').Value:=Trim(FactoryNoName.Text);
|
||
FieldByName('ZdyStr1').Value:='Ӧ<><D3A6><EFBFBD><EFBFBD>';
|
||
Post;
|
||
end;
|
||
end;
|
||
|
||
with ADOQueryTemp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select * from YF_Money_CR where mainID='''+Trim(FmainID)+'''');
|
||
sql.Add('and subID='''+Trim(FsubID)+'''');
|
||
sql.Add('and YFName=''<27><><EFBFBD><EFBFBD><EFBFBD>˻<EFBFBD>'' ');
|
||
Open;
|
||
end;
|
||
if ADOQueryTemp.IsEmpty then
|
||
begin
|
||
if GetLSNo(ADOQueryCmd,YFID,'YF','YF_Money_CR',3,1)=False then
|
||
begin
|
||
Application.MessageBox('ȡ<><C8A1><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
end
|
||
else
|
||
begin
|
||
YFID:=Trim(ADOQueryTemp.fieldbyname('YFID').AsString);
|
||
end;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select * from YF_Money_CR where YFID='''+Trim(YFID)+'''');
|
||
Open;
|
||
end;
|
||
with ADOQueryCmd do
|
||
begin
|
||
if ADOQueryTemp.IsEmpty then
|
||
Append
|
||
else
|
||
Edit;
|
||
FieldByName('YFID').Value:=Trim(YFID);
|
||
FieldByName('YFTypeId').Value:=Order_Main.fieldbyName('conNo').asstring;
|
||
FieldByName('CRID').Value:=StrToInt(CRID);
|
||
FieldByName('Filler').Value:=Trim(DName);
|
||
FieldByName('CRType').Value:='Ӧ<><D3A6><EFBFBD><EFBFBD><EFBFBD>Ǽ<EFBFBD>';
|
||
FieldByName('CRFlag').Value:='Ӧ<><D3A6><EFBFBD><EFBFBD>';
|
||
FieldByName('QtyFlag').Value:=1;
|
||
FieldByName('FactoryName').Value:=Order_Main.fieldbyName('FactoryNoName').asstring;
|
||
FieldByName('CRTime').Value:=ClientDataSet3.fieldbyname('TPdate').AsDateTime;
|
||
// FieldByName('Qty').Value:=Order_Sub.fieldbyname('C_Qty').Value;
|
||
// FieldByName('PS').Value:=Order_Sub.fieldbyname('Qty1').Value;
|
||
FieldByName('YFType').Value:='<27>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>';
|
||
FieldByName('Price').Value:=Order_Main.fieldbyname('Price').asfloat;
|
||
FieldByName('HuiLv').Value:=1;
|
||
FieldByName('BZType').Value:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
|
||
FieldByName('ComTaiTou').Value:=Order_Main.fieldbyName('FactoryNoName').asstring;
|
||
FieldByName('QtyUnit').Value:=Trim(ClientDataSet3.fieldbyname('TPUnit').AsString);
|
||
FieldByName('YFName').Value:='<27><><EFBFBD><EFBFBD><EFBFBD>˻<EFBFBD>';
|
||
FieldByName('MainId').Value:=Trim(fMainID);
|
||
FieldByName('subID').Value:=Trim(fsubID);
|
||
Post;
|
||
end;
|
||
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('update YF_Money_CR Set Qty=(select -1*isnull(Sum(TPQty),0) from Contract_Cloth_LLMx A ');
|
||
sql.Add(' where A.mainID=YF_Money_CR.mainID and A.subiD=YF_Money_CR.subiD and A.JGType=''<27>˻<EFBFBD><CBBB><EFBFBD><EFBFBD><EFBFBD>'' )');
|
||
sql.Add(',PS=(select -1 *isnull(sum(TPPS),0) from Contract_Cloth_LLMx A ');
|
||
sql.Add(' where A.mainID=YF_Money_CR.mainID and A.subiD=YF_Money_CR.subiD and A.JGType=''<27>˻<EFBFBD><CBBB><EFBFBD><EFBFBD><EFBFBD>'' )');
|
||
sql.Add(' where YFID='''+Trim(YFID)+'''');
|
||
ExecSQL;
|
||
END;
|
||
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('delete from YF_Money_CR ');
|
||
sql.Add('where YFID='''+Trim(YFID)+''' and Qty=0 ');
|
||
ExecSQL;
|
||
END;
|
||
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('Update YF_Money_CR Set Money=Price*Qty,BBMoney=Price*Qty');
|
||
sql.Add(' where YFID='''+Trim(YFID)+'''');
|
||
ExecSQL;
|
||
end;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add(' Update YF_Money_KC Set KCMoney=(select isnull(Sum(Money*QtyFlag),0) from YF_Money_CR A where A.CRID=YF_Money_KC.CRID)');
|
||
sql.Add(',KCBBMoney=(select isnull(Sum(BBMoney*QtyFlag),0) from YF_Money_CR A where A.CRID=YF_Money_KC.CRID)');
|
||
sql.Add(' where CRID='+CRID);
|
||
ExecSQL;
|
||
end;
|
||
Result:=True;
|
||
except
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmClothContractListLL.ToolButton3Click(Sender: TObject);
|
||
begin
|
||
begin
|
||
if ClientDataSet3.IsEmpty then Exit;
|
||
if Trim(ClientDataSet3.fieldbyname('MXId').AsString)<>'' then
|
||
begin
|
||
if Application.MessageBox('ȷ<><C8B7>Ҫɾ<D2AA><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>','<27><>ʾ',32+4)<>IDYES then Exit;
|
||
end;
|
||
with ADOQueryTemp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
SQL.Add(' select * from Contract_Cloth_LL where LLID='''+Trim(ClientDataSet3.fieldbyname('MXID').AsString)+'''');
|
||
// sql.Add(' and OrdSubId='''+Trim(ClientDataSet3.fieldbyname('OrdSubId').AsString)+'''');
|
||
Open;
|
||
end;
|
||
if ADOQueryTemp.FieldByName('HCQty').AsFloat>0 then
|
||
begin
|
||
Application.MessageBox('<27><><EFBFBD>лز<D0BB><D8B2><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
try
|
||
ADOQueryCmd.Connection.BeginTrans;
|
||
{ with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('UPdate Contract_Cloth_LL Set TPPS=(select isnull(sum(TPPS),0) from Contract_Cloth_LLMX A where A.MJID=Contract_Cloth_LL.LLID');
|
||
SQL.Add(' and A.OrdSubId=Contract_Cloth_LL.OrdSubId)');
|
||
sql.Add(', TPQty=(select isnull(sum(TPYZQty),0) from Contract_Cloth_LLMX A where A.MJID=Contract_Cloth_LL.LLID');
|
||
SQL.Add(' and A.OrdSubId=Contract_Cloth_LL.OrdSubId)');
|
||
sql.Add(', BCPQty=(select isnull(sum(YZQty2),0) from Contract_Cloth_LLMX A where A.MJID=Contract_Cloth_LL.LLID');
|
||
SQL.Add(' and A.OrdSubId=Contract_Cloth_LL.OrdSubId)');
|
||
sql.Add(', TPMQty=(select isnull(sum(TPMQty),0) from Contract_Cloth_LLMX A where A.MJID=Contract_Cloth_LL.LLID');
|
||
SQL.Add(' and A.OrdSubId=Contract_Cloth_LL.OrdSubId)');
|
||
sql.Add(', BCPMQty=(select isnull(sum(MQty2),0) from Contract_Cloth_LLMX A where A.MJID=Contract_Cloth_LL.LLID');
|
||
SQL.Add(' and A.OrdSubId=Contract_Cloth_LL.OrdSubId)');
|
||
sql.Add('where LLID='''+Trim(ClientDataSet3.fieldbyname('MXId').AsString)+'''');
|
||
// SQL.Add(' and OrdSubId='''+Trim(ClientDataSet3.fieldbyname('OrdSubid').AsString)+'''');
|
||
ExecSQL;
|
||
end; }
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('delete Contract_Cloth_LLMx where MXId='''+Trim(ClientDataSet3.fieldbyname('MXId').AsString)+'''');
|
||
sql.Add('delete Contract_Cloth_LL where LLID='''+Trim(ClientDataSet3.fieldbyname('MXId').AsString)+'''');
|
||
ExecSQL;
|
||
end;
|
||
{ with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('Update Contract_Cloth_DH Set TPQtyHZ=(select isnull(Sum(TPYZQty),0) from Contract_Cloth_LLMx A where A.DHID=Contract_Cloth_DH.DHID)');
|
||
sql.Add(',TPMQtyHZ=(select isnull(Sum(TPMQty),0) from Contract_Cloth_LLMx A where A.DHID=Contract_Cloth_DH.DHID)');
|
||
sql.Add(',TPPSHZ=(select isnull(Sum(TPPS),0) from Contract_Cloth_LLMx A where A.DHID=Contract_Cloth_DH.DHID)');
|
||
sql.Add(' where DHID='''+Trim(Order_Main.fieldbyname('DHID').AsString)+'''');
|
||
ExecSQL;
|
||
end; }
|
||
|
||
{ with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('delete Contract_Cloth_LL where not exists(');
|
||
sql.Add(' select * from Contract_Cloth_LLMX LM where LM.MXID=Contract_Cloth_LL.LLID ');
|
||
sql.Add(' and LM.OrdSubId=Contract_Cloth_LL.OrdSubId )');
|
||
// sql.Add(' and DHID='''+Trim(Order_Main.fieldbyname('DHID').AsString)+'''');
|
||
sql.Add(' and isnull(DHIDHelp,'''')='''' ');
|
||
ExecSQL;
|
||
end; }
|
||
{ if YFData()=False then
|
||
begin
|
||
ADOQueryCmd.Connection.RollbackTrans;
|
||
Application.MessageBox('<27><><EFBFBD>¸<C2B8><D7B7>쳣!','<27><>ʾ',0);
|
||
Exit;
|
||
end; }
|
||
ADOQueryCmd.Connection.CommitTrans;
|
||
ClientDataSet3.Delete;
|
||
except;
|
||
ADOQueryCmd.Connection.RollbackTrans;
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>쳣!','<27><>ʾ',0);
|
||
end;
|
||
|
||
{with Order_Main do
|
||
begin
|
||
Edit;
|
||
if ClientDataSet3.IsEmpty=False then
|
||
FieldByName('KCQty').Value:=Order_Main.fieldbyname('DHQty').Value-tv3.DataController.Summary.FooterSummaryValues[0]
|
||
else
|
||
FieldByName('KCQty').Value:=Order_Main.fieldbyname('DHQty').Value;
|
||
Post;
|
||
end; }
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmClothContractListLL.v2Column3PropertiesButtonClick(
|
||
Sender: TObject; AButtonIndex: Integer);
|
||
begin
|
||
try
|
||
frmZDYHelp:=TfrmZDYHelp.Create(Application);
|
||
with frmZDYHelp do
|
||
begin
|
||
flag:='RKPlace';
|
||
flagname:='<27><><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD>';
|
||
if ShowModal=1 then
|
||
begin
|
||
with ClientDataSet2 do
|
||
begin
|
||
Edit;
|
||
FieldByName('RKPlace').Value:=Trim(frmZDYHelp.ClientDataSet1.fieldbyname('ZDYName').AsString);
|
||
end;
|
||
end;
|
||
end;
|
||
finally
|
||
frmZDYHelp.Free;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmClothContractListLL.v3Column2PropertiesEditValueChanged(
|
||
Sender: TObject);
|
||
var
|
||
mvalue,fieldname:String;
|
||
qty1,qty2:double;
|
||
|
||
begin
|
||
If Trim(TcxTextEdit(Sender).EditingText)<>'' then
|
||
begin
|
||
mvalue:=TcxTextEdit(Sender).EditingText;
|
||
end else
|
||
begin
|
||
mvalue:='0';
|
||
end;
|
||
fieldname:=Tv3.Controller.FocusedColumn.DataBinding.FilterFieldName;
|
||
with ClientDataSet3 do
|
||
begin
|
||
Edit;
|
||
FieldByName(Trim(fieldname)).Value:=mvalue;
|
||
Post;
|
||
end;
|
||
{
|
||
with Order_Main do
|
||
begin
|
||
Edit;
|
||
FieldByName('KCQty').Value:=Order_Main.fieldbyname('DHQty').Value-tv3.DataController.Summary.FooterSummaryValues[0];
|
||
Post;
|
||
end;
|
||
if Trim(ClientDataSet3.fieldbyname('TPQty').AsString)<>'' then
|
||
begin
|
||
qty1:=ClientDataSet3.fieldbyname('TPQty').AsString;
|
||
end else
|
||
begin
|
||
qty1:='0';
|
||
end;
|
||
if Trim(ClientDataSet3.fieldbyname('Qty2').AsString)<>'' then
|
||
begin
|
||
Qty2:=ClientDataSet3.fieldbyname('Qty2').AsString;
|
||
end else
|
||
begin
|
||
Qty2:='0';
|
||
end; }
|
||
qty1:=ClientDataSet3.fieldbyname('TPQty').AsFloat;
|
||
Qty2:=ClientDataSet3.fieldbyname('Qty2').AsFloat;
|
||
if qty1*Qty2=0 then Exit;
|
||
with ClientDataSet3 do
|
||
begin
|
||
Edit;
|
||
FieldByName('qty3').Value:=(qty1-qty2)*1.00*100/qty1;
|
||
Post;
|
||
end;
|
||
self.tv3.Controller.EditingController.ShowEdit();
|
||
end;
|
||
|
||
procedure TfrmClothContractListLL.j(
|
||
Sender: TcxCustomGridTableView;
|
||
ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
|
||
AShift: TShiftState; var AHandled: Boolean);
|
||
begin
|
||
if Order_Main.IsEmpty then exit;
|
||
with ADOQueryTemp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
SQL.Add('select A.* ');
|
||
SQL.Add('from Contract_Cloth_LLMx A ');
|
||
sql.Add('where A.mainid='''+Trim(Order_Main.fieldbyname('mainid').AsString)+'''');
|
||
sql.Add('and A.subid='''+Trim(Order_Main.fieldbyname('subid').AsString)+'''');
|
||
//ShowMessage(SQL.Text);
|
||
Open;
|
||
end;
|
||
ClientDataSet3.EnableControls;
|
||
SCreateCDS20(ADOQueryTemp,ClientDataSet3);
|
||
SInitCDSData20(ADOQueryTemp,ClientDataSet3);
|
||
end;
|
||
|
||
procedure TfrmClothContractListLL.ConNoKeyPress(Sender: TObject;
|
||
var Key: Char);
|
||
begin
|
||
if Key=#13 then
|
||
begin
|
||
if Length(Trim(ConNo.Text))<4 then Exit;
|
||
try
|
||
ADOQueryMain.DisableControls;
|
||
with ADOQueryMain do
|
||
begin
|
||
Filtered:=False;
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select AA.*,ClothPS=DHPS-TPPSHZ,ClothQty=DHQty-TPQtyHZ, ');
|
||
SQL.Add('BCPPS=TPPSHZ-HCPS,BCPQty=FBCPQty-HCQty,');
|
||
SQL.Add('KCPS=DHPS-HCPS,KCQty=DHQty-TPQtyHZ+FBCPQty-HCQty');
|
||
SQL.Add(' from (select A.*,B.ConNo,C.C_CodeName,B.FactoryNoName,C.C_Spec,C.MFQty,C.KZQty, ');
|
||
sql.Add('HCPS=(select isnull(Sum(HCPS),0) from Contract_Cloth_LL MM where MM.DHID=A.DHID),');
|
||
sql.Add('HCQty=(select isnull(Sum(HCQty),0) from Contract_Cloth_LL MM where MM.DHID=A.DHID),');
|
||
sql.Add('FBCPQty=(select isnull(Sum(YZQty2),0) from Contract_Cloth_LLMx MM where MM.DHID=A.DHID) ');
|
||
sql.Add(' from Contract_Cloth_DH A inner join Contract_Main B on A.Mainid=B.Mainid');
|
||
sql.Add('inner join Contract_Sub C on A.Subid=C.Subid');
|
||
//sql.Add(' where exists(select * from Contract_Sub_MX SM where SM.SubId=A.SubId and SM.RKPlace=A.FirstName) ');
|
||
SQL.Add(' )AA where AA.ConNo like '''+'%'+Trim(ConNo.Text)+'%'+'''');
|
||
Open;
|
||
end;
|
||
SCreateCDS20(ADOQueryMain,Order_Main);
|
||
SInitCDSData20(ADOQueryMain,Order_Main);
|
||
finally
|
||
ADOQueryMain.EnableControls;
|
||
end;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmClothContractListLL.v3ToNamePropertiesButtonClick(
|
||
Sender: TObject; AButtonIndex: Integer);
|
||
begin
|
||
try
|
||
frmZDYHelp:=TfrmZDYHelp.Create(Application);
|
||
with frmZDYHelp do
|
||
begin
|
||
//flag:='RKPlace';
|
||
flagname:='<27>ӹ<EFBFBD><D3B9><EFBFBD>';
|
||
flag:='FactoryNo1Name';
|
||
MainType:='Ⱦ<><C8BE>';
|
||
if ShowModal=1 then
|
||
begin
|
||
ClientDataSet3.Edit;
|
||
ClientDataSet3.FieldByName('ToName').Value:=Trim(frmZDYHelp.ClientDataSet1.fieldbyname('ZDYName').AsString);
|
||
ClientDataSet3.FieldByName('ToNo').Value:=Trim(frmZDYHelp.ClientDataSet1.fieldbyname('ZDYNo').AsString);
|
||
end;
|
||
end;
|
||
finally
|
||
frmZDYHelp.Free;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmClothContractListLL.v3Column13PropertiesButtonClick(
|
||
Sender: TObject; AButtonIndex: Integer);
|
||
begin
|
||
try
|
||
frmZDYHelp:=TfrmZDYHelp.Create(Application);
|
||
with frmZDYHelp do
|
||
begin
|
||
flag:='OrdColor';
|
||
flagname:='<27><>ɫ';
|
||
V1Name.Caption:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
|
||
V1Note.Caption:='Ӣ<><D3A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
|
||
MainType:=Trim(DName);
|
||
// fnote:=True;
|
||
if ShowModal=1 then
|
||
begin
|
||
Self.ClientDataSet3.Edit;
|
||
Self.ClientDataSet3.FieldByName('C_color').Value:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString)+'#';;
|
||
// Self.CDS_Sub.FieldByName('SOrddefstr4').Value:=Trim(ClientDataSet1.fieldbyname('Note').AsString);
|
||
end;
|
||
end;
|
||
finally
|
||
frmZDYHelp.Free;
|
||
end;
|
||
self.tv3.Controller.EditingController.ShowEdit();
|
||
end;
|
||
|
||
procedure TfrmClothContractListLL.v3Column13PropertiesEditValueChanged(
|
||
Sender: TObject);
|
||
var
|
||
mvalue:string;
|
||
begin
|
||
mvalue:=TcxTextEdit(Sender).EditingText;
|
||
|
||
IF trim(mvalue)='' then exit;
|
||
|
||
IF rightBstr(trim(mvalue),1)<>'#'THEN
|
||
BEGIn
|
||
mvalue:=trim(mvalue)+'#';
|
||
END;
|
||
|
||
|
||
with ClientDataSet3 do
|
||
begin
|
||
Edit;
|
||
FieldByName('C_Color').Value:=Trim(mvalue);
|
||
Post;
|
||
end;
|
||
self.tv3.Controller.EditingController.ShowEdit();
|
||
end;
|
||
|
||
end.
|