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

Delphi控件源码

开发平台:

Delphi

  1. unit Am_wjbjs;
  2. interface
  3. uses
  4.   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  5.   Dialogs, ExtCtrls, StdCtrls, Buttons, DB, Mask, DBCtrls, DBCtrlsEh,
  6.   DBLookupEh, TFlatHintUnit, DBClient;
  7. type
  8.   TAm_wjgl_bj = class(TForm)
  9.     Panel1: TPanel;
  10.     Panel2: TPanel;
  11.     Quit: TBitBtn;
  12.     Add: TBitBtn;
  13.     Label1: TLabel;
  14.     Label2: TLabel;
  15.     Label4: TLabel;
  16.     DBEdit4: TDBEdit;
  17.     Label6: TLabel;
  18.     Label7: TLabel;
  19.     Label8: TLabel;
  20.     DBEdit8: TDBEdit;
  21.     Label9: TLabel;
  22.     DBEdit9: TDBEdit;
  23.     Label10: TLabel;
  24.     Label11: TLabel;
  25.     Label12: TLabel;
  26.     Label13: TLabel;
  27.     Label14: TLabel;
  28.     DBEdit14: TDBEdit;
  29.     Label15: TLabel;
  30.     DBEdit15: TDBEdit;
  31.     Label16: TLabel;
  32.     Label17: TLabel;
  33.     Label18: TLabel;
  34.     Label19: TLabel;
  35.     DBEdit19: TDBEdit;
  36.     Label20: TLabel;
  37.     DBEdit20: TDBEdit;
  38.     Label3: TLabel;
  39.     DBMemo1: TDBMemo;
  40.     DBMemo2: TDBMemo;
  41.     DBMemo3: TDBMemo;
  42.     DBEditEh1: TDBEditEh;
  43.     DBLookupComboboxEh1: TDBLookupComboboxEh;
  44.     DBLookupComboboxEh2: TDBLookupComboboxEh;
  45.     DBDateTimeEditEh1: TDBDateTimeEditEh;
  46.     DBDateTimeEditEh2: TDBDateTimeEditEh;
  47.     Label5: TLabel;
  48.     DBLookupComboboxEh3: TDBLookupComboboxEh;
  49.     SpeedButton1: TSpeedButton;
  50.     SpeedButton2: TSpeedButton;
  51.     DBNumberEditEh1: TDBNumberEditEh;
  52.     Label21: TLabel;
  53.     Label22: TLabel;
  54.     Label23: TLabel;
  55.     FlatHint1: TFlatHint;
  56.     DBEditEh2: TDBEditEh;
  57.     ClientDataSet1: TClientDataSet;
  58.     DBEditEh3: TDBEditEh;
  59.     DBEditEh4: TDBEditEh;
  60.     ClientDataSet2: TClientDataSet;
  61.     procedure QuitClick(Sender: TObject);
  62.     procedure FormClose(Sender: TObject; var Action: TCloseAction);
  63.     procedure AddClick(Sender: TObject);
  64.     procedure FormShow(Sender: TObject);
  65.     procedure DBEdit7Exit(Sender: TObject);
  66.     procedure DBEdit20Exit(Sender: TObject);
  67.     procedure FormCreate(Sender: TObject);
  68.     procedure SpeedButton1Click(Sender: TObject);
  69.     procedure SpeedButton2Click(Sender: TObject);
  70.     procedure DBMemo1KeyDown(Sender: TObject; var Key: Word;
  71.       Shift: TShiftState);
  72.     procedure DBMemo1KeyPress(Sender: TObject; var Key: Char);
  73.     procedure DBMemo1MouseDown(Sender: TObject; Button: TMouseButton;
  74.       Shift: TShiftState; X, Y: Integer);
  75.     procedure DBMemo2KeyDown(Sender: TObject; var Key: Word;
  76.       Shift: TShiftState);
  77.     procedure DBMemo2KeyPress(Sender: TObject; var Key: Char);
  78.     procedure DBMemo2MouseDown(Sender: TObject; Button: TMouseButton;
  79.       Shift: TShiftState; X, Y: Integer);
  80.     procedure DBMemo3KeyDown(Sender: TObject; var Key: Word;
  81.       Shift: TShiftState);
  82.     procedure DBMemo3MouseDown(Sender: TObject; Button: TMouseButton;
  83.       Shift: TShiftState; X, Y: Integer);
  84.     procedure DBMemo3KeyPress(Sender: TObject; var Key: Char);
  85.     procedure DBEdit20KeyPress(Sender: TObject; var Key: Char);
  86.     procedure DBNumberEditEh1Exit(Sender: TObject);
  87.   private
  88.     { Private declarations }
  89.   public
  90.     { Public declarations }
  91.   end;
  92. var
  93.   Am_wjgl_bj: TAm_wjgl_bj;
  94.   cpos,lpos,linelength:integer;
  95.   N_yc:integer;//文件页次
  96. implementation
  97. uses DMs,am_yljs,mainfrms,u_public,ajgls, am_Sdqcs;
  98. {$R *.dfm}
  99. procedure TAm_wjgl_bj.QuitClick(Sender: TObject);
  100. begin
  101.  Close;
  102. end;
  103. procedure TAm_wjgl_bj.FormClose(Sender: TObject; var Action: TCloseAction);
  104. begin
  105.   am_wjgl_bj:=nil;
  106.   action:=cafree;
  107.   frm_name2:='';
  108. end;
  109. procedure TAm_wjgl_bj.AddClick(Sender: TObject);
  110. var i:integer;
  111. begin
  112.   if DbLookUpComboboxeh3.Text='' then
  113.    begin
  114.      application.MessageBox('文件类别不能为空','提示',mb_ok+mb_iconinformation);
  115.      DbLookUpComboboxeh3.SetFocus;
  116.      exit;
  117.    end;
  118.    if DbLookUpComboboxeh1.Text='' then
  119.    begin
  120.      application.MessageBox('责任者不能为空','提示',mb_ok+mb_iconinformation);
  121.      DbLookUpComboboxeh1.SetFocus;
  122.      exit;
  123.    end;
  124.    if DbLookUpComboboxeh2.Text='' then
  125.    begin
  126.      application.MessageBox('载体类别不能为空','提示',mb_ok+mb_iconinformation);
  127.      DbLookUpComboboxeh2.SetFocus;
  128.      exit;
  129.    end;
  130.  //----------------------------------------------------------------
  131.   dm.Am_wjgl.ApplyUpdates(0);
  132.   i:=dm.Am_wjgl.ApplyUpdates(0);
  133.   if i=0 then
  134.    begin
  135.      application.MessageBox('数据保存成功','提示',mb_ok+mb_iconinformation);
  136.      dm.Am_wjgl.Close;
  137.      dm.am_wjgl.CommandText:='select * from am_wjgl';
  138.      dm.am_wjgl.Open;
  139.      dm.V_Wjgl.Close;
  140.      dm.V_Wjgl.CommandText:='select * from V_wjgl';
  141.      dm.V_Wjgl.Open;//案卷管理对应的是v_wjgl
  142.      dm.V_Wjgl2.Close;
  143.      dm.V_Wjgl2.CommandText:='select * from v_wjgl2';
  144.      dm.V_Wjgl2.Open;//案卷管理对应的是v_wjgl2
  145.      close;
  146.    end
  147.   else
  148.    begin
  149.      application.MessageBox('数据保存失败','提示',mb_ok+mb_iconinformation);
  150.      exit;
  151.    end;
  152. end;
  153. procedure TAm_wjgl_bj.FormShow(Sender: TObject);
  154. var now1:Tdatetime;
  155.     n:integer;
  156. begin
  157.  if  frm_name='am_ajgl' then
  158.  begin
  159.    n:=pos('-',am_ajgl.tree.selected.Text)-1;
  160.    epos1:=copy(am_ajgl.tree.Selected.Text,1,n);//案卷代码
  161.    Epos2:=copy(am_ajgl.tree.Selected.Text,n+2,length(am_ajgl.tree.Selected.Text));
  162.    DBEdit4.Text:=Epos2;
  163.    dbediteh1.Text:=YearNow();
  164.    s_ajxh:=dm.V_ajgl.fieldbyname('aj_xh').AsString;
  165.    Clientdataset1.Close;
  166.    Clientdataset1.CommandText:='select * from v_wjgl where aj_xh='+''''+s_ajxh+''''+'';
  167.    Clientdataset1.Open;
  168.    Clientdataset2.Close;//查找最大的文件页次号
  169.    clientdataset2.CommandText:='select max(wj_yc) as wj_yc from am_wjgl where aj_xh='+''''+s_ajxh+''''+'';
  170.    Clientdataset2.Open;
  171.    N_Yc:=Clientdataset2.fieldbyname('wj_yc').AsInteger;
  172.    dbediteh2.Text:=inttostr(Clientdataset1.RecordCount+1);
  173.    DBDatetimeEditeh1.Text:=formatdatetime('yyyy-mm-dd',now);
  174.    dbedit14.Text:=am_ajgl.DBGridEh1.FieldColumns['bgqx_mc'].DisplayText;
  175.    dbedit15.Text:=dm.V_ajgl.fieldbyname('mj_mc').AsString;
  176.    dm.Am_wjgl.FieldByName('user_name').AsString:=user_name;
  177.    dm.Am_wjgl.fieldbyname('aj_xh').AsString:=dm.V_ajgl.fieldbyname('aj_xh').AsString;
  178.  end
  179.  else if frm_name='am_ylj' then//预立卷
  180.  begin
  181.    n:=pos('-',am_ylj.tree.selected.Text)-1;
  182.    epos1:=copy(am_ylj.tree.Selected.Text,1,n);//案卷代码
  183.    Epos2:=copy(am_ylj.tree.Selected.Text,n+2,length(am_ylj.tree.Selected.Text));
  184.    DBEdit4.Text:=Epos2;
  185.    dbediteh1.Text:=YearNow();
  186.    s_ajxh:=dm.V_ylj.fieldbyname('aj_xh').AsString;
  187.    Clientdataset1.Close;
  188.    Clientdataset1.CommandText:='select * from v_wjgl where aj_xh='+''''+s_ajxh+''''+'';
  189.    Clientdataset1.Open;
  190.    Clientdataset2.Close;//查找最大的文件页次号
  191.    clientdataset2.CommandText:='select max(wj_yc) as wj_yc from am_wjgl where aj_xh='+''''+s_ajxh+''''+'';
  192.    Clientdataset2.Open;
  193.    N_Yc:=Clientdataset2.fieldbyname('wj_yc').AsInteger;
  194.    dbediteh2.Text:=inttostr(Clientdataset1.RecordCount+1);
  195.    DBDatetimeEditeh1.Text:=formatdatetime('yyyy-mm-dd',now);
  196.    dbedit14.Text:=dm.V_ylj.fieldbyname('bgqx_mc').AsString;
  197.    dbedit15.Text:=dm.V_ylj.fieldbyname('mj_mc').AsString;
  198.    dm.Am_wjgl.FieldByName('user_name').AsString:=user_name;
  199.    dm.Am_wjgl.fieldbyname('aj_xh').AsString:=dm.V_ylj.fieldbyname('aj_xh').AsString;
  200.  end;
  201. end;
  202. procedure TAm_wjgl_bj.DBEdit7Exit(Sender: TObject);
  203. begin
  204.    if frm_name='am_ylj' then
  205.       dbedit9.Text:=ylj_s2+'-'+dbediteh1.Text+'-'+s_ajxh+'-'+dbedit20.Text;
  206.    if frm_name='am_ajgl' then
  207.       dbedit9.Text:=ajgl_s2+'-'+dbediteh1.Text+'-'+s_ajxh+'-'+dbedit20.Text;
  208. end;
  209. procedure TAm_wjgl_bj.DBEdit20Exit(Sender: TObject);
  210. begin
  211.   if frm_name='am_ylj' then
  212.       dbedit9.Text:=ylj_s2+'-'+dbediteh1.Text+'-'+s_ajxh+'-'+dbedit20.Text;
  213.    if frm_name='am_ajgl' then
  214.       dbedit9.Text:=ajgl_s2+'-'+dbediteh1.Text+'-'+s_ajxh+'-'+dbedit20.Text;
  215. end;
  216. procedure TAm_wjgl_bj.FormCreate(Sender: TObject);
  217. begin
  218.  frm_name2:='am_Wjgl_bj';
  219. end;
  220. procedure TAm_wjgl_bj.SpeedButton1Click(Sender: TObject);
  221. begin
  222.  DbEditeh3.Text:='';
  223. end;
  224. procedure TAm_wjgl_bj.SpeedButton2Click(Sender: TObject);
  225. begin
  226.  if am_sdqc=NIl then
  227.   begin
  228.     am_sdqc:=Tam_sdqc.create(application);
  229.     am_sdqc.showmodal;
  230.   end;
  231. end;
  232. procedure TAm_wjgl_bj.DBMemo1KeyDown(Sender: TObject; var Key: Word;
  233.   Shift: TShiftState);
  234. begin
  235.   Lpos:=sendmessage(dbmemo1.Handle,EM_linefromchar,dbmemo1.SelStart,0);
  236.   Cpos:=sendmessage(dbmemo1.Handle,em_lineindex,lpos,0);
  237.   linelength:=sendmessage(dbmemo1.Handle,em_linelength,cpos,0);
  238.   Cpos:=dbmemo1.SelStart-cpos;
  239. end;
  240. procedure TAm_wjgl_bj.DBMemo1KeyPress(Sender: TObject; var Key: Char);
  241. begin
  242.   if (Cpos>76)or(linelength>76)then
  243.   begin
  244.       key:=#13;
  245.       lpos:=lpos+1;
  246.       cpos:=1;
  247.       linelength:=1;
  248.   end;
  249. end;
  250. procedure TAm_wjgl_bj.DBMemo1MouseDown(Sender: TObject;
  251.   Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  252. begin
  253.   Lpos:=sendmessage(dbmemo1.Handle,EM_linefromchar,dbmemo1.SelStart,0);
  254.   Cpos:=sendmessage(dbmemo1.Handle,em_lineindex,lpos,0);
  255.   linelength:=sendmessage(dbmemo1.Handle,em_linelength,cpos,0);
  256.   Cpos:=dbmemo1.SelStart-cpos;
  257. end;
  258. procedure TAm_wjgl_bj.DBMemo2KeyDown(Sender: TObject; var Key: Word;
  259.   Shift: TShiftState);
  260. begin
  261.   Lpos:=sendmessage(dbmemo2.Handle,EM_linefromchar,dbmemo2.SelStart,0);
  262.   Cpos:=sendmessage(dbmemo2.Handle,em_lineindex,lpos,0);
  263.   linelength:=sendmessage(dbmemo2.Handle,em_linelength,cpos,0);
  264.   Cpos:=dbmemo2.SelStart-cpos;
  265. end;
  266. procedure TAm_wjgl_bj.DBMemo2KeyPress(Sender: TObject; var Key: Char);
  267. begin
  268.   if (Cpos>76)or(linelength>76)then
  269.   begin
  270.       key:=#13;
  271.       lpos:=lpos+1;
  272.       cpos:=1;
  273.       linelength:=1;
  274.   end;
  275. end;
  276. procedure TAm_wjgl_bj.DBMemo2MouseDown(Sender: TObject;
  277.   Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  278. begin
  279.   Lpos:=sendmessage(dbmemo2.Handle,EM_linefromchar,dbmemo2.SelStart,0);
  280.   Cpos:=sendmessage(dbmemo2.Handle,em_lineindex,lpos,0);
  281.   linelength:=sendmessage(dbmemo2.Handle,em_linelength,cpos,0);
  282.   Cpos:=dbmemo2.SelStart-cpos;
  283. end;
  284. procedure TAm_wjgl_bj.DBMemo3KeyDown(Sender: TObject; var Key: Word;
  285.   Shift: TShiftState);
  286. begin
  287.   Lpos:=sendmessage(dbmemo3.Handle,EM_linefromchar,dbmemo3.SelStart,0);
  288.   Cpos:=sendmessage(dbmemo3.Handle,em_lineindex,lpos,0);
  289.   linelength:=sendmessage(dbmemo3.Handle,em_linelength,cpos,0);
  290.   Cpos:=dbmemo3.SelStart-cpos;
  291. end;
  292. procedure TAm_wjgl_bj.DBMemo3MouseDown(Sender: TObject;
  293.   Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  294. begin
  295.   Lpos:=sendmessage(dbmemo3.Handle,EM_linefromchar,dbmemo3.SelStart,0);
  296.   Cpos:=sendmessage(dbmemo3.Handle,em_lineindex,lpos,0);
  297.   linelength:=sendmessage(dbmemo3.Handle,em_linelength,cpos,0);
  298.   Cpos:=dbmemo3.SelStart-cpos;
  299. end;
  300. procedure TAm_wjgl_bj.DBMemo3KeyPress(Sender: TObject; var Key: Char);
  301. begin
  302.   if (Cpos>76)or(linelength>76)then
  303.   begin
  304.       key:=#13;
  305.       lpos:=lpos+1;
  306.       cpos:=1;
  307.       linelength:=1;
  308.   end;
  309. end;
  310. procedure TAm_wjgl_bj.DBEdit20KeyPress(Sender: TObject; var Key: Char);
  311. begin
  312.    if not(key in['0'..'9',#13,#8]) then
  313.       key:=#0;
  314. end;
  315. procedure TAm_wjgl_bj.DBNumberEditEh1Exit(Sender: TObject);
  316. var s:string;
  317. begin//怎样实现?
  318.   DbEditeh4.Text:=IntToStr(strToInt(DBNumberEditEh1.Text)+N_yc);
  319.   //s:=dm.V_ylj.fieldbyname('aj_xh').AsString;
  320. end;
  321. end.