producetype.pas
上传用户:bjkrmsxy
上传日期:2010-01-31
资源大小:9004k
文件大小:3k
源码类别:

百货/超市行业

开发平台:

Delphi

  1. unit producetype;
  2. interface
  3. uses
  4.   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  5.   Dialogs, StdCtrls, Mask, DBCtrls, DB, ADODB, Grids, DBGrids, ExtCtrls,
  6.   DBTables;
  7. type
  8.   TPType_Form = class(TForm)
  9.     Panel1: TPanel;
  10.     DBGrid1: TDBGrid;
  11.     Label1: TLabel;
  12.     Button1: TButton;
  13.     DataSource1: TDataSource;
  14.     Label2: TLabel;
  15.     DBEdit2: TDBEdit;
  16.     DBEdit1: TDBEdit;
  17.     GroupBox1: TGroupBox;
  18.     Button2: TButton;
  19.     Button3: TButton;
  20.     Button5: TButton;
  21.     GroupBox2: TGroupBox;
  22.     Button7: TButton;
  23.     Button6: TButton;
  24.     Button4: TButton;
  25.     ADOQuery1: TADOQuery;
  26.     procedure Button1Click(Sender: TObject);
  27.     procedure Button2Click(Sender: TObject);
  28.     procedure Button3Click(Sender: TObject);
  29.     procedure Button4Click(Sender: TObject);
  30.     procedure Button5Click(Sender: TObject);
  31.     procedure FormActivate(Sender: TObject);
  32.     procedure Button6Click(Sender: TObject);
  33.     procedure Button7Click(Sender: TObject);
  34.   private
  35.     { Private declarations }
  36.   public
  37.     { Public declarations }
  38.   end;
  39. var
  40.   PType_Form: TPType_Form;
  41. implementation
  42. uses datamodule;
  43. {$R *.dfm}
  44. procedure TPType_Form.Button1Click(Sender: TObject);
  45. begin
  46. adoquery1.active:=false;
  47. PType_Form.close;
  48. end;
  49. procedure TPType_Form.Button2Click(Sender: TObject);
  50. begin
  51.  button3.visible:=false;
  52.  button5.visible:=false;
  53.  button4.visible:=true;
  54.  adoquery1.insert;
  55. end;
  56. procedure TPType_Form.Button3Click(Sender: TObject);
  57. begin
  58. button4.visible:=true;
  59. button2.visible:=false;
  60. button5.visible:=false;
  61. adoquery1.edit;
  62. end;
  63. procedure TPType_Form.Button4Click(Sender: TObject);
  64. begin
  65.   try
  66.     adoquery1.post;
  67.   except
  68.   on exception do
  69.      begin
  70.        showmessage('保存不成功');
  71.        adoquery1.cancel;
  72.      end;
  73.   end;
  74.   button4.visible:=false;
  75.   button2.visible:=true;
  76.   button3.visible:=true;
  77.   button5.visible:=true;
  78. end;
  79. procedure TPType_Form.Button5Click(Sender: TObject);
  80. var
  81. ret:integer;
  82. k:integer;
  83. begin
  84.     ret:=messagebox(0,'警告:将删除该类型和他所对应的所有商品??','不可恢复的删除确定',52);
  85.     if ret=idyes then
  86.      begin
  87.        k:=strtoint(dbedit1.text);
  88.        with datamodule1.adocommand1 do
  89.          begin
  90.            commandtext:='delete from produce_t where p_type=:i';
  91.            parameters.ParamValues['i']:=k;
  92.            execute;
  93.          end;
  94.        adoquery1.delete;
  95.      end;
  96. end;
  97. procedure TPType_Form.FormActivate(Sender: TObject);
  98. begin
  99. if not adoquery1.active then
  100.     adoquery1.active:=true;
  101. end;
  102. procedure TPType_Form.Button6Click(Sender: TObject);
  103. begin
  104.  adoquery1.prior;
  105. end;
  106. procedure TPType_Form.Button7Click(Sender: TObject);
  107. begin
  108. adoquery1.next;
  109. end;
  110. end.