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.     procedure SpeedButton2Click(Sender: TObject);
  27.     procedure FormClose(Sender: TObject; var Action: TCloseAction);
  28.     procedure SpeedButton1Click(Sender: TObject);
  29.     procedure FormShow(Sender: TObject);
  30.     procedure DBMemo1MouseDown(Sender: TObject; Button: TMouseButton;
  31.       Shift: TShiftState; X, Y: Integer);
  32.     procedure DBMemo1KeyPress(Sender: TObject; var Key: Char);
  33.     procedure DBMemo1KeyDown(Sender: TObject; var Key: Word;
  34.       Shift: TShiftState);
  35.   private
  36.     { Private declarations }
  37.   public
  38.     { Public declarations }
  39.   end;
  40. var
  41.   Am_ylj_bj: TAm_ylj_bj;
  42.   cpos,Lpos,linelength:integer;
  43. implementation
  44. uses DMs,am_yljs,u_public, ajgls;
  45. {$R *.dfm}
  46. procedure TAm_ylj_bj.SpeedButton2Click(Sender: TObject);
  47. begin
  48.   close;
  49. end;
  50. procedure TAm_ylj_bj.FormClose(Sender: TObject; var Action: TCloseAction);
  51. begin
  52.   am_ylj_bj:=nil;
  53.   action:=cafree;
  54. end;
  55. procedure TAm_ylj_bj.SpeedButton1Click(Sender: TObject);
  56. begin
  57.   dm.Am_ajgl.Edit;
  58.   dm.Am_ajgl.FieldByName('ajzt_mc').AsString:='预立卷';
  59.   dm.Am_ajgl.FieldByName('ajlb_dm').AsString:=am_ylj.epos1;
  60.   dm.Am_ajgl.ApplyUpdates(0);
  61.   if dm.Am_ajgl.ApplyUpdates(0)=0 then
  62.   begin
  63.      application.MessageBox('数据保存成功','提示',mb_ok+mb_iconinformation);
  64.      am_ylj.ToolButton1.Click;
  65.      am_ylj.xiugai.Enabled:=true;
  66.      am_ylj.dele1.Enabled:=true;
  67.      am_ylj.ToolButton1.Enabled:=true;
  68.      am_ylj.WJCZ.Enabled:=true;
  69.      am_ylj.YLJ1.Enabled:=true;
  70.      close;
  71.   end
  72.   else
  73.   begin
  74.     application.MessageBox('数据保存失败','提示',mb_ok+mb_iconinformation);
  75.   end;
  76. end;
  77. procedure TAm_ylj_bj.FormShow(Sender: TObject);
  78. var now1:Tdatetime;
  79.     year,month,day:word;
  80.     s1,s2:string;
  81.     epos:integer;
  82. begin
  83.   now1:=date();
  84.   decodedate(now1,year,month,day);
  85.   dbediteh2.Text:=inttostr(year);
  86.   dbediteh3.Text:=user_name;
  87.   s1:=am_ylj.Tree.Selected.Text;
  88.   Epos:=pos('-',s1);
  89.   s2:=copy(ylj_s1,0,Epos-1);//案卷类别代码
  90.   dm.sz_ajlb.Close;
  91.   dm.sz_ajlb.CommandText:='select * from sz_ajlb where ajlb_dm='+''''+s2+''''+'';
  92.   dm.sz_ajlb.Open;
  93.   dbediteh1.Text:=dm.sz_ajlb.FieldByName('ajlb_mc').AsString;//将案卷类别代码赋给
  94. end;                                                         //dbediteh1
  95. procedure TAm_ylj_bj.DBMemo1MouseDown(Sender: TObject;
  96.   Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  97. begin
  98.   Lpos:=sendmessage(dbmemo1.Handle,em_linefromchar,dbmemo1.SelStart,0);
  99.   Cpos:=sendmessage(dbmemo1.Handle,em_lineindex,lpos,0);
  100.   linelength:=sendmessage(dbmemo1.Handle,em_linelength,cpos,0);
  101.   cpos:=dbmemo1.SelStart-cpos;
  102. end;
  103. procedure TAm_ylj_bj.DBMemo1KeyPress(Sender: TObject; var Key: Char);
  104. begin
  105.    if (Cpos>76)or(linelength>76)then
  106.   begin
  107.       key:=#13;
  108.       lpos:=lpos+1;
  109.       cpos:=1;
  110.       linelength:=1;
  111.   end;
  112. end;
  113. procedure TAm_ylj_bj.DBMemo1KeyDown(Sender: TObject; var Key: Word;
  114.   Shift: TShiftState);
  115. begin
  116.   lpos:=SendMessage(dbMemo1.Handle,EM_linefromchar,dbmemo1.SelStart,0);
  117.   Cpos:=Sendmessage(dbmemo1.Handle,em_lineindex,lpos,0);
  118.   Linelength:=Sendmessage(dbmemo1.Handle,em_linelength,cpos,0);
  119.   Cpos:=dbmemo1.SelStart-Cpos;
  120. end;
  121. end.