ps_comproduct.pas

来自「DELPHI5加SQL SERVER2000完成的进销存系统,具体哪些内容记不清」· PAS 代码 · 共 149 行

PAS
149
字号
unit PS_comproduct;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, DBCtrls, Mask, Menus,db;

type
  TF_comproduct = class(TForm)
    GroupBox1: TGroupBox;
    L_productid: TLabel;
    L_productname: TLabel;
    L_unit: TLabel;
    L_suggprice: TLabel;
    L_stdbuying: TLabel;
    L_earlycost: TLabel;
    L_presentcost: TLabel;
    L_stdcost: TLabel;
    L_taxrate: TLabel;
    L_memo: TLabel;
    E_productid: TDBEdit;
    E_productname: TDBEdit;
    E_unit: TDBEdit;
    E_suggprice: TDBEdit;
    E_stdbuying: TDBEdit;
    E_earlycost: TDBEdit;
    E_presentcost: TDBEdit;
    E_stdcost: TDBEdit;
    E_taxrate: TDBEdit;
    M_memo: TDBMemo;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
    procedure BeforeInsert;
    procedure insert;
    procedure AfterInsert;
    procedure E_productidClick(Sender: TObject);
    procedure FormActivate(Sender: TObject);
    procedure NoRecord;
    procedure HaveRecord;
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  F_comproduct: TF_comproduct;

implementation

uses PS_db, PS_main;

{$R *.DFM}
//自定义函数部分
procedure TF_comproduct.insert;
begin
  with comdatabase.comproduct do begin
    if f_main.savetocache then begin
      f_comproduct.beforeinsert;
      append;
      end;
    end;
  tf_comproduct(f_main.activemdichild).E_productid.setfocus;
end;

procedure TF_comproduct.AfterInsert;
begin
  if f_main.activemdichild<>nil then
    with tf_comproduct(f_main.activemdichild) do begin
      E_presentcost.ReadOnly:=true;
      E_presentcost.TabStop:=false;
    end;
end;

procedure TF_comproduct.BeforeInsert;
begin
  with tf_comproduct(f_main.activemdichild) do begin
    e_productid.setfocus;
    E_presentcost.ReadOnly:=false;
    E_presentcost.TabStop:=true;
    end;
end;

procedure TF_comproduct.NoRecord;
begin
  with tf_comproduct(f_main.activemdichild) do begin
    E_productid.Enabled:=false;
    E_productname.Enabled:=false;
    E_unit.Enabled:=false;
    E_suggprice.Enabled:=false;
    E_stdbuying.Enabled:=false;
    E_earlycost.Enabled:=false;
    E_presentcost.Enabled:=false;
    E_stdcost.Enabled:=false;
    E_taxrate.Enabled:=false;
    M_memo.Enabled:=false;
    end;
end;

procedure TF_comproduct.HaveRecord;
begin
  with tf_comproduct(f_main.activemdichild) do begin
    E_productid.Enabled:=true;
    E_productname.Enabled:=true;
    E_unit.Enabled:=true;
    E_suggprice.Enabled:=true;
    E_stdbuying.Enabled:=true;
    E_earlycost.Enabled:=true;
    E_presentcost.Enabled:=true;
    E_stdcost.Enabled:=true;
    E_taxrate.Enabled:=true;
    M_memo.Enabled:=true;
    end;
end;
//程序正体部分
procedure TF_comproduct.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  with comdatabase do begin
    comproduct.close;
    end;
  f_main.currentTable:=nil;
  action:=cafree;
end;

procedure TF_comproduct.FormCloseQuery(Sender: TObject;
  var CanClose: Boolean);
begin
  canclose:=f_main.savetocache;
end;

procedure TF_comproduct.E_productidClick(Sender: TObject);
begin
  tedit(sender).selectall;
end;

procedure TF_comproduct.FormActivate(Sender: TObject);
begin
  with comdatabase do begin
    comproduct.open;
    end;
  f_main.currentTable:=comdatabase.comproduct;
  f_main.TableName:=Rcomproduct;
  f_main.buttonstate;
end;

end.

⌨️ 快捷键说明

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