⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unit8.pas

📁 PosEasy收银系统源码,Pos机前后台管理代码
💻 PAS
📖 第 1 页 / 共 2 页
字号:
unit Unit8;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Buttons, StdCtrls, ExtCtrls, Db, DBTables, Mask, DBCtrls, ComCtrls;

type
  Tfrmdepchange = class(TForm)
    Image1: TImage;
    Edpinming: TEdit;
    Edpaihao: TEdit;
    Edfenlei: TEdit;
    Edchangjia: TEdit;
    SpeedButton1: TSpeedButton;
    SpeedButton2: TSpeedButton;
    DataSource1: TDataSource;
    Query1: TQuery;
    Edshuliang: TEdit;
    Eddengji: TEdit;
    Edbaozhiqi: TEdit;
    Edjingshouren: TEdit;
    Edchangjiadaibiao: TEdit;
    Edbeizhu: TEdit;
    dtpicker1: TDateTimePicker;
    ComboBox1: TComboBox;
    edjiezhangjine: TEdit;
    edhetonghao: TEdit;
    edjinjia: TEdit;
    edshoujia: TEdit;
    dtpicker2: TDateTimePicker;
    edxiaoshoubumen: TEdit;
    edwujiayuan: TEdit;
    Label1: TLabel;
    edchukudanhao: TEdit;
    Label2: TLabel;
    Edit1: TEdit;
    procedure SpeedButton2Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure SpeedButton1Click(Sender: TObject);
    procedure EdshuliangChange(Sender: TObject);
  private
    { Private declarations }
  public
       sum:integer;
       tiaoma,gonghuoshang:string;
  end;

var
  frmdepchange: Tfrmdepchange;

implementation
 uses unit7,unit1,main
{$R *.DFM};
procedure Tfrmdepchange.formcreate(sender:tobject);
var
  tmpSql,s,t,shuilv:string;
  year,month,day:word;
  textid:textfile;
  present:tdatetime;
