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

Delphi控件源码

开发平台:

Delphi

  1. unit sz_xtajlbs;
  2. interface
  3. uses
  4.   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  5.   Dialogs, StdCtrls, DB, Mask, DBCtrls, DBCtrlsEh, Grids, DBGridEh,
  6.   ExtCtrls, Buttons;
  7. type
  8.   Tsz_xtajlb = class(TForm)
  9.     GroupBox1: TGroupBox;
  10.     Label1: TLabel;
  11.     DBEdit1: TDBEdit;
  12.     DataSource1: TDataSource;
  13.     Label2: TLabel;
  14.     DBEdit2: TDBEdit;
  15.     Label3: TLabel;
  16.     Label4: TLabel;
  17.     DBEdit4: TDBEdit;
  18.     Label35: TLabel;
  19.     Edit1: TEdit;
  20.     Label36: TLabel;
  21.     Label37: TLabel;
  22.     DBCheckBoxEh1: TDBCheckBoxEh;
  23.     Label5: TLabel;
  24.     Panel6: TPanel;
  25.     DBGridEh6: TDBGridEh;
  26.     SpeedButton19: TSpeedButton;
  27.     SpeedButton21: TSpeedButton;
  28.     SpeedButton22: TSpeedButton;
  29.     SpeedButton23: TSpeedButton;
  30.     Refresh: TSpeedButton;
  31.     SpeedButton25: TSpeedButton;
  32.     procedure SpeedButton25Click(Sender: TObject);
  33.     procedure RefreshClick(Sender: TObject);
  34.     procedure SpeedButton19Click(Sender: TObject);
  35.     procedure SpeedButton21Click(Sender: TObject);
  36.     procedure SpeedButton22Click(Sender: TObject);
  37.     procedure SpeedButton23Click(Sender: TObject);
  38.     procedure FormClose(Sender: TObject; var Action: TCloseAction);
  39.     procedure FormCreate(Sender: TObject);
  40.     procedure DBEdit1KeyPress(Sender: TObject; var Key: Char);
  41.   private
  42.     { Private declarations }
  43.   public
  44.     { Public declarations }
  45.   end;
  46. var
  47.   sz_xtajlb: Tsz_xtajlb;
  48. implementation
  49. uses DMs;
  50. {$R *.dfm}
  51. procedure Tsz_xtajlb.SpeedButton25Click(Sender: TObject);
  52. begin
  53.  close;
  54. end;
  55. procedure Tsz_xtajlb.RefreshClick(Sender: TObject);
  56. begin
  57.  dm.sz_xtajlb.Close;
  58.  dm.sz_xtajlb.CommandText:='Select * from sz_xtajlb';
  59.  dm.sz_xtajlb.Open;
  60. end;
  61. procedure Tsz_xtajlb.SpeedButton19Click(Sender: TObject);
  62. begin
  63.   dm.sz_xtajlb.Close;
  64.   dm.sz_xtajlb.CommandText:='select * from sz_xtajlb where xt_dm='+''''+''''+'';
  65.   dm.sz_xtajlb.Open;
  66.   DbEdit1.SetFocus;
  67.   DBCheckboxEh1.Checked:=true;
  68. end;
  69. procedure Tsz_xtajlb.SpeedButton21Click(Sender: TObject);
  70. begin
  71.  dm.sz_xtajlb.Edit;
  72.  DbEDit1.SetFocus;
  73. end;
  74. procedure Tsz_xtajlb.SpeedButton22Click(Sender: TObject);
  75. begin
  76.  if datasource1.DataSet.RecordCount=0 then
  77.   begin
  78.      application.MessageBox('表中没有数据,不能删除','提示',mb_ok+mb_iconquestion);
  79.      exit;
  80.   end
  81.   else
  82.   if application.MessageBox('您确定要删除?','警告',mb_okcancel+mb_iconquestion)=idok then
  83.   begin
  84.       dm.sz_xtajlb.Delete;
  85.       dm.sz_xtajlb.ApplyUpdates(0);
  86.       Refresh.Click;
  87.   end
  88.   else
  89.       datasource1.DataSet.Cancel;
  90. end;
  91. procedure Tsz_xtajlb.SpeedButton23Click(Sender: TObject);
  92. var i:integer;
  93.     hint:string;
  94. begin
  95.  if DbEdit1.Text='' then
  96.   begin
  97.      application.MessageBox('系统案卷类别代码不可为空','提示',mb_ok+mb_iconinformation);
  98.      exit;
  99.   end;
  100.   if DbEdit2.Text='' then
  101.   begin
  102.      application.MessageBox('系统案卷类别名称不可为空','提示',mb_ok+mb_iconinformation);
  103.      exit;
  104.   end;
  105.   if DbCheckboxEh1.State=cbGrayed then
  106.   begin
  107.      application.MessageBox('归档案卷可否编辑必选','提示',mb_ok+mb_iconinformation);
  108.      exit;
  109.   end;
  110.   if length(trim(DbEdit1.Text))<>length(Edit1.Text) then
  111.   begin
  112.      hint:='请输入'+inttoStr(length(Edit1.Text))+'位代码';
  113.      application.MessageBox(Pchar(Hint),'提示',mb_ok+mb_iconinformation);
  114.      exit;
  115.   end;
  116.   //------------以上为判断不符合条件的情况
  117.   if dm.sz_xtajlb.FieldByName('xt_kfbj').AsBoolean then
  118.       dm.sz_xtajlb.FieldByName('xt_kfbj_sm').AsString:='可以编辑'
  119.    else
  120.      dm.sz_xtajlb.FieldByName('xt_kfbj_sm').AsString:='不可以编辑';
  121.   dm.sz_xtajlb.ApplyUpdates(0);
  122.   i:=dm.sz_xtajlb.ApplyUpdates(0);
  123.   if i=0  then
  124.   begin
  125.     application.MessageBox('数据保存成功','提示',mb_ok+mb_iconinformation);
  126.     Refresh.Click;
  127.   end
  128.   else
  129.     application.MessageBox('数据保存失败','提示',mb_ok+mb_iconinformation);
  130. end;
  131. procedure Tsz_xtajlb.FormClose(Sender: TObject; var Action: TCloseAction);
  132. begin
  133.   dm.sz_xtajlb.Active:=false;
  134.   action:=cafree;
  135.   sz_xtajlb:=nil;
  136. end;
  137. procedure Tsz_xtajlb.FormCreate(Sender: TObject);
  138. begin
  139.   dm.sz_xtajlb.Active:=true;
  140.   Dm.xt_lbjs.Close;
  141.   Dm.xt_lbjs.CommandText:='Select lb_dmgz,lbjs_sm from xt_lbjs where lb_dm='+''''+'sz_xtajlb'+''''+'';
  142.   Dm.xt_lbjs.Open;
  143.   edit1.Text:=dm.xt_lbjs.fieldbyname('lb_dmgz').asstring;
  144.   DBCheckboxEh1.Checked:=true;
  145. end;
  146. procedure Tsz_xtajlb.DBEdit1KeyPress(Sender: TObject; var Key: Char);
  147. begin
  148.   if key=#13 then
  149.      Dbedit2.SetFocus;
  150. end;
  151. end.