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

📄 spfl_unit.pas

📁 网上搜索来的进销存源码
💻 PAS
字号:
unit spfl_unit;

interface

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

type
  Tspfl_form = class(TForm)
    GroupBox1: TGroupBox;
    Label1: TLabel;
    Edit1: TEdit;
    Label2: TLabel;
    Edit2: TEdit;
    Label3: TLabel;
    Edit3: TEdit;
    GroupBox6: TGroupBox;
    SpeedButton15: TSpeedButton;
    SpeedButton16: TSpeedButton;
    SpeedButton17: TSpeedButton;
    SpeedButton18: TSpeedButton;
    SpeedButton1: TSpeedButton;
    SpeedButton2: TSpeedButton;
    SpeedButton3: TSpeedButton;
    SpeedButton4: TSpeedButton;
    DBGrid1: TDBGrid;
    StatusBar1: TStatusBar;
    PopupMenu1: TPopupMenu;
    N1: TMenuItem;
    N2: TMenuItem;
    U1: TMenuItem;
    F1: TMenuItem;
    R1: TMenuItem;
    Edit4: TEdit;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormCreate(Sender: TObject);
    procedure SpeedButton15Click(Sender: TObject);
    procedure SpeedButton4Click(Sender: TObject);
    procedure SpeedButton16Click(Sender: TObject);
    procedure SpeedButton17Click(Sender: TObject);
    procedure SpeedButton1Click(Sender: TObject);
    procedure SpeedButton2Click(Sender: TObject);
    procedure SpeedButton3Click(Sender: TObject);
    procedure DBGrid1CellClick(Column: TColumn);
    procedure Edit1KeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure Edit2KeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure Edit3KeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure N1Click(Sender: TObject);
    procedure U1Click(Sender: TObject);
    procedure N2Click(Sender: TObject);
    procedure F1Click(Sender: TObject);
    procedure R1Click(Sender: TObject);
    procedure SpeedButton18Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  spfl_form: Tspfl_form;

implementation

uses data_unit, spfl_find_unit;

{$R *.dfm}

procedure Tspfl_form.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  action := cafree;
end;

procedure Tspfl_form.FormCreate(Sender: TObject);
begin
  self.Top := 74;
  self.Left := 11;
  self.Height := 491;
  self.Width := 767;
  with database do
  begin
    adoq1.Connection := adoc;
    adoq1.SQL.Clear;
    adoq1.SQL.Add('select * from spfl ');
    adoq1.active := true;
    statusbar1.Panels[1].Text := inttostr(adoq1.Recordset.RecordCount);
    datas1.DataSet := adoq1;
    dbgrid1.DataSource := datas1;
  end;

end;

procedure Tspfl_form.SpeedButton15Click(Sender: TObject);
begin
  if (length(edit1.Text) <> 0) and (length(edit2.Text) <> 0) then
  begin
    with database do
    begin
      adoq1.Connection := adoc;
      adoq1.SQL.Clear;
      adoq1.SQL.Add('select 类别编码 from spfl where 类别编码=:lbbm');
      adoq1.Parameters.ParamByName('lbbm').Value := edit1.Text;
      adoq1.Active := true;
      if adoq1.Recordset.RecordCount > 0 then
      begin
        showmessage('已有此信息,请重输!');
        adoq1.SQL.Clear;
        adoq1.SQL.Add('select * from spfl order by 类别编码');
        adoq1.Active := true;
        statusbar1.Panels[1].Text := inttostr(adoq1.Recordset.RecordCount);
        datas1.DataSet := adoq1;
        dbgrid1.DataSource := datas1;
        edit1.SetFocus;
      end
      else
      begin
        adoq1.SQL.Clear;
        adoq1.SQL.Add('insert into spfl(类别编码,类别名称,说明) values(:spflbm,:spflmc,:sm)');
        adoq1.parameters.ParamByName('spflbm').value := edit1.text;
        adoq1.parameters.ParamByName('spflmc').value := edit2.text;
        adoq1.parameters.ParamByName('sm').value := edit3.text;
        adoq1.ExecSQL;
        adoq1.SQL.Clear;
        adoq1.SQL.Add('select * from spfl');
        adoq1.Active := true;
        datas1.DataSet := adoq1;
        dbgrid1.DataSource := datas1;
        statusbar1.Panels[1].Text := inttostr(adoq1.Recordset.RecordCount);
        edit1.Clear; edit2.Clear; edit3.Clear;
        edit1.SetFocus;
      end;
    end;
  end
  else
  begin
    showmessage('请正确输入类型编码和类型名称');
    edit1.SetFocus;
  end;


end;

procedure Tspfl_form.SpeedButton4Click(Sender: TObject);
begin
  speedbutton15.Enabled := true;
  speedbutton17.Enabled := true;
  edit1.ReadOnly := false;
  edit1.SetFocus;
  with database do
  begin
    adoq1.Connection := adoc;
    adoq1.SQL.Clear;
    adoq1.SQL.Add('select * from spfl order by 类别编码');
    adoq1.Active := true;
    datas1.DataSet := adoq1;
    dbgrid1.DataSource := datas1;
    statusbar1.Panels[1].Text := inttostr(adoq1.Recordset.RecordCount);
  end;

