?? unit_setupdiploma.pas
字號:
unit Unit_SetupDiploma;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Unit_Config, DBTables, Db, StdCtrls, TFlatEditUnit, TFlatButtonUnit,
ExtCtrls, Grids, DBGrids, crypt, Procedurep;
type
TFrm_SetupDiploma = class(TFrm_Config)
Query: TQuery;
Table_PUBTemp: TTable;
UpdateSQL1: TUpdateSQL;
procedure BitBtnAddClick(Sender: TObject);
procedure BitBtnAlterClick(Sender: TObject);
procedure BitBtnDelClick(Sender: TObject);
procedure BitBtnSaveClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure BitBtnCancelClick(Sender: TObject);
procedure Query_PUBAfterScroll(DataSet: TDataSet);
procedure sqlcommit;
procedure FlatEdit1KeyPress(Sender: TObject; var Key: Char);
private
{ Private declarations }
//當(dāng)前的節(jié)日編碼
P_CurrentCode :string;
//判斷是否為插入狀態(tài)
P_Insert :boolean;
public
{ Public declarations }
end;
var
Frm_SetupDiploma: TFrm_SetupDiploma;
implementation
uses main, dmmain,unit_public;
{$R *.DFM}
procedure TFrm_SetupDiploma.BitBtnAddClick(Sender: TObject);
begin
inherited;
kk:=1;
FlatEdit1.Text:='';
FlatEdit1.Enabled :=true;
FlatEdit1.SetFocus;
//ShowMessage(' 請輸入學(xué)歷名稱! ');
with Query_PUB do
begin
if Not Active then
Active:=true;
end;
SetBitBtn(false);
end;
procedure TFrm_SetupDiploma.BitBtnAlterClick(Sender: TObject);
begin
inherited;
kk:=2;
//ShowMessage(' 請輸入需要修改的學(xué)歷名稱! ');
FlatEdit1.Enabled :=true;
FlatEdit1.SelectAll;
FlatEdit1.SetFocus;
SetBitBtn(false);
//Query_PUB.AfterScroll(nil);
end;
procedure TFrm_SetupDiploma.BitBtnDelClick(Sender: TObject);
var
sql :string;
begin
inherited;
if JBDM=3 then
begin
MessageDlg('無權(quán)限操作,請詢問管理員!',mtConfirmation, [mbYes], 0);
exit;
end
else
begin
if Query_PUB.FieldByName('PAR_VALUES').AsString = '99' then
begin
MessageDlg('無權(quán)限操作,請詢問管理員!',mtConfirmation, [mbYes], 0);
//showmessage('對不起,你不能刪除其它學(xué)歷');
Exit;
end
else
begin
if MessageDlg('是否要刪除該記錄?',mtConfirmation, [mbYes,mbNo], 0)=mrNo then exit;
//if (Application.MessageBox('是否要刪除該記錄?',
// '提示',MB_OKCANCEL)=IDCANCEL) then exit;
Sql :='Delete T_D_Config where PAR_NAME=''Diploma_ID'' and PAR_VALUES='+
#39+Query_PUB.FieldByName('PAR_VALUES').AsString+#39;
if AnalyzeSql(SQL)=1 then exit;
//Dm_Main.Databasedh.Commit;
FlatEdit1.text :='';
Query_Pub.Delete;
//Query_Pub.Close;
//Query_Pub.Open;
//sqlcommit;
Query_PUB.AfterScroll(nil);
end;
end;
end;
procedure TFrm_SetupDiploma.BitBtnSaveClick(Sender: TObject);
var
xlh, editxlh,sql : string;
begin
inherited;
//提示是否更新
if kk=2 then
//if (Application.MessageBox('是否要更新該記錄?',
// '提示',MB_OKCANCEL)=IDCANCEL) then exit;
if MessageDlg('是否要更新該記錄?',mtConfirmation, [mbYes,mbNo], 0)=mrNo then exit;
if trim(FlatEdit1.Text) ='' then
begin
MessageDlg('學(xué)歷名稱字段不能為空!',mtConfirmation, [mbYes], 0);
exit;
end;
if length(FlatEdit1.Text) >100 then
begin
MessageDlg('學(xué)歷名稱字段超過長度!',mtConfirmation, [mbYes], 0);
exit;
end;
//新增時如果行業(yè)名稱已經(jīng)存在就提示出錯,怎么會用Locate?
if kk=1 then
begin
Query_Tmp.Close;
Query_Tmp.sql.text :=
'select count(PAR_DESC) from T_D_Config where upper(PAR_NAME)='
+#39+'DIPLOMA_ID'+#39+' and PAR_DESC='+#39+FlatEdit1.Text+#39;
Query_Tmp.open;
if Query_Tmp.Fields[0].AsInteger >0 then
begin
Application.MessageBox('學(xué)歷名稱已存在!請重新輸入!','提示',MB_OK+MB_ICONWARNING);
FlatEdit1.SetFocus;
Exit;
end;
end;
//Dm_Main.Databasedh.StartTransaction;
case kk of
1: // add
Begin
Query_Tmp.Close;
Query_Tmp.SQL.Clear;
Query_Tmp.SQL.Add('select max(to_number(PAR_VALUES))+1 as xlh from T_D_Config where PAR_NAME=''Diploma_ID'' and PAR_VALUES <>''99'' ');
Query_Tmp.Open;
if Query_Tmp.fieldbyname('xlh').AsString = '99' then
xlh := '100'
else
xlh := Query_Tmp.fieldbyname('xlh').AsString;
Sql :='insert into T_D_Config(PAR_NAME,PAR_VALUES,PAR_DESC,PAR_OTHER) values('+
#39+'Diploma_ID'+#39+','+#39+xlh+#39+','+#39+FlatEdit1.Text+#39
+','+#39+'教育程度'+#39+')';
if AnalyzeSql(SQL)=1 then exit;
end;
2: // edit
begin
Sql :='update T_D_Config set PAR_DESC='+#39+FlatEdit1.Text+#39
+' where upper(PAR_NAME)='+#39+'DIPLOMA_ID'+#39+' and PAR_VALUES='
+#39+Query_PUB.FieldByName('PAR_VALUES').AsString+#39;
if AnalyzeSql(SQL)=1 then exit;
end;
end;
//Dm_Main.Databasedh.Commit;
{
with Query_Pub do
begin
Close;
Open;
if kk=1 then
Locate('PAR_VALUES;PAR_NAME', VarArrayOf([xlh,'Diploma_ID']), [])
else
Locate('PAR_VALUES;PAR_NAME', VarArrayOf([editxlh,'Diploma_ID']), [])
end; }
//*************數(shù)據(jù)同步********************
case kk of
1: // add
Begin
P_Insert :=true;
Query_Pub.insert;
Query_Tmp.close;
Query_Tmp.sql.text := //大小寫問題Diploma_ID
'select nvl(max(PAR_VALUES),0) from T_D_Config where upper(PAR_NAME)='+#39
+'DIPLOMA_ID'+#39+' and PAR_VALUES <>''99''';
Query_Tmp.open;
P_CurrentCode :=Query_Tmp.fields[0].asstring;
end;
2: // edit
begin
P_Insert :=true;
Query_Pub.Edit;
end;
end;
Query_PUB.FieldByName('PAR_NAME').AsString := 'Diploma_ID';
Query_PUB.FieldByName('PAR_OTHER').AsString := '教育程度';
Query_PUB.FieldByName('PAR_DESC').AsString :=FlatEdit1.Text;
Query_PUB.FieldByName('PAR_VALUES').AsString :=P_CurrentCode;
P_Insert :=false;
Query_Pub.Post;
//*****************************************
SetBitBtn(true);
Query_PUB.AfterScroll(nil);
end;
procedure TFrm_SetupDiploma.FormShow(Sender: TObject);
begin
inherited;
FlatEdit1.Enabled :=false;
P_Insert :=false;
//showmessage('dd');
crypt.UserEnter_Log(Caption,'瀏覽',-1,Gh,'登入窗體');
setFunVisible(Self,gh);
FormMain.Gp_setbuttonpos(Pal_button);
//if not Query_PUB.Active then
// Query_PUB.Active:=true;
SetBitBtn(true);
//Query_PUB.AfterScroll(nil);
//修改部分 2001-07-10 ChenQingBo
BitBtnAdd.Enabled:=(JBDM<=2);
BitBtnAlter.Enabled:=(JBDM<=2);
BitBtnDel.Enabled:=(JBDM<=2);
Query_PUBAfterScroll(nil);
end;
procedure TFrm_SetupDiploma.BitBtnCancelClick(Sender: TObject);
begin
inherited;
Query_PUB.AfterScroll(nil);
end;
procedure TFrm_SetupDiploma.Query_PUBAfterScroll(DataSet: TDataSet);
begin
inherited;
FlatEdit1.Enabled :=false;
if P_Insert then exit;
FlatEdit1.Text := Query_PUB.fieldbyname('PAR_Desc').AsString;
P_CurrentCode :=Query_PUB.FieldByName('PAR_VALUES').AsString;
//***********當(dāng)沒有記錄時要控制按鈕及權(quán)限************
If not(Query_PuB.bof and Query_PuB.eof) Then
begin
//
BitBtnAdd.Enabled:=true;
BitBtnAlter.Enabled:=true;
BitBtnDel.Enabled:=true;
//權(quán)限
BitBtnAdd.Enabled:=(JBDM<=2);
BitBtnAlter.Enabled:=(JBDM<=2);
BitBtnDel.Enabled:=(JBDM<=2);
end
else
begin
//BitBtnAdd.Enabled:=false;
BitBtnAlter.Enabled:=false;
BitBtnDel.Enabled:=false;
end;
//*******************************************
end;
procedure TFrm_SetupDiploma.sqlcommit;
begin
with Query_Tmp do
begin
Close;
Sql.Clear;
Sql.Add('commit');
ExecSql;
end;
end;
procedure TFrm_SetupDiploma.FlatEdit1KeyPress(Sender: TObject;
var Key: Char);
begin
inherited;
if key = #13 then
BitBtnSaveClick(nil);
end;
end.
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -