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

📄 yhzhgl.pas

📁 delphi开发的完整的客户管理系统(带数据库)
💻 PAS
字号:
unit yhzhgl;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, Buttons, ImgList, ToolWin, ComCtrls, StdCtrls, Grids;

type
  TForm10 = class(TForm)
    Panel1: TPanel;
    StringGrid1: TStringGrid;
    Panel2: TPanel;
    Label1: TLabel;
    Label3: TLabel;
    ComboBox1: TComboBox;
    Label2: TLabel;
    Label4: TLabel;
    Edit3: TEdit;
    Panel3: TPanel;
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    BitBtn3: TBitBtn;
    Label6: TLabel;
    Shape3: TShape;
    Label7: TLabel;
    Shape1: TShape;
    procedure FormCreate(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure Panel1MouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure Edit3KeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure ComboBox1Change(Sender: TObject);
    procedure BitBtn1Click(Sender: TObject);
    procedure BitBtn2Click(Sender: TObject);
    procedure Clear;
    procedure Edit3KeyPress(Sender: TObject; var Key: Char);
    procedure ComboBox1KeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form10: TForm10;
  Yhzh : array[0..10]of String;
  nsr: String;//记录纳税人
implementation
  uses data2;
{$R *.dfm}

procedure TForm10.FormCreate(Sender: TObject);
begin
  StringGrid1.Cells[0,0]:= '        往来单位';
  StringGrid1.Cells[1,0]:= '        开户银行';
  StringGrid1.Cells[2,0]:= '        银行账号';
  StringGrid1.Cells[3,0]:= '        存款金额';
  StringGrid1.Cells[4,0]:= '        纳 税 人';
end;

procedure TForm10.FormShow(Sender: TObject);
begin
  with Datam.ADOQuery1 do
  begin
    Close;
    SQL.Clear;
    SQL.Add('select * from 客户基础信息表');
    Open;
  end;
  While Not Datam.ADOQuery1.Eof do
  begin
    ComboBox1.Items.Add(Datam.ADOQuery1.FieldByName('客户全称').AsString);
    Datam.ADOQuery1.Next;
  end;
  ComboBox1.SetFocus;
end;

procedure TForm10.Panel1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
  BitBtn1.Font.Color := clBlue;
  BitBtn2.Font.Color := clBlue;
  BitBtn3.Font.Color := clBlue;
end;

procedure TForm10.Edit3KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if (Trim(Edit3.Text)<>'')and(key = VK_RETurn) then
    BitBtn1.SetFocus;
end;

procedure TForm10.ComboBox1Change(Sender: TObject);
begin
  with Datam.ADOQuery1 do
  begin
    Close;
    SQL.Clear;
    SQL.Add('select * from 客户基础信息表 where 客户全称 = :a');
    Parameters.ParamByName('a').Value := Trim(ComboBox1.Text);
    Open;
  end;
  label6.Caption := Trim(Datam.ADOQuery1.FieldByName('开户银行').Value);
  label7.Caption := Trim(Datam.ADOQuery1.FieldByName('银行账号').Value);
  nsr := Trim(Datam.ADOQuery1.FieldByName('纳税人').Value);
  Edit3.Clear;
  Edit3.SetFocus;
end;

procedure TForm10.BitBtn1Click(Sender: TObject);
var
  m: integer;
begin
  for m := 1 to StringGrid1.RowCount -2 do
  if Trim(ComboBox1.Text) = Trim(StringGrid1.Cells[0,m]) then
    Exit;
  if (Trim(ComboBox1.Text)<>'')and(Trim(label6.Caption)<>'')and(Trim(label7.Caption)<>'')
    and(Trim(Edit3.Text)<>'')and(Trim(nsr)<>'')then
  begin
    with Datam.ADOQuery1 do
    begin
      Close;
      SQL.Clear;
      SQL.Add('Select * from 银行账户管理表 where 往来单位 = :a');
      Parameters.ParamByName('a').Value := ComboBox1.Text;
      Open;
    end;
    if Datam.ADOQuery1.RecordCount <1 then
    begin
      StringGrid1.Cells[0,StringGrid1.RowCount -1]:= ComboBox1.Text;
      StringGrid1.Cells[1,StringGrid1.RowCount -1]:= label6.Caption;
      StringGrid1.Cells[2,StringGrid1.RowCount -1]:= label7.Caption;
      StringGrid1.Cells[3,StringGrid1.RowCount -1]:= Edit3.Text;
      StringGrid1.Cells[4,StringGrid1.RowCount -1]:= nsr;
      StringGrid1.RowCount := StringGrid1.RowCount +1 ;
      BitBtn2.Enabled := True;
    end
    else
      Application.MessageBox('该单位在银行账户表中已经存在。','提示',0+64);
  end
  else
    Application.MessageBox('项目不能为空。','提示',0+64);
end;

procedure TForm10.BitBtn2Click(Sender: TObject);
var
  a,b: integer;
begin
  try
    For a := 1 to StringGrid1.RowCount -2 do
    begin
      With Datam.ADOQuery1 do
      begin
        Close;
        SQL.Clear;
        SQL.Add('insert 银行账户管理表 values (:a ,:b ,:c ,:d ,:e)');
        For b := 0 to StringGrid1.ColCount -1 do
        Yhzh[b]:= StringGrid1.Cells[b,a];
        Parameters.ParamByName('a').Value := Trim(Yhzh[0]);
        Parameters.ParamByName('b').Value:= Trim(Yhzh[1]);
        Parameters.ParamByName('c').Value:= Trim(Yhzh[2]);
        Parameters.ParamByName('d').Value := StrToFloat(Trim(Yhzh[3]));
        Parameters.ParamByName('e').Value := Trim(Yhzh[4]);
        ExecSQL;
      end;
    end;
    Application.MessageBox('数据已经成功插入表中','提示',0+64);
    Clear;
    StringGrid1.RowCount := 2;
    BitBtn2.Enabled := False;
  Except
    Application.MessageBox('系统出错','提示',0+64);
    Close;
  end;
end;

procedure TForm10.Clear;
var
  a,b: integer;
begin
  For a := 1 to StringGrid1.RowCount -1 do
    For b := 0 to StringGrid1.ColCount -1 do
      StringGrid1.Cells[b,a]:= '';

end;

procedure TForm10.Edit3KeyPress(Sender: TObject; var Key: Char);
var
  m: Boolean;
begin
  m := (key <#8)or(Key>#8)and(key < #46)or(key>#46)and(key <#48)or(key > #57);
  if m then
    key := #0;
end;
procedure TForm10.ComboBox1KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if (Trim(ComboBox1.Text)<>'')and(key = VK_RETurn) then
    Edit3.SetFocus;
end;

end.

⌨️ 快捷键说明

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