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

📄 khwldzd.pas

📁 用delphi编写的销售管理系统
💻 PAS
字号:
unit khwldzd;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, DB, StdCtrls, Grids, DBGrids, Buttons, ExtCtrls;

type
  TForm48 = class(TForm)
    Panel1: TPanel;
    Panel2: TPanel;
    Label1: TLabel;
    SpeedButton1: TSpeedButton;
    ComboBox1: TComboBox;
    DBGrid1: TDBGrid;
    Panel4: TPanel;
    Label3: TLabel;
    Label7: TLabel;
    DBGrid2: TDBGrid;
    Panel3: TPanel;
    Label2: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    Panel5: TPanel;
    Label9: TLabel;
    Label10: TLabel;
    Label11: TLabel;
    DataSource1: TDataSource;
    DataSource2: TDataSource;
    BitBtn1: TBitBtn;
    Label13: TLabel;
    Shape3: TShape;
    Shape1: TShape;
    Label14: TLabel;
    Shape2: TShape;
    Label15: TLabel;
    Shape4: TShape;
    Label16: TLabel;
    Shape6: TShape;
    Label18: TLabel;
    Shape7: TShape;
    Label19: TLabel;
    Procedure Clear;
    procedure FormShow(Sender: TObject);
    procedure SpeedButton1Click(Sender: TObject);
    procedure BitBtn1MouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure BitBtn1MouseUp(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure ComboBox1KeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form48: TForm48;
   khbh: String = '' ;//客户编号
implementation
   uses DataModal,khxx1;
{$R *.dfm}

procedure TForm48.Clear;
begin
  DataSource1.DataSet := nil;
  DataSource2.DataSet := nil;
  ComboBox1.Text := '';
  Label13.Caption := '';
  Label14.Caption := '';
  Label15.Caption := '';
  Label16.Caption := '';
  Label18.Caption := '';
  Label19.Caption := '';
end;

procedure TForm48.FormShow(Sender: TObject);
begin
   ComboBox1.Clear;
  begin
    with Data.ADOQuery1 do
    begin
      Close;
      SQL.Clear;
      //此处没有从销售表中查询是因为配送申请表中包含向客户配送的商品金额
      //销售表中不存在的客户可以在配送申请表中存在
      SQL.Add('select distinct 客户全称 from 客户基础信息表 ');
      Open;
    end;
    while Not Data.ADOQuery1.Eof do
    begin
      ComboBox1.Items.Add(Data.ADOQuery1.FieldByName('客户全称').Value);
      Data.ADOQuery1.Next;
    end;
  end;
  Clear;
end;

procedure TForm48.SpeedButton1Click(Sender: TObject);
var
  syje: Real; //记录未付金额与结款金额之差
begin
  DataSource1.DataSet := nil;
  DataSource2.DataSet := nil;
  Label13.Caption := '';
  Label14.Caption := '';
  Label15.Caption := '';
  Label16.Caption := '';
  Label18.Caption := '';
  Label19.Caption := '';
  if Trim(ComboBox1.Text)<>'' then
  begin
    with Data.ADOQuery1 do
    begin
      Close;
      SQL.Clear;
      SQL.Add('select * from 客户基础信息表 where 客户全称 = :a');
      Parameters.ParamByName('a').Value := Trim(ComboBox1.Text);
      Open;
    end;
    if Data.ADOQuery1.RecordCount>1 then
    begin
      Application.CreateForm(TForm51,Form51);
      Form51.DataSource1.DataSet := Data.ADOQuery1 ;
      Form51.ShowModal;
      Form51.Free;
    end
    else if  Data.ADOQuery1.RecordCount< 1  then
      Exit
    else 
      khbh := Data.ADOQuery1.FieldByName('客户编号').Value;
    with Data.ADOQuery2 do
    begin
      Close;
      SQL.Clear;
      SQL.Add('select * from 销售表 where 客户编号 = :a');
      Parameters.ParamByName('a').Value := Trim(khbh);
      Open;
    end;
    if Data.ADOQuery2.RecordCount>0 then
    begin
      DataSource1.DataSet := Data.ADOQuery2;
      if Data.ADOQuery2.RecordCount <1 then
      begin
         label13.Caption := '0.0';
         label14.Caption := '0.0';
         label15.Caption := '0.0';
      end
      else
      begin
        with Data.ADOQuery4 do
        begin
          Close;
          SQL.Clear;
          SQL.Add('select sum(实付金额)as sfje, sum(应付金额)as zje from 销售票号表 where 销售票号 in (select 销售票号 From 销售表 where  客户编号 = :b)');
          Parameters.ParamByName('b').Value := Trim(khbh);
          Open;
        end;
        label13.Caption := FloatToStr(Data.ADOQuery4.FieldByName('zje').Value);
        label14.Caption := FloatToStr(Data.ADOQuery4.FieldByName('sfje').Value);
        label15.Caption := FloatToStr(StrToFloat(Label13.Caption)-StrToFloat(Label14.Caption));
      end;
      with Data.ADOQuery4 do
      begin
        Close;
        SQL.Clear;
        SQL.Add('select * from 客户结款记录表 where 客户编号 = :b');
        Parameters.ParamByName('b').Value :=Trim(khbh);
        Open;
      end;
      DataSource2.DataSet := Data.ADOQuery4;
      with Data.ADOQuery5 do
      begin
        Close;
        SQL.Clear;
        SQL.Add('select sum(结款金额)as jkje  From 客户结款记录表 where 客户编号 = :b');
        Parameters.ParamByName('b').Value := Trim(khbh);
        Open;
      end;
      if Data.ADOQuery5.FieldByName('jkje').Value <>null then
        label16.Caption := FloatToStr(Data.ADOQuery5.FieldByName('jkje').Value)
      else
        label16.Caption := '0.0';
      syje := StrToFloat(label15.Caption)-StrToFloat(label16.Caption);
      if syje >=0 then
      begin
        label18.Caption := FloatToStr(syje);
        label19.Caption := '0.0';
      end
      else
      begin
        label18.Caption := '0.0';
        label19.Caption := FloatToStr(abs(syje));
      end;
    end
    else
      Application.MessageBox('对不起,没有向该客户销售商品。','提示',64);
  end;
end;

procedure TForm48.BitBtn1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  TBitBtn(Sender).Font.Color := clRed;
end;

procedure TForm48.BitBtn1MouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  TBitBtn(Sender).Font.Color := clBlue;
end;

procedure TForm48.ComboBox1KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if Key = VK_ReTurn then
    SpeedButton1.OnClick(Sender);
end;

end.

⌨️ 快捷键说明

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