begin
dtpicker2.DateTime:=now;
with query1 do
begin
close;
sql.clear;
tmpsql:='select * from goodsbase where id='''+inttostr(mainfm.tmpqueryspe2['id'])+'''';
//showmessage(tmpsql);
sql.add(tmpsql);
open

end;
tiaoma:=query1['条码'];
gonghuoshang:=query1['供货商'];
edxiaoshoubumen.Text:=query1['销售部门'];
if query1['品名']=NULL then edpinming.Text:='空'
else edpinming.text:=query1['品名'];
if query1['牌号']=NULL then edpaihao.Text:='空'
else edpaihao.text:=query1['牌号'];
if query1['分类']=NULL then edfenlei.Text:='空'
else edfenlei.text:=query1['分类'];
if query1['等级']=NULL then eddengji.Text:='空'
else eddengji.Text:=query1['等级'];
if query1['厂家']=NULL then edchangjia.Text:='空'
else edchangjia.Text:=query1['厂家'];
if query1['当前库存']=null then sum:=0
else sum:=strtoint(query1['当前库存']);
if query1['进价']=null then edjinjia.Text:='0'
else edjinjia.Text:=query1['进价'];
if query1['售价']=null then edshoujia.Text:='0'
else edshoujia.Text:=query1['售价'];
if query1['合同号']=null then edhetonghao.Text:=''
else edhetonghao.Text:=query1['合同号'];

with query1 do
begin
close;
sql.clear;
tmpsql:='select * from purchaserecordbase where 条码='+tiaoma+'';
//showmessage(tmpsql);
sql.add(tmpsql);
open
end;
if query1['出库单号']=null then edchukudanhao.Text:=''
else edchukudanhao.Text:=query1['出库单号'];
dtpicker1.DateTime:=now;
//生成合同号码
getdir(0,s);
assignfile(textid,'\\GH_SERVER\autonumbro\autonumber.txt');
reset(textid);
readln(textid,t);
//showmessage(t);
t:=inttostr(strtoint(t));
if strtoint(t)<999 then t:=inttostr(strtoint(t)+1)
else t:='1';
closefile(textid);
rewrite(textid);
writeln(textid,t);
closefile(textid);
present:=now;
decodedate(present,year,month,day);
if edhetonghao.Text='' then  edhetonghao.Text:='ht'+inttostr(year)+inttostr(month)+t;
if edchukudanhao.Text='' then  edchukudanhao.Text:='ck'+inttostr(year)+inttostr(month)+t;
//if (query1['结账方式']='') or (query1['结账方式']=null) then combobox1.Text:='请选择结账方式'
//else combobox1.Text:=query1['结账方式'];
end;

procedure Tfrmdepchange.SpeedButton2Click(Sender: TObject);
begin
frmdepchange.close;
mainfm.tabdepappend.Active:=false;
mainfm.tabdepappend.Active:=true;
end;



procedure Tfrmdepchange.SpeedButton1Click(Sender: TObject);
var
 jinjia,shoujia,cbje,xsje,tmpsql,tiaoma,kucun,yijiesuan,xiaoshoujie,qiankuan,zongqiankuan,hetonghao:string;
 jinhuoshuliang,guige,fenlei,tmpsql5,yingfujine,shuliang,yingjiesuan,dengji,gonghuoshang,tongzhidan,jinhuoshangxian,sunhaoxianebi,zhuanlihao,jiancebianhao,shangbiaodaima,kucunjiesuan:string;
 jinhuojine,jinhuopingheng,jiezhangfangshi,jinhuopici,shuilv,jiliangdanwei,daokoubili:string;
 sum1:integer;
 shangxian:integer;
 tmpquery,tmpquery1:tquery;
 checkpass:integer;
 soperator,shoujiakoulv:string;
begin

if edshuliang.text='' then
  begin
      showmessage('请输入数量');
      edshuliang.SetFocus;
      exit;
   end;

if edjingshouren.text='' then
   begin
       showmessage('请输入经手人的名字');
       edjingshouren.setfocus;
       exit;
   end;
if (combobox1.Text='请选择结账方式') or (trim(combobox1.text)='')then
   begin
       showmessage('您没有选择结账方式');
       exit;
   end;
if edhetonghao.Text='' then
   begin
       showmessage('您没有输入合同号');
       exit;
   end;
checkpass:=mainfm.checkpass(Edjingshouren.Text,5,soperator);
if checkpass=101 then exit;
sum1:=sum+strtoint(edshuliang.text);
with query1 do
begin
close;
sql.clear;
tmpsql:=('select * from goodsbase where id='''+inttostr(mainfm.tmpqueryspe2['id'])+'''');
//showmessage(tmpsql);
sql.add(tmpsql);
open;
end;
//更新goodsbase
shuliang:=Edshuliang.text;
jiliangdanwei:=query1['计量单位'];
tiaoma:=query1['条码'];
guige:=query1['规格'];
dengji:=query1['等级'];
gonghuoshang:=query1['供货商'];
if query1['新增商品通知单来源']=null then tongzhidan:=''
else tongzhidan:=query1['新增商品通知单来源'];
fenlei:=query1['分类'];
if query1['税率']=null then shuilv:='1'
else shuilv:=query1['税率'];
if query1['进货上限']=null then jinhuoshangxian:='null'
else jinhuoshangxian:=query1['进货上限'];
if query1['损耗限额比']=null then sunhaoxianebi:='null'
else sunhaoxianebi:=query1['损耗限额比'];
if (query1['专利号']=null) or (query1['专利号']='') then zhuanlihao:='null'
else zhuanlihao:=query1['专利号'];
if (query1['检测报告编号']=null) or (query1['检测报告编号']='') then jiancebianhao:='null'
else jiancebianhao:=query1['检测报告编号'];
if (query1['商标代码']=null) or (query1['商标代码']='') then  shangbiaodaima:='null'
else shangbiaodaima:=query1['商标代码'];
if (query1['合同号']=null) or (query1['合同号']='') then hetonghao:='null'
else hetonghao:=query1['合同号'];
if query1['进货数量']=null then jinhuoshuliang:='0'
else jinhuoshuliang:=query1['进货数量'];
if query1['已结算金额']=null then yijiesuan:='0'
else yijiesuan:=query1['已结算金额'];
if query1['应结算金额']=null then yingjiesuan:='0'
else yingjiesuan:=query1['应结算金额'];
if query1['当前库存']=null then kucun:='0'
else kucun:=query1['当前库存'];
if query1['进价']=null then jinjia:='0'
else jinjia:=query1['进价'];
if query1['售价']=null then shoujia:='0'
else shoujia:=query1['售价'];
if query1['倒扣比例']=null then daokoubili:='0'
else daokoubili:=query1['倒扣比例'];
if (query1['结账方式']=null) or (query1['结账方式']='') then jiezhangfangshi:=''
else jiezhangfangshi:=query1['结账方式'];
if combobox1.Text='代销' then  yingjiesuan:=floattostr(strtofloat(yingjiesuan)+0)
else yingjiesuan:=floattostr(strtofloat(yingjiesuan)+strtofloat(edshuliang.Text)*strtofloat(edjinjia.Text));
if query1['售价扣率']=null then shoujiakoulv:='0'
else shoujiakoulv:=query1['售价扣率'];
yijiesuan:=floattostr(strtofloat(yijiesuan)+strtofloat(edjiezhangjine.Text));
kucunjiesuan:=floattostr(sum1*strtofloat(edjinjia.text));
//yingjiesuan:=floattostr(strtofloat(kucunjiesuan)-strtofloat(yijiesuan));
jinhuoshuliang:=inttostr(strtoint(jinhuoshuliang)+strtoint(edshuliang.Text));
//如果合同号相等,进行更新
if hetonghao=edhetonghao.Text then
 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 (jiezhangfangshi<>'6') and (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;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -