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

Delphi控件源码

开发平台:

Delphi

  1. unit Am_ylj_bjs;
  2. interface
  3. uses
  4.   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  5.   Dialogs, ExtCtrls, DB, StdCtrls, Mask, DBCtrls, Buttons, DBCtrlsEh,
  6.   TFlatHintUnit;
  7. type
  8.   TAm_ylj_bj = class(TForm)
  9.     Panel1: TPanel;
  10.     Label1: TLabel;
  11.     ds_ajgl: TDataSource;
  12.     Label2: TLabel;
  13.     Label3: TLabel;
  14.     Label4: TLabel;
  15.     Label5: TLabel;
  16.     DBMemo1: TDBMemo;
  17.     Label6: TLabel;
  18.     L_bgqx: TDBLookupComboBox;
  19.     L_mj: TDBLookupComboBox;
  20.     SpeedButton1: TSpeedButton;
  21.     SpeedButton2: TSpeedButton;
  22.     DBEditEh1: TDBEditEh;
  23.     DBEditEh2: TDBEditEh;
  24.     DBEditEh3: TDBEditEh;
  25.     FlatHint1: TFlatHint;
  26.     Label7: TLabel;
  27.     Label8: TLabel;
  28.     Label9: TLabel;
  29.     procedure SpeedButton2Click(Sender: TObject);
  30.     procedure FormClose(Sender: TObject; var Action: TCloseAction);
  31.     procedure SpeedButton1Click(Sender: TObject);
  32.     procedure FormShow(Sender: TObject);
  33.     procedure DBMemo1MouseDown(Sender: TObject; Button: TMouseButton;
  34.       Shift: TShiftState; X, Y: Integer);
  35.     procedure DBMemo1KeyPress(Sender: TObject; var Key: Char);
  36.     procedure DBMemo1KeyDown(Sender: TObject; var Key: Word;
  37.       Shift: TShiftState);
  38.   private
  39.     { Private declarations }
  40.   public
  41.     { Public declarations }
  42.   end;
  43. var
  44.   Am_ylj_bj: TAm_ylj_bj;
  45.   cpos,Lpos,linelength:integer;
  46. implementation
  47. uses DMs,am_yljs,u_public, ajgls;
  48. {$R *.dfm}
  49. procedure TAm_ylj_bj.SpeedButton2Click(Sender: TObject);
  50. begin
  51.   close;
  52. end;
  53. procedure TAm_ylj_bj.FormClose(Sender: TObject; var Action: TCloseAction);
  54. begin
  55.   am_ylj_bj:=nil;
  56.   action:=cafree;
  57. end;
  58. procedure TAm_ylj_bj.SpeedButton1Click(Sender: TObject);
  59. begin
  60.   dm.Am_ajgl.Edit;
  61.   dm.Am_ajgl.FieldByName('ajzt_mc').AsString:='预立卷';
  62.   dm.Am_ajgl.FieldByName('ajlb_dm').AsString:=am_ylj.epos1;
  63.   dm.Am_ajgl.ApplyUpdates(0);
  64.   if dm.Am_ajgl.ApplyUpdates(0)=0 then
  65.   begin
  66.      application.MessageBox('数据保存成功','提示',mb_ok+mb_iconinformation);
  67.      am_ylj.ToolButton1.Click;
  68.      am_ylj.xiugai.Enabled:=true;
  69.      am_ylj.dele1.Enabled:=true;
  70.      am_ylj.ToolButton1.Enabled:=true;
  71.      am_ylj.WJCZ.Enabled:=true;
  72.      am_ylj.YLJ1.Enabled:=true;
  73.      close;
  74.   end
  75.   else
  76.   begin
  77.     application.MessageBox('数据保存失败','提示',mb_ok+mb_iconinformation);
  78.   end;
  79. end;
  80. procedure TAm_ylj_bj.FormShow(Sender: TObject);
  81. var now1:Tdatetime;
  82.     year,month,day:word;
  83.     s1,s2:string;
  84.     epos:integer;
  85. begin
  86.   now1:=date();
  87.   decodedate(now1,year,month,day);
  88.   dbediteh2.Text:=inttostr(year);
  89.   dbediteh3.Text:=user_name;
  90.   s1:=am_ylj.Tree.Selected.Text;
  91.   Epos:=pos('-',s1);
  92.   s2:=copy(ylj_s1,0,Epos-1);//案卷类别代码
  93.   dm.sz_ajlb.Close;
  94.   dm.sz_ajlb.CommandText:='select * from sz_ajlb where ajlb_dm='+''''+s2+''''+'';
  95.   dm.sz_ajlb.Open;
  96.   dbediteh1.Text:=dm.sz_ajlb.FieldByName('ajlb_mc').AsString;//将案卷类别代码赋给
  97. end;                                                         //dbediteh1
  98. procedure TAm_ylj_bj.DBMemo1MouseDown(Sender: TObject;
  99.   Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  100. begin
  101.   Lpos:=sendmessage(dbmemo1.Handle,em_linefromchar,dbmemo1.SelStart,0);
  102.   Cpos:=sendmessage(dbmemo1.Handle,em_lineindex,lpos,0);
  103.   linelength:=sendmessage(dbmemo1.Handle,em_linelength,cpos,0);
  104.   cpos:=dbmemo1.SelStart-cpos;
  105. end;
  106. procedure TAm_ylj_bj.DBMemo1KeyPress(Sender: TObject; var Key: Char);
  107. begin
  108.    if (Cpos>76)or(linelength>76)then
  109.   begin
  110.       key:=#13;
  111.       lpos:=lpos+1;
  112.       cpos:=1;
  113.       linelength:=1;
  114.   end;
  115. end;
  116. procedure TAm_ylj_bj.DBMemo1KeyDown(Sender: TObject; var Key: Word;
  117.   Shift: TShiftState);
  118. begin
  119.   lpos:=SendMessage(dbMemo1.Handle,EM_linefromchar,dbmemo1.SelStart,0);
  120.   Cpos:=Sendmessage(dbmemo1.Handle,em_lineindex,lpos,0);
  121.   Linelength:=Sendmessage(dbmemo1.Handle,em_linelength,cpos,0);
  122.   Cpos:=dbmemo1.SelStart-Cpos;
  123. end;
  124. end.