📄 unit8.pas
字号:
end;
end
else //合同号不同,插入新的纪录
begin
tmpsql5:='select * from goodsbase where 合同号='''+trim(edhetonghao.Text)+'''';
tmpquery1:=tquery.Create(self);
tmpquery1.DatabaseName:='guohua1';
tmpquery1.Close;
tmpquery1.SQL.Clear;
tmpquery1.SQL.Add(tmpsql5);
tmpquery1.Prepare;
tmpquery1.open;
//tmpquery1.free;
if tmpquery1.Eof then
begin
if messagedlg('您要新增加合同吗?',mtinformation,mbyesnocancel,0)<>mryes then exit
else
begin
sum1:=strtoint(edshuliang.Text);
kucunjiesuan:=floattostr(sum1*strtofloat(edjinjia.text));
if combobox1.Text='代销' then yingjiesuan:='0'
else yingjiesuan:=floattostr(strtofloat(edshuliang.Text)*strtofloat(edjinjia.Text));
tmpsql:='insert into goodsbase(品名,牌号,条码,规格,分类,等级,厂家,供货商,销售部门,新增商品通知单来源,进货上限,损耗限额比,专利号,检测报告编号,商标代码,';
tmpsql:=tmpsql+'进货数量,当前库存,进价,售价,结账方式,物价员,最后更新日期,备注,厂家经手人,经手人,合同号,结账日期,已结算金额,应结算金额,库存结算金额,销售结算金额,销售数量,税率,计量单位,结算数量,交易更新时间,倒扣比例,折扣折让,销售金额,售价扣率,选择)';
tmpsql:=tmpsql+'values('''+trim(edpinming.text)+''','''+trim(edpaihao.text)+''','+tiaoma+','''+trim(guige)+''','''+trim(fenlei)+''','''+trim(eddengji.text)+''','''+trim(edchangjia.text)+''',';
tmpsql:=tmpsql+''''+trim(gonghuoshang)+''','''+trim(edxiaoshoubumen.text)+''','''+trim(tongzhidan)+''','+jinhuoshangxian+','+sunhaoxianebi+','+zhuanlihao+','+jiancebianhao+','+shangbiaodaima+',';
tmpsql:=tmpsql+''''+trim(edshuliang.text)+''','''+trim(edshuliang.text)+''',';
tmpsql:=tmpsql+edjinjia.text+',';
tmpsql:=tmpsql+edshoujia.text+',';
tmpsql:=tmpsql+''''+trim(ComboBox1.text)+''','''+trim(edwujiayuan.text)+''','''+formatdatetime('20yy-mm-dd',dtpicker1.DateTime)+''',';
if edbeizhu.text='' then tmpsql:=tmpsql+'null,'
else tmpsql:=tmpsql+''''+trim(edbeizhu.text)+''',';
tmpsql:=tmpsql+''''+trim(Edchangjiadaibiao.text)+''','''+trim(edjingshouren.text)+''','''+trim(edhetonghao.Text)+''','''+formatdatetime('20yy-mm-dd',dtpicker2.DateTime)+''','+edjiezhangjine.Text+','+yingjiesuan+','+kucunjiesuan+',0,0,'+shuilv+','''+trim(jiliangdanwei)+''',0,'''+formatdatetime('20yy-mm-dd',now)+''','+trim(daokoubili)+',0,0,';
if shoujiakoulv='0' then tmpsql:=tmpsql+'null,0)'
else tmpsql:=tmpsql+''+shoujiakoulv+',0)';
tmpquery:=tquery.Create(self);
tmpquery.DatabaseName:='guohua1';
tmpquery.Close;
tmpquery.SQL.Clear;
tmpquery.SQL.Add(tmpsql);
tmpquery.Prepare;
tmpquery.ExecSQL;
tmpsql:='update pricebase set 进价='+edjinjia.Text+' where 条码='+tiaoma+'';
tmpquery.Close;
tmpquery.SQL.Clear;
tmpquery.SQL.Add(tmpsql);
tmpquery.Prepare;
tmpquery.ExecSQL;
//tmpquery.free;
end;
end
else
begin
if edjinjia.Text<>jinjia then //进价不符,不让进货
begin
showmessage('不允许修改了本次合同的进价,请修改合同号');
edjinjia.Text:=jinjia;
exit;
end;
if edshoujia.Text<>shoujia then
begin
showmessage('不允许修改了本次合同的售价,请修改合同号');
edshoujia.Text:=shoujia;
exit;
end;
if ComboBox1.Text<>jiezhangfangshi then
begin
showmessage('不允许修改结账方式,请修改合同号');
//combobox1.SelText:=jiezhangfangshi;
exit
end
else
begin
with query1 do
begin
close;
sql.clear;
tmpsql:=('select * from goodsbase where id='''+inttostr(mainfm.tmpqueryspe2['id'])+'''');
//showmessage(tmpsql);
sql.add(tmpsql);
open;
end;
if query1['进货上限']=null then
begin
showmessage('进货上限是0');
tmpsql:='update goodsbase set 进货上限='''+trim(edshuliang.text)+''',当前库存='''+trim(inttostr(sum1))+''',最后更新日期='''+FormatDateTime('20yy-mm-dd hh:mm',now)+''',已结算金额='+yijiesuan+',进货数量='+jinhuoshuliang+',库存结算金额='+kucunjiesuan+',备注='''+trim(edbeizhu.text)+''',厂家经手人='''+trim(edchangjiadaibiao.text)+''',经手人='''+trim(edjingshouren.text)+''',应结算金额='+yingjiesuan+' where 品名='''+trim(edpinming.text)+''' and 牌号='''+trim(edpaihao.text)+'''and id='''+inttostr(mainfm.tmpqueryspe2['id'])+'''';
//tmpsql:=tmpsql+' update goodsbase set 当前库存='''+trim(inttostr(sum1))+''' where 品名='''+trim(edpinming.text)+''' and 牌号='''+trim(edpaihao.text)+'''and id='''+inttostr(mainfm.tabdepappend['id'])+'''';
//tmpsql:=tmpsql+' update goodsbase set 最后更新日期='''+FormatDateTime('yy-mm-dd hh:mm',now)+''' where 品名='''+trim(edpinming.text)+''' and 牌号='''+trim(edpaihao.text)+'''and id='''+inttostr(mainfm.tabdepappend['id'])+'''';
//tmpsql:=tmpsql+' undate goodsbase set 已结算金额='+yijiesuan+'where 品名='''+trim(edpinming.text)+''' and 牌号='''+trim(edpaihao.text)+'''and id='''+inttostr(mainfm.tabdepappend['id'])+'''';
//tmpsql:=tmpsql+' update goodsbase set 进货数量='+jinhuoshuliang+',库存结算金额='+kucunjiesuan+',备注='''+trim(edbeizhu.text)+''',厂家经手人='''+trim(edchangjiadaibiao.text)+''',经手人='''+trim(edjingshouren.text)+'''where 品名='''+trim(edpinming.text)+''' and 牌号='''+trim(edpaihao.text)+'''and id='''+inttostr(mainfm.tabdepappend['id'])+'''';
end
else
begin
shangxian:=strtoint(query1['进货上限']);
if sum1>shangxian then
if MessageDlg('输入的数量大于库存上限,您确定吗?',mtinformation,mbYesNoCancel,0)<>mrYes then exit
else tmpsql:='update goodsbase set 当前库存='''+trim(inttostr(sum1))+''',已结算金额='+yijiesuan+',进货数量='+jinhuoshuliang+',库存结算金额='+kucunjiesuan+',备注='''+trim(edbeizhu.text)+''',厂家经手人='''+trim(edchangjiadaibiao.text)+''',经手人='''+trim(edjingshouren.text)+''',应结算金额='+yingjiesuan+' where 品名='''+trim(edpinming.text)+''' and 牌号='''+trim(edpaihao.text)+'''and id='''+inttostr(mainfm.tmpqueryspe2['id'])+''''
else tmpsql:='update goodsbase set 当前库存='''+trim(inttostr(sum1))+''',最后更新日期='''+FormatDateTime('20yy-mm-dd hh:mm',now)+''',已结算金额='+yijiesuan+',进货数量='+jinhuoshuliang+',库存结算金额='+kucunjiesuan+',备注='''+trim(edbeizhu.text)+''',厂家经手人='''+trim(edchangjiadaibiao.text)+''',经手人='''+trim(edjingshouren.text)+''',应结算金额='+yingjiesuan+' where 品名='''+trim(edpinming.text)+''' and 牌号='''+trim(edpaihao.text)+'''and id='''+inttostr(mainfm.tmpqueryspe2['id'])+'''';
//tmpsql:=tmpsql+' update goodsbase set 最后更新日期='''+FormatDateTime('yy-mm-dd hh:mm',now)+''',已结算金额='+yijiesuan+',进货数量='+jinhuoshuliang+',库存结算金额='+kucunjiesuan+',备注='''+trim(edbeizhu.text)+''',厂家经手人='''+trim(edchangjiadaibiao.text)+''',经手人='''+trim(edjingshouren.text)+''' where 品名='''+trim(edpinming.text)+''' and 牌号='''+trim(edpaihao.text)+'''and id='''+inttostr(mainfm.tabdepappend['id'])+'''';
end;
with query1 do
begin
close;
sql.clear;
//showmessage(tmpsql);
sql.add(tmpsql);
prepare;
execsql;
end;
tmpquery1.Next;
end;
end;
end;
//更新purchaserecordbase
tmpsql:='select a=max(进货批次) from purchaserecordbase where 合同号='''+trim(edhetonghao.Text)+'''';
tmpquery:=tquery.Create(self);
tmpquery.DatabaseName:='guohua1';
tmpquery.Close;
tmpquery.SQL.Clear;
tmpquery.SQL.Add(tmpsql);
tmpquery.Prepare;
tmpquery.open;
if (tmpquery['a']=null) or(tmpquery['a']='') then jinhuopici:='0'
else jinhuopici:=tmpquery['a'];
jinhuopici:=inttostr(strtoint(jinhuopici)+1);
tmpsql:='insert into purchaserecordbase (厂家,品名,条码,牌号,规格,分类编码,等级,进价,售价,数量,原库存数量,厂家经手人,经手人,合同号,结账日期,进货批次,进价折扣,进价折扣方式,进货日期,出库单号,选择)';
tmpsql:=tmpsql+'values ('''+trim(gonghuoshang)+''','''+trim(edpinming.text)+''','+tiaoma+','''+trim(edpaihao.Text)+''','''+trim(guige)+''','''+trim(edfenlei.text)+''','''+trim(eddengji.text)+''',';
tmpsql:=tmpsql+''+edjinjia.text+','+edshoujia.text+','''+trim(edshuliang.text)+''','''+trim(inttostr(sum))+''','''+trim(edchangjiadaibiao.text)+''',';
tmpsql:=tmpsql+''''+trim(edjingshouren.text)+''','''+trim(edhetonghao.text)+''','''+formatdatetime('20yy-mm-dd',dtpicker2.DateTime)+''','''+trim(jinhuopici)+''',0,0,'''+formatdatetime('20yy-mm-dd',dtpicker1.DateTime)+''','''+trim(edchukudanhao.Text)+''',0)';
tmpquery:=tquery.Create(self);
tmpquery.DatabaseName:='guohua1';
tmpquery.Close;
tmpquery.SQL.Clear;
tmpquery.SQL.Add(tmpsql);
tmpquery.Prepare;
tmpquery.ExecSQL;
{with query1 do
begin
close;
sql.clear;
tmpsql:=('select * from goodsbase where id='''+inttostr(mainfm.tabdepappend['id'])+'''');
//showmessage(tmpsql);
sql.add(tmpsql);
open
end;
//showmessage(query1['进价']);
jinjia:=query1['进价'];
shoujia:=query1['售价'];
cbje:=floattostr(strtofloat(edshuliang.text)* query1['进价']);
xsje:=floattostr(strtofloat(edshuliang.text)* query1['售价']);
tmpsql:='insert into goodsflowbase(品名,牌号,规格,分类编码,等级,物流方向标记,物流来源,';
tmpsql:=tmpsql+'物流目标,数量,单位,成本单价,销售单价,成本金额,销售金额,支付方式,操作员,操作日期,备注,保质期,部门编码,经手人,厂家代表,返货日期)';
tmpsql:=tmpsql+' values('''+trim(Edpinming.text)+''''+',';
tmpsql:=tmpsql+''''+trim(edpaihao.text)+''',';
tmpsql:=tmpsql+''''+trim(query1['规格'])+''',';
tmpsql:=tmpsql+''''+trim(query1['条码'])+''',';
if eddengji.Text='' then tmpsql:=tmpsql+'null,'
else tmpsql:=tmpsql+''''+trim(query1['等级'])+''',';
tmpsql:=tmpsql+''''+trim('进货')+''','''+trim('厂家')+''','''+trim(edbumenbianma.text)+''',';
tmpsql:=tmpsql+edshuliang.text+',';
tmpsql:=tmpsql+''''+trim(query1['计量单位'])+''',';
tmpsql:=tmpsql+jinjia+',';
tmpsql:=tmpsql+shoujia+',';
tmpsql:=tmpsql+cbje+',';
tmpsql:=tmpsql+xsje+',';
tmpsql:=tmpsql+''''+trim(query1['支付方式'])+''',';
tmpsql:=tmpsql+''''+trim(edcaizuoyuan.text)+''',';
tmpsql:=tmpsql+''''+formatdatetime('yyyy-mm-dd',dtpicker1.datetime)+''',';
if edbeizhu.text='' then tmpsql:=tmpsql+'null,'
else tmpsql:=tmpsql+''''+trim(edbeizhu.text)+''',';
if Edbaozhiqi.text='' then tmpsql:=tmpsql+'null,'
else tmpsql:=tmpsql+''''+trim(edbaozhiqi.text)+''',';
if edbumenbianma.text='' then tmpsql:=tmpsql+'null,'
else tmpsql:=tmpsql+''''+trim(edbumenbianma.text)+''',';
if edjingshouren.text='' then tmpsql:=tmpsql+'null,'
else tmpsql:=tmpsql+''''+trim(edjingshouren.text)+''',';
if edchangjiadaibiao.text='' then tmpsql:=tmpsql+'null,'
else tmpsql:=tmpsql+''''+trim(edchangjiadaibiao.text)+''',';
tmpsql:=tmpsql+'null)';
with query1 do
begin
close;
sql.clear;
//showmessage(tmpsql);
sql.add(tmpsql);
prepare;
execsql;
end;
}
{
tmpsql:='select * from copebase where 条码='''+trim(tiaoma)+'''';
tmpquery.Close;
tmpquery.SQL.Clear;
tmpquery.SQL.Add(tmpsql);
tmpquery.Prepare;
tmpquery.ExecSQL;
if tmpquery['库存结算金额']=null then kucunjie:='0'
else kucunjie:=tmpquery['库存结算金额'];
kucunjie:=floattostr(strtofloat(cbje)+strtofloat(kucunjie));
tmpsql:='update copebase set 库存数量='''+trim(inttostr(sum1))+''',库存结算金额='+kucunjie+' where 条码='''+trim(tiaoma)+'''';
tmpquery.Close;
tmpquery.SQL.Clear;
tmpquery.SQL.Add(tmpsql);
tmpquery.Prepare;
tmpquery.ExecSQL;}
{tmpsql:='select a=sum(销售结算金额),b=sum(库存结算金额) from goodsbase where 供货商='''+trim(gonghuoshang)+'''';
tmpquery1:=tquery.Create(self);
tmpquery1.DatabaseName:='guohua1';
tmpquery1.Close;
tmpquery1.SQL.Clear;
tmpquery1.SQL.Add(tmpsql);
tmpquery1.Prepare;
tmpquery1.Open;
if tmpquery1['a']=null then xiaoshoujie:='0'
else xiaoshoujie:=tmpquery1['a'];
if tmpquery1['b']=null then kucunjiesuan:='0'
else kucunjiesuan:=tmpquery1['b'];}
//更新copebalancebase
tmpsql:='select * from copebalancebase where 供货商='''+trim(gonghuoshang)+'''';
tmpquery.Close;
tmpquery.SQL.Clear;
tmpquery.SQL.Add(tmpsql);
tmpquery.Prepare;
tmpquery.open;
if (tmpquery['已结算金额']=null) then yijiesuan:='0'
else yijiesuan:=tmpquery['已结算金额'];
if (tmpquery['销售结算金额']=null) then xiaoshoujie:='0'
else xiaoshoujie:=tmpquery['销售结算金额'];
if (tmpquery['库存结算金额']=null) then kucunjiesuan:='0'
else kucunjiesuan:=tmpquery['库存结算金额'];
yijiesuan:=floattostr(strtofloat(yijiesuan)+strtofloat(edjiezhangjine.Text));
kucunjiesuan:=floattostr(strtofloat(kucunjiesuan)+strtofloat(shuliang)*strtofloat(jinjia));
//qiankuan:=floattostr(strtofloat(xiaoshoujie)-strtofloat(yijiesuan));
//zongqiankuan:=kucunjiesuan+qiankuan;
jinhuojine:=floattostr(strtofloat(xiaoshoujie)+strtofloat(kucunjiesuan));
if tmpquery['应付金额']=null then yingfujine:='0'
else yingfujine:=tmpquery['应付金额'];
if combobox1.Text='代销' then yingfujine:=floattostr(strtofloat(yingfujine)+0)
else yingfujine:=floattostr(strtofloat(yingfujine)+strtofloat(shuliang)*strtofloat(jinjia));
jinhuopingheng:=floattostr(strtofloat(jinhuojine)-strtofloat(yijiesuan));
zongqiankuan:=floattostr(strtofloat(yingfujine)-strtofloat(yijiesuan));
tmpsql:='update copebalancebase set 已结算金额='+yijiesuan+',库存结算金额='+kucunjiesuan+',欠款金额='+zongqiankuan+',进货金额='+jinhuojine+',应付金额='+yingfujine+',进货平衡金额='+jinhuopingheng+',更新日期='''+formatdatetime('20yy-mm-dd',now)+''',经手人='''+trim(edjingshouren.Text)+''',备注='''+trim(Edbeizhu.Text)+''' where 供货商='''+trim(gonghuoshang)+'''';
tmpquery.Close;
tmpquery.SQL.Clear;
tmpquery.SQL.Add(tmpsql);
tmpquery.Prepare;
tmpquery.ExecSQL;
//更新accountrecordbase
if edjiezhangjine.Text='0' then
begin
showmessage('进货完毕,请继续');
tmpquery.Free;
tmpquery1.Free;
frmdepchange.close;
exit;
end
else
begin
tmpsql:='insert into accountrecordbase (供货商,结账金额,付款方式,日期,备注,合同号,品名,条码,经手人)';
tmpsql:=tmpsql+'values('''+trim(gonghuoshang)+''','+edjiezhangjine.text+','''+trim(ComboBox1.SelText)+''',';
tmpsql:=tmpsql+''''+formatdatetime('20yy-mm-dd',now)+''',';
if edbeizhu.Text='' then tmpsql:=tmpsql+'null,'
else tmpsql:=tmpsql+''''+trim(edbeizhu.text)+''',';
tmpsql:=tmpsql+''''+trim(edhetonghao.text)+''','''+trim(edpinming.Text)+''','+tiaoma+','''+trim(edjingshouren.text)+''')';
tmpquery.Close;
tmpquery.SQL.Clear;
tmpquery.SQL.Add(tmpsql);
tmpquery.Prepare;
tmpquery.ExecSQL;
end;
showmessage('进货完毕,请继续');
tmpquery.Free;
tmpquery1.Free;
frmdepchange.close
end;
procedure Tfrmdepchange.EdshuliangChange(Sender: TObject);
begin
if trim(edshuliang.Text)<>'' then
edit1.Text:=floattostr(strtofloat(edjinjia.Text)*strtofloat(edshuliang.Text));
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -