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

Delphi控件源码

开发平台:

Delphi

  1. unit ajgl_bjs;
  2. interface
  3. uses
  4.   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  5.   Dialogs, ExtCtrls, ImgList, StdCtrls, Buttons, DB, DBClient, Mask,
  6.   DBCtrls, DBCtrlsEh, DBLookupEh;
  7. type
  8.   TAm_ajgl_bj = class(TForm)
  9.     Panel2: TPanel;
  10.     Delete: TBitBtn;
  11.     ImageList1: TImageList;
  12.     Panel1: TPanel;
  13.     Label1: TLabel;
  14.     Label2: TLabel;
  15.     Label3: TLabel;
  16.     DBEdit3: TDBEdit;
  17.     Label4: TLabel;
  18.     Label5: TLabel;
  19.     DBEdit5: TDBEdit;
  20.     Label6: TLabel;
  21.     DBEdit6: TDBEdit;
  22.     Label7: TLabel;
  23.     Label8: TLabel;
  24.     Label9: TLabel;
  25.     Label10: TLabel;
  26.     DBEdit9: TDBEdit;
  27.     Label11: TLabel;
  28.     Label12: TLabel;
  29.     DBEdit11: TDBEdit;
  30.     Label13: TLabel;
  31.     Label14: TLabel;
  32.     Label15: TLabel;
  33.     Label16: TLabel;
  34.     Label17: TLabel;
  35.     Label18: TLabel;
  36.     Label19: TLabel;
  37.     DBEdit16: TDBEdit;
  38.     Label20: TLabel;
  39.     Label21: TLabel;
  40.     Label22: TLabel;
  41.     Label23: TLabel;
  42.     Label24: TLabel;
  43.     Label25: TLabel;
  44.     Quit: TBitBtn;
  45.     DBLookupComboboxEh1: TDBLookupComboboxEh;
  46.     DBLookupComboboxEh2: TDBLookupComboboxEh;
  47.     DBLookupComboboxEh3: TDBLookupComboboxEh;
  48.     DBEditEh1: TDBEditEh;
  49.     SpeedButton2: TSpeedButton;
  50.     SpeedButton3: TSpeedButton;
  51.     ds_ajgl: TDataSource;
  52.     DBEditEh3: TDBEditEh;
  53.     DBEditEh4: TDBEditEh;
  54.     DBEditEh5: TDBEditEh;
  55.     DBEditEh2: TDBEditEh;
  56.     DBEditEh6: TDBEditEh;
  57.     DBLookupComboboxEh4: TDBLookupComboboxEh;
  58.     DBEditEh7: TDBEditEh;
  59.     ClientDataSet1: TClientDataSet;
  60.     DBEditEh8: TDBEditEh;
  61.     DBMemo1: TDBMemo;
  62.     DBMemo2: TDBMemo;
  63.     DBMemo3: TDBMemo;
  64.     DBEditEh9: TDBEditEh;
  65.     procedure QuitClick(Sender: TObject);
  66.     procedure FormKeyPress(Sender: TObject; var Key: Char);
  67.     procedure FormClose(Sender: TObject; var Action: TCloseAction);
  68.     procedure FormShow(Sender: TObject);
  69.     procedure DeleteClick(Sender: TObject);
  70.     procedure DBEditEh1Exit(Sender: TObject);
  71.     procedure DBEditEh8Exit(Sender: TObject);
  72.     procedure DBMemo1KeyDown(Sender: TObject; var Key: Word;
  73.       Shift: TShiftState);
  74.     procedure DBMemo1MouseDown(Sender: TObject; Button: TMouseButton;
  75.       Shift: TShiftState; X, Y: Integer);
  76.     procedure DBMemo1KeyPress(Sender: TObject; var Key: Char);
  77.     procedure SpeedButton2Click(Sender: TObject);
  78.     procedure FormCreate(Sender: TObject);
  79.     procedure SpeedButton3Click(Sender: TObject);
  80.     procedure DBMemo2KeyDown(Sender: TObject; var Key: Word;
  81.       Shift: TShiftState);
  82.     procedure DBMemo2MouseDown(Sender: TObject; Button: TMouseButton;
  83.       Shift: TShiftState; X, Y: Integer);
  84.     procedure DBMemo2KeyPress(Sender: TObject; var Key: Char);
  85.     procedure DBMemo3KeyDown(Sender: TObject; var Key: Word;
  86.       Shift: TShiftState);
  87.     procedure DBMemo3MouseDown(Sender: TObject; Button: TMouseButton;
  88.       Shift: TShiftState; X, Y: Integer);
  89.     procedure DBMemo3KeyPress(Sender: TObject; var Key: Char);
  90.   private
  91.     { Private declarations }
  92.   public
  93.     { Public declarations }
  94.   end;
  95. var
  96.   Am_ajgl_bj: TAm_ajgl_bj;
  97.   lpos,cpos,linelength:integer;
  98. implementation
  99. uses dms,mainfrms,u_public, ajgls, am_Sdqcs;
  100. {$R *.dfm}
  101. procedure TAm_ajgl_bj.QuitClick(Sender: TObject);
  102. begin
  103.  close;
  104. end;
  105. //----------------------------------------------------------------
  106. procedure TAm_ajgl_bj.FormKeyPress(Sender: TObject; var Key: Char);
  107. begin
  108.   if key=#13 then
  109.   begin
  110.      key:=#0;
  111.      Perform(WM_NextDlgCtl,0,0);
  112.   end;
  113. end;//焦点转移
  114. procedure TAm_ajgl_bj.FormClose(Sender: TObject; var Action: TCloseAction);
  115. begin
  116.   action:=cafree;
  117.   am_ajgl_bj:=nil;
  118.   frm_name2:='';
  119. end;
  120. procedure TAm_ajgl_bj.FormShow(Sender: TObject);
  121. var n:integer;
  122.     s_ajxh:string;//案卷序号
  123. begin
  124.     n:=pos('-',am_ajgl.tree.selected.Text)-1;
  125.     epos1:=copy(am_ajgl.tree.Selected.Text,1,n);//案卷代码
  126.     Epos2:=copy(am_ajgl.tree.Selected.Text,n+2,length(am_ajgl.tree.Selected.Text));
  127.     DBEditeh2.Text:=Epos2;
  128.     dbediteh1.Text:=YearNow();
  129.     //案卷序号自动加一inc()
  130.     s_ajxh:=dm.V_ajgl.fieldbyname('aj_xh').AsString;
  131.     Clientdataset1.Close;
  132.     Clientdataset1.CommandText:='select * from v_ajgl where aj_xh='+''''+s_ajxh+''''+'';
  133.     Clientdataset1.Open;
  134.     dbediteh8.Text:=inttostr(Clientdataset1.RecordCount+1);
  135.     dbedit5.Text:=ePos1+'-'+dbediteh1.Text+'-'+dbediteh8.Text;
  136.     DBEditeh4.Text:=formatdatetime('yyyy-mm-dd',now);
  137.     DBEditeh5.Text:=formatdatetime('yyyy-mm-dd',now);
  138.     dbediteh7.Text:=user_name;
  139.     DBEditeh6.text:='案卷';
  140.     DBEditeh3.text:=user_name;
  141. end;
  142. //*****************************************************************************
  143. procedure TAm_ajgl_bj.DeleteClick(Sender: TObject);
  144. var i,n:integer;
  145. begin
  146.   if trim(dbediteh1.text)='' then
  147.   begin
  148.      application.MessageBox('年代号不能为空','提示',mb_ok+mb_iconinformation);
  149.      exit;
  150.   end;
  151.   if trim(DBLookupComboboxEh3.Text)='' then
  152.   begin
  153.      application.MessageBox('保管期限不能为空','提示',mb_ok+mb_iconinformation);
  154.      DBLookupComboboxEh3.SetFocus;
  155.      exit;
  156.   end;
  157.   if trim(DBLookupComboboxEh2.Text)='' then
  158.   begin
  159.      application.MessageBox('密级不能为空','提示',mb_ok+mb_iconinformation);
  160.      DBLookupComboboxEh2.SetFocus;
  161.      exit;
  162.   end;
  163.   //数据完整性验证
  164.   dm.Am_ajgl.edit;
  165.    n:=pos('-',am_ajgl.tree.selected.Text)-1;
  166.    epos1:=copy(am_ajgl.tree.Selected.Text,1,n);//案卷代码
  167.   dbediteh7.Text:=user_name;
  168.   dm.Am_ajgl.fieldbyname('ajlb_dm').asstring:=epos1;//案卷类别代码
  169.   dm.am_ajgl.FieldByName('aj_ndh').AsString:=dbediteh1.Text;//年代号
  170.   dm.Am_ajgl.FieldByName('aj_ljr').AsString:=dbediteh7.Text;//立卷人
  171.   dm.am_ajgl.FieldByName('aj_bzqsrq').AsString:=dbediteh4.Text;//编制起始日期
  172.   dm.am_ajgl.FieldByName('aj_gdqsrq').AsString:=dbediteh5.Text;//归档起始日期
  173.   dm.Am_ajgl.fieldbyname('ajzt_mc').AsString:=dbediteh6.Text;//案卷状态
  174.   dm.Am_ajgl.FieldByName('user_name').AsString:=dbediteh3.Text;//用户名
  175.   dm.Am_ajgl.FieldByName('aj_Bmmc').AsString:=DbLookUPcomboboxeh1.Text;
  176.   //-----------------------------------------
  177.   dm.am_ajgl.ApplyUpdates(0);
  178.   //---------------------------
  179.   i:=dm.am_ajgl.ApplyUpdates(0);
  180.   if i=0 then
  181.    begin
  182.      application.MessageBox('数据保存成功','提示',mb_ok+mb_iconinformation);
  183.      am_ajgl.refresh1.Click;
  184.      am_ajgl.Ajgd1.Enabled:=true;
  185.      am_ajgl.xiugai.Enabled:=true;
  186.      am_ajgl.dele1.Enabled:=true;
  187.      am_ajgl.WJCZ.Enabled:=true;
  188.      close;
  189.    end
  190.   else
  191.    begin
  192.      application.MessageBox('数据保存失败','提示',mb_ok+mb_iconinformation);
  193.      exit;
  194.    end;
  195. end;
  196. //******************************************************************************
  197. procedure TAm_ajgl_bj.DBEditEh1Exit(Sender: TObject);
  198. begin
  199.  dbedit5.Text:=ePos1+'-'+dbediteh1.Text+'-'+dbediteh8.Text;
  200. end;
  201. procedure TAm_ajgl_bj.DBEditEh8Exit(Sender: TObject);
  202. begin
  203.   dbedit5.Text:=ePos1+'-'+dbediteh1.Text+'-'+dbediteh8.Text;
  204. end;
  205. procedure TAm_ajgl_bj.DBMemo1KeyDown(Sender: TObject; var Key: Word;
  206.   Shift: TShiftState);
  207. begin
  208.   Lpos:=sendmessage(dbmemo1.Handle,EM_linefromchar,dbmemo1.SelStart,0);
  209.   Cpos:=sendmessage(dbmemo1.Handle,em_lineindex,lpos,0);
  210.   linelength:=sendmessage(dbmemo1.Handle,em_linelength,cpos,0);
  211.   Cpos:=dbmemo1.SelStart-cpos;
  212. end;
  213. procedure TAm_ajgl_bj.DBMemo1MouseDown(Sender: TObject;
  214.   Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  215. begin
  216.   Lpos:=sendmessage(dbmemo1.Handle,EM_linefromchar,dbmemo1.SelStart,0);
  217.   Cpos:=sendmessage(dbmemo1.Handle,em_lineindex,lpos,0);
  218.   linelength:=sendmessage(dbmemo1.Handle,em_linelength,cpos,0);
  219.   Cpos:=dbmemo1.SelStart-cpos;
  220. end;
  221. procedure TAm_ajgl_bj.DBMemo1KeyPress(Sender: TObject; var Key: Char);
  222. begin
  223.   if (Cpos>76)or(linelength>76)then
  224.   begin
  225.       key:=#13;
  226.       lpos:=lpos+1;
  227.       cpos:=1;
  228.       linelength:=1;
  229.   end;
  230. end;
  231. procedure TAm_ajgl_bj.SpeedButton2Click(Sender: TObject);
  232. begin
  233.  DbEditeh9.Text:='';
  234. end;
  235. procedure TAm_ajgl_bj.FormCreate(Sender: TObject);
  236. begin
  237.   frm_name2:='am_ajgl_bj';
  238. end;
  239. procedure TAm_ajgl_bj.SpeedButton3Click(Sender: TObject);
  240. begin
  241.  if am_sdqc=nil then
  242.   begin
  243.     am_sdqc:=Tam_sdqc.create(application);
  244.     am_sdqc.showmodal;
  245.   end;
  246. end;
  247. procedure TAm_ajgl_bj.DBMemo2KeyDown(Sender: TObject; var Key: Word;
  248.   Shift: TShiftState);
  249. begin
  250.   Lpos:=sendmessage(dbmemo2.Handle,EM_linefromchar,dbmemo2.SelStart,0);
  251.   Cpos:=sendmessage(dbmemo2.Handle,em_lineindex,lpos,0);
  252.   linelength:=sendmessage(dbmemo2.Handle,em_linelength,cpos,0);
  253.   Cpos:=dbmemo2.SelStart-cpos;
  254. end;
  255. procedure TAm_ajgl_bj.DBMemo2MouseDown(Sender: TObject;
  256.   Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  257. begin
  258.   Lpos:=sendmessage(dbmemo2.Handle,EM_linefromchar,dbmemo2.SelStart,0);
  259.   Cpos:=sendmessage(dbmemo2.Handle,em_lineindex,lpos,0);
  260.   linelength:=sendmessage(dbmemo2.Handle,em_linelength,cpos,0);
  261.   Cpos:=dbmemo2.SelStart-cpos;
  262. end;
  263. procedure TAm_ajgl_bj.DBMemo2KeyPress(Sender: TObject; var Key: Char);
  264. begin
  265.   if (Cpos>76)or(linelength>76)then
  266.   begin
  267.       key:=#13;
  268.       lpos:=lpos+1;
  269.       cpos:=1;
  270.       linelength:=1;
  271.   end;
  272. end;
  273. procedure TAm_ajgl_bj.DBMemo3KeyDown(Sender: TObject; var Key: Word;
  274.   Shift: TShiftState);
  275. begin
  276.   Lpos:=sendmessage(dbmemo3.Handle,EM_linefromchar,dbmemo3.SelStart,0);
  277.   Cpos:=sendmessage(dbmemo3.Handle,em_lineindex,lpos,0);
  278.   linelength:=sendmessage(dbmemo3.Handle,em_linelength,cpos,0);
  279.   Cpos:=dbmemo3.SelStart-cpos;
  280. end;
  281. procedure TAm_ajgl_bj.DBMemo3MouseDown(Sender: TObject;
  282.   Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  283. begin
  284.   Lpos:=sendmessage(dbmemo3.Handle,EM_linefromchar,dbmemo3.SelStart,0);
  285.   Cpos:=sendmessage(dbmemo3.Handle,em_lineindex,lpos,0);
  286.   linelength:=sendmessage(dbmemo3.Handle,em_linelength,cpos,0);
  287.   Cpos:=dbmemo3.SelStart-cpos;
  288. end;
  289. procedure TAm_ajgl_bj.DBMemo3KeyPress(Sender: TObject; var Key: Char);
  290. begin
  291.   if (Cpos>76)or(linelength>76)then
  292.   begin
  293.       key:=#13;
  294.       lpos:=lpos+1;
  295.       cpos:=1;
  296.       linelength:=1;
  297.   end;
  298. end;
  299. end.