ajgl_bjs.~pas
资源名称:挡案管理系统.rar [点击查看]
上传用户:szruida
上传日期:2007-06-01
资源大小:6518k
文件大小:10k
源码类别:
Delphi控件源码
开发平台:
Delphi
- unit ajgl_bjs;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, ExtCtrls, ImgList, StdCtrls, Buttons, DB, DBClient, Mask,
- DBCtrls, DBCtrlsEh, DBLookupEh;
- type
- TAm_ajgl_bj = class(TForm)
- Panel2: TPanel;
- Delete: TBitBtn;
- ImageList1: TImageList;
- Panel1: TPanel;
- Label1: TLabel;
- Label2: TLabel;
- Label3: TLabel;
- DBEdit3: TDBEdit;
- Label4: TLabel;
- Label5: TLabel;
- DBEdit5: TDBEdit;
- Label6: TLabel;
- DBEdit6: TDBEdit;
- Label7: TLabel;
- Label8: TLabel;
- Label9: TLabel;
- Label10: TLabel;
- DBEdit9: TDBEdit;
- Label11: TLabel;
- Label12: TLabel;
- DBEdit11: TDBEdit;
- Label13: TLabel;
- Label14: TLabel;
- Label15: TLabel;
- Label16: TLabel;
- Label17: TLabel;
- Label18: TLabel;
- Label19: TLabel;
- DBEdit16: TDBEdit;
- Label20: TLabel;
- Label21: TLabel;
- Label22: TLabel;
- Label23: TLabel;
- Label24: TLabel;
- Label25: TLabel;
- Quit: TBitBtn;
- DBLookupComboboxEh1: TDBLookupComboboxEh;
- DBLookupComboboxEh2: TDBLookupComboboxEh;
- DBLookupComboboxEh3: TDBLookupComboboxEh;
- DBEditEh1: TDBEditEh;
- SpeedButton2: TSpeedButton;
- SpeedButton3: TSpeedButton;
- ds_ajgl: TDataSource;
- DBEditEh3: TDBEditEh;
- DBEditEh4: TDBEditEh;
- DBEditEh5: TDBEditEh;
- DBEditEh2: TDBEditEh;
- DBEditEh6: TDBEditEh;
- DBLookupComboboxEh4: TDBLookupComboboxEh;
- DBEditEh7: TDBEditEh;
- ClientDataSet1: TClientDataSet;
- DBEditEh8: TDBEditEh;
- DBMemo1: TDBMemo;
- DBMemo2: TDBMemo;
- DBMemo3: TDBMemo;
- DBEditEh9: TDBEditEh;
- procedure QuitClick(Sender: TObject);
- procedure FormKeyPress(Sender: TObject; var Key: Char);
- procedure FormClose(Sender: TObject; var Action: TCloseAction);
- procedure FormShow(Sender: TObject);
- procedure DeleteClick(Sender: TObject);
- procedure DBEditEh1Exit(Sender: TObject);
- procedure DBEditEh8Exit(Sender: TObject);
- procedure DBMemo1KeyDown(Sender: TObject; var Key: Word;
- Shift: TShiftState);
- procedure DBMemo1MouseDown(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- procedure DBMemo1KeyPress(Sender: TObject; var Key: Char);
- procedure SpeedButton2Click(Sender: TObject);
- procedure FormCreate(Sender: TObject);
- procedure SpeedButton3Click(Sender: TObject);
- procedure DBMemo2KeyDown(Sender: TObject; var Key: Word;
- Shift: TShiftState);
- procedure DBMemo2MouseDown(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- procedure DBMemo2KeyPress(Sender: TObject; var Key: Char);
- procedure DBMemo3KeyDown(Sender: TObject; var Key: Word;
- Shift: TShiftState);
- procedure DBMemo3MouseDown(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- procedure DBMemo3KeyPress(Sender: TObject; var Key: Char);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- Am_ajgl_bj: TAm_ajgl_bj;
- lpos,cpos,linelength:integer;
- implementation
- uses dms,mainfrms,u_public, ajgls, am_Sdqcs;
- {$R *.dfm}
- procedure TAm_ajgl_bj.QuitClick(Sender: TObject);
- begin
- close;
- end;
- //----------------------------------------------------------------
- procedure TAm_ajgl_bj.FormKeyPress(Sender: TObject; var Key: Char);
- begin
- if key=#13 then
- begin
- key:=#0;
- Perform(WM_NextDlgCtl,0,0);
- end;
- end;//焦点转移
- procedure TAm_ajgl_bj.FormClose(Sender: TObject; var Action: TCloseAction);
- begin
- action:=cafree;
- am_ajgl_bj:=nil;
- frm_name2:='';
- end;
- procedure TAm_ajgl_bj.FormShow(Sender: TObject);
- var n:integer;
- s_ajxh:string;//案卷序号
- begin
- n:=pos('-',am_ajgl.tree.selected.Text)-1;
- epos1:=copy(am_ajgl.tree.Selected.Text,1,n);//案卷代码
- Epos2:=copy(am_ajgl.tree.Selected.Text,n+2,length(am_ajgl.tree.Selected.Text));
- DBEditeh2.Text:=Epos2;
- dbediteh1.Text:=YearNow();
- //案卷序号自动加一inc()
- s_ajxh:=dm.V_ajgl.fieldbyname('aj_xh').AsString;
- Clientdataset1.Close;
- Clientdataset1.CommandText:='select * from v_ajgl where aj_xh='+''''+s_ajxh+''''+'';
- Clientdataset1.Open;
- dbediteh8.Text:=inttostr(Clientdataset1.RecordCount+1);
- dbedit5.Text:=ePos1+'-'+dbediteh1.Text+'-'+dbediteh8.Text;
- DBEditeh4.Text:=formatdatetime('yyyy-mm-dd',now);
- DBEditeh5.Text:=formatdatetime('yyyy-mm-dd',now);
- dbediteh7.Text:=user_name;
- DBEditeh6.text:='案卷';
- DBEditeh3.text:=user_name;
- end;
- //*****************************************************************************
- procedure TAm_ajgl_bj.DeleteClick(Sender: TObject);
- var i,n:integer;
- begin
- if trim(dbediteh1.text)='' then
- begin
- application.MessageBox('年代号不能为空','提示',mb_ok+mb_iconinformation);
- exit;
- end;
- if trim(DBLookupComboboxEh3.Text)='' then
- begin
- application.MessageBox('保管期限不能为空','提示',mb_ok+mb_iconinformation);
- DBLookupComboboxEh3.SetFocus;
- exit;
- end;
- if trim(DBLookupComboboxEh2.Text)='' then
- begin
- application.MessageBox('密级不能为空','提示',mb_ok+mb_iconinformation);
- DBLookupComboboxEh2.SetFocus;
- exit;
- end;
- //数据完整性验证
- dm.Am_ajgl.edit;
- n:=pos('-',am_ajgl.tree.selected.Text)-1;
- epos1:=copy(am_ajgl.tree.Selected.Text,1,n);//案卷代码
- dbediteh7.Text:=user_name;
- dm.Am_ajgl.fieldbyname('ajlb_dm').asstring:=epos1;//案卷类别代码
- dm.am_ajgl.FieldByName('aj_ndh').AsString:=dbediteh1.Text;//年代号
- dm.Am_ajgl.FieldByName('aj_ljr').AsString:=dbediteh7.Text;//立卷人
- dm.am_ajgl.FieldByName('aj_bzqsrq').AsString:=dbediteh4.Text;//编制起始日期
- dm.am_ajgl.FieldByName('aj_gdqsrq').AsString:=dbediteh5.Text;//归档起始日期
- dm.Am_ajgl.fieldbyname('ajzt_mc').AsString:=dbediteh6.Text;//案卷状态
- dm.Am_ajgl.FieldByName('user_name').AsString:=dbediteh3.Text;//用户名
- dm.Am_ajgl.FieldByName('aj_Bmmc').AsString:=DbLookUPcomboboxeh1.Text;
- //-----------------------------------------
- dm.am_ajgl.ApplyUpdates(0);
- //---------------------------
- i:=dm.am_ajgl.ApplyUpdates(0);
- if i=0 then
- begin
- application.MessageBox('数据保存成功','提示',mb_ok+mb_iconinformation);
- am_ajgl.refresh1.Click;
- am_ajgl.Ajgd1.Enabled:=true;
- am_ajgl.xiugai.Enabled:=true;
- am_ajgl.dele1.Enabled:=true;
- am_ajgl.WJCZ.Enabled:=true;
- close;
- end
- else
- begin
- application.MessageBox('数据保存失败','提示',mb_ok+mb_iconinformation);
- exit;
- end;
- end;
- //******************************************************************************
- procedure TAm_ajgl_bj.DBEditEh1Exit(Sender: TObject);
- begin
- dbedit5.Text:=ePos1+'-'+dbediteh1.Text+'-'+dbediteh8.Text;
- end;
- procedure TAm_ajgl_bj.DBEditEh8Exit(Sender: TObject);
- begin
- dbedit5.Text:=ePos1+'-'+dbediteh1.Text+'-'+dbediteh8.Text;
- end;
- procedure TAm_ajgl_bj.DBMemo1KeyDown(Sender: TObject; var Key: Word;
- Shift: TShiftState);
- begin
- Lpos:=sendmessage(dbmemo1.Handle,EM_linefromchar,dbmemo1.SelStart,0);
- Cpos:=sendmessage(dbmemo1.Handle,em_lineindex,lpos,0);
- linelength:=sendmessage(dbmemo1.Handle,em_linelength,cpos,0);
- Cpos:=dbmemo1.SelStart-cpos;
- end;
- procedure TAm_ajgl_bj.DBMemo1MouseDown(Sender: TObject;
- Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
- begin
- Lpos:=sendmessage(dbmemo1.Handle,EM_linefromchar,dbmemo1.SelStart,0);
- Cpos:=sendmessage(dbmemo1.Handle,em_lineindex,lpos,0);
- linelength:=sendmessage(dbmemo1.Handle,em_linelength,cpos,0);
- Cpos:=dbmemo1.SelStart-cpos;
- end;
- procedure TAm_ajgl_bj.DBMemo1KeyPress(Sender: TObject; var Key: Char);
- begin
- if (Cpos>76)or(linelength>76)then
- begin
- key:=#13;
- lpos:=lpos+1;
- cpos:=1;
- linelength:=1;
- end;
- end;
- procedure TAm_ajgl_bj.SpeedButton2Click(Sender: TObject);
- begin
- DbEditeh9.Text:='';
- end;
- procedure TAm_ajgl_bj.FormCreate(Sender: TObject);
- begin
- frm_name2:='am_ajgl_bj';
- end;
- procedure TAm_ajgl_bj.SpeedButton3Click(Sender: TObject);
- begin
- if am_sdqc=nil then
- begin
- am_sdqc:=Tam_sdqc.create(application);
- am_sdqc.showmodal;
- end;
- end;
- procedure TAm_ajgl_bj.DBMemo2KeyDown(Sender: TObject; var Key: Word;
- Shift: TShiftState);
- begin
- Lpos:=sendmessage(dbmemo2.Handle,EM_linefromchar,dbmemo2.SelStart,0);
- Cpos:=sendmessage(dbmemo2.Handle,em_lineindex,lpos,0);
- linelength:=sendmessage(dbmemo2.Handle,em_linelength,cpos,0);
- Cpos:=dbmemo2.SelStart-cpos;
- end;
- procedure TAm_ajgl_bj.DBMemo2MouseDown(Sender: TObject;
- Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
- begin
- Lpos:=sendmessage(dbmemo2.Handle,EM_linefromchar,dbmemo2.SelStart,0);
- Cpos:=sendmessage(dbmemo2.Handle,em_lineindex,lpos,0);
- linelength:=sendmessage(dbmemo2.Handle,em_linelength,cpos,0);
- Cpos:=dbmemo2.SelStart-cpos;
- end;
- procedure TAm_ajgl_bj.DBMemo2KeyPress(Sender: TObject; var Key: Char);
- begin
- if (Cpos>76)or(linelength>76)then
- begin
- key:=#13;
- lpos:=lpos+1;
- cpos:=1;
- linelength:=1;
- end;
- end;
- procedure TAm_ajgl_bj.DBMemo3KeyDown(Sender: TObject; var Key: Word;
- Shift: TShiftState);
- begin
- Lpos:=sendmessage(dbmemo3.Handle,EM_linefromchar,dbmemo3.SelStart,0);
- Cpos:=sendmessage(dbmemo3.Handle,em_lineindex,lpos,0);
- linelength:=sendmessage(dbmemo3.Handle,em_linelength,cpos,0);
- Cpos:=dbmemo3.SelStart-cpos;
- end;
- procedure TAm_ajgl_bj.DBMemo3MouseDown(Sender: TObject;
- Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
- begin
- Lpos:=sendmessage(dbmemo3.Handle,EM_linefromchar,dbmemo3.SelStart,0);
- Cpos:=sendmessage(dbmemo3.Handle,em_lineindex,lpos,0);
- linelength:=sendmessage(dbmemo3.Handle,em_linelength,cpos,0);
- Cpos:=dbmemo3.SelStart-cpos;
- end;
- procedure TAm_ajgl_bj.DBMemo3KeyPress(Sender: TObject; var Key: Char);
- begin
- if (Cpos>76)or(linelength>76)then
- begin
- key:=#13;
- lpos:=lpos+1;
- cpos:=1;
- linelength:=1;
- end;
- end;
- end.