u_yfdwkp.pas
上传用户:psxgmh
上传日期:2013-04-08
资源大小:15112k
文件大小:4k
源码类别:

Delphi/CppBuilder

开发平台:

Delphi

  1. unit u_yfdwkp;
  2. interface
  3. uses
  4.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  5.   StdCtrls, DBCtrls, Mask, ComCtrls, Buttons, ExtCtrls, Db, DBClient,
  6.   Grids, DBGrids;
  7. type
  8.   TForm62 = class(TForm)
  9.     Panel1: TPanel;
  10.     SpeedButton1: TSpeedButton;
  11.     SpeedButton2: TSpeedButton;
  12.     ClientDataSet1: TClientDataSet;
  13.     ClientDataSet1ID: TIntegerField;
  14.     ClientDataSet1CDSDesigner: TStringField;
  15.     ClientDataSet1CDSDesigner2: TStringField;
  16.     Panel2: TPanel;
  17.     PageControl1: TPageControl;
  18.     TabSheet1: TTabSheet;
  19.     Label1: TLabel;
  20.     Label2: TLabel;
  21.     Label3: TLabel;
  22.     Label4: TLabel;
  23.     Label6: TLabel;
  24.     Label7: TLabel;
  25.     Label5: TLabel;
  26.     Label16: TLabel;
  27.     DBEdit1: TDBEdit;
  28.     DBEdit2: TDBEdit;
  29.     DBEdit3: TDBEdit;
  30.     DBEdit4: TDBEdit;
  31.     DBEdit6: TDBEdit;
  32.     DBEdit7: TDBEdit;
  33.     DBCheckBox2: TDBCheckBox;
  34.     DBCheckBox1: TDBCheckBox;
  35.     DBEdit5: TDBEdit;
  36.     BitBtn1: TBitBtn;
  37.     Edit1: TEdit;
  38.     TabSheet2: TTabSheet;
  39.     Label8: TLabel;
  40.     Label9: TLabel;
  41.     Label10: TLabel;
  42.     Label11: TLabel;
  43.     Label12: TLabel;
  44.     Label13: TLabel;
  45.     Label14: TLabel;
  46.     Label15: TLabel;
  47.     DBEdit8: TDBEdit;
  48.     DBEdit9: TDBEdit;
  49.     DBEdit10: TDBEdit;
  50.     DBEdit11: TDBEdit;
  51.     DBEdit12: TDBEdit;
  52.     DBEdit13: TDBEdit;
  53.     DBEdit14: TDBEdit;
  54.     DBEdit15: TDBEdit;
  55.     ClientDataSet_index: TClientDataSet;
  56.     DBGrid1: TDBGrid;
  57.     DataSource1: TDataSource;
  58.     procedure SpeedButton1Click(Sender: TObject);
  59.     procedure SpeedButton2Click(Sender: TObject);
  60.     procedure FormClose(Sender: TObject; var Action: TCloseAction);
  61.     procedure BitBtn1Click(Sender: TObject);
  62.     procedure FormActivate(Sender: TObject);
  63.     procedure DBEdit5Change(Sender: TObject);
  64.     procedure DBGrid1DblClick(Sender: TObject);
  65.   private
  66.     { Private declarations }
  67.   public
  68.     { Public declarations }
  69.   end;
  70. var
  71.   Form62: TForm62;
  72. implementation
  73. uses U_yfdw, U_mainform;
  74. {$R *.DFM}
  75. procedure TForm62.SpeedButton1Click(Sender: TObject);
  76. var
  77.   s_yfdwbh: string;
  78. begin
  79.   if trim(dbedit1.text) = '' then
  80.   begin
  81.     application.messagebox('乙方单位编号应该输入,请确认!', '物资管理系统', mb_iconinformation + mb_defbutton1);
  82.     dbedit1.SetFocus;
  83.     exit;
  84.   end;
  85. //重复编号
  86.   s_yfdwbh := dbedit1.Text;
  87.   clientdataset_index.IndexFieldNames := '乙方单位编号';
  88.   clientdataset_index.Refresh;
  89.   if form60.clientdataset1.state = dsinsert then
  90.   begin
  91.     if clientdataset_index.FindKey([s_yfdwbh]) then
  92.     begin
  93.       application.MessageBox('乙方单位编号已重复', '物资管理系统', mb_iconinformation + mb_defbutton1);
  94.       pagecontrol1.ActivePageIndex := 0;
  95.       dbedit1.SetFocus;
  96.       exit;
  97.     end;
  98.   end;
  99.   if trim(dbedit2.text) = '' then
  100.   begin
  101.     application.messagebox('乙方单位名称应该输入,请确认!', '物资管理系统', mb_iconinformation + mb_defbutton1);
  102.     dbedit2.SetFocus;
  103.     exit;
  104.   end;
  105.   form60.clientdataset1.Post;
  106.   form60.clientdataset1.ApplyUpdates(0);
  107.   close;
  108. end;
  109. procedure TForm62.SpeedButton2Click(Sender: TObject);
  110. begin
  111.   close;
  112. end;
  113. procedure TForm62.FormClose(Sender: TObject; var Action: TCloseAction);
  114. begin
  115.   form60.clientdataset1.Cancel;
  116.   form60.clientdataset1.cancelupdates;
  117. end;
  118. procedure TForm62.BitBtn1Click(Sender: TObject);
  119. begin
  120. dbgrid1.Visible:=true;
  121. {application.createform(Tform14,form14);
  122. try
  123. form14.showmodal;
  124. finally
  125. form14.free;
  126. form60.ClientDataSet1.FieldByName('所属地区码').value:=gs_dqbm;
  127. end;}
  128. end;
  129. procedure TForm62.FormActivate(Sender: TObject);
  130. var
  131.   s_dqdm: string;
  132. begin
  133. {s_dqdm:=dbedit5.Text;
  134. clientdataset1.IndexFieldNames:='类别编码';
  135. if clientdataset1.FindKey([s_dqdm]) then
  136. edit1.text:=clientdataset1.fieldbyname('类别名称').asstring
  137. else
  138. edit1.text:=''; }
  139. end;
  140. procedure TForm62.DBEdit5Change(Sender: TObject);
  141. var
  142.   s_dqdm: string;
  143. begin
  144. {s_dqdm:=dbedit5.Text;
  145. clientdataset1.IndexFieldNames:='类别编码';
  146. if clientdataset1.FindKey([s_dqdm]) then
  147. edit1.text:=clientdataset1.fieldbyname('类别名称').asstring
  148. else
  149. edit1.text:='';}
  150. end;
  151. procedure TForm62.DBGrid1DblClick(Sender: TObject);
  152. begin
  153. form60.ClientDataSet1.FieldByName('所属地区码').value:=ClientDataSet1.FieldByName('类别编码').value;
  154. edit1.text:=ClientDataSet1.FieldByName('类别名称').value;
  155. dbgrid1.Visible:=false;
  156. end;
  157. end.