// 源程序名称：本程序的外部名字（U_groupHelp.pas）
// 软件著作权：富通软件有限公司 版权所有
//   系统名称：生产成本核算系统
//   模块名称：班组选择
//   功能说明：班组选择

//   相关文档：相关详细设计文档号 <<成本核算功能流程图.vsd>>、<<成本核算数据表结构.doc >>
//       作者：官惠平
//       审核：
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//1．修改日期 2006-08-16  修改人员 官惠平
unit U_GroupHelp;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, DB, ADODB, Grids, DBGrids, ComCtrls, ToolWin, cxStyles,
  cxCustomData, cxGraphics, cxFilter, cxData, cxDataStorage, cxEdit,
  cxDBData, cxGridLevel, cxGridCustomTableView, cxGridTableView,
  cxGridDBTableView, cxClasses, cxControls, cxGridCustomView, cxGrid,
  ImgList;

type
  TfrmGroupHelp = class(TForm)
    ToolBar2: TToolBar;
    Tok: TToolButton;
    ToolButton7: TToolButton;
    DataSource1: TDataSource;
    ADOQueryHelp: TADOQuery;
    ADOQueryHelpGroupNo: TStringField;
    ADOQueryHelpGroupName: TStringField;
    cxGrid1: TcxGrid;
    tv1: TcxGridDBTableView;
    tv1DeptName: TcxGridDBColumn;
    tv1groupNo: TcxGridDBColumn;
    tv1groupName: TcxGridDBColumn;
    DBGrid1Level1: TcxGridLevel;
    ADOQueryHelpdeptName: TStringField;
    ImageList24: TImageList;
    ADOConnection1: TADOConnection;
    cxStyleRepository1: TcxStyleRepository;
    cxStyle1: TcxStyle;
    cxStyle2: TcxStyle;
    cxStyle_gridRow: TcxStyle;
    cxStyle_gridFoot: TcxStyle;
    cxStyle_gridHead: TcxStyle;
    cxStyle_gridGroupBox: TcxStyle;
    cxStyle_yellow: TcxStyle;
    cxStyle_Red: TcxStyle;
    cxStyleTree: TcxStyle;
    cxStyle3: TcxStyle;
    procedure DBGrid1DblClick(Sender: TObject);
    procedure TokClick(Sender: TObject);
    procedure ToolButton7Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure tv1DblClick(Sender: TObject);
  private
    { Private declarations }
  public
    fFrameNo:string;
  end;

var
  frmGroupHelp: TfrmGroupHelp;

implementation
uses
  U_global;
{$R *.dfm}

procedure TfrmGroupHelp.DBGrid1DblClick(Sender: TObject);
begin
  ModalResult:=1;
end;

procedure TfrmGroupHelp.TokClick(Sender: TObject);
begin
  if ADOQueryHelp.IsEmpty then exit;
  ModalResult:=1;
end;

procedure TfrmGroupHelp.ToolButton7Click(Sender: TObject);
begin
  ModalResult:=-1;
end;

procedure TfrmGroupHelp.FormCreate(Sender: TObject);
begin
  cxgrid1.Align:=alClient;
  with ADOConnection1 do
  begin
    Connected:=false;
    ConnectionString:=gConString;
    Connected:=true;
  end;
end;

procedure TfrmGroupHelp.FormShow(Sender: TObject);
begin
  with ADOQueryHelp do
  begin
    close;
    sql.Clear ;
    sql.Add('select A.* ,');
    sql.Add('deptName=(select frameName from YC_frame where frameNo=A.dept),');
    sql.Add('GroupChief=(select name from YC_stuff where code=GroupChief)');
    sql.Add('from mc_group A');
    if trim(fFrameNo)<>'' then
      sql.Add('where A.dept='''+fFrameNo+'''');
    sql.Add('order by A.groupName');
    open;
  end;
end;

procedure TfrmGroupHelp.tv1DblClick(Sender: TObject);
begin
  TOk.Click ;
end;

end.
