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

1035 lines
32 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_CPRK_Other;
interface
uses
Windows, Messages,strutils, SysUtils, Variants, cxTextEdit,Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, ComCtrls, ToolWin, StdCtrls, cxStyles, cxCustomData,
cxGraphics, cxFilter, cxData, cxDataStorage, cxEdit, DB, cxDBData,
cxButtonEdit, cxDropDownEdit, cxGridLevel, cxGridCustomTableView,
cxGridTableView, cxGridDBTableView, cxClasses, cxControls,
cxGridCustomView, cxGrid, DBClient, ADODB, BtnEdit, cxCurrencyEdit;
type
TfrmCPRK_Other = class(TForm)
ToolBar1: TToolBar;
TBSave: TToolButton;
TBClose: TToolButton;
Panel1: TPanel;
Label1: TLabel;
CRTIME: TDateTimePicker;
cxGrid1: TcxGrid;
Tv1: TcxGridDBTableView;
v1Column1: TcxGridDBColumn;
v1PRTSpec: TcxGridDBColumn;
v1PRTColor: TcxGridDBColumn;
v1PRTKZ: TcxGridDBColumn;
v1ClothQty: TcxGridDBColumn;
v1Column5: TcxGridDBColumn;
v1ClothUnit: TcxGridDBColumn;
v1Column2: TcxGridDBColumn;
v1Column3: TcxGridDBColumn;
v1money: TcxGridDBColumn;
cxGrid1Level1: TcxGridLevel;
ToolBar2: TToolBar;
ToolButton1: TToolButton;
ToolButton2: TToolButton;
ADOQueryTmp: TADOQuery;
ADOQueryCmd: TADOQuery;
DataSource1: TDataSource;
CDS_main: TClientDataSet;
v1C_Color: TcxGridDBColumn;
v1MJXH: TcxGridDBColumn;
v1MJId: TcxGridDBColumn;
Label2: TLabel;
kcKw: TBtnEditA;
Edit1: TEdit;
Label3: TLabel;
v1Column8: TcxGridDBColumn;
v1CRType: TcxGridDBColumn;
CRType: TComboBox;
Label16: TLabel;
Label4: TLabel;
CustomerNoName: TBtnEditC;
Label5: TLabel;
Edit2: TEdit;
ADOQueryTemp: TADOQuery;
Label6: TLabel;
note: TEdit;
v1Price: TcxGridDBColumn;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormDestroy(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure v1Column1PropertiesButtonClick(Sender: TObject;
AButtonIndex: Integer);
procedure ToolButton1Click(Sender: TObject);
procedure ToolButton2Click(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure TBCloseClick(Sender: TObject);
procedure TBSaveClick(Sender: TObject);
procedure v1C_ColorPropertiesButtonClick(Sender: TObject;
AButtonIndex: Integer);
procedure kcKwBtnClick(Sender: TObject);
procedure Edit1KeyPress(Sender: TObject; var Key: Char);
procedure v1Column1PropertiesEditValueChanged(Sender: TObject);
procedure v1C_ColorPropertiesEditValueChanged(Sender: TObject);
procedure CustomerNoNameBtnUpClick(Sender: TObject);
procedure CustomerNoNameBtnDnClick(Sender: TObject);
procedure Edit2KeyPress(Sender: TObject; var Key: Char);
procedure v1Column8PropertiesEditValueChanged(Sender: TObject);
procedure v1PricePropertiesEditValueChanged(Sender: TObject);
private
procedure IntGrid();
function savedate():boolean;
function YSData(crkNo:string):Boolean;
function YFData(crkNo:string):Boolean;
{ Private declarations }
public
fkeyNo:string;
fBCID:string;
fFlag:integer;
{ Public declarations }
end;
var
frmCPRK_Other: TfrmCPRK_Other;
implementation
uses
U_DataLink,U_ZDYHelp,U_Fun,U_ZDYHelpSel, U_ZdyAttachCP, U_ZdyAttachment;
{$R *.dfm}
function TfrmCPRK_Other.YFData(crkNo:string):Boolean;
var
CRID,YFID,Price,PriceUnit,OrderUnit,FComTaiTou,fYFDefFlag1,fCustomerNoName:String;
begin
Result:=False;
fYFDefFlag1:='2';
// fYFDefFlag1:='1';
fCustomerNoName:=trim(CustomerNoName.text);
// IF trim(CustomerNoName.text)='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>в<EFBFBD>'then
// fCustomerNoName:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֯';
with ADOQueryTemp do
begin
Close;
SQL.Clear;
sql.Add('select * from YF_Money_KC where FactoryName='''+trim(fCustomerNoName)+'''');
sql.Add(' and YFDefFlag1='''+trim(fYFDefFlag1)+''' ');
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 where 1<>1');
Open;
end;
with ADOQueryCmd do
begin
Append;
FieldByName('CRID').Value:=StrToInt(CRID);
FieldByName('FactoryName').Value:=trim(fCustomerNoName);
FieldByName('YFDefFlag1').Value:=fYFDefFlag1;
FieldByName('ZdyStr1').Value:=<><D3A6><EFBFBD><EFBFBD>';
Post;
end;
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('delete from YF_Money_CR ');
sql.Add(' where MainID='''+Trim(crkNO)+'''');
sql.Add(' and YFName='''+trim(CRType.Text)+''' ');
execsql;
end;
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add('select C_CodeName,C_Color,SUM(RollNum) as RollNum,SUM(Qty) as Qty from CK_BanCP_CR1 ');
sql.Add(' where CKOrdNo='''+Trim(crkNO)+'''');
sql.Add(' and CRType='''+trim(CRType.Text)+''' ');
sql.Add(' group by C_CodeName,C_Color ');
Open;
end;
while not ADOQueryTemp.eof do
begin
if GetLSNo(ADOQueryCmd,YFID,'CS','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;
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(crkNO);
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:=trim(fCustomerNoName);
FieldByName('CRTime').Value:=Trim(FormatDateTime('yyyy-MM-dd',CRTIME.DateTime));
FieldByName('YFType').Value:='<27>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>';
FieldByName('Price').Value:=0;
FieldByName('PS').Value:= ADOQueryTemp.fieldbyname('RollNum').AsFloat;
FieldByName('Qty').Value:= ADOQueryTemp.fieldbyname('Qty').AsFloat;
FieldByName('P_CodeName').Value:=ADOQueryTemp.fieldbyname('C_CodeName').AsString;
FieldByName('P_Color').Value:=ADOQueryTemp.fieldbyname('C_Color').AsString;
//FieldByName('HuiLv').Value:=1;
FieldByName('HuiLv').Value:=1;
FieldByName('BZType').Value:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
FieldByName('QtyUnit').Value:='M';
FieldByName('ComTaiTou').Value:=trim(CustomerNoName.Text);
FieldByName('YFName').Value:=trim(CRType.Text);
FieldByName('MainId').Value:=Trim(crkNO);
FieldByName('subID').Value:='';
FieldByName('YFDefFlag1').Value:=fYFDefFlag1;
FieldByName('syrName').Value:='<27><><EFBFBD>˷<EFBFBD>֯';
// FieldByName('status').Value:='1';
Post;
end;
ADOQueryTemp.next;
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;
end;
function TfrmCPRK_Other.YSData(crkNo:string):Boolean;
var
CRID,YFID,Price,PriceUnit,OrderUnit,FComTaiTou,fYFDefFlag1:String;
begin
Result:=False;
fYFDefFlag1:='2';
with ADOQueryTemp do
begin
Close;
SQL.Clear;
sql.Add('select * from YF_Money_KC where FactoryName='''+Trim(CustomerNoName.Text)+'''');
sql.Add(' and YFDefFlag1='''+trim(fYFDefFlag1)+''' ');
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 where 1<>1');
Open;
end;
with ADOQueryCmd do
begin
Append;
FieldByName('CRID').Value:=StrToInt(CRID);
FieldByName('FactoryName').Value:=Trim(CustomerNoName.Text);
FieldByName('YFDefFlag1').Value:=fYFDefFlag1;
FieldByName('ZdyStr1').Value:=<><D3A6><EFBFBD><EFBFBD>';
Post;
end;
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('delete from YF_Money_CR ');
sql.Add(' where MainID='''+Trim(crkNO)+'''');
sql.Add(' and YFName=''<27>˻<EFBFBD><CBBB><EFBFBD><EFBFBD><EFBFBD>'' ');
execsql;
end;
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add('select C_CodeName,C_Color,SUM(RollNum) as RollNum,SUM(Qty) as Qty,sum(money) as Money,Price from CK_BanCP_CR1 ');
sql.Add(' where CKOrdNo='''+Trim(crkNO)+'''');
sql.Add(' and CRType=''<27>˻<EFBFBD><CBBB><EFBFBD><EFBFBD><EFBFBD>'' ');
sql.Add(' group by C_CodeName,C_Color,Price ');
Open;
end;
while not ADOQueryTemp.eof do
begin
if GetLSNo(ADOQueryCmd,YFID,'CS','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;
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(crkNO);
FieldByName('CRID').Value:=StrToInt(CRID);
FieldByName('Filler').Value:=Trim(DName);
FieldByName('CRType').Value:=<>տ<EFBFBD><D5BF>Ǽ<EFBFBD>';
FieldByName('CRFlag').Value:=<><D3A6><EFBFBD><EFBFBD>';
FieldByName('QtyFlag').Value:=1;
FieldByName('FactoryName').Value:=Trim(CustomerNoName.Text);
FieldByName('CRTime').Value:=Trim(FormatDateTime('yyyy-MM-dd',CRTIME.DateTime));
FieldByName('YFType').Value:='<27>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>';
FieldByName('Price').Value:=0;
FieldByName('PS').Value:=-1 * ADOQueryTemp.fieldbyname('RollNum').AsFloat;
FieldByName('Qty').Value:=-1 * ADOQueryTemp.fieldbyname('Qty').AsFloat;
FieldByName('Price').Value:= ADOQueryTemp.fieldbyname('Price').AsFloat;
FieldByName('money').Value:= -1* ADOQueryTemp.fieldbyname('money').AsFloat;
FieldByName('BBmoney').Value:= -1* ADOQueryTemp.fieldbyname('money').AsFloat;
FieldByName('P_CodeName').Value:=ADOQueryTemp.fieldbyname('C_CodeName').AsString;
FieldByName('P_Color').Value:=ADOQueryTemp.fieldbyname('C_Color').AsString;
//FieldByName('HuiLv').Value:=1;
FieldByName('HuiLv').Value:=1;
FieldByName('BZType').Value:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
FieldByName('QtyUnit').Value:='M';
FieldByName('ComTaiTou').Value:=Trim(CustomerNoName.Text);
FieldByName('YFName').Value:='<27>˻<EFBFBD><CBBB><EFBFBD><EFBFBD><EFBFBD>';
FieldByName('MainId').Value:=Trim(crkNO);
FieldByName('subID').Value:='';
FieldByName('status').Value:='1';
FieldByName('YFDefFlag1').Value:=fYFDefFlag1;
FieldByName('syrName').Value:='<27><><EFBFBD>˷<EFBFBD>֯';
Post;
end;
ADOQueryTemp.next;
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;
end;
function TfrmCPRK_Other.savedate():boolean;
var
maxno:String;
CRID:Integer;
MaxCkNo:String;
begin
result:=false;
ADOQueryCmd.Connection.BeginTrans;
try
if fflag=0 then
begin
if GetLSNo(ADOQueryCmd,fkeyNo,'RT','CK_BanCP_CR1',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;
end;
CDS_Main.DisableControls;
with CDS_Main do
begin
First;
while not Eof do
begin
if trim(Fieldbyname('BCID').AsString)='' then
begin
with ADOQueryCmd do
begin
Close;
sql.Clear;
SQL.add('Update CK_BanCP_CRID1 Set CRID=CRID+1');
sql.Add('select * from CK_BanCP_CRID1');
Open;
end;
CRID:=ADOQueryCmd.fieldbyname('CRID').AsInteger;
if GetLSNo(ADOQueryCmd,MaxCkNo,'JT','CK_BanCP_CR1',4,1)=False then
begin
ADOQueryCmd.Connection.RollbackTrans;
Exit;
end;
end
else
begin
CRID:=fieldbyname('CRID').AsInteger;
MaxCkNo:=fieldbyname('BCID').AsString;
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('select * from CK_BanCP_CR1 ');
sql.Add('where BCID='+quotedstr(trim(MaxCkNo)));
sql.Add('and CRID='+inttostr(CRID));
Open;
end;
with ADOQueryCmd do
begin
if IsEmpty then Append else edit;
IF trim(CRType.Text)='<27>ڳ<EFBFBD><DAB3><EFBFBD><EFBFBD><EFBFBD>' then
begin
FieldByName('MainId').Value:='CM001';
FieldByName('SubId').Value:='CS001';
end
else
begin
FieldByName('MainId').Value:='';
FieldByName('SubId').Value:='';
end;
FieldByName('MainId').Value:='CM001';
FieldByName('SubId').Value:='CS001';
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('C_Color').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('kcKw').Value:=Trim(CDS_Main.fieldbyname('kcKw').AsString);
FieldByName('RCGangNo').Value:=Trim(CDS_Main.fieldbyname('RCGangNo').AsString);
FieldByName('BCGangNo').Value:=Trim(CDS_Main.fieldbyname('BCGangNo').AsString);
FieldByName('BCID').Value:=Trim(MaxCkNo);
FieldByName('ckordNo').Value:=Trim(fkeyNo);
FieldByName('CRTime').Value:=FormatDateTime('yyyy-MM-dd',CRTime.DateTime);
FieldByName('CRFlag').Value:='<27><><EFBFBD><EFBFBD>';
FieldByName('CRType').Value:=trim(CRType.Text);
//FieldByName('JTType').Value:=Trim(XJFlag);
FieldByName('CRID').Value:=CRID;
FieldByName('KGQty').Value:=CDS_Main.fieldbyname('KGQty').AsFloat;
FieldByName('Qty').Value:=CDS_Main.fieldbyname('Qty').AsFloat;
FieldByName('RollNum').Value:=CDS_Main.fieldbyname('RollNum').AsFloat;
FieldByName('Price').Value:=CDS_Main.fieldbyname('Price').AsFloat;
FieldByName('Money').Value:=CDS_Main.fieldbyname('Money').AsFloat;
FieldByName('QtyUnit').Value:=CDS_Main.fieldbyname('QtyUnit').Value;
FieldByName('CPType').Value:=Trim(CDS_Main.fieldbyname('CPType').AsString);
FieldByName('Filler').Value:=Trim(DName);
FieldByName('FillTime').Value:=SGetServerDateTime(ADOQueryTmp);
// FieldByName('kcKw').Value:=Trim(kcKw.Text);
fieldbyname('kcKw').Value:=GetKw(ADOQueryTemp,CDS_Main.fieldbyname('C_CodeName').AsString,CDS_Main.fieldbyname('C_Color').AsString);
FieldByName('ThCust').Value:=Trim(CustomerNoName.Text);
FieldByName('note').Value:=Trim(note.Text);
Post;
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('select * from CK_BanCP_KC1 ');
sql.Add('where BCID='+quotedstr(trim(MaxCkNo)));
sql.Add('and CRID='+inttostr(CRID));
Open;
end;
with ADOQueryCmd do
begin
if IsEmpty then Append else edit;
FieldByName('CRID').Value:=CRID;
FieldByName('BCID').Value:=Trim(MaxCkNo);
FieldByName('MJID').Value:=Trim(CDS_Main.fieldbyname('MJID').AsString);
FieldByName('MJxh').Value:=Trim(CDS_Main.fieldbyname('MJxh').AsString);
FieldByName('kcKw').Value:=Trim(CDS_Main.fieldbyname('kcKw').AsString);
FieldByName('KCKGQty').Value:=CDS_Main.fieldbyname('KGQty').AsFloat;
FieldByName('KCQty').Value:=CDS_Main.fieldbyname('Qty').AsFloat;
FieldByName('KCRollNum').Value:=CDS_Main.fieldbyname('RollNum').AsFloat;
FieldByName('KCQtyUnit').Value:=CDS_Main.fieldbyname('QtyUnit').Value;
FieldByName('CRTime').Value:=FormatDateTime('yyyy-MM-dd',CRTime.DateTime);
FieldByName('CPType').Value:=Trim(CDS_Main.fieldbyname('CPType').AsString);
FieldByName('CRType').Value:=trim(CRType.Text);
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('C_Color').AsString);
FieldByName('RCGangNo').Value:=Trim(CDS_Main.fieldbyname('RCGangNo').AsString);
FieldByName('BCGangNo').Value:=Trim(CDS_Main.fieldbyname('BCGangNo').AsString);
fieldbyname('kcKw').Value:=GetKw(ADOQueryTemp,CDS_Main.fieldbyname('C_CodeName').AsString,CDS_Main.fieldbyname('C_Color').AsString);
// FieldByName('kcKw').Value:=Trim(kcKw.Text);
Post;
end;
CDS_Main.Next;
end;
end;
CDS_Main.EnableControls;
IF trim(CRType.Text)='<27>˻<EFBFBD><CBBB><EFBFBD><EFBFBD><EFBFBD>' then
begin
iF not YSData(fkeyNO) then
begin
ADOQueryCmd.Connection.RollbackTrans;
exit;
end;
{ IF (trim(CustomerNoName.Text)='<27><EFBFBD><E3B6AB><EFBFBD>в<EFBFBD>') or (trim(CustomerNoName.Text)='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>в<EFBFBD>') then
begin
iF not YFData(fkeyNO) then
begin
ADOQueryCmd.Connection.RollbackTrans;
exit;
end;
end
else
begin
iF not YSData(fkeyNO) then
begin
ADOQueryCmd.Connection.RollbackTrans;
exit;
end;
end; }
end;
IF trim(CRType.Text)='<27>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD><EFBFBD>' then
begin
iF not YFData(fkeyNO) then
begin
ADOQueryCmd.Connection.RollbackTrans;
exit;
end;
end;
ADOQueryCmd.Connection.CommitTrans;
result:=true;
except
ADOQueryCmd.Connection.RollbackTrans;
end;
end;
procedure TfrmCPRK_Other.IntGrid();
begin
with adoqueryTmp do
begin
Close;
SQL.Clear;
sql.Add(' select * from CK_BanCP_CR1 ');
sql.Add('where ckordNo='+quotedstr(fkeyNO));
sql.Add('and BCID='+quotedstr(fBCID));
open;
end;
SCreateCDS20(adoqueryTmp,CDS_main);
SInitCDSData20(adoqueryTmp,CDS_main);
if not CDS_main.IsEmpty then
begin
CRTIME.DateTime:=CDS_main.fieldbyname('CRTime').AsDateTime;
kcKw.Text:=CDS_main.fieldbyname('kckw').AsString;
CRType.ItemIndex:=CRType.Items.IndexOf(trim(CDS_main.fieldbyname('CRType').AsString));
CustomerNoName.Text:=CDS_main.fieldbyname('thcust').AsString;
note.Text:=CDS_main.fieldbyname('note').AsString;
end;
end;
procedure TfrmCPRK_Other.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action:=cahide;
end;
procedure TfrmCPRK_Other.FormDestroy(Sender: TObject);
begin
frmCPRK_Other:=nil;
end;
procedure TfrmCPRK_Other.FormCreate(Sender: TObject);
begin
cxGrid1.Align:=alclient;
CRTIME.DateTime:=date();
end;
procedure TfrmCPRK_Other.v1Column1PropertiesButtonClick(Sender: TObject;
AButtonIndex: Integer);
begin
try
frmZdyAttachCP:=TfrmZdyAttachCP.Create(Application);
with frmZdyAttachCP do
begin
if ShowModal=1 then
begin
Self.CDS_main.Edit;
Self.CDS_main.FieldByName('C_Code').Value:=Trim(CDS_HZ.fieldbyname('ZdyCode').AsString);
Self.CDS_main.FieldByName('C_CodeName').Value:=Trim(CDS_HZ.fieldbyname('ZDYName').AsString);
Self.CDS_main.FieldByName('C_Color').Value:=Trim(CDS_HZ.fieldbyname('DEFstr3').AsString);
// Self.Order_Sub.FieldByName('SOrddefstr4').Value:=Trim(ClientDataSet1.fieldbyname('Note').AsString);
Self.CDS_main.Post;
end;
end;
finally
frmZdyAttachCP.Free;
end;
self.tv1.Controller.EditingController.ShowEdit();
end;
procedure TfrmCPRK_Other.ToolButton1Click(Sender: TObject);
var
maxno:string;
begin
if GetLSNo(ADOQueryCmd,maxno,'T','APTM',4,1)=False then
begin
Application.MessageBox(<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>!','<27><>ʾ',0);
Exit;
end;
with CDS_main do
begin
Append;
fieldbyname('BCID').Value:='';
fieldbyname('CPTYpe').Value:='<27><>Ʒ';
fieldbyname('MJID').Value:=maxno;
fieldbyname('MJXH').Value:=1;
fieldbyname('QtyUnit').Value:='M';
Post;
end;
end;
procedure TfrmCPRK_Other.ToolButton2Click(Sender: TObject);
begin
if CDS_main.IsEmpty then exit;
{ with ADOQueryCmd do
begin
close;
sql.Clear;
sql.Add('delete from CK_BanCP_CR ');
sql.Add('where BCID='+quotedstr(trim(CDS_main.fieldbyname('BCID').AsString)));
sql.Add('and CKOrdNo='+quotedstr(trim(CDS_main.fieldbyname('CKOrdNo').AsString)));
sql.Add('delete from CK_BanCP_KC ');
sql.Add('where BCID='+quotedstr(trim(CDS_main.fieldbyname('BCID').AsString)));
sql.Add('AND crid='+quotedstr(trim(CDS_main.fieldbyname('crid').AsString)));
execsql;
end; }
CDS_main.Delete;
end;
procedure TfrmCPRK_Other.FormShow(Sender: TObject);
begin
IntGrid();
end;
procedure TfrmCPRK_Other.TBCloseClick(Sender: TObject);
begin
close;
end;
procedure TfrmCPRK_Other.TBSaveClick(Sender: TObject);
begin
CRTIME.SetFocus;
if CDS_main.IsEmpty then exit;
if trim(CRType.Text)='' then
begin
application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ͳ<EFBFBD><CDB2><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>','<27><>ʾ<EFBFBD><CABE>Ϣ',0);
exit;
end;
if trim(CRType.Text)='<27>˻<EFBFBD><CBBB><EFBFBD><EFBFBD><EFBFBD>' then
begin
if trim(CustomerNoName.Text)='' then
begin
application.MessageBox('<27>˻<EFBFBD><CBBB>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>','<27><>ʾ<EFBFBD><CABE>Ϣ',0);
exit;
end;
end;
if CDS_main.Locate('Qtyunit','',[]) then
begin
application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>','<27><>ʾ<EFBFBD><CABE>Ϣ',0);
exit;
end;
if CDS_main.Locate('Qtyunit',NULL,[]) then
begin
application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>','<27><>ʾ<EFBFBD><CABE>Ϣ',0);
exit;
end;
if CDS_main.Locate('MJID',NULL,[]) then
begin
application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EBB2BB>Ϊ<EFBFBD>գ<EFBFBD>','<27><>ʾ<EFBFBD><CABE>Ϣ',0);
exit;
end;
if CDS_main.Locate('MJXH',NULL,[]) then
begin
application.MessageBox('<27><><EFBFBD>Ų<EFBFBD><C5B2><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>','<27><>ʾ<EFBFBD><CABE>Ϣ',0);
exit;
end;
if savedate() then
begin
application.MessageBox('<27><><EFBFBD>ݱ<EFBFBD><DDB1><EFBFBD><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD>','<27><>ʾ<EFBFBD><CABE>Ϣ');
ModalResult:=1;
end
else
application.MessageBox('<27><><EFBFBD>ݱ<EFBFBD><DDB1><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>','<27><>ʾ<EFBFBD><CABE>Ϣ',0);
end;
procedure TfrmCPRK_Other.v1C_ColorPropertiesButtonClick(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.CDS_main.Edit;
Self.CDS_main.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;
end;
procedure TfrmCPRK_Other.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;
procedure TfrmCPRK_Other.Edit1KeyPress(Sender: TObject; var Key: Char);
var
FReal:Double;
maxno:string;
begin
if Key=#13 then
begin
if Trim(Edit1.Text)='' then Exit;
if TryStrToFloat(Edit1.Text,FReal)=False then
begin
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>!','<27><>ʾ',0);
Exit;
end;
if CDS_main.IsEmpty then
begin
CDS_main.Append;
CDS_main.fieldbyname('Qty').Value:=Edit1.Text;
CDS_main.fieldbyname('kcKw').Value:=kcKw.Text;
CDS_main.fieldbyname('RollNum').Value:=1;
CDS_main.fieldbyname('MJXH').Value:=1;
CDS_main.fieldbyname('CPTYpe').Value:='<27><>Ʒ';
CDS_main.fieldbyname('QtyUnit').Value:='M';
try
ADOQueryCmd.Connection.BeginTrans;
if GetLSNo(ADOQueryCmd,maxno,'T','APTM',4,1)=False then
begin
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox(<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>!','<27><>ʾ',0);
Exit;
end;
ADOQueryCmd.Connection.CommitTrans;
except
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox(<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>!','<27><>ʾ',0);
end;
CDS_main.fieldbyname('MJID').Value:=Trim(maxno);
CDS_main.Post;
end else
begin
CopyAddRowCDS(CDS_main);
tv1.Controller.EditingController.ShowEdit();
with CDS_main do
begin
Edit;
FieldByName('MJXH').Value:=FieldByName('MJXH').Value+1;
try
ADOQueryCmd.Connection.BeginTrans;
if GetLSNo(ADOQueryCmd,maxno,'T','APTM',4,1)=False then
begin
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox(<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>!','<27><>ʾ',0);
Exit;
end;
ADOQueryCmd.Connection.CommitTrans;
except
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox(<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>!','<27><>ʾ',0);
end;
FieldByName('MJId').Value:=Trim(maxno);
fieldbyname('Qty').Value:=Edit1.Text;
fieldbyname('kcKw').Value:=kcKw.Text;
fieldbyname('RollNum').Value:=1;
Post;
end;
end;
Edit1.Text:='';
end;
tv1.Controller.EditingController.ShowEdit();
end;
procedure TfrmCPRK_Other.v1Column1PropertiesEditValueChanged(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 CDS_main do
begin
Edit;
FieldByName('C_CodeName').Value:=Trim(mvalue);
Post;
end;
with ADOQueryCmd do
begin
close;
sql.Clear;
sql.Add('select * from KH_Zdy_Attachment A ');
sql.Add('where zdyName='+quotedstr(trim(CDS_main.fieldbyname('C_CodeName').AsString)));
open;
end;
IF ADOQueryCmd.IsEmpty then
begin
application.MessageBox('Ʒ<><C6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD>','<27><>ʾ<EFBFBD><CABE>Ϣ',0);
with CDS_main do
begin
Edit;
FieldByName('C_CodeName').Value:='';
Post;
end;
end;
self.tv1.Controller.EditingController.ShowEdit();
end;
procedure TfrmCPRK_Other.v1C_ColorPropertiesEditValueChanged(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 CDS_main do
begin
Edit;
FieldByName('C_Color').Value:=Trim(mvalue);
Post;
end;
with ADOQueryCmd do
begin
close;
sql.Clear;
sql.Add('select * from KH_Zdy_Attachment A ');
sql.Add('where zdyName='+quotedstr(trim(CDS_main.fieldbyname('C_CodeName').AsString)));
sql.Add('and DEFstr3='+quotedstr(trim(CDS_main.fieldbyname('C_Color').AsString)));
open;
end;
IF ADOQueryCmd.IsEmpty then
begin
application.MessageBox('<27><>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD>','<27><>ʾ<EFBFBD><CABE>Ϣ',0);
with CDS_main do
begin
Edit;
FieldByName('C_Color').Value:='';
Post;
end;
end;
self.tv1.Controller.EditingController.ShowEdit();
end;
procedure TfrmCPRK_Other.CustomerNoNameBtnUpClick(Sender: TObject);
begin
{ try
frmZDYHelp:=TfrmZDYHelp.Create(Application);
with frmZDYHelp do
begin
flag:='CustomerNoName';
flagname:='<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>';
if ShowModal=1 then
begin
CustomerNoName.Text:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
CustomerNoName.TxtCode:=Trim(ClientDataSet1.fieldbyname('ZDYNo').AsString);
end;
end;
finally
frmZDYHelp.Free;
end; }
try
frmZdyAttachment:=TfrmZdyAttachment.Create(Application);
with frmZdyAttachment do
begin
fkhType:='<27><><EFBFBD>˷<EFBFBD>֯';
if ShowModal=1 then
begin
CustomerNoName.Text:=Trim(frmZdyAttachment.CDS_HZ.fieldbyname('ZDYName').AsString);
CustomerNoName.TxtCode:=Trim(frmZdyAttachment.CDS_HZ.fieldbyname('ZdyCode').AsString);
end;
end;
finally
frmZdyAttachment.Free;
end;
end;
procedure TfrmCPRK_Other.CustomerNoNameBtnDnClick(Sender: TObject);
begin
CustomerNoName.Text:='';
CustomerNoName.TxtCode:='';
end;
procedure TfrmCPRK_Other.Edit2KeyPress(Sender: TObject; var Key: Char);
var
FReal:Double;
maxno:string;
I:integer;
begin
if Key=#13 then
begin
if Trim(Edit2.Text)='' then Exit;
if TryStrToFlOAT(Edit2.Text,FReal)=False then
begin
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>!','<27><>ʾ',0);
Exit;
end;
if CDS_main.IsEmpty then exit;
i:=STRTOintdef(Edit2.Text,0);
for i:=1 to STRTOintdef(Edit2.Text,0) do
begin
CopyAddRowCDS(CDS_main);
with CDS_main do
begin
Edit;
FieldByName('MJXH').Value:=FieldByName('MJXH').Value+1;
try
ADOQueryCmd.Connection.BeginTrans;
if GetLSNo(ADOQueryCmd,maxno,'9','WFB_MJJY',4,1)=False then
begin
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox(<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>!','<27><>ʾ',0);
Exit;
end;
ADOQueryCmd.Connection.CommitTrans;
except
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox(<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>!','<27><>ʾ',0);
end;
FieldByName('MJId').Value:=Trim(maxno);
// fieldbyname('Qty').Value:=Edit1.Text;
// fieldbyname('kcKw').Value:=kcKw.Text;
// fieldbyname('RollNum').Value:=1;
Post;
end;
end;
Edit1.Text:='';
end;
tv1.Controller.EditingController.ShowEdit();
end;
procedure TfrmCPRK_Other.v1Column8PropertiesEditValueChanged(Sender: TObject);
var
mvalue:string;
begin
mvalue:=TcxTextEdit(Sender).EditingText;
IF trim(mvalue)='' then exit;
IF rightBstr(trim(mvalue),1)<>'W'THEN
BEGIn
mvalue:=trim(mvalue)+'W';
END;
with CDS_main do
begin
Edit;
FieldByName('BCgangNo').Value:=Trim(mvalue);
Post;
end;
self.tv1.Controller.EditingController.ShowEdit();
end;
procedure TfrmCPRK_Other.v1PricePropertiesEditValueChanged(
Sender: TObject);
var
mvalue,FFieldName:String;
begin
mvalue:=TcxTextEdit(Sender).EditingText;
if Trim(mvalue)='' then
begin
mvalue:='0';
end;
FFieldName:=Trim(Tv1.Controller.FocusedColumn.DataBinding.FilterFieldName);
with CDS_main do
begin
Edit;
FieldByName(FFieldName).Value:=Trim(mvalue);
FieldByName('Money').Value:=format('%.2f',[fieldbyname('Qty').AsFloat * fieldbyname('Price').AsFloat]);
Post;
end;
tv1.Controller.EditingController.ShowEdit();
end;
end.