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

📄 bas_enter_passbom.pas

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

Interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Base_Check_Body, Db, ActnList, AdODB, Grids, DBGridEh, StdCtrls,
  ExtCtrls, ComCtrls, ToolWin, jpeg;

Type
  TFrm_Bas_Enter_PassBom = Class(TFrm_Base_Check_Body)
    AdoQry_BodyItemCode: TStringField;
    AdoQry_BodyItemName: TStringField;
    AdoQry_BodyPmCode: TIntegerField;
    AdoQry_BodyBomItemType: TIntegerField;
    AdoQry_BodyBomQty: TFloatField;
    AdoQry_BodyBomScrAp_Percent: TFloatField;
    AdoQry_BodyBomSTATUS: TIntegerField;
    AdoQry_BodyDeptB: TStringField;
    AdoQry_Bodyusestyle: TIntegerField;
    AdoQry_BodyPrepareLT: TIntegerField;
    AdoQry_BodyRunLT: TIntegerField;
    AdoQry_BodyQcLT: TIntegerField;
    AdoQry_BodydesignNO: TStringField;
    AdoQry_Bodyflag: TIntegerField;
    AdoQry_BodyBomMArk: TIntegerField;
    AdoQry_BodyDeptCode: TStringField;
    AdoQry_BodyremArk: TStringField;
    AdoQry_BodyIte_ItemCode: TStringField;
    AdoQry_BodyUomName: TStringField;
    Label1: TLabel;
    Edt_ItemCode: TLabel;
    Label3: TLabel;
    edt_ItemName: TLabel;
    Label5: TLabel;
    edt_UomName: TLabel;
    Label7: TLabel;
    edt_PmCode: TLabel;
    Label9: TLabel;
    edt_PAred: TLabel;
    Label11: TLabel;
    edt_run: TLabel;
    Label13: TLabel;
    edt_QA: TLabel;
    Label15: TLabel;
    edt_Designno: TLabel;
    Label17: TLabel;
    edt_ItemType: TLabel;
    procedure FormShow(Sender: TObject);
    procedure DBGridEhTitleClick(Column: TColumnEh);
    procedure Act_CheckExecute(Sender: TObject);
    procedure Act_CancelCheckExecute(Sender: TObject);
    procedure DBGridEhGetCellParams(Sender: TObject; Column: TColumnEh;
      AFont: TFont; var Background: TColor; State: TGridDrawState);
    procedure FormActivate(Sender: TObject);
  private
    { Private declarations }
    Flag:Boolean;
    Pass:Boolean;
    ParentItemCode:string;
    procedure GetChild(ite_ItemCode:string);   //得到所有没批准的子项
    procedure PassBom;                         //在Bom中插入BomA中批准的记录
    procedure NoPassBom;
    procedure ModyFlag;                        //修改Bom的是否准标志flag的值
    procedure updateBomOk(BomOK:integer);
  public
    { Public declarations }
  end;

var
  Frm_Bas_Enter_PassBom: TFrm_Bas_Enter_PassBom;

implementation
uses Bas_Enter_PassBomH;
{$R *.DFM}
procedure TFrm_Bas_Enter_PassBom.updateBomOk(BomOK:integer);
var
  updatesSQl:string;
begin
  updatesSQl:='update Item set Bomok='+inttostr(BomOK)+
              ' where ItemCode='+QuotedStr(ParentItemCode);
  with AdoQry_tmp do
  begin
    Close;
    SQL.clear;
    SQL.Add(updatesSQl);
    Prepared;
    ExecSQL;
  end;
end;

procedure TFrm_Bas_Enter_PassBom.GetChild(ite_ItemCode:string);
var
  sSQL:string;
begin
  sSQL:=' Select BomA.Ite_ItemCode,'+
               ' BomA.ItemCode,'+
               ' Item.ItemName,'+
               ' Uom.UomName,'+
               ' Item.PmCode,'+
               ' BomA.BomItemType,'+
               ' BomA.BomQty,'+
               ' BomA.BomScrAp_Percent,'+
               ' BomA.BomSTATUS,'+
               ' BomA.DeptCode,'+
               ' BomA.DeptCode+'' ''+Dept.DeptName as DeptB,'+
               ' BomA.remArk,'+
               ' BomA.usestyle,'+
               ' Item.PrepareLT,'+
               ' Item.RunLT,'+
               ' Item.QcLT,'+
               ' Item.designNO,'+
               ' BomA.Passflag,'+
               ' BomA.BomMArk'+
        ' From BomA'+
        ' Join Item on BomA.ItemCode=Item.ItemCode'+
        ' Join Uom on Item.UomCode=Uom.UomCode'+
        ' Join Dept on BomA.DeptCode=Dept.DeptCode'+
        ' where BomA.Ite_ItemCode='+QuotedStr(ite_ItemCode);
  with AdoQry_Body do
  begin
    Close;
    SQL.clear;
    SQL.Add(sSQL);
    Open;
  end;                      
