?? base_entry_head.pas
字號:
AdoQry_Head.SQL.clear;
AdoQry_Head.SQL.Text:=SelectFromSQL;
if(Condition<>'')then
begin
if(ConditionUserDefine<>'')then
AdoQry_Head.SQL.Text:=AdoQry_Head.SQL.Text+' Where '+Condition+' and '+ConditionUserDefine
else
AdoQry_Head.SQL.Text:=AdoQry_Head.SQL.Text+' Where '+Condition;
end
else if(ConditionUserDefine<>'')then
AdoQry_Head.SQL.Text:=AdoQry_Head.SQL.Text+' Where '+ConditionUserDefine;
AdoQry_Head.Open;
AdoQry_Head.Sort:=OrderByFields;
AdoQry_Head.EnableControls;
end;
end;
procedure TFrm_Base_Entry_Head.Act_FilterExecute(Sender: TObject);
var
TableName:string;
begin//數據過濾處理過程
inherited;
TableName:= '#'+self.Name ;
if Frm_Sys_Condition=nil then
Frm_Sys_Condition:=TFrm_Sys_Condition.Create(Application);
Frm_Sys_Condition.SetUserParam(Param1,Param2,Param3,Param4,Param5,Param6);
Frm_Sys_Condition.SetSysParam(UserCode,ModuleCode,MenuId,LoginDate);
Frm_Sys_Condition.SetDBConnect(DBConnect);
if Frm_Sys_Condition is TFrm_Sys_Condition then
TFrm_Sys_Condition(Frm_Sys_Condition).SetSrcGrid(DBGridEh,TableName);
Frm_Sys_Condition.FatherForm:=Self;
if Frm_Sys_Condition.Showmodal=mrOk then
begin
Condition:=Frm_Sys_Condition.Condition;
Lbl_Condition.Caption:=Frm_Sys_Condition.ConditionHint;
GetData;
end;
end;
procedure TFrm_Base_Entry_Head.Act_NewExecute(Sender: TObject);
begin//新增處理過程
inherited;
if(Frm_Entry_Body<>nil)then
begin
Frm_Entry_Body.SetUserParam(Param1,Param2,Param3,Param4,Param5,Param6);
Frm_Entry_Body.SetSysParam(UserCode,ModuleCode,MenuId,LoginDate);
Frm_Entry_Body.InitForm(DBConnect,'Add',AdoQry_Head);
Frm_Entry_Body.ShowModal;
end;
end;
procedure TFrm_Base_Entry_Head.Act_ModifyExecute(Sender: TObject);
begin//修改處理過程
inherited;
if(Frm_Entry_Body<>nil)and(not AdoQry_Head.IsEmpty)then
begin
Frm_Entry_Body.SetUserParam(Param1,Param2,Param3,Param4,Param5,Param6);
Frm_Entry_Body.SetSysParam(UserCode,ModuleCode,MenuId,LoginDate);
Frm_Entry_Body.InitForm(DBConnect,'Edit',AdoQry_Head);
Frm_Entry_Body.ShowModal;
end;
end;
procedure TFrm_Base_Entry_Head.FormClose(Sender: TObject;
var Action: TCloseAction);
begin//善后處理,釋放資源
inherited;
try
AdoQry_tmp.Close;
AdoQry_tmp.SQL.clear;
AdoQry_tmp.SQL.Text :='Drop Table '+ '#'+self.Name+','+'#'+self.Name+'Chb';
AdoQry_tmp.ExecSQL;
except
end;
if Frm_Sys_Condition<>nil then
Frm_Sys_Condition.Release;
if Frm_Entry_Body<>nil then
Frm_Entry_Body.Release;
if Frm_Sys_SortOrder<>nil then
Frm_Sys_SortOrder.Release;
if Frm_Sys_QuickLocate<>nil then
Frm_Sys_QuickLocate.Release;
if Frm_Sys_SetColumn<>nil then
Frm_Sys_SetColumn.Release;
Action:=CaFree;
end;
procedure TFrm_Base_Entry_Head.Act_SetColumnExecute(Sender: TObject);
begin//顯示列設置處理過程
inherited;
Frm_Sys_SetColumn.SetUserParam(Param1,Param2,Param3,Param4,Param5,Param6);
Frm_Sys_SetColumn.SetSysParam(UserCode,ModuleCode,MenuId,LoginDate);
Frm_Sys_SetColumn.SetDBConnect(DBConnect);
Frm_Sys_SetColumn.SetSrcGrid(DBGridEH,self.Name);
Frm_Sys_SetColumn.ShowModal;
end;
procedure TFrm_Base_Entry_Head.Act_LocateExecute(Sender: TObject);
begin//快速定位處理過程
inherited;
Frm_Sys_QuickLocate.SetSrcGrid(DBGridEh);
if Frm_Sys_QuickLocate.ShowModal=mrok then
begin
AdoQry_Head.Locate(Frm_Sys_QuickLocate.LocateFieldName,Frm_Sys_QuickLocate.LocateFieldValue,[loPArtialKey]);
end;
end;
procedure TFrm_Base_Entry_Head.FormCreate(Sender: TObject);
var
StrTemp:String;
begin//,------>/ 創建必要窗體
inherited;
TAdoQueryExpress(AdoQry_Head).CommandTimeOut:=0;
StrTemp:=Lbl_Condition.Caption;
while pos(',',StrTemp)<>0 do
StrTemp[pos(',',StrTemp)]:='/';
Lbl_Condition.Caption:=StrTemp;
StrTemp:=Lbl_Order.Caption;
while pos(',',StrTemp)<>0 do
StrTemp[pos(',',StrTemp)]:='/';
Lbl_Order.Caption:=StrTemp;
Frm_Sys_SortOrder:=TFrm_Sys_SortOrder.Create(Application);
Frm_Sys_QuickLocate:=TFrm_Sys_QuickLocate.Create(Application);
Frm_Sys_SetColumn:=TFrm_Sys_SetColumn.Create(Application);
end;
procedure TFrm_Base_Entry_Head.Act_DeleteExecute(Sender: TObject);
begin//刪除處理過程
inherited;
AdoQry_tmp.Close;
AdoQry_tmp.SQL.Text:=SetDeleteSql;
if(AdoQry_tmp.SQL.Text<>'')and(not AdoQry_Head.IsEmpty)and
(DispInfo(' 真的刪除當前記錄嗎? ',2)='y')then
begin
try
AdoQry_tmp.ExecSQL;
AdoQry_Head.Delete;
except
DispInfo(' 無法刪除當前記錄,可能已經被其他數據表引用!',1);
Abort;
end;
end;
end;
function TFrm_Base_Entry_Head.SetDeleteSql: String;
begin
Result:='';
end;
procedure TFrm_Base_Entry_Head.InitForm(AdOConnection: TAdOConnection;
ReadOnly: Boolean);
var i:integer;
sqltext:string;
begin//設置數據庫連接
inherited;
if ReadOnly then
begin
Act_New.Visible:=False;
Act_Modify.Visible:=False;
Act_Delete.Visible:=False;
Act_New.Enabled:=False;
Act_Modify.Enabled:=False;
Act_Delete.Enabled:=False;
end;
SetDBConnect(AdOConnection);
AdoQry_Head.Connection:=AdOConnection;
for i:=0 to toolBar.ControlCount-1 do
if (Ttoolbutton(toolBar.controls[i]).action = act_SetColumn) and (act_SetColumn.Enabled and act_SetColumn.Visible) then
begin
sqltext:='select top 1 * from Sys_SetColumn '
+' where formName='+quotedstr(self.Name)
+' and useEmployeeCode='+quotedstr(userCode);
Executesql(AdoQry_tmp,sqltext,0);
if AdoQry_tmp.RecordCount<>0 then
dbgrideh.FrozenCols:=AdoQry_tmp.fieldbyname('frozencols').asinteger;
end;
end;
procedure TFrm_Base_Entry_Head.HideColumnClick(Sender: TObject);
begin//彈出菜單隱藏列處理
inherited;
if(DBGridEh.SelectedIndex>=0)then
DBGridEh.Columns[DBGridEh.SelectedIndex].Visible:=False;
end;
procedure TFrm_Base_Entry_Head.Act_LookExecute(Sender: TObject);
begin//鼠標雙擊處理
inherited;
if(Frm_Entry_Body<>nil)and(not AdoQry_Head.IsEmpty)then
begin
Frm_Entry_Body.SetUserParam(Param1,Param2,Param3,Param4,Param5,Param6);
Frm_Entry_Body.SetSysParam(UserCode,ModuleCode,MenuId,LoginDate);
Frm_Entry_Body.InitForm(DBConnect,'Query',AdoQry_Head);
Frm_Entry_Body.ShowModal;
end;
end;
procedure TFrm_Base_Entry_Head.DBGridEhDblClick(Sender: TObject);
begin//查看處理
inherited;
if Act_Modify.Enabled then
Act_Modify.Execute
else if Act_Look.Enabled then
Act_Look.Execute;
end;
procedure TFrm_Base_Entry_Head.Act_PreviewExecute(Sender: TObject);
begin
inherited;
SetReport;
ExtPrintReport.Preview;
end;
procedure TFrm_Base_Entry_Head.Act_PrintExecute(Sender: TObject);
begin
inherited;
SetReport;
ExtPrintReport.Print(self);
end;
procedure TFrm_Base_Entry_Head.Act_ExcelExecute(Sender: TObject);
begin
inherited;
DBGridEhToExcel(DBGridEh,Pnl_Head);
end;
end.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -