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

Delphi控件源码

开发平台:

Delphi

  1. unit xt_yhz_ms;
  2. interface
  3. uses
  4.   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  5.   Dialogs, ComCtrls, ToolWin, Grids, DBGridEh, StdCtrls, ExtCtrls, DB,
  6.   DBClient, DBGrids, XPBarMenu, PrnDbgeh;
  7. type
  8.   Txt_yhz = class(TForm)
  9.     CoolBar1: TCoolBar;
  10.     ToolBar1: TToolBar;
  11.     ToolButton1: TToolButton;
  12.     ToolButton2: TToolButton;
  13.     ToolButton3: TToolButton;
  14.     ToolButton4: TToolButton;
  15.     DataSource1: TDataSource;
  16.     ToolButton6: TToolButton;
  17.     ToolButton7: TToolButton;
  18.     DataSource2: TDataSource;
  19.     DataSource3: TDataSource;
  20.     XPBarMenu1: TXPBarMenu;
  21.     GroupBox1: TGroupBox;
  22.     DBGridEh1: TDBGridEh;
  23.     PrintDBGridEh1: TPrintDBGridEh;
  24.     procedure ToolButton1Click(Sender: TObject);
  25.     procedure FormCreate(Sender: TObject);
  26.     procedure FormClose(Sender: TObject; var Action: TCloseAction);
  27.     procedure ToolButton2Click(Sender: TObject);
  28.     procedure ToolButton3Click(Sender: TObject);
  29.     procedure ToolButton4Click(Sender: TObject);
  30.     procedure ToolButton7Click(Sender: TObject);
  31.     procedure DBGridEh1TitleClick(Column: TColumnEh);
  32.     procedure DBGridEh1DblClick(Sender: TObject);
  33.     procedure ToolButton6Click(Sender: TObject);
  34.   private
  35.     { Private declarations }
  36.   public
  37.     { Public declarations }
  38.   end;
  39. var
  40.   xt_yhz: Txt_yhz;
  41. implementation
  42. uses yhz_bjs,dms,u_public;
  43. {$R *.dfm}
  44. procedure Txt_yhz.ToolButton1Click(Sender: TObject);
  45. begin
  46.  //DM.xt_yhz.Append;
  47.  dm.xt_yhz.Close;
  48.  dm.xt_yhz.CommandText:='select * from xt_UserGroup where yhz_dm='+''''+''''+'';
  49.  dm.xt_yhz.Open;
  50.  yhz_bj:=Tyhz_bj.create(application);
  51.  yhz_bj.showmodal;
  52.  yhz_bj.Label1.Caption:='增加用户组';
  53. end;
  54. procedure Txt_yhz.FormCreate(Sender: TObject);
  55. begin
  56.   DM.xt_yhz.Active:=true;
  57.   Dm.xt_js.Active:=true;
  58.   Dm.ug_js.Active:=true;
  59.   //  dm.xt_yhz.MasterSource:=datasource2;
  60. //  dm.xt_yhz.MasterFields:='js_dm';
  61. end;
  62. procedure Txt_yhz.FormClose(Sender: TObject; var Action: TCloseAction);
  63. begin
  64.   action:=cafree;
  65.   xt_yhz:=nil;
  66. end;
  67. procedure Txt_yhz.ToolButton2Click(Sender: TObject);
  68. var s:string;
  69. begin
  70.   s:=dm.ug_js.fieldbyname('yhz_dm').AsString;
  71.   yhz_bj:=Tyhz_bj.create(self);
  72.   yhz_bj.Label1.Caption:='修改用户组';
  73.   Dm.xt_yhz.Close;
  74.   dm.XT_yhz.CommandText:='select * from xt_UserGroup where yhz_dm='+''''+s+''''+'';
  75.   dm.xt_yhz.Open;
  76.   DM.xt_yhz.Edit;
  77.   yhz_bj.showmodal;
  78. end;
  79. procedure Txt_yhz.ToolButton3Click(Sender: TObject);
  80. var s:string;
  81. begin
  82.  s:=dm.ug_js.fieldbyname('yhz_dm').AsString;
  83.  if Dm.xt_yhz.RecordCount=0 then
  84.  begin
  85.     application.MessageBox('表中没有数据不能删除!','提示',mb_iconinformation+mb_defbutton1);
  86.     Abort;
  87.   end
  88.   else
  89.    if application.MessageBox('你确定删除吗?','警告',mb_okcancel+mb_iconquestion)=idok then
  90.    begin
  91.        {Dm.xt_yhz.Close;
  92.        dm.XT_yhz.CommandText:='select * from xt_UserGroup where yhz_dm='+''''+s+''''+'';
  93.        dm.xt_yhz.Open;
  94.        Dm.xt_yhz.Delete;
  95.        Dm.xt_yhz.ApplyUpdates(0);}
  96.        Dm.xt_yhz.Close;
  97.        dm.XT_yhz.CommandText:='delete xt_UserGroup where yhz_dm='+''''+s+''''+'';
  98.        dm.xt_yhz.Execute;
  99.        Dm.xt_yhz.Close;
  100.        dm.XT_yhz.CommandText:='select * from xt_UserGroup';
  101.        dm.xt_yhz.Open;
  102.        toolbutton4.Click;
  103.     end;
  104. end;
  105. procedure Txt_yhz.ToolButton4Click(Sender: TObject);
  106. begin
  107.  dm.ug_js.Close;
  108.  dm.ug_js.CommandText:='select * from ug_js';
  109.  dm.ug_js.Open;
  110. end;
  111. procedure Txt_yhz.ToolButton7Click(Sender: TObject);
  112. begin
  113.   close;
  114. end;
  115. procedure Txt_yhz.DBGridEh1TitleClick(Column: TColumnEh);
  116. begin
  117.    //  Dm.xt_yhz.IndexFieldNames:=Column.Field.FieldName;
  118. end;
  119. procedure Txt_yhz.DBGridEh1DblClick(Sender: TObject);
  120. begin
  121.   toolbutton2.Click;
  122. end;
  123. procedure Txt_yhz.ToolButton6Click(Sender: TObject);
  124. begin
  125.  PrintDBGridEh1.Preview;
  126. end;
  127. end.