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

161 lines
4.2 KiB
ObjectPascal

unit U_kcchEdit_other;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, cxControls, cxContainer, cxEdit, cxTextEdit,
cxCurrencyEdit, ExtCtrls, DB, ADODB;
type
TfrmkcchEdit_other = 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_other: TfrmkcchEdit_other;
implementation
uses
U_DataLink,U_Fun, U_ZDYHelp;
{$R *.dfm}
procedure TfrmkcchEdit_other.Button2Click(Sender: TObject);
begin
close;
end;
procedure TfrmkcchEdit_other.FormDestroy(Sender: TObject);
begin
frmkcchEdit_other:=nil;
end;
procedure TfrmkcchEdit_other.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
Action:=cahide;
end;
procedure TfrmkcchEdit_other.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 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_KC1 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_CRID1 Set CRID=CRID+1');
sql.Add('select * from CK_BanCP_CRID1');
Open;
end;
CRID:=ADOQueryCmd.fieldbyname('CRID').AsInteger;
with ADOQueryCmd do
begin
close;
sql.Clear;
sql.Add('select * from CK_BanCP_KC1 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('KCStatus').Value:=NULL;
ADOQueryCmd.FieldByName('MJID').Value:=trim(fAPTM);
ADOQueryCmd.fieldbyname('ZDYstr1').Value:='库存拆分';
ADOQueryCmd.fieldbyname('ZDYFlote1').Value:= 0;
ADOQueryCmd.Post;
with ADOQueryCmd do
begin
close;
sql.Clear;
sql.Add('select * from CK_BanCP_KC1 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.fieldbyname('ZDYstr1').Value:='库存拆分';
ADOQueryCmd.fieldbyname('ZDYFlote1').Value:= ADOQueryCmd.FieldByName('KCQty').AsFloat;
ADOQueryCmd.Post;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('UPDATE CK_BanCp_KC1 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.