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

📄 mrp_qry_gridanalyzercapacity_d_new.pas

📁 一个MRPII系统源代码版本
💻 PAS
字号:
unit Mrp_Qry_GridAnalyzerCapacity_D_New;

Interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Base_Qry, Menus, ExtPrintReport, Db, ActnList, AdODB, Grids, DBGridEh,
  StdCtrls, ExtCtrls, ComCtrls, ToolWin, DBCtrls, DBSumLst;

Type
  TFrm_Mrp_Qry_GridAnalyzerCapacity_D_New = Class(TFrm_Base_Qry)
    Label2: TLabel;
    Label1: TLabel;
    dbtxtItemflag: TDBText;
    dbtxtmono: TDBText;
    Label3: TLabel;
    dbtxtOverCapacityrate: TDBText;
    dbtxtMpsType: TDBText;
    Label4: TLabel;
    procedure DBGridEhDrawColumnCell(Sender: TObject; const Rect: TRect;
      DataCol: Integer; Column: TColumnEh; State: TGridDrawState);
    procedure DBGridEhGetCellParams(Sender: TObject; Column: TColumnEh;
      AFont: TFont; var Background: TColor; State: TGridDrawState);
  private
    procedure initfoot; 
    { Private declarations }
  public
       procedure InitForm(AdOConnection:TAdOConnection;ShowExtendColumn:Boolean);Override;
    { Public declarations }
  end;

var
  Frm_Mrp_Qry_GridAnalyzerCapacity_D_New: TFrm_Mrp_Qry_GridAnalyzerCapacity_D_New;

implementation

uses  Sys_Global,Mrp_Qry_AnalyzerCapacity_New;

{$R *.DFM}

{ TFrm_Mrp_Qry_GridAnalyzerCapacity_D }

procedure TFrm_Mrp_Qry_GridAnalyzerCapacity_D_New.InitForm(
  AdOConnection: TAdOConnection; ShowExtendColumn: Boolean);
var sqltext,modate,moqty,Capacityhours:string;
    mohours:Double;
