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

📄 p_tk.pas

📁 超市系统超市系统超市系统超市系统超市系统超市系统超市系统超市系统超市系统超市系统超市系统超市系统超市系统超市系统
💻 PAS
字号:
unit P_TK;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs,P_MC, Grids, DBGrids, ExtCtrls, SUIImagePanel, SUIGroupBox,
  SUIRadioGroup, StdCtrls, ComCtrls, SUIButton, SUIEdit, Buttons, Mask,
  DBCtrls, SUIDBCtrls;

type
  TF_TK = class(Tf_mc)
    DBGrid1: TDBGrid;
    rg_tklx: TsuiRadioGroup;
    Panel1: TPanel;
    dt1: TDateTimePicker;
    Label2: TLabel;
    dt2: TDateTimePicker;
    rq: TsuiCheckBox;
    ckdh: TsuiCheckBox;
    eckdh: TsuiEdit;
    spm: TsuiCheckBox;
    espm: TsuiEdit;
    BitBtn1: TBitBtn;
    Panel2: TPanel;
    Label1: TLabel;
    etksl: TsuiEdit;
    b_add: TBitBtn;
    b_cancel: TBitBtn;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    suiDBEdit1: TsuiDBEdit;
    suiDBEdit2: TsuiDBEdit;
    suiDBEdit3: TsuiDBEdit;
    suiDBEdit4: TsuiDBEdit;
    rg_lx: TsuiRadioGroup;
    rg_sslx: TsuiRadioGroup;
    c: TLabel;
    Label8: TLabel;
    k: TLabel;
    Label10: TLabel;
    procedure DBGrid1CellClick(Column: TColumn);
    procedure b_cancelClick(Sender: TObject);
    procedure rg_tklxClick(Sender: TObject);
    procedure etkslKeyPress(Sender: TObject; var Key: Char);
    procedure FormCreate(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure b_addClick(Sender: TObject);
    procedure rg_lxClick(Sender: TObject);
    procedure thdj;     //退货登记
    procedure delth;    //删除退货
    procedure ssdj;
    procedure rqClick(Sender: TObject);
    procedure ckdhClick(Sender: TObject);
    procedure spmClick(Sender: TObject);
    procedure BitBtn1Click(Sender: TObject);     //实收登记
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  F_TK: TF_TK;

implementation

uses p_dm;
{$R *.dfm}

procedure tf_tk.ssdj;
begin
  if dm.Query.RecordCount=0 then
  begin
    application.MessageBox('没有出库信息!','提示',mb_ok+mb_iconinformation);
    exit;
  end;
  with dm do
  begin
    query1.SQL.Clear;
    query1.SQL.Add('update ck_info set scsl=:z where ddh=:a and sph=:b and c=:d and hcl=:e and szmd=:f and ysx=:g and cklx=:h');
    query1.Parameters[0].Value:=trim(etksl.Text);
    query1.Parameters[1].value:=query['ddh'];
    query1.Parameters[2].value:=query['sph'];
    query1.Parameters[3].value:=query['c'];
    query1.Parameters[4].value:=query['hcl'];
    query1.Parameters[5].value:=query['szmd'];
    query1.Parameters[6].value:=query['ysx'];
    query1.Parameters[7].value:='出库';
    query1.ExecSQL;
    application.MessageBox('客户实收数量修改成功!','信息',mb_ok+mb_iconinformation);
    query.SQL.Clear;
    query.SQL.Add('select * from ck_info,sp_info,spxh_info where ck_info.sph=sp_info.sph and sp_info.xhh=spxh_info.xhh and cklx=:cklx');
    query.Parameters[0].Value:='出库';
    query.Open;
  end;
end;

procedure tf_tk.delth;
begin
  with dm do
  begin
    if query.RecordCount=0 then
    begin
      application.MessageBox('没有退货信息!','信息',mb_ok+mb_iconinformation);
      exit;
    end;
    query1.SQL.Clear;
    query1.SQL.Add('update ck_info set scsl=scsl+:sl where ddh=:a and sph=:b and c=:d and hcl=:e and szmd=:f and ysx=:g and cklx=:cklx');
    query1.Parameters[0].value:=query['sl'];
    query1.Parameters[1].value:=query['ddh'];
    query1.Parameters[2].value:=query['sph'];
    query1.Parameters[3].value:=query['c'];
    query1.Parameters[4].value:=query['hcl'];
    query1.Parameters[5].value:=query['szmd'];
    query1.Parameters[6].value:=query['ysx'];
    query1.Parameters[7].Value:='出库';
    query1.ExecSQL;
    query1.SQL.Clear;
    query1.SQL.Add('update kc_info set sl=sl-:thsl where ddh=:ddh and sph=:sph and c=:c and hcl=:hcl and szmd=:szmd and ysx=:ysx');
    query1.Parameters[0].Value:=trim(etksl.Text);
    query1.Parameters[1].value:=query['rkdh'];
    query1.Parameters[2].value:=query['sph'];
    query1.Parameters[3].value:=query['c'];
    query1.Parameters[4].value:=query['hcl'];
    query1.Parameters[5].value:=query['szmd'];
    query1.Parameters[6].value:=query['ysx'];
    query1.ExecSQL;
    query1.SQL.Clear;
    query1.SQL.Add('delete from ck_info where ddh=:a and sph=:b and c=:d and hcl=:e and szmd=:f and ysx=:g and cklx=:h and sl=:i');
    query1.Parameters[0].value:=query['ddh'];
    query1.Parameters[1].value:=query['sph'];
    query1.Parameters[2].value:=query['c'];
    query1.Parameters[3].value:=query['hcl'];
    query1.Parameters[4].value:=query['szmd'];
    query1.Parameters[5].value:=query['ysx'];
    query1.Parameters[6].value:='退库';
    query1.Parameters[7].Value:=query['sl'];
    query1.ExecSQL;
    application.MessageBox('删除退货信息成功!','信息',mb_ok+mb_iconinformation);
    rg_tklx.OnClick(self);
  end;
end;

procedure tf_tk.thdj;
var
 yzwsl:real;
begin
  inherited;
  if dm.Query.RecordCount=0 then
  begin
    application.MessageBox('没有出库信息!','提示',mb_ok+mb_iconinformation);
    exit;
  end;
  if etksl.Text='' then etksl.Text:='0';
  yzwsl:=strtofloat(trim(etksl.Text));
  if yzwsl<=0 then
  begin
    application.MessageBox('退货数量不能小于等于0!','错误',mb_ok+mb_iconwarning);
    exit;
  end;
  if yzwsl>dm.Query['scsl'] then
  begin
    application.MessageBox('退货数量不能大于实出数量!','错误',mb_ok+mb_iconwarning);
    exit;
  end;
  with dm do
  begin
    query1.SQL.Clear;
    query1.SQL.Add('select * from ck_info where rkdh=:a and sph=:b and c=:d and hcl=:e and szmd=:f and ysx=:g and cklx=:h and ddh=:z');
    query1.Parameters[0].value:=query['rkdh'];
    query1.Parameters[1].value:=query['sph'];
    query1.Parameters[2].value:=query['c'];
    query1.Parameters[3].value:=query['hcl'];
    query1.Parameters[4].value:=query['szmd'];
    query1.Parameters[5].value:=query['ysx'];
    query1.Parameters[6].Value:='退库';
    query1.Parameters[7].Value:=query['ddh'];
    query1.open;
    if query1.RecordCount<>0 then
    begin
      application.MessageBox('该商品已有退货,如果退货数量不符,请删除退货信息后重新退货登记!','提示',mb_ok+mb_iconinformation);
      exit;
    end;
    query1.SQL.Clear;
    query1.SQL.Add('delete from tempck_info');
    query1.ExecSQL;
    query1.SQL.Clear;
    query1.SQL.Add('insert into tempck_info select * from ck_info where ddh=:a and sph=:b and c=:d and hcl=:e and szmd=:f and ysx=:g and cklx=:h');
    query1.Parameters[0].value:=query['ddh'];
    query1.Parameters[1].value:=query['sph'];
    query1.Parameters[2].value:=query['c'];
    query1.Parameters[3].value:=query['hcl'];
    query1.Parameters[4].value:=query['szmd'];
    query1.Parameters[5].value:=query['ysx'];
    query1.Parameters[6].value:='出库';
    query1.ExecSQL;
    query1.SQL.Clear;
    query1.SQL.Add('update tempck_info set scsl=:a,cklx=:b,sl=:c');
    query1.Parameters[0].Value:=0;
    query1.Parameters[1].Value:='退库';
    query1.Parameters[2].Value:=trim(etksl.Text);
    query1.ExecSQL;
    query1.SQL.Clear;
    query1.SQL.Add('insert into ck_info select * from tempck_info');
    query1.ExecSQL;
    query1.SQL.Clear;
    query1.SQL.Add('update ck_info set scsl=scsl-:sl where ddh=:a and sph=:b and c=:d and hcl=:e and szmd=:f and ysx=:g and cklx=:cklx');
    query1.Parameters[0].value:=strtofloat(trim(etksl.Text));
    query1.Parameters[1].value:=query['ddh'];
    query1.Parameters[2].value:=query['sph'];
    query1.Parameters[3].value:=query['c'];
    query1.Parameters[4].value:=query['hcl'];
    query1.Parameters[5].value:=query['szmd'];
    query1.Parameters[6].value:=query['ysx'];
    query1.Parameters[7].Value:='出库';
    query1.ExecSQL;
    query1.SQL.Clear;
    query1.SQL.Add('update kc_info set sl=sl+:thsl where ddh=:ddh and sph=:sph and c=:c and hcl=:hcl and szmd=:szmd and ysx=:ysx');
    query1.Parameters[0].Value:=trim(etksl.Text);
    query1.Parameters[1].value:=query['rkdh'];
    query1.Parameters[2].value:=query['sph'];
    query1.Parameters[3].value:=query['c'];
    query1.Parameters[4].value:=query['hcl'];
    query1.Parameters[5].value:=query['szmd'];
    query1.Parameters[6].value:=query['ysx'];
    query1.ExecSQL;
    query.Requery;
    application.MessageBox('退货登记成功!','退货成功',mb_ok+mb_iconinformation);
  end;
end;


procedure TF_TK.DBGrid1CellClick(Column: TColumn);
begin
  inherited;
  if dm.Query.RecordCount=0 then
  begin
    //application.MessageBox('')
    exit;
  end;
  etksl.Text:=dm.Query['scsl'];
  try
   etksl.SetFocus;
  except
  end;
end;

procedure TF_TK.b_cancelClick(Sender: TObject);
begin
  inherited;
  close;
end;

procedure TF_TK.rg_tklxClick(Sender: TObject);
begin
  inherited;
  if rg_tklx.ItemIndex=0 then
  begin
    b_add.Caption:='退货登记';
    etksl.Enabled:=true;
    c.Caption:='出';
    k.Caption:='库';
    with dm do
    begin
      query.SQL.Clear;
      query.SQL.Add('select * from ck_info,sp_info,spxh_info where ck_info.sph=sp_info.sph and sp_info.xhh=spxh_info.xhh and cklx=:cklx');
      query.Parameters[0].Value:='出库';
      query.Open;
      rq.Checked:=false;
      ckdh.Checked:=false;
      spm.Checked:=false;
      dt1.Enabled:=false;
      dt2.Enabled:=false;
      eckdh.Enabled:=false;
      espm.Enabled:=false;
    end;
  end else
  begin
    with dm do
    begin
      query.SQL.Clear;
      query.SQL.Add('select * from ck_info,sp_info,spxh_info where ck_info.sph=sp_info.sph and sp_info.xhh=spxh_info.xhh and cklx=:cklx');
      query.Parameters[0].Value:='退库';
      query.Open;
      if query.RecordCount=0 then
      begin
        //application.MessageBox('没有退货信息,不能进行删除!','提示',mb_ok+mb_iconinformation);
        rg_tklx.ItemIndex:=0;
        query.SQL.Clear;
        query.SQL.Add('select * from ck_info,sp_info,spxh_info where ck_info.sph=sp_info.sph and sp_info.xhh=spxh_info.xhh and cklx=:cklx');
        query.Parameters[0].Value:='出库';
        query.Open;
        rq.Checked:=false;
        ckdh.Checked:=false;
        spm.Checked:=false;
        dt1.Enabled:=false;
        dt2.Enabled:=false;
        eckdh.Enabled:=false;
        espm.Enabled:=false;
        b_add.Caption:='删除退货';
        exit;
      end;
    end;
    b_add.Caption:='删除退货';
    etksl.Enabled:=false;
    c.Caption:='退';
    k.Caption:='货';
    rq.Checked:=false;
    ckdh.Checked:=false;
    spm.Checked:=false;
    dt1.Enabled:=false;
    dt2.Enabled:=false;
    eckdh.Enabled:=false;
    espm.Enabled:=false;
  end;
end;

procedure TF_TK.etkslKeyPress(Sender: TObject; var Key: Char);
begin
  inherited;
  if not(key in['0'..'9',#8,'.']) then
  begin
    key:=#0;
  end;
end;

procedure TF_TK.FormCreate(Sender: TObject);
begin
  inherited;
  with dm do
  begin
    dt1.Date:=now;
    dt2.Date:=now;
    query.SQL.Clear;
    query.SQL.Add('select * from ck_info,sp_info,spxh_info where ck_info.sph=sp_info.sph and sp_info.xhh=spxh_info.xhh and cklx=:cklx');
    query.Parameters[0].Value:='出库';
    query.Open;
    dbgrid1.Columns[1].Width:=70;
    dbgrid1.Columns[2].Width:=65;
  end;
end;

procedure TF_TK.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  inherited;
  dm.Query.Close;
  dm.QUERY1.Close;
end;

procedure TF_TK.b_addClick(Sender: TObject);
begin
  if b_add.Caption='退货登记' then
    f_tk.thdj;
  if b_add.Caption='删除退货' then
    f_tk.delth;
  if b_add.Caption='实收登记' then
    f_tk.ssdj;
end;

procedure TF_TK.rg_lxClick(Sender: TObject);
begin
  inherited;
  if rg_lx.ItemIndex=0 then
  begin
    rg_tklx.Visible:=true;
    rg_tklx.OnClick(self);
    rg_sslx.Visible:=false;
    b_add.Caption:='退货登记';
    label1.Caption:='退货数量:';
  end else
  begin
    b_add.Caption:='实收登记';
    label1.Caption:='实收数量:';
    rg_tklx.Visible:=false;
    rg_sslx.Visible:=true;
    etksl.Enabled:=true;
    c.Caption:='出';
    k.Caption:='库';
  end;
end;

procedure TF_TK.rqClick(Sender: TObject);
begin
  inherited;
  if rq.Checked then
  begin
    dt1.Enabled:=true;
    dt2.Enabled:=true;
  end else
  begin
    dt1.Enabled:=false;
    dt2.Enabled:=false;
  end;
end;

procedure TF_TK.ckdhClick(Sender: TObject);
begin
  inherited;
  if ckdh.Checked then
    eckdh.Enabled:=true
  else
    eckdh.Enabled:=false;
end;

procedure TF_TK.spmClick(Sender: TObject);
begin
  inherited;
  if spm.Checked then
    espm.Enabled:=true
  else
    espm.Enabled:=false;
end;

procedure TF_TK.BitBtn1Click(Sender: TObject);
begin
  inherited;
  with dm do
  begin
    query.SQL.Clear;
    query.SQL.Add('select * from ck_info,sp_info,spxh_info where ck_info.sph=sp_info.sph and sp_info.xhh=spxh_info.xhh');
    if (rg_lx.ItemIndex=0)and(rg_tklx.ItemIndex=1) then
    begin
      query.SQL.Add(' and cklx=:cklx');
      query.Parameters.ParamValues['cklx']:='退库';
    end else
    begin
      query.SQL.Add(' and cklx=:cklx');
      query.Parameters.ParamValues['cklx']:='出库';
    end;
    if rq.Checked then
    begin
      query.SQL.Add(' and ckrq>=:ckrq1 and ckrq<=:ckrq2');
      query.Parameters.ParamValues['ckrq1']:=formatdatetime('yyyy.mm.dd',dt1.Date);
      query.Parameters.ParamValues['ckrq2']:=formatdatetime('yyyy.mm.dd',dt2.Date);
    end;
    if ckdh.Checked then
    begin
      query.SQL.Add(' and ddh like :ddh');
      query.Parameters.ParamValues['ddh']:=trim(eckdh.Text)+'%';
    end;
    if spm.Checked then
    begin
      query.SQL.Add(' and spm like :spm');
      query.Parameters.ParamValues['spm']:=trim(espm.Text)+'%';
    end;
    query.Open;
  end; //with .. end
  
end;

end.

⌨️ 快捷键说明

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