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

📄 usellpriceupdate.pas

📁 PosEasy收银系统源码,Pos机前后台管理代码
💻 PAS
字号:
unit USellPriceUpdate;

interface

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

type
  TSellPriceUpdate = class(TForm)
    Query1: TQuery;
    Image1: TImage;
    StaticText1: TStaticText;
    StaticText2: TStaticText;
    StaticText3: TStaticText;
    StaticText4: TStaticText;
    StaticText5: TStaticText;
    StaticText6: TStaticText;
    StaticText7: TStaticText;
    StaticText8: TStaticText;
    StaticText9: TStaticText;
    StaticText10: TStaticText;
    StaticText11: TStaticText;
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    Edit4: TEdit;
    SpeedButton1: TSpeedButton;
    SpeedButton2: TSpeedButton;
    procedure FormCreate(Sender: TObject);
    procedure SpeedButton1Click(Sender: TObject);
    procedure SpeedButton2Click(Sender: TObject);
    procedure FormKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
  private
    tiaoma:string;{ Private declarations }
  public
    shoujiakoulv,dangqiankucun:string;{ Public declarations }
  end;

var
  SellPriceUpdate: TSellPriceUpdate;

implementation

uses USellPrice, main;

{$R *.DFM}

procedure TSellPriceUpdate.FormCreate(Sender: TObject);
begin
  StaticText1.Caption := SellPrice.Query1['品名'];
  StaticText2.Caption := SellPrice.Query1['牌号'];
  StaticText3.Caption := SellPrice.Query1['进货数量'];
  StaticText4.Caption := SellPrice.Query1['进价'];
  StaticText5.Caption := SellPrice.Query1['合同号'];
  StaticText6.Caption := SellPrice.Query1['供货商'];
  StaticText7.Caption := SellPrice.Query1['销售数量'];
  StaticText8.Caption := SellPrice.Query1['售价'];
  StaticText9.Caption := SellPrice.Query1['销售部门'];
  StaticText10.Caption := SellPrice.Query1['当前库存'];
  StaticText11.Caption := SellPrice.Query1['结账方式'];
  if sellprice.Query1['售价扣率']=null then shoujiakoulv:='0'
  else shoujiakoulv:=sellprice.Query1['售价扣率'] ;
  dangqiankucun:=sellprice.query1['当前库存'];
  Edit2.Text := StaticText5.Caption;
  tiaoma:=SellPrice.Query1['条码'];
  //showmessage(tiaoma);
end;

procedure TSellPriceUpdate.SpeedButton1Click(Sender: TObject);
var
  Aid:integer;
  StrikeMode:boolean;
  tmpa,tmpb,ARStrikeMoney,BehoveStrikeMoney,MoveStrikeMoney,StockStrikeMoney:real;
  Merchant,TmpSql:string;
  checkpass:integer;
  soperator,shoujia,jinjia,jiesuanfangshi,xiaoshoujie,yijie,kujie,qiankuan,jinhuo,yingfu,jinhuopingheng,cha,jinjia1:string;
