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

📄 inv_realopqty_b.pas

📁 一个MRPII系统源代码版本
💻 PAS
📖 第 1 页 / 共 2 页
字号:
unit Inv_RealOpQty_B;

Interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Base_Entry_Body, Db, ActnList, AdODB, Grids, DBGridEh, ExtCtrls,
  ComCtrls, ToolWin, Mask, StdCtrls, ExtEdit, DBCtrls, ExtPrintReport,
  DBGrids;

Type
  TFrm_Inv_RealOpQty_B = Class(TFrm_Base_Entry_Body)
    Label1: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label10: TLabel;
    Lbl_WhCode: TLabel;
    lbl_WhPositionCode: TLabel;
    Label2: TLabel;
    Lbl_PoNo: TLabel;
    Label9: TLabel;
    Lbl_Vendor: TLabel;
    AdoQry_Material: TAdoQuery;
    DataSource1: TDataSource;
    Panel2: TPanel;
    Label3: TLabel;
    DBText1: TDBText;
    DBGridEh1: TDBGridEh;
    Lbl_BillNo: TLabel;
    Lbl_Date: TLabel;
    AdoQry_MaterialInvBillId: TIntegerField;
    AdoQry_MaterialInvBillLineNo: TStringField;
    AdoQry_MaterialIte_ItemCode: TStringField;
    AdoQry_MaterialItemCode: TStringField;
    AdoQry_MaterialItemName: TStringField;
    AdoQry_MaterialIte_ItemName: TStringField;
    AdoQry_MaterialRealOpQty: TFloatField;
    AdoQry_MaterialRealOPScrAp_Percent: TFloatField;
    AdoQry_MaterialRealOpQtyNew: TFloatField;
    AdoQry_MaterialRealOPScrAp_PercentNew: TFloatField;
    procedure DataSourceDataChange(Sender: TObject; Field: TField);
    procedure Act_ModifyExecute(Sender: TObject);
    procedure Act_InsertLineExecute(Sender: TObject);
    procedure Act_DeleteLineExecute(Sender: TObject);
    procedure DBGridEh1GetCellParams(Sender: TObject; Column: TColumnEh;
      AFont: TFont; var Background: TColor; State: TGridDrawState);
    procedure FormCreate(Sender: TObject);
    procedure Act_CheckExecute(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    procedure InitControls;Override;
  end;

var
  Frm_Inv_RealOpQty_B: TFrm_Inv_RealOpQty_B;

implementation

uses Sys_Global,Inv_Global, Inv_RealOpQty_D;

{$R *.DFM}

procedure TFrm_Inv_RealOpQty_B.InitControls;
var
  Bill_id:String;
begin
  if ShowFlag=True then
    Exit;
  AdoQry_Material.Connection:=DBConnect;
  AmountFields:='InvBillNoTaxAmount,InvBillAmount,';
  PriceFields:='InvBillNoTaxPrice,InvBillPrice,';
  Bill_ID:=AdoQry_Head.fieldbyname('InvBillId').AsString;
  if AdoQry_Head.fieldbyname('InvBillWHChck').AsInteger=1 then
    Status:='ReadOnly'
  else
    Status:='Edit';
  inherited;
  if Status='ReadOnly' then
    Act_Check.Enabled:=False
  else
    Act_Check.Enabled:=True;

  AdoQry_Body.Close;
  AdoQry_Body.SQL.Text:='Select InvInBillLine.InvBillId'
    +',InvInBillLine.InvBillLineNo'
    +',InvInBillLine.PoNo'
    +',InvInBillLine.PoLineNo'
    +',InvInBillLine.BatchNo'
    +',InvInBillLine.InvBillQty'
    +',InvInBillLine.InvBillSfcQty'
    +',InvInBillLine.ItemCode'
    +',InvInBillLine.BillLineRemArk'
    +',Item.ItemName'
    +',Uom.UomName'
    +',InvInBillLine.InvBillPriceC As InvBillPrice'
    +',InvInBillLine.InvBillAmountC As InvBillAmount'
    +',InvInBillLine.InvBillNoTaxPriceC As InvBillNoTaxPrice'
    +',InvInBillLine.InvBillNoTaxAmountC As InvBillNoTaxAmount'
    +',InvInBillLine.Valuation'
    +' From InvInBillLine'
    +' Join Item On InvInBillLine.ItemCode=Item.ItemCode '
    +' Join Uom On Item.UomCode=Uom.UomCode '
    +' Where InvInBillLine.InvBillId='+Bill_id;
  AdoQry_Body.Open;
  AdoQry_Body.Sort:='InvBillId,InvBillLineNo,ItemCode';

  AdoQry_Material.Close;
  AdoQry_Material.SQL.Text:='Select RealOpQty.InvBillId'
    +',RealOpQty.InvBillLineNo'
    +',RealOpQty.ItemCode'
    +',Item2.ItemName'
    +',RealOpQty.Ite_ItemCode'
    +',RealOpQty.Ite_ItemCode+'' ''+Item1.ItemName As Ite_ItemName'
    +',RealOpQty.RealOpQty'
    +',RealOpQty.RealOPScrAp_Percent'
    +',RealOpQty.RealOpQtyNew'
    +',RealOpQty.RealOPScrAp_PercentNew'
    +' From RealOpQty'
    +' Left Join Item Item1 On RealOpQty.Ite_ItemCode=Item1.ItemCode'
    +' Left Join Item Item2 On RealOpQty.ItemCode=Item2.ItemCode'
    +' Where RealOpQty.InvBillId='+Bill_id;
  AdoQry_Material.Open;
  AdoQry_Material.Sort:='Ite_ItemCode,ItemCode';

  with AdoQry_Head do
  begin
    Lbl_WhCode.Caption:=fieldbyname('WHCodeName').AsString;
    Lbl_WhPositionCode.Caption:=fieldbyname('WhPositionCodeName').AsString;
    Lbl_Vendor.Caption:=fieldbyname('VendorCode').AsString+' '
      +fieldbyname('VendorName').AsString;
    Lbl_BillNo.Caption:=fieldbyname('InvBillNo').AsString;
    Lbl_Date.Caption:=fieldbyname('InvBillDate').AsString;
    Lbl_PoNo.Caption:=fieldbyname('PoNo').AsString;
  end;
end;

procedure TFrm_Inv_RealOpQty_B.DataSourceDataChange(Sender: TObject;
  Field: TField);
begin//
  inherited;
  AdoQry_Material.Filtered:=False;
  AdoQry_Material.Filter:='InvBillId='+AdoQry_Body.fieldbyname('InvBillId').AsString+''
    +' And InvBillLineNo='''+AdoQry_Body.fieldbyname('InvBillLineNo').AsString+'''';
  AdoQry_Material.Filtered:=True;
end;

procedure TFrm_Inv_RealOpQty_B.Act_ModifyExecute(Sender: TObject);
begin
  //inherited;
  if not AdoQry_Material.Eof  then
  begin
    Frm_Inv_RealOpQty_D:=TFrm_Inv_RealOpQty_D.Create(Application);
    Frm_Inv_RealOpQty_D.SetFormParam(AdoQry_Body.fieldbyname('InvBillId').AsString,
      AdoQry_Body.fieldbyname('InvBillLineNo').AsString,
      AdoQry_Body.fieldbyname('ItemCode').AsString,'','','');
    Frm_Inv_RealOpQty_D.InitForm(DBConnect,'Edit',AdoQry_Material);
    Frm_Inv_RealOpQty_D.ShowModal;
    Frm_Inv_RealOpQty_D.Release;
  end;
end;

procedure TFrm_Inv_RealOpQty_B.Act_InsertLineExecute(Sender: TObject);
begin
  //inherited;
  Frm_Inv_RealOpQty_D:=TFrm_Inv_RealOpQty_D.Create(Application);
  Frm_Inv_RealOpQty_D.InitForm(DBConnect,'Add',AdoQry_Material);
  Frm_Inv_RealOpQty_D.SetFormParam(AdoQry_Body.fieldbyname('InvBillId').AsString,
    AdoQry_Body.fieldbyname('InvBillLineNo').AsString,
    AdoQry_Body.fieldbyname('ItemCode').AsString,'','','');
  Frm_Inv_RealOpQty_D.ShowModal;
  Frm_Inv_RealOpQty_D.Release;
end;

procedure TFrm_Inv_RealOpQty_B.Act_DeleteLineExecute(Sender: TObject);
begin
  //inherited;
  with AdoQry_Material do
  begin
    Edit;
    fieldbyname('RealOpQty').AsString:='0';
    fieldbyname('RealOpQtyNew').AsString:='0';
    fieldbyname('RealOPScrAp_Percent').AsString:='0';
    fieldbyname('RealOPScrAp_PercentNew').AsString:='0';
    Post;
  end;
end;

procedure TFrm_Inv_RealOpQty_B.DBGridEh1GetCellParams(Sender: TObject;
  Column: TColumnEh; AFont: TFont; var Background: TColor;
  State: TGridDrawState);
begin
  DBGridEhGetCellParams(Sender,Column,AFont,Background,State);
  if (gdSelected in State)or(gdFocused in State) then
  begin
    Background:=clNavy;
    AFont.Color:=clWindow;
  end
  else
  begin
    if(AdoQry_Material.fieldbyname('RealOpQty').AsFloat<>
      AdoQry_Material.fieldbyname('RealOpQtyNew').AsFloat)  then
      afont.Color:=clBlue
    else
      afont.Color:=clBlack;
  end;
end;

procedure TFrm_Inv_RealOpQty_B.FormCreate(Sender: TObject);
begin
  inherited;
  ToolButton2.Action:=Act_Check;
end;

procedure TFrm_Inv_RealOpQty_B.Act_CheckExecute(Sender: TObject);
var
  BillId,MaterialBillId,FWhPositionCode,DispStr,Tempstr:String;
  NeedChangePrice:Boolean;
begin
  //取当前仓库的待检货位
  AdoQry_Tmp.Close;
  AdoQry_Tmp.SQL.Text:='Select WhPositionCode'
    +' From WhPosition Where WhPositionType=1'
    +' And WHCode='''+GetCode(Lbl_WhCode.Caption)+'''';
  AdoQry_Tmp.Open;
  FWhPositionCode:=AdoQry_Tmp.fieldbyname('WhPositionCode').AsString;

  if AdoQry_Material.State<>dsBrowse then
    AdoQry_Material.Post;
  AdoQry_Material.Filtered:=False;
  //取当前单和材料费单ID
  BillId:=AdoQry_Body.fieldbyname('InvBillId').AsString;
  MaterialBillId:=IntToStr((StrToInt(BillId)+1));

  AdoQry_Material.DisableControls;
  AdoQry_Body.DisableControls;
  DBConnect.beginTrans;
  try
    NeedChangePrice:=NeedChangeAveragePrice(AdoQry_Tmp,Copy(Lbl_Date.Caption,1,7));

⌨️ 快捷键说明

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