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

📄 upriceupdate.pas

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

interface

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

type
  Tpriceupdate = class(TForm)
    OutlookBtn1: TOutlookBtn;
    OutlookBtn2: TOutlookBtn;
    Query1: TQuery;
    StaticText1: TStaticText;
    StaticText2: TStaticText;
    StaticText3: TStaticText;
    StaticText4: TStaticText;
    StaticText5: TStaticText;
    StaticText6: TStaticText;
    StaticText7: TStaticText;
    StaticText8: TStaticText;
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    Edit4: TEdit;
    Edit5: TEdit;
    Image1: TImage;
    StaticText9: TStaticText;
    StaticText10: TStaticText;
    StaticText11: TStaticText;
    procedure FormCreate(Sender: TObject);
    procedure OutlookBtn1Click(Sender: TObject);
    procedure OutlookBtn2Click(Sender: TObject);
    procedure FormKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  priceupdate: Tpriceupdate;

implementation

uses UPrice, main;

{$R *.DFM}

procedure Tpriceupdate.FormCreate(Sender: TObject);
begin
  //Query1.Close;
  //Query1.SQL.Clear;
  //Query1.SQL.Add('select 结账日期 from purchaserecordbase where 合同号='''+Price.QueryPrice['合同号']+''' order by 结账日期');
  //Query1.Open;
  //Query1.Last;
  StaticText1.Caption := Price.QueryPrice['供货商'];
  StaticText2.Caption := Price.QueryPrice['合同号'];
  StaticText3.Caption := Price.QueryPrice['进货数量'];
  StaticText4.Caption := Price.QueryPrice['销售数量'];
  StaticText5.Caption := Price.QueryPrice['售价'];
  StaticText6.Caption := Price.QueryPrice['结账方式'];
  StaticText7.Caption := Price.QueryPrice['进价'];
  StaticText8.Caption := Price.QueryPrice['当前库存'];
  StaticText9.Caption := Price.QueryPrice['品名'];
  StaticText10.Caption := Price.QueryPrice['牌号'];
  StaticText11.Caption := Price.QueryPrice['销售部门'];
  Edit2.Text := StaticText8.Caption;
  Edit3.Text := StaticText2.Caption;
end;

procedure Tpriceupdate.OutlookBtn1Click(Sender: TObject);
var
  Aid,StrikeMode,SellNumber:integer;
  a,b,tem,ARStrikeMoney,BehoveStrikeMoney,StrikeMoney,StockStrikeMoney,CopeBalanceMoney,SellStrikeMoney,BehoveSellMoney,ARSellMoney,NewSellMoney,CopeMoney:real;
  TmpSql,Merchant:string;
  checkpass:integer;
  soperator:string;