begin
  if edit4.Text='' then
  begin
    showmessage('请填写经手人代码');
    edit4.SetFocus;
    exit
  end;
  if Edit2.Text=StaticText5.Caption then
  begin
     showmessage('合同号不能相同');
     edit2.SetFocus;
     exit;
  end;
  if trim(edit2.Text)='' then
  begin
     showmessage('请输入合同号');
     edit2.SetFocus;
     exit;
  end;
  checkpass:=mainfm.checkpass(Edit4.Text,5,soperator);
  if checkpass=101 then exit;
  Aid:=SellPrice.Query1['id'];
  Merchant:=SellPrice.Query1['供货商'];
  ARStrikeMoney:=SellPrice.Query1['已结算金额'];
  BehoveStrikeMoney:=SellPrice.Query1['应结算金额'];
  jiesuanfangshi:=sellprice.Query1['结账方式'];
  if (sellprice.Query1['库存结算金额']=null)  then stockStrikeMoney:=0
  else StockStrikeMoney:=SellPrice.Query1['库存结算金额'];
  if (Edit1.Text<>'') and (Edit1.Text<>StaticText8.Caption) then
    begin
      if StaticText11.Caption = '经销' then StrikeMode:=True;
      Query1.Close;
      Query1.SQL.Clear;
      if ARStrikeMoney>BehoveStrikeMoney then
        begin
          MoveStrikeMoney:=ARStrikeMoney-BehoveStrikeMoney;
          Query1.SQL.Add('update goodsbase set 已结算金额='+floattostr(BehoveStrikeMoney)+',应结算金额='+floattostr(SellPrice.Query1['销售结算金额'])+',当前库存=0,库存结算金额=0,进货数量='+statictext7.Caption+',最后更新日期='''+formatdatetime('20yy-mm-dd',now)+''' where id='+inttostr(Aid)+'');
          Query1.ExecSQL;
        end
      else
        begin
          MoveStrikeMoney:=0;
          Query1.SQL.Add('update goodsbase set 应结算金额='+floattostr(SellPrice.Query1['销售结算金额'])+',当前库存=0,库存结算金额=0,进货数量='+statictext7.Caption+',最后更新日期='''+formatdatetime('20yy-mm-dd',now)+''' where id='+inttostr(Aid)+'');
          Query1.ExecSQL;
          Query1.Close;
          Query1.SQL.Clear;
          Query1.SQL.Add('select * from goodsbase where id='+inttostr(Aid)+'');
          Query1.Open;
          tmpa:=Query1['已结算金额'];
          tmpb:=Query1['应结算金额'];
          if tmpa>tmpb then
            begin
              MoveStrikeMoney:=tmpa-tmpb;
              Query1.Close;
              Query1.SQL.Clear;
              Query1.SQL.Add('update goodsbase set 已结算金额='+floattostr(tmpb)+' where id='+inttostr(Aid)+'');
              Query1.ExecSQL;
            end;
          Query1.Close;
          Query1.SQL.Clear;
          Query1.SQL.Add('select * into #tg from goodsbase where id='+inttostr(Aid)+'');
          Query1.ExecSql;

          tmpsql:='select 进价 from goodsbase where id='+inttostr(Aid)+'';
          query1.close;
          query1.SQL.Clear;
          query1.SQL.Add(tmpsql);
          query1.open;
          jinjia:=query1['进价'];
          jinjia1:=jinjia;
          if Edit2.Text<>'' then
            begin
              if Edit2.Text<>StaticText5.Caption then
                begin
                  if (shoujiakoulv='0') or (shoujiakoulv=null) then jinjia:=jinjia
                  else jinjia:=floattostr(strtofloat(edit1.Text)*(1-strtofloat(shoujiakoulv)));
                  stockStrikeMoney:=strtofloat(dangqiankucun)*strtofloat(jinjia);
                  TmpSql:='update #tg set 售价='+edit1.Text+',进价='+jinjia+',进货数量='+dangqiankucun+',当前库存='+dangqiankucun+',合同号='''+edit2.Text+''',最后更新日期='''+formatdatetime('20yy-mm-dd',now)+''',';
                  TmpSql:=TmpSql+'物价员='''+edit3.Text+''',经手人='''+edit4.Text+''',';
                  TmpSql:=TmpSql+'库存结算金额='+floattostr(StockStrikeMoney)+',销售数量=0,销售结算金额=0 where id='+inttostr(Aid)+'';
                  Query1.Close;
                  Query1.SQL.Clear;
                  Query1.SQL.Add(tmpsql);
                  Query1.ExecSQL;
                  Query1.Close;
                  Query1.SQL.Clear;
                  if StrikeMode=True then
                    begin
                      TmpSql:='update #tg set 应结算金额='+floattostr(StockStrikeMoney)+',已结算金额='+floattostr(MoveStrikeMoney)+',结算数量=0';
                      TmpSql:=TmpSql+' where id='+inttostr(Aid)+'';
                      Query1.SQL.Add(TmpSql);
                      Query1.ExecSQL;
                    end
                  else
                    begin
                      TmpSql:='update #tg set 应结算金额=0,已结算金额='+floattostr(MoveStrikeMoney)+',结算数量=0';
                      TmpSql:=TmpSql+' where id='+inttostr(Aid)+'';
                      Query1.SQL.Add(TmpSql);
                      Query1.ExecSQL;
                    end;
                  TmpSql:='insert into goodsbase select 品名,牌号,条码,规格,分类,等级,厂家,供货商,进价,售价,';
                  TmpSql:=TmpSql+'销售部门,新增商品通知单来源,进货上限,进货数量,当前库存,库存损耗数量,结账方式,损耗限额比,物价员,';
                  TmpSql:=TmpSql+'最后更新日期,专利号,检测报告编号,商标代码,厂家经手人,经手人,合同号,结账日期,销售数量,';
                  TmpSql:=TmpSql+'销售结算金额,库存结算金额,库存损耗金额,应结算金额,交易更新时间,已结算金额,备注,折扣标志,计量单位,销售更新标志,税率,结算数量,折扣,折扣折让,倒扣比例,进价扣率,售价扣率,销售金额,审核人,选择 from #tg where id='''+inttostr(Aid)+'''';
                  Query1.Close;
                  Query1.SQL.Clear;
                  Query1.SQL.Add(tmpsql);
                  Query1.ExecSQL;
                  //更新pricebase
                  shoujia:=edit1.Text;
                  tmpsql:='update pricebase set 售价='+shoujia+' where 条码='+tiaoma+'';
                  Query1.Close;
                  Query1.SQL.Clear;
                  Query1.SQL.Add(tmpsql);
                  query1.Prepare;
                  Query1.ExecSQL;
                  //代销商品更新copebalancebase
                  if jiesuanfangshi<>'代销' then exit
                  else
                     begin
                        tmpsql:='select * from copebalancebase where 供货商='''+trim(Merchant)+'''';
                        Query1.Close;
                        Query1.SQL.Clear;
                        Query1.SQL.Add(tmpsql);
                        query1.Prepare;
                        Query1.Open;
                        xiaoshoujie:=query1['销售结算金额'];
                        yijie:=query1['已结算金额'];
                        kujie:=query1['库存结算金额'];
                        qiankuan:=query1['欠款金额'];
                        jinhuo:=query1['进货金额'];
                        yingfu:=query1['应付金额'];
                        jinhuopingheng:=query1['进货平衡金额'];
                        cha:=floattostr((strtofloat(jinjia1)-strtofloat(jinjia))*strtofloat(dangqiankucun));
                        kujie:=floattostr(strtofloat(kujie)-strtofloat(cha));
                        jinhuo:=floattostr(strtofloat(jinhuo)-strtofloat(cha));
                        jinhuopingheng:=floattostr(strtofloat(jinhuo)-strtofloat(yijie));
                        tmpsql:='update copebalancebase set 库存结算金额='+kujie+',进货金额='+jinhuo+',进货平衡金额='+jinhuopingheng+' where 供货商='''+trim(Merchant)+'''';
                        Query1.Close;
                        Query1.SQL.Clear;
                        Query1.SQL.Add(tmpsql);
                        query1.Prepare;
                        Query1.ExecSQL;
                     end;
                end
              else
                begin
                  Application.MessageBox('合同号不能相同!','提示',MB_IconInformation);
                end;
            end
          else
            begin
              Application.MessageBox('请输入合同号!','消息',MB_IconInformation);
            end;
          Query1.Close;
          Query1.SQL.Clear;
          Query1.SQL.Add('drop table #tg');
          Query1.ExecSQL;
          Edit1.Text:='';
          Edit2.Text:='';
          Edit3.Text:='';
          Edit4.Text:='';
        end;
    end
  else
    begin
      Application.MessageBox('新售价无效!','消息',MB_IconInformation);
    end;
end;

procedure TSellPriceUpdate.SpeedButton2Click(Sender: TObject);
var
  Merchant:string;
begin
  Merchant:=SellPrice.Query1['供货商'];
  with SellPrice do
    begin
      Query1.Close;
      Query1.SQL.Clear;
      Query1.SQL.Add('select * from goodsbase where 供货商='''+Trim(Merchant)+''' and 进货数量<>0');
      Query1.Prepare;
      Query1.Open;
    end;
  SellPrice.OnActivate(self);
  SellPriceUpdate.Release;
  SellPriceUpdate.Close;
end;

procedure TSellPriceUpdate.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
 if Key=VK_Return then
   begin
     Key:=0;
     postmessage(handle,WM_NEXTDlGctl,0,0);
   end;
 if Key=VK_F1 then
   begin
     SpeedButton1.Click;
   end;
 if Key=VK_ESCAPE then
   begin
     SpeedButton2.Click;
   end;
end;

end.

⌨️ 快捷键说明

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