U_qxgl_yhsz.pas
上传用户:psxgmh
上传日期:2013-04-08
资源大小:15112k
文件大小:5k
- unit U_qxgl_yhsz;
- interface
- uses
- Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
- ComCtrls, DBCtrls, Buttons, ExtCtrls, StdCtrls, Mask, Db, DBClient,
- Grids, DBGrids;
- type
- TfrmQXGL_YHSZ = class(TForm)
- Panel1: TPanel;
- Panel2: TPanel;
- SpeedButton1: TSpeedButton;
- SpeedButton2: TSpeedButton;
- SpeedButton3: TSpeedButton;
- SpeedButton4: TSpeedButton;
- SpeedButton5: TSpeedButton;
- SpeedButton6: TSpeedButton;
- DBNavigator1: TDBNavigator;
- StatusBar1: TStatusBar;
- DS_QXGL_YHSZ: TDataSource;
- Label1: TLabel;
- DBEdit1: TDBEdit;
- Label2: TLabel;
- DBedtUserAlias: TDBEdit;
- Label3: TLabel;
- DBLookupComboBox1: TDBLookupComboBox;
- DS_QXGL_ZHSZ: TDataSource;
- BitBtn1: TBitBtn;
- procedure FormClose(Sender: TObject; var Action: TCloseAction);
- procedure SpeedButton1Click(Sender: TObject);
- procedure SpeedButton2Click(Sender: TObject);
- procedure SpeedButton3Click(Sender: TObject);
- procedure SpeedButton4Click(Sender: TObject);
- procedure SpeedButton5Click(Sender: TObject);
- procedure SpeedButton6Click(Sender: TObject);
- procedure BitBtn1Click(Sender: TObject);
- procedure FormCreate(Sender: TObject);
- private
- procedure btn_valid;
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- frmQXGL_YHSZ: TfrmQXGL_YHSZ;
- implementation
- uses U_mainform, U_fzlr_zgxm, WzglDB;
- {$R *.DFM}
- procedure TfrmQXGL_YHSZ.FormClose(Sender: TObject; var Action: TCloseAction);
- begin
- action := cafree;
- frmQxgl_Yhsz := nil;
- end;
- procedure TfrmQXGL_YHSZ.btn_valid;
- begin
- dbnavigator1.Enabled := not dbnavigator1.Enabled;
- speedbutton1.enabled := not speedbutton1.enabled;
- speedbutton2.enabled := not speedbutton2.enabled;
- speedbutton3.enabled := not speedbutton3.enabled;
- speedbutton4.enabled := not speedbutton4.enabled;
- speedbutton5.enabled := not speedbutton5.enabled;
- speedbutton6.enabled := not speedbutton6.enabled;
- panel1.Enabled := not panel1.Enabled;
- end;
- procedure TfrmQXGL_YHSZ.SpeedButton1Click(Sender: TObject);
- begin
- DM.CDS_QXGL_YHSZ.Insert;
- btn_valid;
- dbedit1.SetFocus;
- end;
- procedure TfrmQXGL_YHSZ.SpeedButton2Click(Sender: TObject);
- begin
- if DM.CDS_QXGL_YHSZ.recordcount = 0 then
- begin
- application.messagebox('没有记录可删除', '物资管理系统', mb_iconinformation + mb_defbutton1);
- exit;
- end;
- if DM.CDS_QXGL_YHSZ.fieldbyname('用户别名').asstring = 'system' then
- begin
- application.messagebox('系统用户不可删除', '物资管理系统', mb_iconinformation + mb_defbutton1);
- exit;
- end;
- if application.messagebox('请确认是否删除', '物资管理系统', mb_iconinformation + mb_yesno) = idyes then
- begin
- DM.CDS_QXGL_YHSZ.delete;
- DM.CDS_QXGL_YHSZ.ApplyUpdates(0);
- end;
- end;
- procedure TfrmQXGL_YHSZ.SpeedButton3Click(Sender: TObject);
- begin
- if DM.CDS_QXGL_YHSZ.recordcount = 0 then
- begin
- application.messagebox('没有记录可编辑', '物资管理系统', mb_iconinformation + mb_defbutton1);
- exit;
- end;
- if DM.CDS_QXGL_YHSZ.fieldbyname('用户别名').asstring = 'system' then
- DBedtUserAlias.ReadOnly := true
- else
- DBedtUserAlias.ReadOnly := False;
- DM.CDS_QXGL_YHSZ.edit;
- btn_valid;
- dbedit1.setfocus;
- end;
- procedure TfrmQXGL_YHSZ.SpeedButton4Click(Sender: TObject);
- begin
- DM.CDS_QXGL_YHSZ.Cancel;
- DM.CDS_QXGL_YHSZ.cancelupdates;
- btn_valid;
- end;
- procedure TfrmQXGL_YHSZ.SpeedButton5Click(Sender: TObject);
- var
- vs_yhbh: string;
- begin
- if dbedit1.text = '' then
- begin
- application.MessageBox('用户编号还未输入', '物资管理系统', mb_iconinformation + mb_defbutton1);
- dbedit1.setfocus;
- exit;
- end;
- vs_yhbh := dbedit1.Text;
- DM.CDS_QXGL_YHSZ_INDEX.IndexFieldNames := '用户编号';
- DM.CDS_QXGL_YHSZ_INDEX.Refresh;
- if DM.CDS_QXGL_YHSZ.state = dsinsert then
- begin
- if DM.CDS_QXGL_YHSZ_INDEX.FindKey([vs_yhbh]) then
- begin
- application.MessageBox('用户编号已重复', '物资管理系统', mb_iconinformation + mb_defbutton1);
- dbedit1.SetFocus;
- exit;
- end;
- end;
- if dblookupcombobox1.text = '' then
- begin
- application.MessageBox('用户组号还未选择', '物资管理系统', mb_iconinformation + mb_defbutton1);
- dblookupcombobox1.setfocus;
- exit;
- end;
- DM.CDS_QXGL_YHSZ.FieldByName('用户密码').value := '000';
- DM.CDS_QXGL_YHSZ.Post;
- DM.CDS_QXGL_YHSZ.applyupdates(0);
- btn_valid;
- end;
- procedure TfrmQXGL_YHSZ.SpeedButton6Click(Sender: TObject);
- begin
- DM.CDS_QXGL_YHSZ.Refresh;
- end;
- procedure TfrmQXGL_YHSZ.BitBtn1Click(Sender: TObject);
- begin
- application.createform(TfrmZgda_fzlr, frmZgda_fzlr);
- try
- frmZgda_fzlr.showmodal;
- finally
- dbedit1.text := pub_zgxm;
- frmZgda_fzlr.free;
- end;
- end;
- procedure TfrmQXGL_YHSZ.FormCreate(Sender: TObject);
- begin
- with DM do
- begin
- CDS_QXGL_YHSZ.Active := True;
- CDS_QXGL_YHSZ_INDEX.Active := True;
- CDS_QXGL_ZHSZ.Active := True;
- end;
- end;
- end.