📄 ps_ordbill.pas
字号:
stkbillmain.AppendRecord([fields[0].value,fields[1].value,fields[2].value,fields[3].value,fields[4].value,warehouseid,fields[5].value,fields[6].value,cash,0,fields[7].value]);
end;
with ordbillsub do begin
disablecontrols;
first;
while not eof do begin
// edit;
// fieldvalues['translated']:=true;
// post;
stkbillsub.AppendRecord([fields[0].value,fields[1].value,fields[2].value,fields[3].value,fields[4].value,fields[5].value,fields[6].value,fields[7].value,fields[8].value,null,fields[9].value]);
if fieldvalues['flag']=2 then
with comproduct do begin
locate('productid',ordbillsub.fieldvalues['productid'],[lopartialkey]);
stkbillsub.edit;
stkbillsub.fieldvalues['costs']:=comproduct.fieldvalues['presentcost'];
stkbillsub.post;
end;
next;
end;
with Q_public do begin
sql.Clear;
sql.Add('update ordbillsub set translated=1 where billno='''+ordbillmain.fieldvalues['billno']+'''');
execsql;
end;
close;
open;
enablecontrols;
end;
end;
end;
procedure TF_ordbill.Turn;
var
fstkplus:tf_stkplus;
begin
with comdatabase do begin
if stkbillmain.locate('flag;billno',vararrayof([ordbillmain.fieldvalues['flag'],ordbillmain.fieldvalues['billno']]),[lopartialkey])
then showmessage('已转订')
else begin
fstkplus:=tf_stkplus.Create(self);
if fstkplus.ShowModal=idok then
if fstkplus.CB_warehouseid.text='' then
showmessage('请选择仓库')
else
if ordbillmain.FieldValues['flag']=1 then begin
comcustomer.Locate('id',ordbillmain.fieldvalues['targetid'],[lopartialkey]);
comcustomer.Edit;
comcustomer.FieldValues['presentfunds']:=comcustomer.FieldValues['presentfunds']+
ordbillmain.FieldValues['totalmoney']+
ordbillmain.FieldValues['totaltax']-
strtoint(fstkplus.E_cash.Text);
comcustomer.Post;
ordbillsub.First;
while not ordbillsub.Eof do begin
if comwareamount.Locate('productid',ordbillsub.FieldValues['productid'],[lopartialkey])
then begin
comwareamount.edit;
comwareamount.FieldValues['presentamount']:=comwareamount.FieldValues['presentamount']+
ordbillsub.FieldValues['amount'];
comwareamount.post;
end
else begin
comwareamount.AppendRecord([ordbillsub.fieldvalues['productid'],fstkplus.cb_warehouseid.text,0,ordbillsub.fieldvalues['amount']]);
end;
ordbillsub.Next;
end;
turnPlus(fstkplus.cb_warehouseid.text,fstkplus.E_cash.Text);
end
else begin
comcustomer.Locate('id',ordbillmain.fieldvalues['targetid'],[lopartialkey]);
if ordbillmain.FieldValues['totalmoney']+
ordbillmain.FieldValues['totaltax']-
strtoint(fstkplus.E_cash.Text)>
comcustomer.FieldValues['limitcredit']
then showmessage('未付帐款超过帐款额度')
else begin
ordbillsub.First;
while not ordbillsub.Eof do
if not comwareamount.Locate('productid',ordbillsub.FieldValues['productid'],[lopartialkey]) then begin
showmessage('仓库中数量不足');
break;
end
else
if comwareamount.FieldValues['presentamount']<ordbillsub.FieldValues['amount'] then begin
showmessage('仓库中数量不足');
break;
end
else
ordbillsub.Next;
if ordbillsub.Eof then begin
comcustomer.Locate('id',ordbillmain.fieldvalues['targetid'],[lopartialkey]);
comcustomer.Edit;
comcustomer.FieldValues['presentfunds']:=comcustomer.FieldValues['presentfunds']+
ordbillmain.FieldValues['totalmoney']+
ordbillmain.FieldValues['totaltax']-
strtoint(fstkplus.E_cash.Text);
comcustomer.Post;
ordbillsub.First;
while not ordbillsub.Eof do begin
comwareamount.Locate('productid',ordbillsub.FieldValues['productid'],[lopartialkey]);
comwareamount.edit;
comwareamount.FieldValues['presentamount']:=comwareamount.FieldValues['presentamount']-
ordbillsub.FieldValues['amount'];
comwareamount.post;
ordbillsub.next;
end;
turnplus(fstkplus.CB_warehouseid.Text,fstkplus.E_cash.Text);
end;
end;
end;
end;
end;//comdatabase's end
end;
procedure TF_ordbill.SetCb_items;
begin
with comdatabase do
if ordbillmain.locate('flag;billno',vararrayof([flag,cb_billno.text]),[loPartialKey]) then begin
with ordbillsub do begin
cb_deliveryaddr.Items.Clear;
if isempty then
dbgrid2.readonly:=true
else begin
dbgrid2.readonly:=false;
disablecontrols;
first;
while not eof do begin
cb_deliveryaddr.items.add(inttostr(fieldvalues['serialno']));
Next;
end;
first;
enablecontrols;
end;
end;
if comcustomer.Locate('id',ordbillmain.fieldvalues['targetid'],[lopartialkey]) then
cb_deliveryaddr.text:=comcustomer.fieldvalues['address'];
comperson.Locate('id',ordbillmain.fieldvalues['personid'],[lopartialkey]);
end
else
cb_billno.Items.Delete(cb_billno.ItemIndex);
end;
procedure tf_ordbill.status;
begin
with tf_ordbill(f_main.activemdichild).cb_billno do
text:=items.strings[Items.IndexOf(comdatabase.ordbillmain.fieldvalues['billno'])];
end;
procedure tf_ordbill.substatus;
begin
with tf_ordbill(f_main.ActiveMDIChild).CB_deliveryaddr do
text:=items.Strings[items.indexof(inttostr(comdatabase.ordbillsub.fieldvalues['serialno']))];
end;
//程序正体部分
//窗体程序
procedure TF_ordbill.FormCreate(Sender: TObject);
begin
with comdatabase do begin
ordbillmain.open;
ordbillmain.CachedUpdates:=true;
ordbillsub.open;
ordbillsub.cachedupdates:=true;
stkbillmain.open;
stkbillmain.cachedupdates:=true;
stkbillsub.open;
stkbillsub.cachedupdates:=true;
comwarehouse.open;
comwareamount.open;
comcustomer.open;
comproduct.open;
comperson.open;
end;
flag:=f_main.flag;
with comdatabase do begin
with comcustomer do begin
disablecontrols;
case flag of
1:filter:='flag=2';
2:filter:='flag=1';
0:filter:='';//为以后实现表中“切换状态”做准备
end;
filtered:=true;
enablecontrols;
end;
with ordbillmain do begin
disablecontrols;
case flag of
1:begin filter:='flag=1';L_title1.caption:='采购单信息:';L_targetid1.caption:='厂商编号:';L_personid1.caption:='采购编号:';end;
2:begin filter:='flag=2';L_title1.caption:='订购单信息:';L_targetid1.caption:='客户编号:';L_personid1.caption:='业务编号:';end;
0:filter:='';
end;
filtered:=true;
if isempty then begin
cb_billno.Text:='无任何表单信息';
end
else begin
first;
while not eof do begin
cb_billno.Items.Add(fieldvalues['billno']);
next;
end;
end;
enablecontrols;
end;
end;
if not comdatabase.ordbillmain.IsEmpty then begin
cb_billno.Text:=CB_billno.items.strings[0];
setcb_items;
end;
end;
procedure TF_ordbill.FormActivate(Sender: TObject);
begin
with comdatabase do begin
ordbillmain.open;
ordbillmain.CachedUpdates:=true;
ordbillsub.open;
ordbillsub.cachedupdates:=true;
stkbillmain.open;
stkbillmain.cachedupdates:=true;
stkbillsub.open;
stkbillsub.cachedupdates:=true;
comwarehouse.open;
comwareamount.open;
comcustomer.open;
comproduct.open;
comperson.open;
end;
case flag of
1:f_main.ActiveMDIChild.caption:='采购单资料查询';
2:f_main.ActiveMDIChild.caption:='订货单资料查询';
end;
f_main.currentTable:=comdatabase.ordbillmain;
f_main.TableName:=Rordbillmain;
f_main.buttonstate;
f_main.TB_turn.Enabled:=true;
end;
procedure TF_ordbill.FormDeactivate(Sender: TObject);
begin
f_main.TB_turn.Enabled:=false;
end;
procedure TF_ordbill.FormCloseQuery(Sender: TObject;
var CanClose: Boolean);
begin
canclose:=send;
end;
procedure TF_ordbill.FormClose(Sender: TObject; var Action: TCloseAction);
begin
f_main.TB_turn.Enabled:=false;
with comdatabase do begin
ordbillmain.close;
// ordbillmain.filtered:=false;
ordbillsub.close;
// ordbillsub.filtered:=false;
stkbillmain.close;
stkbillmain.cachedupdates:=false;
stkbillsub.close;
stkbillsub.cachedupdates:=false;
comwarehouse.close;
comwareamount.close;
comproduct.close;
comcustomer.close;
comcustomer.filtered:=false;
comperson.close;
end;
f_main.currentTable:=nil;
action:=cafree;
end;
//各下拉列单控制
procedure TF_ordbill.CB_billnoChange(Sender: TObject);
begin
if send then begin
if not cb_deliveryaddr.Enabled then
cb_deliveryaddr.Enabled:=true;
setcb_items;
end
else begin
cb_billno.text:=cb_billno.items.strings[cb_billno_currentitem]
end;
end;
procedure TF_ordbill.CB_deliveryaddrChange(Sender: TObject);
begin
with comdatabase do begin
ordbillsub.Locate('serialno',cb_deliveryaddr.text,[lopartialkey]);
end;
end;
procedure TF_ordbill.CB_targetid1CloseUp(Sender: TObject);
begin
with comdatabase do begin
ordbillmain.edit;
ordbillmain.fieldvalues['targetid']:=comcustomer.fieldvalues['id'];
ordbillmain.fieldvalues['deliveryaddr']:=comcustomer.fieldvalues['address'];
cb_deliveryaddr.text:=comcustomer.fieldvalues['address'];
end;
end;
procedure TF_ordbill.CB_personid1CloseUp(Sender: TObject);
begin
with comdatabase do begin
ordbillmain.edit;
ordbillmain.fieldvalues['personid']:=comperson.fieldvalues['id'];
end;
end;
//以下三个程序实现主从表操作的切换
procedure TF_ordbill.GroupBox1MouseUp(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
with comdatabase do begin
f_main.currentTable:=ordbillmain;
f_main.TableName:=Rordbillmain;
f_main.buttonstate;
end;
end;
procedure TF_ordbill.DBGrid2MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
with comdatabase do begin
f_main.currentTable:=ordbillsub;
f_main.TableName:=Rordbillsub;
f_main.buttonstate;
end;
end;
//结束
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -