D7wmguihua/桂华管理系统/U_CpRkSaoMNew.pas
DESKTOP-E401PHE\Administrator b4b5840f18 1
2025-01-18 16:22:10 +08:00

920 lines
35 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_CpRkSaoMNew;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData,
cxDataStorage, cxEdit, DB, cxDBData, StdCtrls, ExtCtrls, ADODB, DBClient,
cxGridCustomPopupMenu, cxGridPopupMenu, cxGridLevel,
cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxClasses,
cxControls, cxGridCustomView, cxGrid, MovePanel, cxCheckBox, Menus,
ComCtrls, BtnEdit;
type
TfrmCpRkSaoMNew = class(TForm)
cxGrid2: TcxGrid;
Tv1: TcxGridDBTableView;
v1Column1: TcxGridDBColumn;
v2Column5: TcxGridDBColumn;
v2Column6: TcxGridDBColumn;
cxGrid2Level1: TcxGridLevel;
cxGridPopupMenu1: TcxGridPopupMenu;
CDS_Main: TClientDataSet;
DataSource1: TDataSource;
ADOQueryTemp: TADOQuery;
ADOQueryCmd: TADOQuery;
ADOQueryMain: TADOQuery;
Panel1: TPanel;
BaoID: TEdit;
Label1: TLabel;
v1Column5: TcxGridDBColumn;
Button2: TButton;
Button3: TButton;
CDS_Sub: TClientDataSet;
DataSource2: TDataSource;
ADOQuerySub: TADOQuery;
cxGridPopupMenu2: TcxGridPopupMenu;
cxGridPopupMenu3: TcxGridPopupMenu;
cxGrid3: TcxGrid;
Tv3: TcxGridDBTableView;
cxGridDBColumn1: TcxGridDBColumn;
cxGridDBColumn4: TcxGridDBColumn;
cxGridDBColumn6: TcxGridDBColumn;
cxGridLevel1: TcxGridLevel;
DS_MainSel: TDataSource;
CDS_MainSel: TClientDataSet;
v3Column1: TcxGridDBColumn;
Button1: TButton;
cxGridPopupMenu4: TcxGridPopupMenu;
MovePanel1: TMovePanel;
Edit1: TEdit;
Edit2: TEdit;
Label2: TLabel;
Label3: TLabel;
Button4: TButton;
cxGrid1: TcxGrid;
Tv2: TcxGridDBTableView;
v1OrderNo: TcxGridDBColumn;
v2Column2: TcxGridDBColumn;
v1Column10: TcxGridDBColumn;
v1Column14: TcxGridDBColumn;
cxGridDBColumn3: TcxGridDBColumn;
cxGrid1Level1: TcxGridLevel;
v1Column2: TcxGridDBColumn;
v3Column2: TcxGridDBColumn;
v1Column3: TcxGridDBColumn;
v1Column4: TcxGridDBColumn;
v3Column3: TcxGridDBColumn;
v3Column4: TcxGridDBColumn;
v1Column6: TcxGridDBColumn;
v3Column5: TcxGridDBColumn;
Button5: TButton;
v1Column7: TcxGridDBColumn;
v3Column6: TcxGridDBColumn;
PopupMenu1: TPopupMenu;
N1: TMenuItem;
N2: TMenuItem;
PopupMenu2: TPopupMenu;
MenuItem1: TMenuItem;
MenuItem2: TMenuItem;
MovePanel2: TMovePanel;
CRTime: TDateTimePicker;
Label4: TLabel;
v1RollNum: TcxGridDBColumn;
v3RollNum: TcxGridDBColumn;
kcKw: TBtnEditA;
Label5: TLabel;
v2Column1: TcxGridDBColumn;
v2Aorddefstr1: TcxGridDBColumn;
v2Column3: TcxGridDBColumn;
v2Column4: TcxGridDBColumn;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormDestroy(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure BaoIDKeyPress(Sender: TObject; var Key: Char);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Tv2CellDblClick(Sender: TcxCustomGridTableView;
ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
AShift: TShiftState; var AHandled: Boolean);
procedure Button4Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure N1Click(Sender: TObject);
procedure N2Click(Sender: TObject);
procedure MenuItem1Click(Sender: TObject);
procedure MenuItem2Click(Sender: TObject);
procedure kcKwBtnClick(Sender: TObject);
private
{ Private declarations }
procedure InitGrid();
procedure InitSubGrid();
procedure SavedataCK();
public
{ Public declarations }
end;
var
frmCpRkSaoMNew: TfrmCpRkSaoMNew;
implementation
uses
U_DataLink,U_Fun,U_OrderSelRK , U_PbSelRK, U_ZDYHelp;
{$R *.dfm}
procedure TfrmCpRkSaoMNew.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
Action:=caFree;
end;
procedure TfrmCpRkSaoMNew.FormDestroy(Sender: TObject);
begin
frmCpRkSaoMNew:=nil;
end;
procedure TfrmCpRkSaoMNew.InitGrid();
begin
try
ADOQueryMain.DisableControls;
with ADOQueryMain do
begin
Filtered:=False;
Close;
sql.Clear;
SQL.Add('select A.*,OrderNo=(select OrderNo from JYOrder_Main where MainId=A.MainId) ');
SQL.Add(',PRTColor=(select PRTColor from JYOrder_Sub where SubId=A.SubId)');
sql.Add(',gangNO=(select gangNO from JYOrder_Sub_AnPai where ApId=A.ApId)');
sql.Add(',AOrdDefstr1=(select AOrdDefstr1 from JYOrder_Sub_AnPai where ApId=A.ApId)');
sql.Add(',MJXH=(select MJXH from WFB_MJJY where MJID=A.MJID)');
sql.Add('from CK_BanCP_CR A');
sql.add('where 1<>1');
Open;
end;
SCreateCDS20(ADOQueryMain,CDS_Main);
SInitCDSData20(ADOQueryMain,CDS_Main);
with ADOQueryMain do
begin
Filtered:=False;
Close;
sql.Clear;
SQL.Add('select A.*,OrderNo=(select OrderNo from JYOrder_Main where MainId=A.MainId) ');
SQL.Add(',PRTColor=(select PRTColor from JYOrder_Sub where SubId=A.SubId)');
sql.Add(',gangNO=(select gangNO from JYOrder_Sub_AnPai where ApId=A.ApId)');
sql.Add(',AOrdDefstr1=(select AOrdDefstr1 from JYOrder_Sub_AnPai where ApId=A.ApId)');
sql.Add(',MJXH=(select MJXH from WFB_MJJY where MJID=A.MJID)');
sql.Add('from CK_BanCP_CR A');
sql.add('where 1<>1');
Open;
end;
SCreateCDS20(ADOQueryMain,CDS_MainSel);
SInitCDSData20(ADOQueryMain,CDS_MainSel);
finally
ADOQueryMain.EnableControls;
end;
end;
procedure TfrmCpRkSaoMNew.FormShow(Sender: TObject);
begin
ReadCxGrid('<27><><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>',Tv2,'<27><>Ʒ<EFBFBD>ֿ<EFBFBD>');
ReadCxGrid('<27><>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD>',Tv1,'<27><>Ʒ<EFBFBD>ֿ<EFBFBD>');
ReadCxGrid('<27><>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD>Sels',Tv3,'<27><>Ʒ<EFBFBD>ֿ<EFBFBD>');
InitSubGrid();
InitGrid();
CRTime.DateTime:=SGetServerDate(ADOQueryTemp);
end;
procedure TfrmCpRkSaoMNew.BaoIDKeyPress(Sender: TObject; var Key: Char);
var
maxno:String;
CRID:Integer;
MaxCkNo,MaxCkSubNo:String;
begin
if Key=#13 then
begin
if CDS_Sub.IsEmpty then
begin
BaoID.Text:='';
Application.MessageBox(ѡ<CEB4><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɨ<EFBFBD><C9A8><EFBFBD><EFBFBD><EFBFBD>⣡','<27><>ʾ',0);
Exit;
end;
if CDS_Main.Locate('MJId',Trim(BaoID.Text),[])=False then
begin
BaoID.Text:='';
//Application.MessageBox('<27>˾<EFBFBD><CBBE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ľ<EFBFBD><C4BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD>','<27><>ʾ',0);
Exit;
end;
CDS_Main.Locate('MJId',Trim(BaoID.Text),[]);
try
ADOQueryCmd.Connection.BeginTrans;
with CDS_Main do
begin
with ADOQueryCmd do
begin
Close;
sql.Clear;
SQL.add('Update CK_BanCP_CRID Set CRID=CRID+1');
sql.Add('select * from CK_BanCP_CRID');
Open;
end;
CRID:=ADOQueryCmd.fieldbyname('CRID').Value;
if GetLSNo(ADOQueryCmd,MaxCkNo,'JR','CK_BanCP_CR',5,1)=False then
begin
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox(<><C8A1>Ʒ<EFBFBD>ֿ<EFBFBD><D6BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>','<27><>ʾ',0);
Exit;
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('select * from CK_BanCP_CR where 1<>1');
Open;
end;
with ADOQueryCmd do
begin
Append;
FieldByName('MainId').Value:=Trim(CDS_Main.fieldbyname('MainId').AsString);
FieldByName('SubId').Value:=Trim(CDS_Main.fieldbyname('SubId').AsString);
FieldByName('C_Code').Value:=Trim(CDS_Main.fieldbyname('C_Code').AsString);
FieldByName('C_CodeName').Value:=Trim(CDS_Main.fieldbyname('C_CodeName').AsString);
FieldByName('C_SPec').Value:=Trim(CDS_Main.fieldbyname('C_SPec').AsString);
FieldByName('C_Color').Value:=Trim(CDS_Main.fieldbyname('PRTColor').AsString);
FieldByName('APID').Value:=Trim(CDS_Main.fieldbyname('APID').AsString);
FieldByName('MJID').Value:=Trim(CDS_Main.fieldbyname('MJId').AsString);
FieldByName('mjxh').Value:=Trim(CDS_Main.fieldbyname('mjxh').AsString);
FieldByName('BCGangNO').Value:=Trim(CDS_Main.fieldbyname('AOrddefstr1').AsString);
FieldByName('RCGangNO').Value:=Trim(CDS_Main.fieldbyname('GangNo').AsString);
FieldByName('BCID').Value:=Trim(MaxCkNo);
FieldByName('CRTime').Value:=FormatDateTime('yyyy-MM-dd',SGetServerDateTime(ADOQueryTemp));
FieldByName('CRFlag').Value:='<27><><EFBFBD><EFBFBD>';
FieldByName('CRType').Value:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
//FieldByName('JTType').Value:=Trim(XJFlag);
FieldByName('CRID').Value:=CRID;
FieldByName('KGQty').Value:=CDS_Main.fieldbyname('KGQty').Value;
FieldByName('RollNum').Value:=CDS_Main.fieldbyname('RollNum').Value;
FieldByName('Qty').Value:=CDS_Main.fieldbyname('Qty').Value;
FieldByName('QtyUnit').Value:=CDS_Main.fieldbyname('QtyUnit').Value;
FieldByName('CPType').Value:=CDS_Main.fieldbyname('CPType').Value;
FieldByName('Filler').Value:=Trim(DName);
FieldByName('FillTime').Value:=SGetServerDateTime(ADOQueryTemp);
FieldByName('kcKw').Value:=Trim(kcKw.Text);
Post;
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('select * from CK_BanCP_KC where 1<>1');
Open;
end;
with ADOQueryCmd do
begin
Append;
FieldByName('CRID').Value:=CRID;
FieldByName('BCID').Value:=Trim(MaxCkNo);
FieldByName('CRTime').Value:=FormatDateTime('yyyy-MM-dd',SGetServerDateTime(ADOQueryTemp));
FieldByName('CRType').Value:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
FieldByName('CPType').Value:=CDS_Main.fieldbyname('CPType').Value;
FieldByName('C_Code').Value:=Trim(CDS_Main.fieldbyname('C_Code').AsString);
FieldByName('C_CodeName').Value:=Trim(CDS_Main.fieldbyname('C_CodeName').AsString);
FieldByName('C_SPec').Value:=Trim(CDS_Main.fieldbyname('C_SPec').AsString);
FieldByName('C_Color').Value:=Trim(CDS_Main.fieldbyname('PRTColor').AsString);
FieldByName('BCGangNO').Value:=Trim(CDS_Main.fieldbyname('AOrddefstr1').AsString);
FieldByName('RCGangNO').Value:=Trim(CDS_Main.fieldbyname('GangNo').AsString);
FieldByName('MJID').Value:=Trim(CDS_Main.fieldbyname('MJID').AsString);
FieldByName('KCKGQty').Value:=CDS_Main.fieldbyname('KGQty').Value;
FieldByName('KCQty').Value:=CDS_Main.fieldbyname('Qty').Value;
FieldByName('KCRollNum').Value:=CDS_Main.fieldbyname('RollNum').Value;
FieldByName('KCQtyUnit').Value:=CDS_Main.fieldbyname('QtyUnit').Value;
FieldByName('mjxh').Value:=Trim(CDS_Main.fieldbyname('mjxh').AsString);
FieldByName('KCNote').Value:=CDS_Main.fieldbyname('Note').Value;
FieldByName('kcKw').Value:=Trim(kcKw.Text);
Post;
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('Update WFB_MJJY Set MJStr2=''<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'' where MJID='''+Trim(CDS_Main.fieldbyname('MJID').AsString)+'''');
ExecSQL;
end;
end;
ADOQueryCmd.Connection.CommitTrans;
with CDS_MainSel do
begin
Append;
FieldByName('MainId').Value:=CDS_Main.fieldbyname('MainId').Value;
FieldByName('SubId').Value:=Self.CDS_Main.fieldbyname('SubId').Value;
FieldByName('OrderNo').Value:=Self.CDS_Main.fieldbyname('OrderNo').Value;
FieldByName('KGQty').Value:=Self.CDS_Main.fieldbyname('KGQty').Value;
FieldByName('Qty').Value:=Self.CDS_Main.fieldbyname('Qty').Value;
FieldByName('QtyUnit').Value:=Self.CDS_Main.fieldbyname('QtyUnit').Value;
FieldByName('MJId').Value:=Self.CDS_Main.fieldbyname('MJId').Value;
FieldByName('CRId').Value:=IntToStr(CRID);
FieldByName('APID').Value:=Self.CDS_Main.fieldbyname('APID').Value;
FieldByName('CPType').Value:=CDS_Main.fieldbyname('CPType').Value;
FieldByName('BCID').Value:=Trim(MaxCkNo);
FieldByName('C_CodeName').Value:=Self.CDS_Main.fieldbyname('C_CodeName').Value;
FieldByName('PRTColor').Value:=Self.CDS_Main.fieldbyname('PRTColor').Value;
FieldByName('MJXH').Value:=Self.CDS_Main.fieldbyname('MJXH').Value;
FieldByName('AOrdDefstr1').Value:=CDS_Main.fieldbyname('AOrdDefstr1').Value;
FieldByName('gangNO').Value:=CDS_Main.fieldbyname('gangNO').Value;
//FieldByName('JZXNo').Value:=Trim(JZXNo.Text);
Post;
end;
CDS_Main.Delete;
MovePanel1.Visible:=True;
if CDS_MainSel.IsEmpty=False then
Edit1.Text:=IntToStr(Tv3.DataController.Summary.FooterSummaryValues[2])
else
Edit1.Text:='0';
Edit2.Text:=Trim(BaoID.Text);
BaoID.Text:='';
Exit;
except
BaoID.Text:='';
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><ECB3A3>','<27><>ʾ',0);
end;
end;
end;
procedure TfrmCpRkSaoMNew.SavedataCK();
var
CRID:Integer;
MaxCkNo,MaxCkSubNo:String;
begin
//if Trim(Cds_Main.fieldbyname('SubType').AsString)='<27><><EFBFBD><EFBFBD>' then
//////////////////////////////////////////////////////////////<2F><><EFBFBD><EFBFBD><E6B5BD><EFBFBD><EFBFBD>Ʒ<EFBFBD>ֿ<EFBFBD>////////////////////////////////////////////////
with ADOQueryCmd do
begin
Close;
sql.Clear;
SQL.add('Update CK_BanCP_CRID Set CRID=CRID+1');
sql.Add('select * from CK_BanCP_CRID');
Open;
end;
CRID:=ADOQueryCmd.fieldbyname('CRID').Value;
if GetLSNo(ADOQueryCmd,MaxCkNo,'JR','CK_BanCP_CR',4,1)=False then
begin
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox(<><C8A1>Ʒ<EFBFBD>ֿ<EFBFBD><D6BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>','<27><>ʾ',0);
Exit;
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('select * from CK_BanCP_CR where 1<>1');
Open;
end;
with ADOQueryCmd do
begin
Append;
FieldByName('MainId').Value:=Trim(CDS_Main.fieldbyname('MainId').AsString);
FieldByName('SubId').Value:=Trim(CDS_Main.fieldbyname('SubId').AsString);
FieldByName('APID').Value:=Trim(CDS_Main.fieldbyname('APID').AsString);
FieldByName('MJID').Value:=Trim(CDS_Main.fieldbyname('MJId').AsString);
FieldByName('BCID').Value:=Trim(MaxCkNo);
FieldByName('CRTime').Value:=SGetServerDateTime(ADOQueryTemp);
FieldByName('CRFlag').Value:='<27><><EFBFBD><EFBFBD>';
FieldByName('CRType').Value:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
//FieldByName('JTType').Value:=Trim(XJFlag);
FieldByName('CRID').Value:=CRID;
FieldByName('KGQty').Value:=CDS_Main.fieldbyname('KGQty').Value;
FieldByName('Qty').Value:=CDS_Main.fieldbyname('Qty').Value;
FieldByName('QtyUnit').Value:=CDS_Main.fieldbyname('QtyUnit').Value;
FieldByName('CPType').Value:=CDS_Main.fieldbyname('CPType').Value;
FieldByName('Filler').Value:=Trim(DName);
FieldByName('FillTime').Value:=SGetServerDateTime(ADOQueryTemp);
Post;
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('select * from CK_BanCP_KC where 1<>1');
Open;
end;
with ADOQueryCmd do
begin
Append;
FieldByName('CRID').Value:=CRID;
FieldByName('BCID').Value:=Trim(MaxCkNo);
FieldByName('MJID').Value:=Trim(CDS_Main.fieldbyname('MJID').AsString);
FieldByName('KCKGQty').Value:=CDS_Main.fieldbyname('KGQty').Value;
FieldByName('KCQty').Value:=CDS_Main.fieldbyname('Qty').Value;
FieldByName('KCQtyUnit').Value:=CDS_Main.fieldbyname('QtyUnit').Value;
Post;
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('Update WFB_MJJY Set MJStr2=''<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'' where MJID='''+Trim(CDS_Main.fieldbyname('MJID').AsString)+'''');
ExecSQL;
end;
end;
procedure TfrmCpRkSaoMNew.Button2Click(Sender: TObject);
begin
Close;
WriteCxGrid('<27><><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>',Tv2,'<27><>Ʒ<EFBFBD>ֿ<EFBFBD>');
WriteCxGrid('<27><>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD>',Tv1,'<27><>Ʒ<EFBFBD>ֿ<EFBFBD>');
WriteCxGrid('<27><>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD>Sels',Tv3,'<27><>Ʒ<EFBFBD>ֿ<EFBFBD>');
end;
procedure TfrmCpRkSaoMNew.Button3Click(Sender: TObject);
begin
{if CDS_Main.IsEmpty=False then
begin
Application.MessageBox('<27><>ɨ<EFBFBD><EFBFBD>ܸ<EFBFBD><DCB8>ĵ<EFBFBD><C4B5>ţ<EFBFBD>','<27><>ʾ',0);
Exit;
end;}
CDS_Sub.EmptyDataSet;
CDS_Main.EmptyDataSet;
CDS_Main.DisableControls;
try
frmPbSelRK:=TfrmPbSelRK.Create(Application);
with frmPbSelRK do
begin
if ShowModal=1 then
begin
CDS_OrderSel.DisableControls;
with CDS_OrderSel do
begin
First;
while not Eof do
begin
if FieldByName('SSel').Value=True then
begin
if Self.CDS_Sub.Locate('APID',Trim(CDS_OrderSel.fieldbyname('APID').AsString),[])=False then
begin
with Self.CDS_Sub do
begin
Append;
FieldByName('MainId').Value:=Trim(CDS_OrderSel.fieldbyname('MainId').AsString);
FieldByName('SubId').Value:=Trim(CDS_OrderSel.fieldbyname('SubId').AsString);
FieldByName('APID').Value:=Trim(CDS_OrderSel.fieldbyname('APID').AsString);
// FieldByName('CustomerNo').Value:=Trim(CDS_OrderSel.fieldbyname('CustomerNo').AsString);
FieldByName('conNO').Value:=Trim(CDS_OrderSel.fieldbyname('conNO').AsString);
FieldByName('Aorddefstr4').Value:=Trim(CDS_OrderSel.fieldbyname('Aorddefstr4').AsString);
FieldByName('C_CodeName').Value:=Trim(CDS_OrderSel.fieldbyname('C_CodeName').AsString);
FieldByName('AOrdQty2').Value:=Trim(CDS_OrderSel.fieldbyname('AOrdQty2').AsString);
FieldByName('AOrdQty1').Value:=Trim(CDS_OrderSel.fieldbyname('AOrdQty1').AsString);
FieldByName('C_Color').Value:=Trim(CDS_OrderSel.fieldbyname('C_Color').AsString);
FieldByName('ZPPS').Value:=Trim(CDS_OrderSel.fieldbyname('ZPPS').AsString);
FieldByName('ZPQty').Value:=Trim(CDS_OrderSel.fieldbyname('ZPQty').AsString);
// FieldByName('MPRTMF').Value:=Trim(CDS_OrderSel.fieldbyname('MPRTMF').AsString);
// FieldByName('MPRTKZ').Value:=Trim(CDS_OrderSel.fieldbyname('MPRTKZ').AsString);
Post;
end;
end;
end;
Next;
end;
end;
CDS_OrderSel.EnableControls;
CDS_Sub.DisableControls;
with CDS_Sub do
begin
First;
while not Eof do
begin
if Trim(Self.CDS_Sub.fieldbyname('SFlag').AsString)<>'2' then
begin
with Self.ADOQueryTemp do
begin
Close;
SQL.Clear;
sql.Add('select orderNo=A.conNO');
sql.Add(',A.C_Color,A.C_Code,A.C_CodeName,A.C_spec ');
sql.Add(',AOrdDefStr1=A.BCgangNO');
sql.Add(',gangNO=A.BcgangNO,A.* ');
sql.Add(' from WFB_MJJY A ');
// sql.Add(' inner join Contract_Sub C on C.MainId=A.mainID and C.SubId=A.subID ');
sql.Add(' where A.APID='''+Trim(CDS_Sub.fieldbyname('APID').AsString)+'''');
SQL.Add(' and A.SubId='''+Trim(CDS_Sub.fieldbyname('SubId').AsString)+'''');
SQL.Add(' and A.C_CodeName='''+Trim(CDS_Sub.fieldbyname('C_CodeName').AsString)+'''');
SQL.Add(' and A.C_Color='''+Trim(CDS_Sub.fieldbyname('C_Color').AsString)+'''');
sql.Add(' and isnull(A.MJStr2,'''')<>''<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'' and A.MJLen<>0 ');
Open;
end;
Self.ADOQueryTemp.DisableControls;
with Self.ADOQueryTemp do
begin
First;
while not Eof do
begin
with CDS_Main do
begin
Append;
FieldByName('MainId').Value:=Self.ADOQueryTemp.fieldbyname('MainId').Value;
FieldByName('SubId').Value:=Self.ADOQueryTemp.fieldbyname('SubId').Value;
FieldByName('C_Code').Value:=Self.ADOQueryTemp.fieldbyname('C_Code').Value;
FieldByName('C_CodeName').Value:=Self.ADOQueryTemp.fieldbyname('C_CodeName').Value;
FieldByName('C_Spec').Value:=Self.ADOQueryTemp.fieldbyname('C_Spec').Value;
// FieldByName('SubId').Value:=Self.ADOQueryTemp.fieldbyname('SubId').Value;
FieldByName('APId').Value:=Self.ADOQueryTemp.fieldbyname('APId').Value;
FieldByName('OrderNo').Value:=Self.ADOQueryTemp.fieldbyname('OrderNo').Value;
FieldByName('KgQty').Value:=Self.ADOQueryTemp.fieldbyname('MJMaoZ').Value;
FieldByName('RollNum').Value:=1;
FieldByName('Qty').Value:=Self.ADOQueryTemp.fieldbyname('MJLen').Value;
FieldByName('QtyUnit').Value:=Self.ADOQueryTemp.fieldbyname('MJTypeOther').Value;
FieldByName('MJId').Value:=Self.ADOQueryTemp.fieldbyname('MJId').Value;
FieldByName('CPType').Value:=Self.ADOQueryTemp.fieldbyname('MJType').Value;
FieldByName('PRTColor').Value:=Self.ADOQueryTemp.fieldbyname('C_Color').Value;
FieldByName('AOrddefstr1').Value:=Self.ADOQueryTemp.fieldbyname('AOrddefstr1').Value;
FieldByName('Note').Value:=Self.ADOQueryTemp.fieldbyname('note').Value;
FieldByName('gangNO').Value:=Self.ADOQueryTemp.fieldbyname('gangNO').Value;
FieldByName('MJXH').Value:=Self.ADOQueryTemp.fieldbyname('MJXH').Value;
Post;
end;
Next;
end;
end;
Self.ADOQueryTemp.EnableControls;
end;
CDS_Sub.Edit;
CDS_Sub.FieldByName('SFlag').Value:='2';
CDS_Sub.Post;
Next;
end;
end;
CDS_Sub.EnableControls;
end;
end;
finally
frmPbSelRK.Free;
CDS_Main.EnableControls;
end;
end;
procedure TfrmCpRkSaoMNew.InitSubGrid();
begin
try
ADOQuerySub.DisableControls;
with ADOQuerySub do
begin
Close;
sql.Clear;
sql.Add('select A.*,ZPPS=0.00,ZPQty=0.00 ');
sql.Add(' from JYOrder_Sub_AnPai A inner join Contract_sub B on A.MainId=B.Mainid');
sql.Add(' where 1<>1 ');
Open;
end;
SCreateCDS20(ADOQuerySub,CDS_Sub);
SInitCDSData20(ADOQuerySub,CDS_Sub);
finally
ADOQuerySub.EnableControls;
end;
end;
procedure TfrmCpRkSaoMNew.Button1Click(Sender: TObject);
begin
if CDS_MainSel.IsEmpty then Exit;
if CDS_MainSel.Locate('SSel',True,[])=False then
begin
Application.MessageBox(<><C3BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!','<27><>ʾ',0);
Exit;
end;
if Application.MessageBox(<><C8B7>Ҫִ<D2AA>д˲<D0B4><CBB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>','<27><>ʾ',32+4)<>IDYES then Exit;
MovePanel2.Visible:=True;
MovePanel2.Refresh;
try
ADOQueryCmd.Connection.BeginTrans;
CDS_MainSel.DisableControls;
with CDS_MainSel do
begin
First;
while not Eof do
begin
if CDS_MainSel.FieldByName('SSel').AsBoolean=True then
begin
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('delete CK_BanCP_CR where BCID='''+Trim(CDS_MainSel.fieldbyname('BCID').AsString)+'''');
sql.Add('delete CK_BanCP_KC where CRID='+Trim(CDS_MainSel.fieldbyname('CRID').AsString));
sql.Add('Update WFB_MJJY Set MJStr2='<><CEB4><EFBFBD><EFBFBD>'' where MJID='''+Trim(CDS_MainSel.fieldbyname('MJID').AsString)+'''');
ExecSQL;
end;
with CDS_Main do
begin
Append;
FieldByName('MainId').Value:=CDS_MainSel.fieldbyname('MainId').Value;
FieldByName('SubId').Value:=Self.CDS_MainSel.fieldbyname('SubId').Value;
FieldByName('OrderNo').Value:=Self.CDS_MainSel.fieldbyname('OrderNo').Value;
FieldByName('KgQty').Value:=Self.CDS_MainSel.fieldbyname('KgQty').Value;
FieldByName('Qty').Value:=Self.CDS_MainSel.fieldbyname('Qty').Value;
FieldByName('QtyUnit').Value:=Self.CDS_MainSel.fieldbyname('QtyUnit').Value;
FieldByName('MJId').Value:=Self.CDS_MainSel.fieldbyname('MJId').Value;
FieldByName('APID').Value:=Self.CDS_MainSel.fieldbyname('APID').Value;
FieldByName('CPType').Value:=Self.CDS_MainSel.fieldbyname('CPType').Value;
FieldByName('PRTColor').Value:=Self.CDS_MainSel.fieldbyname('PRTColor').Value;
FieldByName('C_CodeName').Value:=Self.CDS_MainSel.fieldbyname('C_CodeName').Value;
FieldByName('AOrddefstr1').Value:=Self.CDS_MainSel.fieldbyname('AOrddefstr1').Value;
FieldByName('MJXH').Value:=Self.CDS_MainSel.fieldbyname('MJXH').Value;
FieldByName('gangNO').Value:=CDS_Main.fieldbyname('gangNO').Value;
Post;
end;
CDS_MainSel.Delete;
end else
Next;
end;
end;
CDS_MainSel.EnableControls;
ADOQueryCmd.Connection.CommitTrans;
MovePanel2.Visible:=False;
{MovePanel1.Visible:=True;
if CDS_MainSel.IsEmpty=False then
Edit1.Text:=IntToStr(Tv3.DataController.Summary.FooterSummaryValues[2])
else
Edit1.Text:='0';
Edit2.Text:=Trim(CDS_Main.fieldbyname('MJId').AsString); }
except
MovePanel2.Visible:=False;
CDS_MainSel.DisableControls;
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD>','<27><>ʾ',0);
end;
end;
procedure TfrmCpRkSaoMNew.Tv2CellDblClick(Sender: TcxCustomGridTableView;
ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
AShift: TShiftState; var AHandled: Boolean);
begin
// if CDS_MainSel.IsEmpty=False then Exit;
if CDS_Sub.IsEmpty then Exit;
if Application.MessageBox(<><C8B7>Ҫɾ<D2AA><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>','<27><>ʾ',32+4)<>IDYES then Exit;
CDS_Main.DisableControls;
with CDS_Main do
begin
First;
while not Eof do
begin
if Trim(CDS_Main.fieldbyname('SubId').AsString)=Trim(CDS_Sub.fieldbyname('SubId').AsString) then
begin
CDS_Main.Delete;
end else
Next;
end;
end;
CDS_Main.EnableControls;
CDS_Sub.Delete;
end;
procedure TfrmCpRkSaoMNew.Button4Click(Sender: TObject);
begin
MovePanel1.Visible:=False;
end;
procedure TfrmCpRkSaoMNew.Button5Click(Sender: TObject);
var
maxno:String;
CRID:Integer;
MaxCkNo,MaxCkSubNo:String;
MhcTime:TdateTime;
begin
if CDS_Sub.IsEmpty then Exit;
if CDS_Main.Locate('SSel',True,[])=False then
begin
Application.MessageBox(<><C3BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!','<27><>ʾ',0);
Exit;
end;
if Application.MessageBox(<><C8B7>Ҫִ<D2AA><D6B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>','<27><>ʾ',32+4)<>IDYES then exit;
MovePanel2.Visible:=True;
MovePanel2.Refresh;
try
ADOQueryCmd.Connection.BeginTrans;
CDS_Main.DisableControls;
with CDS_Main do
begin
First;
while not Eof do
begin
if CDS_Main.FieldByName('SSel').AsBoolean=True then
begin
with ADOQueryTemp do
begin
close;
sql.Clear;
sql.Add('select * from WFB_MJJY ');
sql.Add(' where MJID='+quotedstr(trim(CDS_Main.fieldbyname('MJID').AsString)));
sql.Add(' and mjstr2=''<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'' ');
open;
IF not ADOQueryTemp.IsEmpty then
begin
application.MessageBox('<27>˲<EFBFBD>ƥ<EFBFBD><C6A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E2A3AC><EFBFBD><EFBFBD><EFBFBD>ٴ<EFBFBD><D9B4><EFBFBD><EFBFBD>⣡','<27><>ʾ<EFBFBD><CABE>Ϣ',MB_ICOnerror);
CDS_Main.EnableControls;
MovePanel2.Visible:=false;
MovePanel2.Refresh;
exit;
end;
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
SQL.add('Update CK_BanCP_CRID Set CRID=CRID+1');
sql.Add('select * from CK_BanCP_CRID');
Open;
end;
CRID:=ADOQueryCmd.fieldbyname('CRID').AsInteger;
if GetLSNo(ADOQueryCmd,MaxCkNo,'JR','CK_BanCP_CR',5,1)=False then
begin
MovePanel2.Visible:=False;
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox(<><C8A1>Ʒ<EFBFBD>ֿ<EFBFBD><D6BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>','<27><>ʾ',0);
Exit;
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('select * from CK_BanCP_CR where 1<>1');
Open;
end;
with ADOQueryTemp do
begin
close;
sql.Clear;
sql.Add('select * from JYOrder_Sub_AnPai ');
sql.Add(' where APID='+quotedstr(trim(CDS_Main.fieldbyname('APID').AsString)));
open;
IF not ADOQueryTemp.IsEmpty then
begin
mhcTime:=ADOQueryTemp.fieldbyname('ADefDate1').AsDateTime;
end
else
begin
mhcTime:=CRTime.DateTime;
end;
end;
with ADOQueryCmd do
begin
Append;
FieldByName('MainId').Value:=Trim(CDS_Main.fieldbyname('MainId').AsString);
FieldByName('SubId').Value:=Trim(CDS_Main.fieldbyname('SubId').AsString);
FieldByName('C_Code').Value:=Trim(CDS_Main.fieldbyname('C_Code').AsString);
FieldByName('C_CodeName').Value:=Trim(CDS_Main.fieldbyname('C_CodeName').AsString);
FieldByName('C_SPec').Value:=Trim(CDS_Main.fieldbyname('C_SPec').AsString);
FieldByName('C_Color').Value:=Trim(CDS_Main.fieldbyname('PRTColor').AsString);
FieldByName('APID').Value:=Trim(CDS_Main.fieldbyname('APID').AsString);
FieldByName('MJID').Value:=Trim(CDS_Main.fieldbyname('MJId').AsString);
FieldByName('mjxh').Value:=Trim(CDS_Main.fieldbyname('mjxh').AsString);
FieldByName('BCGangNO').Value:=Trim(CDS_Main.fieldbyname('AOrddefstr1').AsString);
FieldByName('RCGangNO').Value:=Trim(CDS_Main.fieldbyname('GangNo').AsString);
FieldByName('BCID').Value:=Trim(MaxCkNo);
FieldByName('CRTime').Value:=FormatDateTime('yyyy-MM-dd',SGetServerDateTime(ADOQueryTemp));
FieldByName('CRFlag').Value:='<27><><EFBFBD><EFBFBD>';
FieldByName('CRType').Value:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
//FieldByName('JTType').Value:=Trim(XJFlag);
FieldByName('CRID').Value:=CRID;
FieldByName('KGQty').Value:=CDS_Main.fieldbyname('KGQty').Value;
FieldByName('Qty').Value:=CDS_Main.fieldbyname('Qty').Value;
FieldByName('RollNum').Value:=CDS_Main.fieldbyname('RollNum').Value;
FieldByName('QtyUnit').Value:=CDS_Main.fieldbyname('QtyUnit').Value;
FieldByName('CPType').Value:=CDS_Main.fieldbyname('CPType').Value;
FieldByName('Note').Value:=CDS_Main.fieldbyname('Note').Value;
FieldByName('Filler').Value:=Trim(DName);
FieldByName('FillTime').Value:=SGetServerDateTime(ADOQueryTemp);
// FieldByName('kcKw').Value:=Trim(kcKw.Text);
fieldbyname('kcKw').Value:=GetKw(ADOQueryTemp,CDS_Main.fieldbyname('C_CodeName').AsString,CDS_Main.fieldbyname('PRTColor').AsString);
Post;
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('select * from CK_BanCP_KC where 1<>1');
Open;
end;
with ADOQueryCmd do
begin
Append;
FieldByName('CRID').Value:=CRID;
FieldByName('BCID').Value:=Trim(MaxCkNo);
FieldByName('CRTime').Value:=FormatDateTime('yyyy-MM-dd',SGetServerDateTime(ADOQueryTemp));
FieldByName('CRType').Value:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
FieldByName('CPType').Value:=CDS_Main.fieldbyname('CPType').Value;
FieldByName('C_Code').Value:=Trim(CDS_Main.fieldbyname('C_Code').AsString);
FieldByName('C_CodeName').Value:=Trim(CDS_Main.fieldbyname('C_CodeName').AsString);
FieldByName('C_SPec').Value:=Trim(CDS_Main.fieldbyname('C_SPec').AsString);
FieldByName('C_Color').Value:=Trim(CDS_Main.fieldbyname('PRTColor').AsString);
FieldByName('BCGangNO').Value:=Trim(CDS_Main.fieldbyname('AOrddefstr1').AsString);
FieldByName('RCGangNO').Value:=Trim(CDS_Main.fieldbyname('GangNo').AsString);
FieldByName('MJID').Value:=Trim(CDS_Main.fieldbyname('MJID').AsString);
FieldByName('KCKGQty').Value:=CDS_Main.fieldbyname('KGQty').Value;
FieldByName('KCQty').Value:=CDS_Main.fieldbyname('Qty').Value;
FieldByName('KCRollNum').Value:=CDS_Main.fieldbyname('RollNum').Value;
FieldByName('KCQtyUnit').Value:=CDS_Main.fieldbyname('QtyUnit').Value;
FieldByName('mjxh').Value:=Trim(CDS_Main.fieldbyname('mjxh').AsString);
FieldByName('KCNote').Value:=CDS_Main.fieldbyname('Note').Value;
// FieldByName('kcKw').Value:=Trim(kcKw.Text);
fieldbyname('kcKw').Value:=GetKw(ADOQueryTemp,CDS_Main.fieldbyname('C_CodeName').AsString,CDS_Main.fieldbyname('PRTColor').AsString);
Post;
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('Update WFB_MJJY Set MJStr2=''<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'' where MJID='''+Trim(CDS_Main.fieldbyname('MJID').AsString)+'''');
ExecSQL;
end;
CDS_MainSel.DisableControls;
with CDS_MainSel do
begin
Append;
FieldByName('MainId').Value:=CDS_Main.fieldbyname('MainId').Value;
FieldByName('SubId').Value:=Self.CDS_Main.fieldbyname('SubId').Value;
FieldByName('OrderNo').Value:=Self.CDS_Main.fieldbyname('OrderNo').Value;
FieldByName('KGQty').Value:=Self.CDS_Main.fieldbyname('KGQty').Value;
FieldByName('Qty').Value:=Self.CDS_Main.fieldbyname('Qty').Value;
FieldByName('QtyUnit').Value:=Self.CDS_Main.fieldbyname('QtyUnit').Value;
FieldByName('MJId').Value:=Self.CDS_Main.fieldbyname('MJId').Value;
FieldByName('CRId').Value:=IntToStr(CRID);
FieldByName('APID').Value:=Self.CDS_Main.fieldbyname('APID').Value;
FieldByName('CPType').Value:=CDS_Main.fieldbyname('CPType').Value;
FieldByName('BCID').Value:=Trim(MaxCkNo);
FieldByName('C_CodeName').Value:=Self.CDS_Main.fieldbyname('C_CodeName').Value;
FieldByName('PRTColor').Value:=Self.CDS_Main.fieldbyname('PRTColor').Value;
FieldByName('MJXH').Value:=Self.CDS_Main.fieldbyname('MJXH').Value;
FieldByName('AOrdDefstr1').Value:=CDS_Main.fieldbyname('AOrdDefstr1').Value;
FieldByName('gangNO').Value:=CDS_Main.fieldbyname('gangNO').Value;
//FieldByName('JZXNo').Value:=Trim(JZXNo.Text);
Post;
end;
CDS_MainSel.EnableControls;
CDS_Main.Delete;
end else
CDS_Main.Next;
end;
end;
CDS_Main.EnableControls;
ADOQueryCmd.Connection.CommitTrans;
MovePanel2.Visible:=False;
Exit;
except
BaoID.Text:='';
CDS_Main.EnableControls;
MovePanel2.Visible:=False;
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><ECB3A3>','<27><>ʾ',0);
end;
end;
procedure TfrmCpRkSaoMNew.N1Click(Sender: TObject);
begin
SelOKNo(CDS_Main,True);
end;
procedure TfrmCpRkSaoMNew.N2Click(Sender: TObject);
begin
SelOKNo(CDS_Main,False);
end;
procedure TfrmCpRkSaoMNew.MenuItem1Click(Sender: TObject);
begin
SelOKNo(CDS_MainSel,True);
end;
procedure TfrmCpRkSaoMNew.MenuItem2Click(Sender: TObject);
begin
SelOKNo(CDS_MainSel,False);
end;
procedure TfrmCpRkSaoMNew.kcKwBtnClick(Sender: TObject);
begin
try
frmZDYHelp:=TfrmZDYHelp.Create(Application);
with frmZDYHelp do
begin
flag:='CPKWFlag';
flagname:='<27><>λ<EFBFBD><CEBB>Ϣ';
V1Name.Caption:='<27><>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>';
V1Note.Caption:=<><D3A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
// MainType:=Trim(DName);
fnote:=FALSE;
if ShowModal=1 then
begin
kcKw.Text:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
end;
end;
finally
frmZDYHelp.Free;
end;
end;
end.