begin
  inherited;
{  if dateTypecondition='日' then
  begin
    sqltext:='Select   CAp.WcCode, '+
             ' cAp.mono, '+
             ' cAp.MoLineno, '+
             ' cAp.modate, '+
             ' cAp.moqty, '+
             ' cAp.mohours, '+
             ' it1.Capacityhours, '+
             ' cAp.MpsType, '+
             ' It1.ItemName As WCName, '+
             ' wcflag=cAp.wcCode+'' ''+it1.ItemName, '+
             ' Itemflag=cAp.ItemCode+'' ''+it1.ItemName, '+
             ' cAp.ItemCode,It1.ItemName,OverCapacity=cAp.mohours-it1.Capacityhours, '+
             ' OverCapacityrate=((cAp.mohours-it1.Capacityhours)*100/it1.Capacityhours) '+
               ' From Item it1 '+
               'left  join Capacity CAp  on it1.ItemCode=cAp.wcCode '+
               'left  join Capacity CAp1 on it1.ItemCode=cAp1.ItemCode '+
               'where cAp.wcCode is not null and cAp.ItemCode is not null and ItemUsable=1 '+
               'and it1.ItemCode='''+wcCodecondition+''' ';
    if MpsTypecondition<>'全部' then sqltext:=sqltext+' and cAp.MpsType='''+MpsTypecondition+''' ';
    sqltext:=sqltext+' and cAp.modate between '''+datefm+''' and '''+dateto+''' ';
  end else
  begin}
    sqltext:='exec sp_Capacity_D_New '''+wcCodecondition+''','''+MpsTypecondition+''' ' +
             ','''+datefm+''','''+dateto+''','''+aCapacityhours+''' ';
//    DBGridEh.FooterRowCount:=1;
//  end;
  with AdoQry_Main do
  begin
    Close;
    sql.clear;
    sql.Add(sqltext);
    open;
    Sort:='modate';
    initfoot;
    if dateTypecondition='日' then  DBGridEh.FooterRowCount:=0 else DBGridEh.FooterRowCount:=1;

{    if recordCount=0 then
    begin
      DispInfo('无当前工作中心当前时间段的能力需求相关数据!',3);
      self.Close;
    end;}
{    if dateTypecondition='日' then
    begin
      if recordCount=0 then
      begin
        Append;
        fieldbyname('modate').asstring:=datefm;
        fieldbyname('Capacityhours').asstring:=aCapacityhours;
        abort;
      end;
      if recordCount=1 then abort;
      modate:=fieldbyname('modate').asstring;
      Capacityhours:=fieldbyname('Capacityhours').asstring;
      moqty:=fieldbyname('moqty').asstring;
      mohours:=0;
      First;
      while not eof do
      begin
         mohours:=fieldbyname('mohours').asfloat+mohours;
         next;
      end;
//      OverCapacity:=floattostr(mohours-strtofloat(Capacityhours));
//      OverCapacityrate:=copy(floattostr(AdoQry_Main.fieldbyname('mohours').asfloat-AdoQry_Main.fieldbyname('Capacityhours').asfloat)*100/AdoQry_Main.fieldbyname('Capacityhours').asfloat),1,5)+'%';
      Append;
      fieldbyname('modate').asstring:=modate;
      fieldbyname('Capacityhours').asstring:=Capacityhours;
      fieldbyname('moqty').asstring:=moqty;
      fieldbyname('mohours').asfloat:=mohours;
      fieldbyname('MpsType').asstring:='日小计';
    end;}
  end;
  lbl_Condition.Caption:='完工日期在'+datefm+'在'+dateto+'之间';
end;


procedure TFrm_Mrp_Qry_GridAnalyzerCapacity_D_New.DBGridEhDrawColumnCell(
  Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumnEh;
  State: TGridDrawState);
begin
{  if ((sender as TDBGridEh).dataSource.DataSet.fieldbyname('MpsType').asstring='日小计') then
//    or ((sender as TDBGridEh).dataSource.DataSet.fieldbyname('MpsType').asstring='') then
  begin
    if (Column.FieldName='OverCapacityrate') then
    begin
      if (sender as TDBGridEh).dataSource.DataSet.fieldbyname('OverCapacityrate').asstring='' then
      begin
        Column.Grid.Canvas.FillRect(Rect);
        Column.Grid.Canvas.TextOut(rect.left+30,rect.top+3
                                   ,floattostr((AdoQry_Main.fieldbyname('mohours').asfloat
                                   -AdoQry_Main.fieldbyname('Capacityhours').asfloat)*100
                                    /AdoQry_Main.fieldbyname('Capacityhours').asfloat));
      end;
    end;
    if (Column.FieldName='OverCapacity') then
    begin
      if (sender as TDBGridEh).dataSource.DataSet.fieldbyname('OverCapacity').asstring='' then
      begin
        Column.Grid.Canvas.FillRect(Rect);
        Column.Grid.Canvas.TextOut(rect.left+50,rect.top+3,floattostr(AdoQry_Main.fieldbyname('mohours').asfloat
                                   -AdoQry_Main.fieldbyname('Capacityhours').asfloat));
      end;
    end;
  end;}
end;

procedure TFrm_Mrp_Qry_GridAnalyzerCapacity_D_New.DBGridEhGetCellParams(
  Sender: TObject; Column: TColumnEh; AFont: TFont; var Background: TColor;
  State: TGridDrawState);
begin
  inherited;
  if AdoQry_Main.fieldbyname('MpsType').asstring='日小计' then
  begin
    Background:=clyellow;
    afont.Color:=clblue;
  end;

end;

procedure TFrm_Mrp_Qry_GridAnalyzerCapacity_D_New.initfoot;
var moqty,mohours,Capacityhours,OverCapacity,OverCapacityrate:string;
begin
  if AdoQry_Main.IsEmpty then abort;
  moqty:='0';
  mohours:='0';
  Capacityhours:='0';
  OverCapacity:='0';
  OverCapacityrate:='0';
  with AdoQry_Main do
  begin
    First;
    while not eof do
    begin
      if fieldbyname('MpsType').asstring<>'日小计' then
      begin
        moqty:=floattostr(strtofloat(moqty)+fieldbyname('moqty').asfloat);
        mohours:=inttostr(strtoint(mohours)+fieldbyname('mohours').asinteger);
        OverCapacityrate:=inttostr(strtoint(OverCapacityrate)+fieldbyname('OverCapacityrate').asinteger);
      end;
      next;
    end;
  end;
  AdoQry_Main.First;
  Capacityhours:=inttostr(strtoint(aCapacityhours)*AdoQry_Main.fieldbyname('day').asinteger);
  OverCapacity:=inttostr(strtoint(mohours)-strtoint(Capacityhours));
//  OverCapacityrate:=floattostr(strtoint(OverCapacity)*100/strtofloat(Capacityhours));
//  if pos('.',OverCapacityrate)<>0 then OverCapacityrate:=copy(OverCapacityrate,1,pos('.',OverCapacityrate)-1);
//  if OverCapacityrate='' then OverCapacityrate:='0';
  DBGridEh.Columns[7].Footer.Value:=moqty;
  DBGridEh.Columns[8].Footer.Value:=mohours;
  DBGridEh.Columns[9].Footer.Value:=Capacityhours;
  DBGridEh.Columns[10].Footer.Value:=OverCapacity;
  DBGridEh.Columns[11].Footer.Value:=OverCapacityrate;
  AdoQry_Main.First;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -