157 lines
3.9 KiB
ObjectPascal
157 lines
3.9 KiB
ObjectPascal
unit U_kcchEdit;
|
|
|
|
interface
|
|
|
|
uses
|
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|
Dialogs, StdCtrls, cxControls, cxContainer, cxEdit, cxTextEdit,
|
|
cxCurrencyEdit, ExtCtrls, DB, ADODB;
|
|
|
|
type
|
|
TfrmkcchEdit = class(TForm)
|
|
Panel1: TPanel;
|
|
Label1: TLabel;
|
|
Edit1: TEdit;
|
|
Label2: TLabel;
|
|
Edit2: TEdit;
|
|
Label3: TLabel;
|
|
cxCurrencyEdit1: TcxCurrencyEdit;
|
|
Label4: TLabel;
|
|
cxCurrencyEdit2: TcxCurrencyEdit;
|
|
Button1: TButton;
|
|
Button2: TButton;
|
|
ADOQueryCmd: TADOQuery;
|
|
ADOQueryTmp: TADOQuery;
|
|
procedure Button2Click(Sender: TObject);
|
|
procedure FormDestroy(Sender: TObject);
|
|
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
|
procedure Button1Click(Sender: TObject);
|
|
private
|
|
{ Private declarations }
|
|
public
|
|
fBCID:string;
|
|
fcriD:string;
|
|
{ Public declarations }
|
|
end;
|
|
|
|
var
|
|
frmkcchEdit: TfrmkcchEdit;
|
|
|
|
implementation
|
|
uses
|
|
U_DataLink,U_Fun, U_ZDYHelp;
|
|
{$R *.dfm}
|
|
|
|
procedure TfrmkcchEdit.Button2Click(Sender: TObject);
|
|
begin
|
|
close;
|
|
end;
|
|
|
|
procedure TfrmkcchEdit.FormDestroy(Sender: TObject);
|
|
begin
|
|
frmkcchEdit:=nil;
|
|
end;
|
|
|
|
procedure TfrmkcchEdit.FormClose(Sender: TObject;
|
|
var Action: TCloseAction);
|
|
begin
|
|
Action:=cahide;
|
|
end;
|
|
|
|
procedure TfrmkcchEdit.Button1Click(Sender: TObject);
|
|
var
|
|
CRID:integer;
|
|
i:integer;
|
|
fAPTM:string;
|
|
begin
|
|
if strtofloatdef(cxCurrencyEdit1.Text,0)=0 then
|
|
begin
|
|
application.MessageBox('拆分匹数不能为零!','提示信息',0);
|
|
exit;
|
|
end;
|
|
if strtofloatdef(cxCurrencyEdit2.Text,0)=0 then
|
|
begin
|
|
application.MessageBox('拆分数量不能为零!','提示信息',0);
|
|
exit;
|
|
end;
|
|
if Application.MessageBox('确定要拆分数据吗?','提示',32+4)<>IDYES then Exit;
|
|
ModalResult:=1;
|
|
{ if GetLSNo(ADOQueryCmd,fAPTM,'C','APTM',4,1)=False then
|
|
begin
|
|
Application.MessageBox('取子流水号失败!','提示',0);
|
|
Exit;
|
|
end;
|
|
|
|
ADOQueryCmd.Connection.BeginTrans;
|
|
try
|
|
with ADOQueryTmp do
|
|
begin
|
|
close;
|
|
sql.Clear;
|
|
sql.Add('select * from CK_BanCP_KC A');
|
|
sql.Add('where BCID='+quotedstr(trim(fBCID)));
|
|
sql.Add('and CRID='+quotedstr(trim(fCRID)));
|
|
open;
|
|
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;
|
|
with ADOQueryCmd do
|
|
begin
|
|
close;
|
|
sql.Clear;
|
|
sql.Add('select * from CK_BanCP_KC A');
|
|
sql.Add('where 1=2 ');
|
|
open;
|
|
end;
|
|
ADOQueryCmd.Append;
|
|
for i:=0 to ADOQueryCmd.FieldCount-1 do
|
|
begin
|
|
ADOQueryCmd.fields[i].value:=ADOQueryTmp.Fields[i].Value ;
|
|
end;
|
|
ADOQueryCmd.FieldByName('CRID').Value:=CRID;
|
|
ADOQueryCmd.FieldByName('KCROllNum').Value:=strtofloatdef(cxCurrencyEdit1.Text,0);
|
|
ADOQueryCmd.FieldByName('KCQty').Value:=strtofloatdef(cxCurrencyEdit2.Text,0);
|
|
ADOQueryCmd.FieldByName('oldCRID').Value:=fcrID;
|
|
ADOQueryCmd.FieldByName('MJID').Value:=trim(fAPTM);
|
|
ADOQueryCmd.Post;
|
|
|
|
|
|
with ADOQueryCmd do
|
|
begin
|
|
close;
|
|
sql.Clear;
|
|
sql.Add('select * from CK_BanCP_KC A');
|
|
sql.Add('where CRID='''+trim(fCRID)+'''');
|
|
open;
|
|
end;
|
|
ADOQueryCmd.Edit;
|
|
ADOQueryCmd.FieldByName('KCROllNum').Value:=ADOQueryCmd.FieldByName('KCROllNum').AsFloat - strtofloatdef(cxCurrencyEdit1.Text,0);
|
|
ADOQueryCmd.FieldByName('KCQty').Value:=ADOQueryCmd.FieldByName('KCQty').AsFloat - strtofloatdef(cxCurrencyEdit2.Text,0);
|
|
ADOQueryCmd.Post;
|
|
|
|
with ADOQueryCmd do
|
|
begin
|
|
Close;
|
|
sql.Clear;
|
|
sql.Add('UPDATE CK_BanCp_KC SET KCRollNum =1 ');
|
|
sql.Add('WHERE (KCQty<>0 or KCKgQty<>0)and KcRollNum=0 ');
|
|
ExecSQL;
|
|
end;
|
|
ADOQueryCmd.Connection.CommitTrans;
|
|
application.MessageBox('数据保存成功!','提示信息');
|
|
ModalResult:=1;
|
|
except
|
|
ADOQueryCmd.Connection.RollbackTrans;
|
|
application.MessageBox('数据保存失败!','提示信息',0);
|
|
end; }
|
|
end;
|
|
|
|
end.
|