begin
if edit4.Text='' then
  begin
    showmessage('请填写厂家经手人');
    edit5.SetFocus;
    exit
  end;
  if edit5.Text='' then
  begin
    showmessage('请填写经手人代码');
    edit5.SetFocus;
    exit
  end;
  checkpass:=mainfm.checkpass(Edit5.Text,5,soperator);
  if checkpass=101 then exit;
  Aid:=Price.QueryPrice['id'];
  Merchant:=Price.QueryPrice['供货商'];
  ARStrikeMoney:=Price.QueryPrice['已结算金额'];
  BehoveStrikeMoney:=Price.QueryPrice['应结算金额'];
  tem:=Price.QueryPrice['销售结算金额'];
  if Edit2.Text<>StaticText8.Caption then
    tem:=strtofloat(Edit1.text)*strtoint(Edit2.Text);
  if (Edit1.Text<>'') and (Edit1.Text<>StaticText7.Caption) then
    begin
      if StaticText6.Caption='经销' then StrikeMode:=1;
      if StaticText6.Caption='半经销' then StrikeMode:=2;
      if StaticText6.Caption='代销' then StrikeMode:=3;
      if StaticText6.Caption='半代销' then StrikeMode:=4;
      Query1.Close;
      Query1.SQL.Clear;
      if ARStrikeMoney>tem then
        begin
          StrikeMoney:=ARStrikeMoney-tem;
          Query1.SQL.Add('update goodsbase set 已结算金额='+floattostr(BehoveStrikeMoney)+',当前库存=0,库存结算金额=0,进货数量='+statictext4.Caption+',最后更新日期='''+formatdatetime('20yy-mm-dd',now)+''' where id='+inttostr(Aid)+'');
          Query1.ExecSQL;
        end
      else
        begin
          StrikeMoney:=0;
          Query1.SQL.Add('update goodsbase set 应结算金额='+floattostr(tem)+',当前库存=0,库存结算金额=0,进货数量='+statictext4.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;
          a:=Query1['已结算金额'];
          b:=Query1['应结算金额'];
          if a>b then
            begin
              StrikeMoney:=a-b;
              Query1.Close;
              Query1.SQL.Clear;
              Query1.SQL.Add('update goodsbase set 已结算金额='+floattostr(b)+' where id='+inttostr(Aid)+'');
              Query1.ExecSQL;
            end;
        end;
      Query1.Close;
      Query1.SQL.Clear;
      Query1.SQL.Add('select * into #tg from goodsbase where id='+inttostr(Aid)+'');
      Query1.ExecSql;
      BehoveSellMoney:=(Price.QueryPrice['当前库存']+Price.QueryPrice['销售数量'])*Price.QueryPrice['进价'];
      if (Edit2.Text='') or (Edit2.Text=StaticText8.Caption) then
        begin
          if Edit2.Text='' then
            Edit2.Text:=StaticText8.Caption;
          if Edit3.Text<>'' then
            //begin
            //edit3.Text:=Query1['合同号']+'char(61)';//edit3.text=''.particular
            if Edit3.Text<>StaticText2.Caption then
              begin
                StockStrikeMoney:=strtoint(Edit2.text)*strtofloat(Edit1.text);
                TmpSql:='update #tg set 进价='+edit1.Text+',当前库存='+edit2.Text+',合同号='''+edit3.Text+''',最后更新日期='''+formatdatetime('20yy-mm-dd',now)+''',';
                TmpSql:=TmpSql+'厂家经手人='''+edit4.Text+''',经手人='''+edit5.Text+''',进货数量='+edit2.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;
                Query1.SQL.Add('select * from #tg where id='+inttostr(aid)+'');
                Query1.Open;
                ARSellMoney:=(Price.QueryPrice['当前库存']+Price.QueryPrice['销售数量']-Query1['当前库存'])*Price.QueryPrice['进价'];
                NewSellMoney:=Query1['当前库存']*Query1['进价'];
                Query1.Close;
                Query1.SQL.Clear;
                case StrikeMode of
                  1:
                    begin
                      TmpSql:='update #tg set 应结算金额='+floattostr(StockStrikeMoney)+',已结算金额='+floattostr(StrikeMoney)+'';
                      TmpSql:=TmpSql+' where id='+inttostr(Aid)+'';
                      Query1.SQL.Add(TmpSql);
                      Query1.ExecSQL;
                      Query1.Close;
                      Query1.SQL.Clear;
                      Query1.SQL.Add('select * from copebalancebase where 供货商='''+Merchant+'''');
                      Query1.Open;
                      CopeMoney:=Query1['应付金额'];
                      CopeMoney:=CopeMoney-BehoveSellMoney;
                      CopeMoney:=CopeMoney+ARSellMoney;
                      CopeMoney:=CopeMoney+NewSellMoney;
                      CopeBalanceMoney:=Query1['进货金额']-Query1['应付金额'];
                      a:=Query1['进货金额']-Price.QueryPrice['已结算金额']+tem+StockStrikeMoney;
                      Query1.Close;
                      Query1.SQL.Clear;
                      Query1.SQL.Add('update copebalancebase set 进货金额='+floattostr(a)+',应付金额='+floattostr(CopeMoney)+',进货平衡金额='+floattostr(CopeBalanceMoney)+' where 供货商='''+Merchant+'''');
                      Query1.ExecSQL;
                    end
                else
                  begin
                    Query1.Close;

⌨️ 快捷键说明

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