⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 base_entry_head.pas

📁 一个MRPII系统源代码版本
💻 PAS
📖 第 1 页 / 共 2 页
字号:
    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 + -