end;

procedure TFrm_Bas_Enter_PassBom.FormShow(Sender: TObject);
var
  sSQL:string;
begin
  inherited;
  ParentItemCode:=Frm_Bas_Enter_PassBomH.AdoQry_Head.fieldbyname('Ite_ItemCode').AsString;
  GetChild(ParentItemCode);
  sSQL:='select Bomok from Item where ItemCode='+quotedstr(ParentItemCode);
  with AdoQry_tmp do
  begin
    Close;
    SQL.clear;
    SQL.Add(sSQL);
    Open;
  end;
  if AdoQry_tmp.fieldbyname('Bomok').asinteger=1 then
  begin
  TlBtn_CancelCheck.Enabled:=True;
  TlBtn_Check.Enabled:=False;
  end
  else
  begin
  TlBtn_CancelCheck.Enabled:=False;
  TlBtn_Check.Enabled:=True;
  end;
end;

procedure TFrm_Bas_Enter_PassBom.DBGridEhTitleClick(Column: TColumnEh);
begin
  inherited;
  If Trim(Column.Title.Caption)<>'标记' Then
    Abort;
  If AdoQry_Body.RecordCount=0 Then
    Abort;

  If Not Flag Then
  begin
    AdoQry_Body.First;
    While Not AdoQry_Body.Eof Do
    begin
      AdoQry_Body.Edit;
      AdoQry_Body.fieldbyname('BomMArk').AsInteger:=1;
      AdoQry_Body.Post;
      AdoQry_Body.Next;
    end;
  end
  Else
  begin
    AdoQry_Body.First;
    While Not AdoQry_Body.Eof Do
    begin
      AdoQry_Body.Edit;
      AdoQry_Body.fieldbyname('BomMArk').AsInteger:=0;
      AdoQry_Body.Post;
      AdoQry_Body.Next;
    end;
  end;
  Flag:=Not Flag;
end;

procedure TFrm_Bas_Enter_PassBom.Act_CheckExecute(Sender: TObject);
begin
  inherited;
  Pass:=True;
  PassBom;
  updateBomOk(1);
  ModyFlag;
  TlBtn_CancelCheck.Enabled:=False;
  TlBtn_Check.Enabled:=True;
  Close;
end;

procedure TFrm_Bas_Enter_PassBom.PassBom;
var
  sSQL:string;
  ItemCode,BomItemType,BomSTATUS:string;
  DeptCode,remArk,BomQty:string;
  BomScrAp_Percent,usestyle,BomMArk:string;
begin
  sSQL:=' ';
  AdoQry_Body.First;
  While Not AdoQry_Body.Eof Do
  begin
    ItemCode:=AdoQry_Body.fieldbyname('ItemCode').asstring;
    BomItemType:=AdoQry_Body.fieldbyname('BomItemType').asstring;
    BomSTATUS:=AdoQry_Body.fieldbyname('BomSTATUS').asstring;
    DeptCode:=AdoQry_Body.fieldbyname('DeptCode').asstring;
    remArk:=AdoQry_Body.fieldbyname('remArk').asstring;
    BomQty:=AdoQry_Body.fieldbyname('BomQty').asstring;
    BomScrAp_Percent:=AdoQry_Body.fieldbyname('BomScrAp_Percent').asstring;
    usestyle:=AdoQry_Body.fieldbyname('usestyle').asstring;
    BomMArk:='0';
    sSQL:=sSQL+' insert into Bom(ite_ItemCode,ItemCode,BomItemType,BomSTATUS,'+
                      ' DeptCode,remArk,BomQty,BomScrAp_Percent,usestyle,BomMArk)'+
          ' Values('+QuotedStr(ParentItemCode)+','+QuotedStr(ItemCode)+','+
                     BomItemType+','+BomSTATUS+','+
                     QuotedStr(DeptCode)+','+QuotedStr(remArk)+','+
                     BomQty+','+BomScrAp_Percent+','+
                     usestyle+','+BomMArk+')';
    AdoQry_Body.Next;
  end;

  if Trim(sSQL)='' then
  begin
    Application.MessageBox('没有选定需审核的物料','信息提示',MB_OK+MB_IconInfoRMATION);
    abort;
  end;

  with AdoQry_tmp do
  begin
    try
      Close;
      SQL.clear;
      SQL.Add(sSQL);
      Prepared;
      ExecSQL;
      Application.MessageBox('审核已生效','信息提示',MB_OK+MB_IconInfoRMATION);
    except
      Application.MessageBox('审核无法生效','信息提示',MB_OK+MB_IconInfoRMATION);
    end;
  end;
end;

procedure TFrm_Bas_Enter_PassBom.ModyFlag;
var
  sSQL:string;
begin
  sSQL:=' ';
  AdoQry_Body.First;
  begin
    While Not AdoQry_Body.Eof Do
    begin
        if Pass=True then
        sSQL:=sSQL+' update BomA set Passflag=1 where ite_ItemCode='+QuotedStr(ParentItemCode)+
                   'and ItemCode='+Quotedstr(AdoQry_Body.fieldbyname('ItemCode').Asstring)
        else
        sSQL:=sSQL+' update BomA set Passflag=0 where ite_ItemCode='+QuotedStr(ParentItemCode)+
                   'and ItemCode='+Quotedstr(AdoQry_Body.fieldbyname('ItemCode').Asstring);
      AdoQry_Body.Next;
    end;
  end;

  with AdoQry_tmp do
  begin
    Close;
    SQL.clear;
    SQL.Add(sSQL);
    Prepared;
    ExecSQL;
  end;
end;

procedure TFrm_Bas_Enter_PassBom.NoPassBom;
var
  sSQL:string;
begin
  sSQL:=' ';
  AdoQry_Body.First;
  While Not AdoQry_Body.Eof Do
  begin
    sSQL:=sSQL+' delete from Bom where ite_ItemCode='+
           QuotedStr(AdoQry_Body.fieldbyname('ite_ItemCode').AsString)+
           ' and ItemCode='+
           QuotedStr(AdoQry_Body.fieldbyname('ItemCode').AsString);
    AdoQry_Body.Next;
  end;

  if Trim(sSQL)='' then
  begin
    Application.MessageBox('没有选定需取消审核的物料','信息提示',MB_OK+MB_IconInfoRMATION);
    abort;
  end;

  with AdoQry_tmp do
  begin
    Close;
    SQL.clear;
    SQL.Add(sSQL);
    Prepared;
    ExecSQL;
    Application.MessageBox('取消审核已生效','信息提示',MB_OK+MB_IconInfoRMATION);    
  end;
end;

procedure TFrm_Bas_Enter_PassBom.Act_CancelCheckExecute(Sender: TObject);
begin
  inherited;
  Pass:=False;
  NoPassBom;
  updateBomOk(0);  
  ModyFlag;
  TlBtn_CancelCheck.Enabled:=True;
  TlBtn_Check.Enabled:=False;
  Close;
end;

procedure TFrm_Bas_Enter_PassBom.DBGridEhGetCellParams(Sender: TObject;
  Column: TColumnEh; AFont: TFont; var Background: TColor;
  State: TGridDrawState);
begin
  inherited;
  if AdoQry_Body.fieldbyname('Passflag').AsInteger=0 then
    AFont.Color:=clred; 
end;

procedure TFrm_Bas_Enter_PassBom.FormActivate(Sender: TObject);
begin
  inherited;
  if not Frm_Bas_Enter_PassBomH.AdoQry_Head.IsEmpty then
  begin
    Edt_ItemCode.Caption:=Frm_Bas_Enter_PassBomH.AdoQry_Head.fieldbyname('ite_ItemCode').AsString;
    edt_ItemName.Caption:=Frm_Bas_Enter_PassBomH.AdoQry_Head.fieldbyname('ItemName').AsString;
    edt_UomName.Caption:=Frm_Bas_Enter_PassBomH.AdoQry_Head.fieldbyname('UomName').AsString;
    edt_PmCode.Caption:=Frm_Bas_Enter_PassBomH.AdoQry_Head.fieldbyname('PmCode').AsString;
    edt_PAred.Caption:=Frm_Bas_Enter_PassBomH.AdoQry_Head.fieldbyname('PrepareLT').AsString;
    edt_run.Caption:=Frm_Bas_Enter_PassBomH.AdoQry_Head.fieldbyname('RunLT').AsString;
    edt_QA.Caption:=Frm_Bas_Enter_PassBomH.AdoQry_Head.fieldbyname('QcLT').AsString;
    edt_Designno.Caption:=Frm_Bas_Enter_PassBomH.AdoQry_Head.fieldbyname('designNO').AsString;
    edt_ItemType.Caption:=Frm_Bas_Enter_PassBomH.AdoQry_Head.fieldbyname('ItemType').AsString;
  end
  else
  begin
    Edt_ItemCode.Caption:='';
    edt_ItemName.Caption:='';
    edt_UomName.Caption:='';
    edt_PmCode.Caption:='';
    edt_PAred.Caption:='';
    edt_run.Caption:='';
    edt_QA.Caption:='';
    edt_Designno.Caption:='';
    edt_ItemType.Caption:='';
  end;
end;

end.

⌨️ 快捷键说明

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