Am_Yhgls.pas
上传用户:szruida
上传日期:2007-06-01
资源大小:6518k
文件大小:4k
源码类别:

Delphi控件源码

开发平台:

Delphi

  1. unit Am_Yhgls;
  2. interface
  3. uses
  4.   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  5.   Dialogs, PrnDbgeh, XPBarMenu, DB, Grids, DBGridEh, StdCtrls, ComCtrls,
  6.   ToolWin;
  7. type
  8.   TAm_Yhgl = class(TForm)
  9.     CoolBar1: TCoolBar;
  10.     ToolBar1: TToolBar;
  11.     ToolButton1: TToolButton;
  12.     ToolButton2: TToolButton;
  13.     ToolButton3: TToolButton;
  14.     ToolButton4: TToolButton;
  15.     ToolButton5: TToolButton;
  16.     ToolButton6: TToolButton;
  17.     ToolButton7: TToolButton;
  18.     GroupBox1: TGroupBox;
  19.     DBGridEh1: TDBGridEh;
  20.     DataSource1: TDataSource;
  21.     XPBarMenu1: TXPBarMenu;
  22.     PrintDBGridEh1: TPrintDBGridEh;
  23.     procedure ToolButton7Click(Sender: TObject);
  24.     procedure ToolButton6Click(Sender: TObject);
  25.     procedure ToolButton1Click(Sender: TObject);
  26.     procedure ToolButton2Click(Sender: TObject);
  27.     procedure ToolButton3Click(Sender: TObject);
  28.     procedure FormCreate(Sender: TObject);
  29.     procedure ToolButton4Click(Sender: TObject);
  30.     procedure FormClose(Sender: TObject; var Action: TCloseAction);
  31.     procedure ToolButton5Click(Sender: TObject);
  32.   private
  33.     { Private declarations }
  34.   public
  35.     { Public declarations }
  36.   end;
  37. var
  38.   Am_Yhgl: TAm_Yhgl;
  39. implementation
  40. uses dms,U_Public, Am_Yhgl_Zcs, yhz_bjs, logins, am_yhgl_xgs, xt_user_cxs;
  41. {$R *.dfm}
  42. procedure TAm_Yhgl.ToolButton7Click(Sender: TObject);
  43. begin
  44.   close;
  45. end;
  46. procedure TAm_Yhgl.ToolButton6Click(Sender: TObject);
  47. begin
  48.  PrintDBGridEh1.Preview;
  49. end;
  50. procedure TAm_Yhgl.ToolButton1Click(Sender: TObject);
  51. begin
  52.  if am_yhgl_zc=nil then
  53.  begin
  54.    am_yhgl_zc:=Tam_yhgl_zc.create(application);
  55.    //dm.xt_user.Close;
  56.    //dm.xt_user.CommandText:='select * from user_dm='+''''+''''+'';
  57.    //dm.xt_user.Open;
  58.    dm.xt_user.Append;
  59.    am_yhgl_zc.Label1.Caption:='增加新用户';
  60.    am_yhgl_zc.showmodal;
  61.  end;  
  62. end;
  63. procedure TAm_Yhgl.ToolButton2Click(Sender: TObject);
  64. var s_user_dm:string;
  65. begin
  66.   s_user_dm:=dm.xt_user.fieldbyname('user_dm').AsString;
  67.   if s_user_dm<>user_dm then
  68.    begin
  69.      am_yhgl_xg:=Tam_yhgl_xg.create(self);
  70.      Dm.xt_user.Close;
  71.      dm.xt_user.CommandText:='select * from xt_user where user_dm='+''''+s_user_dm+''''+'';
  72.      dm.xt_user.Open;
  73.      DM.xt_user.Edit;
  74.      //am_yhgl_zc.DBEditEh6.Text:=login.edit2.text;
  75.      am_yhgl_xg.showmodal;
  76.    end
  77.   else
  78.    begin
  79.      am_yhgl_xg:=Tam_yhgl_xg.create(self);
  80.      Dm.xt_user.Close;
  81.      dm.xt_user.CommandText:='select * from xt_user where user_dm='+''''+s_user_dm+''''+'';
  82.      dm.xt_user.Open;
  83.      DM.xt_user.Edit;
  84.      am_yhgl_xg.DBEditEh1.Color:=cl3DLight;
  85.      am_yhgl_xg.DBEditEh1.Enabled:=false;
  86.      am_yhgl_xg.showmodal;
  87.    end;
  88. end;
  89. procedure TAm_Yhgl.ToolButton3Click(Sender: TObject);
  90. var s_user_dm:string;
  91. begin
  92.    if application.MessageBox('你确定删除吗?','警告',mb_okcancel+mb_iconquestion)=idok then
  93.    begin
  94.        s_user_dm:=dm.xt_user.fieldbyname('user_dm').AsString;
  95.        if s_user_dm=user_dm then
  96.         begin
  97.           application.MessageBox('当前用户数据正在被用,'+#13#10+'不能删除','提示',mb_ok+mb_iconinformation);
  98.           exit;
  99.         end
  100.        else
  101.         begin
  102.          Dm.xt_user.Close;
  103.          dm.xt_user.CommandText:='delete xt_user where user_dm='+''''+s_user_dm+''''+'';
  104.          dm.xt_user.Execute;
  105.          Dm.xt_user.Close;
  106.          dm.xt_user.CommandText:='select * from xt_user';
  107.          dm.xt_user.Open;
  108.          toolbutton4.Click;
  109.         end;
  110.    end;
  111. end;
  112. procedure TAm_Yhgl.FormCreate(Sender: TObject);
  113. begin
  114.  dm.xt_user.Active:=true; 
  115. end;
  116. procedure TAm_Yhgl.ToolButton4Click(Sender: TObject);
  117. begin
  118.  dm.xt_user.Close;
  119.  dm.xt_user.CommandText:='select * from xt_user';
  120.  dm.xt_user.Open;
  121. end;
  122. procedure TAm_Yhgl.FormClose(Sender: TObject; var Action: TCloseAction);
  123. begin
  124.  dm.xt_user.Active:=false;
  125.  action:=cafree;
  126.  am_yhgl:=nil;
  127. end;
  128. procedure TAm_Yhgl.ToolButton5Click(Sender: TObject);
  129. begin
  130.  if xt_user_cx=Nil then
  131.    begin
  132.     xt_user_cx:=Txt_user_cx.create(self);
  133.     xt_user_cx.showmodal;
  134.    end;
  135. end;
  136. end.