end;

procedure Tspfl_form.SpeedButton16Click(Sender: TObject);
begin
  speedbutton15.Enabled := false;
  speedbutton17.Enabled := false;
  with database do
  begin
    adoq1.Connection := adoc;
    adoq1.SQL.Clear;
    adoq1.SQL.Add('select * from spfl where 类别编码=:lbbm');
    adoq1.Parameters.ParamByName('lbbm').Value := edit4.Text;
    adoq1.Active := true;
    if adoq1.Recordset.RecordCount > 0 then
    begin
      edit1.Text := adoq1.Fields.Fields[0].AsString;
      edit2.Text := adoq1.Fields.Fields[1].AsString;
      edit3.Text := adoq1.Fields.Fields[2].AsString;
      edit1.ReadOnly := true;
      edit2.SetFocus;
    end
    else
      showmessage('请刷新选择记录!');

  end;

end;

procedure Tspfl_form.SpeedButton17Click(Sender: TObject);
begin
  with database do
  begin
    adoq1.Connection := adoc;
    if application.MessageBox('是否真的删除?', '记录删除', 4) = 6 then
    begin
      adoq1.SQL.Clear;
      adoq1.SQL.Add('delete from spfl where 类别编码=:lbbm');
      adoq1.Parameters.ParamByName('lbbm').Value := edit4.Text;
      adoq1.ExecSQL;
    end;
    adoq1.SQL.Clear;
    adoq1.SQL.Add('select * from spfl');
    adoq1.Active := true;
    datas1.DataSet := adoq1;
    dbgrid1.DataSource := datas1;
    statusbar1.Panels[1].Text := inttostr(adoq1.Recordset.RecordCount);
  end;

end;

procedure Tspfl_form.SpeedButton1Click(Sender: TObject);
begin
  with database do
  begin
    adoq2.Connection := adoc;
    adoq2.SQL.Clear;
    adoq2.SQL.Add('update spfl set 类别名称=:lbmc,说明=:sm where 类别编码=:lbbm');
    adoq2.parameters.ParamByName('lbbm').value := edit1.text;
    adoq2.parameters.ParamByName('lbmc').value := edit2.text;
    adoq2.Parameters.ParamByName('sm').Value := edit3.Text;
    adoq2.ExecSQL;
    adoq1.SQL.Clear;
    adoq1.SQL.Add('select * from spfl');
    adoq1.Active := true;
    datas1.DataSet := adoq1;
    dbgrid1.DataSource := datas1;
    statusbar1.Panels[1].Text := inttostr(adoq1.Recordset.RecordCount);
    edit1.Clear; edit2.Clear; edit3.Clear;
    edit1.SetFocus;
    edit1.ReadOnly := false;
    speedbutton15.Enabled := true;
    speedbutton17.Enabled := true;

  end;

end;

procedure Tspfl_form.SpeedButton2Click(Sender: TObject);
begin
  speedbutton15.Enabled := true;
  speedbutton17.Enabled := true;
  edit1.ReadOnly := false;
  edit1.Clear; edit2.Clear; edit3.Clear;

end;

procedure Tspfl_form.SpeedButton3Click(Sender: TObject);
begin
  edit1.Clear; edit2.Clear; edit3.Clear;
  edit1.SetFocus;
  speedbutton15.Enabled := true;
  speedbutton17.Enabled := true;
  edit1.ReadOnly := false;
  edit1.SetFocus;
  spfl_find_form := Tspfl_find_form.create(application);
  spfl_find_form.show;

end;

procedure Tspfl_form.DBGrid1CellClick(Column: TColumn);
begin
  if dbgrid1.DataSource.DataSet.RecordCount > 0 then
    edit4.Text := dbgrid1.DataSource.DataSet.FieldValues['类别编码'];

end;

procedure Tspfl_form.Edit1KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if key = vk_return then
    edit2.SetFocus;
end;

procedure Tspfl_form.Edit2KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if key = vk_return then
    edit3.SetFocus;

end;

procedure Tspfl_form.Edit3KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if key = vk_return then
    speedbutton15click(nil);
end;

procedure Tspfl_form.N1Click(Sender: TObject);
begin
  speedbutton15click(nil);
end;

procedure Tspfl_form.U1Click(Sender: TObject);
begin
  speedbutton16click(nil);

end;

procedure Tspfl_form.N2Click(Sender: TObject);
begin
  speedbutton17click(nil);
end;

procedure Tspfl_form.F1Click(Sender: TObject);
begin
  speedbutton3click(nil);

end;

procedure Tspfl_form.R1Click(Sender: TObject);
begin
  speedbutton4click(nil);

end;

procedure Tspfl_form.SpeedButton18Click(Sender: TObject);
begin
  close;
end;

end.

⌨️ 快捷键说明

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