📄 base_info.pas
字号:
unit Base_info;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, Spin, StdCtrls, Buttons, ComCtrls, Mask, DBCtrls,
Grids, DBGrids, ImgList, ToolWin, DB, ADODB;
type
TForm_Base_info = class(TForm)
ImageList1: TImageList;
Label14: TLabel;
Label15: TLabel;
TabSheet: TPageControl;
department: TTabSheet;
Bevel2: TBevel;
DBGrid1: TDBGrid;
Panel1: TPanel;
Label1: TLabel;
Bevel3: TBevel;
DBE_dep: TDBEdit;
ToolBar1: TToolBar;
ToolBtn_add: TToolButton;
ToolBtn_edit: TToolButton;
ToolBtn_delete: TToolButton;
ToolButton4: TToolButton;
ToolBtn_save: TToolButton;
ToolBtn_cancel: TToolButton;
ToolButton7: TToolButton;
ToolBtn_exit: TToolButton;
StatusBar2: TStatusBar;
duty: TTabSheet;
Panel2: TPanel;
Label2: TLabel;
Bevel4: TBevel;
DBE_duty: TDBEdit;
StatusBar1: TStatusBar;
DBGrid2: TDBGrid;
customer: TTabSheet;
DBGrid3: TDBGrid;
clothing: TTabSheet;
Panel4: TPanel;
Label4: TLabel;
Bevel6: TBevel;
DBE_clo_name: TDBEdit;
StatusBar4: TStatusBar;
DBGrid4: TDBGrid;
material_type: TTabSheet;
Panel5: TPanel;
Label5: TLabel;
Bevel7: TBevel;
DBE_matype_name: TDBEdit;
StatusBar5: TStatusBar;
DBGrid5: TDBGrid;
ToolBar2: TToolBar;
ToolBtn_add_1: TToolButton;
ToolBtn_edit_1: TToolButton;
ToolBtn_delete_1: TToolButton;
ToolButton12: TToolButton;
ToolBtn_save_1: TToolButton;
ToolBtn_cancel_1: TToolButton;
ToolButton15: TToolButton;
ToolButton16: TToolButton;
ToolBar4: TToolBar;
ToolBtn_add_5: TToolButton;
ToolBtn_edit_5: TToolButton;
ToolBtn_delete_5: TToolButton;
ToolButton30: TToolButton;
ToolBtn_save_5: TToolButton;
ToolBtn_cancel_5: TToolButton;
ToolButton33: TToolButton;
ToolButton34: TToolButton;
ToolBar5: TToolBar;
ToolBtn_add_3: TToolButton;
ToolBtn_edit_3: TToolButton;
ToolBtn_delete_3: TToolButton;
ToolButton39: TToolButton;
ToolBtn_save_3: TToolButton;
ToolBtn_cancel_3: TToolButton;
ToolButton42: TToolButton;
ToolButton43: TToolButton;
Button1: TButton;
DS_dep_T: TDataSource;
ADOT_dep: TADOTable;
ADOT_depdepid: TAutoIncField;
ADOT_depdepname: TStringField;
ADOT_duty: TADOTable;
ADOT_dutydutyid: TAutoIncField;
ADOT_dutydutyname: TStringField;
DS_duty_T: TDataSource;
DS_customer: TDataSource;
DS_clothing: TDataSource;
ADOT_mat_type: TADOTable;
ADOT_mat_typematype_id: TAutoIncField;
ADOT_mat_typematype_name: TStringField;
DS_mat_type: TDataSource;
DBMemo_dep: TDBMemo;
Label6: TLabel;
Label18: TLabel;
DBMemo_duty: TDBMemo;
ToolButton1: TToolButton;
ToolButton2: TToolButton;
ToolButton3: TToolButton;
ToolButton6: TToolButton;
DBMemo_matype: TDBMemo;
DBMemo_cloth: TDBMemo;
Label8: TLabel;
Label19: TLabel;
Panel31: TPanel;
Bevel5: TBevel;
Panel_search: TPanel;
edtname: TEdit;
edt_custname: TEdit;
ToolBar3: TToolBar;
ToolBtn_add_2: TToolButton;
ToolBtn_edit_2: TToolButton;
ToolBtn_delete_2: TToolButton;
ToolButton21: TToolButton;
ToolBtn_save_2: TToolButton;
ToolBtn_cancel_2: TToolButton;
ToolButton24: TToolButton;
ToolButton25: TToolButton;
ToolButton26: TToolButton;
SearchBtn: TBitBtn;
Panel_detail: TPanel;
Label3: TLabel;
StatusBar3: TStatusBar;
Label7: TLabel;
DBE_cust_name: TDBEdit;
Label9: TLabel;
DBE_person_name: TDBEdit;
Label10: TLabel;
DBE_province: TDBEdit;
Label11: TLabel;
DBE_tel1: TDBEdit;
Label12: TLabel;
DBE_tel2: TDBEdit;
Label17: TLabel;
DBE_fax: TDBEdit;
Label16: TLabel;
DBE_mobile1: TDBEdit;
Label13: TLabel;
DBE_mobile2: TDBEdit;
Label20: TLabel;
DBE_Address: TDBEdit;
Label21: TLabel;
Label22: TLabel;
ADOQ_customer: TADOQuery;
ADOT_clothing: TADOTable;
ADOT_clothingclo_id: TAutoIncField;
ADOT_clothingclo_name: TStringField;
Label23: TLabel;
Edt_procince: TEdit;
ADOT_depmemo: TStringField;
ADOT_dutymemo: TStringField;
ADOT_clothingmemo: TStringField;
ADOT_mat_typememo: TStringField;
procedure TabSheetChange(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure ToolBtn_addClick(Sender: TObject);
procedure ToolBtn_editClick(Sender: TObject);
procedure ToolBtn_deleteClick(Sender: TObject);
procedure ToolBtn_saveClick(Sender: TObject);
procedure ToolBtn_cancelClick(Sender: TObject);
procedure ToolBtn_exitClick(Sender: TObject);
procedure DBE_tel1KeyPress(Sender: TObject; var Key: Char);
procedure TabSheetChanging(Sender: TObject; var AllowChange: Boolean);
procedure ADOT_depAfterEdit(DataSet: TDataSet);
procedure ADOT_dutyAfterEdit(DataSet: TDataSet);
procedure ADOT_clothingAfterEdit(DataSet: TDataSet);
procedure ADOT_mat_typeAfterEdit(DataSet: TDataSet);
procedure FormShow(Sender: TObject);
procedure DS_dep_TStateChange(Sender: TObject);
procedure DS_duty_TStateChange(Sender: TObject);
procedure DS_clothingStateChange(Sender: TObject);
procedure DS_mat_typeStateChange(Sender: TObject);
procedure DS_customerStateChange(Sender: TObject);
procedure SearchBtnClick(Sender: TObject);
procedure ADOQ_customerAfterEdit(DataSet: TDataSet);
private
{ Private declarations }
temp_cust_name:string; //修改记录时客户的名称
old_depname, old_dutyname,
old_clotype, old_matype:string;
old_active_page:integer;
procedure show_tabsheet_caption;
procedure edit_rec;
procedure delete_rec;
procedure append_rec;
procedure save_rec;
procedure cancel_rec;
public
{ Public declarations }
end;
var
Form_Base_info: TForm_Base_info;
implementation
uses data, sharevar, sharefun, ColorSetup;
{$R *.dfm}
//显示窗口的标题,并打开对应的数据表
procedure TForm_base_info.show_tabsheet_caption;
begin
case TabSheet.ActivePageIndex of
0:
begin
Form_Base_info.Caption:='基本信息录入 \ 部门管理';
try
if not ADOT_dep.Active then ADOT_dep.Open;
except
MsgErr(handle,'打开基本信息数据库失败!');
end;
DBGrid1.DataSource:=DS_dep_T;
end;
1:
begin
Form_Base_info.Caption:='基本信息录入 \ 职务管理';
try
if not ADOT_duty.Active then ADOT_duty.Open;
except
MsgErr(handle,'打开基本信息数据库失败!');
end;
DBGrid2.DataSource:=DS_duty_T;
end;
2:
begin
Form_Base_info.Caption:='基本信息录入 \ 客户信息管理';
try
if not ADOQ_customer.Active then ADOQ_customer.Open;
except
MsgErr(handle,'打开基本信息数据库失败!');
end;
DBGrid3.DataSource:=DS_customer;
end;
3:
begin
Form_Base_info.Caption:='基本信息录入 \ 服装类别信息管理';
try
if not ADOT_clothing.Active then ADOT_clothing.Open;
except
MsgErr(handle,'打开基本信息数据库失败!');
end;
DBGrid4.DataSource:=DS_clothing;
end;
4:
begin
Form_Base_info.Caption:='基本信息录入 \ 物料类别管理';
try
if not ADOT_mat_type.Active then ADOT_mat_type.Open;
except
MsgErr(handle,'打开基本信息数据库失败!');
end;
DBGrid5.DataSource:=DS_mat_type;
end;
end;
end;
//将改变前的Tabsheet的activepageindex赋值
procedure TForm_Base_info.TabSheetChanging(Sender: TObject;
var AllowChange: Boolean);
begin
old_active_page:=TabSheet.ActivePageIndex;
end;
//当Tabsheet的activepageindex改变时关闭相关的数据表,并且打开相关表
procedure TForm_Base_info.TabSheetChange(Sender: TObject);
var
new_active_page:integer;
begin
new_active_page:=TabSheet.ActivePageIndex;
TabSheet.ActivePageIndex:=old_active_page;
//关闭对应已打开的数据表
case TabSheet.ActivePageIndex of
0:
if not ADOT_dep.Active then ADOT_dep.close;
1:
if ADOT_duty.Active then ADOT_duty.close;
2:
if not ADOQ_customer.Active then ADOQ_customer.close;
3:
if not ADOT_clothing.Active then ADOT_clothing.close;
4:
if not ADOT_mat_type.Active then ADOT_mat_type.close;
end;
TabSheet.ActivePageIndex:=new_active_page;
show_tabsheet_caption;
end;
procedure TForm_Base_info.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
try
if ADOT_dep.Active then ADOT_dep.Close;
if ADOT_duty.Active then ADOT_duty.Close;
if ADOQ_customer.Active then ADOQ_customer.Close;
if ADOT_clothing.Active then ADOT_clothing.Close;
if ADOT_mat_type.Active then ADOT_mat_type.Close;
except
MsgErr(handle,'关闭基本信息数据库失败!');
end;
action:=cafree;
end;
//取消对数据表所做的最近的操作
procedure Tform_base_info.cancel_rec;
begin
case TabSheet.ActivePageIndex of
0:
with ADOT_dep do
begin
if not (State in [dsinsert,dsedit]) then exit;
cancel;
end;
1:
with ADOT_duty do
begin
if not (State in [dsinsert,dsedit]) then exit;
cancel;
end;
2:
with ADOQ_customer do
begin
if not (State in [dsinsert,dsedit]) then exit;
cancel;
end;
3:
with ADOT_clothing do
begin
if not (State in [dsinsert,dsedit]) then exit;
cancel;
end;
4:
with ADOT_mat_type do
begin
if not (State in [dsinsert,dsedit]) then exit;
cancel;
end;
end;
end;
//数据表添加记录
procedure TForm_base_info.append_rec;
begin
case TabSheet.ActivePageIndex of
0:
with ADOT_dep do
begin
if State in [dsinsert,dsedit] then exit;
append; DBE_dep.SetFocus;
end;
1:
with ADOT_duty do
begin
if State in [dsinsert,dsedit] then exit;
append; DBE_duty.SetFocus;
end;
2:
with ADOQ_customer do
begin
if State in [dsinsert,dsedit] then exit;
append; DBE_cust_name.SetFocus;
end;
3:
with ADOT_clothing do
begin
if State in [dsinsert,dsedit] then exit;
append; DBE_clo_name.SetFocus;
end;
4:
with ADOT_mat_type do
begin
if State in [dsinsert,dsedit] then exit;
append; DBE_matype_name.SetFocus;
end;
end;
end;
//数据表编辑记录
procedure TForm_Base_info.edit_rec;
begin
case TabSheet.ActivePageIndex of
0:
with ADOT_dep do
begin
if State in [dsinsert,dsedit] then exit;
if recordcount<1 then exit;
edit; DBE_dep.SetFocus;
end;
1:
with ADOT_duty do
begin
if State in [dsinsert,dsedit] then exit;
if recordcount<1 then exit;
edit; DBE_duty.SetFocus;
end;
2:
with ADOQ_customer do
begin
if State in [dsinsert,dsedit] then exit;
if recordcount<1 then exit;
edit; dbe_cust_name.SetFocus;
end;
3:
with ADOT_clothing do
begin
if State in [dsinsert,dsedit] then exit;
if recordcount<1 then exit;
edit; dbe_clo_name.SetFocus;
end;
4:
with ADOT_mat_type do
begin
if State in [dsinsert,dsedit] then exit;
if recordcount<1 then exit;
edit; DBE_matype_name.SetFocus;
end;
end;
end;
//数据表删除记录
procedure Tform_base_info.delete_rec;
var temp_name:string;
begin
case TabSheet.ActivePageIndex of
0:
with ADOT_dep do
begin
if RecordCount<1 then exit;
if State in [dsinsert,dsedit] then exit;
temp_name:=fieldvalues['depname'];
if MsgQst(handle,'确定删除部门 ['+temp_name+'] 吗?') =IDNO then exit;
try
delete;
except
MsgErr(handle,'当前数据在相关连的表中用到,不能删除!');
exit;
end;
end;
1:
with ADOT_duty do
begin
if RecordCount<1 then exit;
if State in [dsinsert,dsedit] then exit;
temp_name:=fieldvalues['dutyname'];
if MsgQst(handle,'确定删除职务 ['+temp_name+'] 吗?') =IDNO then exit;
try
delete;
except
MsgErr(handle,'当前数据在相关连的表中用到,不能删除!');
exit;
end;
end;
2:
with ADOQ_customer do
begin
if RecordCount<1 then exit;
if State in [dsinsert,dsedit] then exit;
temp_name:=fieldvalues['cust_name'];
if MsgQst(handle,'确定删除客户 ['+temp_name+'] 吗?') =IDNO then exit;
try
delete;
except
MsgErr(handle,'当前数据在相关连的表中用到,不能删除!');
exit;
end;
end;
3:
with ADOT_clothing do
begin
if RecordCount<1 then exit;
if State in [dsinsert,dsedit] then exit;
temp_name:=fieldvalues['clo_name'];
if MsgQst(handle,'确定删除服装类别 ['+temp_name+'] 吗?') =IDNO then exit;
try
delete;
except
MsgErr(handle,'当前数据在相关连的表中用到,不能删除!');
exit;
end;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -