Xt_Cssds.pas
资源名称:挡案管理系统.rar [点击查看]
上传用户:szruida
上传日期:2007-06-01
资源大小:6518k
文件大小:4k
源码类别:
Delphi控件源码
开发平台:
Delphi
- unit Xt_Cssds;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, DB, DBClient, Grids, DBGridEh, ExtCtrls, StdCtrls, DBCtrlsEh,
- Mask, DBCtrls, Buttons;
- type
- TXt_Cssd = class(TForm)
- GroupBox1: TGroupBox;
- Label2: TLabel;
- Label4: TLabel;
- Label35: TLabel;
- Label37: TLabel;
- Label5: TLabel;
- SpeedButton21: TSpeedButton;
- SpeedButton23: TSpeedButton;
- Refresh: TSpeedButton;
- SpeedButton25: TSpeedButton;
- Panel6: TPanel;
- DBGridEh6: TDBGridEh;
- DataSource1: TDataSource;
- ClientDataSet1: TClientDataSet;
- Label3: TLabel;
- DBEditEh1: TDBEditEh;
- DBEditEh3: TDBEditEh;
- DBEditEh5: TDBEditEh;
- DBEditEh2: TDBEditEh;
- procedure FormClose(Sender: TObject; var Action: TCloseAction);
- procedure SpeedButton25Click(Sender: TObject);
- procedure RefreshClick(Sender: TObject);
- procedure SpeedButton21Click(Sender: TObject);
- procedure DBEditEh3Exit(Sender: TObject);
- procedure SpeedButton23Click(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- Xt_Cssd: TXt_Cssd;
- implementation
- {$R *.dfm}
- procedure TXt_Cssd.FormClose(Sender: TObject; var Action: TCloseAction);
- begin
- Clientdataset1.Active:=false;
- Action:=cafree;
- xt_Cssd:=Nil;
- end;
- procedure TXt_Cssd.SpeedButton25Click(Sender: TObject);
- begin
- Close;
- end;
- procedure TXt_Cssd.RefreshClick(Sender: TObject);
- begin
- Clientdataset1.Active:=false;
- Clientdataset1.Active:=true;
- end;
- procedure TXt_Cssd.SpeedButton21Click(Sender: TObject);
- begin
- Clientdataset1.Edit;
- end;
- procedure TXt_Cssd.DBEditEh3Exit(Sender: TObject);
- begin
- if Clientdataset1.FieldByName('lb_dmlx').AsBoolean then
- begin
- if length(DbEditeh3.Text)<>1 then
- begin
- dbediteh3.Text:='';
- application.MessageBox('一级编码'+#13#10+'只能输入一位代码','提示',mb_Ok+mb_iconinformation);
- exit;
- end;
- end;
- end;
- procedure TXt_Cssd.SpeedButton23Click(Sender: TObject);
- var
- Hint,s_dmgz:string;//提示符
- str,str2:string;//用于接收数据
- tempstr:string;//显示编码规则的字符串
- i,j,tempN,s_lbdmcd:Integer;//s_lbdmcd类别代码长度
- begin
- str:=DbEditeh3.Text;
- str2:=Clientdataset1.FieldByName('lbjs_sm').AsString;
- s_dmgz:=Clientdataset1.FieldByName('lb_dmgz').AsString;
- s_lbdmcd:=Clientdataset1.FieldByName('lb_dmcd').AsInteger;
- if trim(DBEditeh3.Text)='' then
- begin
- application.MessageBox('类别说明不能为空','提示',mb_ok+mb_iconinformation);
- Exit;
- end;
- if Clientdataset1.FieldByName('lb_dmlx').AsBoolean then
- begin
- if length(DbEditeh3.Text)<>1 then
- begin
- dbediteh3.Text:=str2;
- application.MessageBox('一级编码'+#13#10+'只能输入一位代码','提示',mb_Ok+mb_iconinformation);
- exit;
- end;
- end;
- //验证是否符合规则
- Clientdataset1.Edit;
- for i:=1 to length(str) do
- begin
- for j:=1 to strToInt(str[i]) do
- tempstr:=tempstr+'#';
- if i<length(str) then
- tempstr:=TempStr+'/';
- DbEditeh5.Text:=tempstr;
- tempN:=tempN+strtoINt(str[i]);
- if tempN>s_lbdmcd then
- begin
- hint:='本类别总长度不能超过'+intToStr(s_lbdmcd);
- application.MessageBox(Pchar(Hint),'提示',mb_Ok+mb_iconinformation);
- Dbediteh3.Text:=str2;
- Dbediteh5.Text:=s_dmgz;
- exit;
- end;
- end;
- if Clientdataset1.ApplyUpdates(0)=0 then
- begin
- application.MessageBox('数据修改成功','提示',mb_ok+mb_iconinformation);
- end
- else
- begin
- application.MessageBox('数据修改失败','提示',mb_ok+mb_iconinformation);
- exit;
- end;
- end;
- end.