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

📄 inv_opoutsale_d.pas

📁 一个MRPII系统源代码版本
💻 PAS
📖 第 1 页 / 共 2 页
字号:
  AllowNegative:=FrmParam1;
  BillDate:=FrmParam2;
  taxpercent:=strtoint(FrmParam3);
end;

procedure TFrm_Inv_OpOutSale_D.FormCreate(Sender: TObject);
begin
  inherited;
  SetFocus_Control:=Edt_PoOutQty;
end;

procedure TFrm_Inv_OpOutSale_D.ExtEdt_ItemCodeExit(Sender: TObject);
var
  tmpfields:string;
begin
  inherited;

  InOutItemCodeCheck(sender);

  if not DefaultWHCheck(AdoQry_tmp,getCode(WhCode) ,Extedt_ItemCode.text) then
  begin
    twincontrol(sender).setfocus;
    abort;
  end;

  if ItemCheckRepeat(ExtEdt_ItemCode.text,Edt_PoLineNo.text,Lbl_PoNo.Caption) then
  begin
    DispInfo('该订单行下已经存在该物料,请重新输入!',1);
    Twincontrol(sender).setfocus;
    abort;
  end;
  if not BatchCtrl(AdoQry_Tmp,ExtEdt_ItemCode.Text) then
  begin
    Edit_BatchNo.Text:='';
    Edit_BatchNo.Color:=clMenu;
    Edit_BatchNo.Enabled:=False;
  end
  else
  begin
    Edit_BatchNo.Color:=clwindow;
    Edit_BatchNo.Enabled:=True;
  end;
  if Pnl_Add.Caption='增加' then
  begin
    tmpfields:=getInvfield(AdoQry_tmp,whCode,Position,'CurrentInv');
    AdoQry_Tmp.Close;
    AdoQry_Tmp.SQL.Text:='select c.'+tmpfields+
                         ' as useablestore,U.UomName '+
                         ' from CurrentInv c,Item I,Uom U '+
                         ' where c.whCode='''+whCode+''' and '+
                         ' c.ItemCode='''+ExtEdt_ItemCode.Text+''' and '+
                         ' c.WhPositionCode='''+position+''' and c.'+
                         tmpfields+'>0 and '+
                         ' I.ItemCode=c.ItemCode and '+
                         ' U.UomCode=I.UomCode ';
    AdoQry_Tmp.Open;
    if (AdoQry_Tmp.IsEmpty) and (activecontrol.Name<>'btn_Cancel') then
    begin
      DispInfo('该物料的当前库存数量为零,不允许领料!',1);
      ExtEdt_ItemCode.SetFocus;
      exit;
    end
    else
    begin
      lbl_useable.Caption:=AdoQry_Tmp.fieldbyname('useablestore').asstring;
      FUom:=AdoQry_Tmp.fieldbyname('UomName').asstring;
    end;
    AdoQry_Tmp.Close;
    AdoQry_Tmp.SQL.Text:='select U.UomName '+
                         '  from Item I,Uom U '+
                         ' where I.ItemCode='''+ExtEdt_ItemCode.text+''' and '+
                         '       U.UomCode=I.UomCode';
    AdoQry_Tmp.Open;
    if not AdoQry_Tmp.IsEmpty  then
    Lbl_UomName.Caption:=AdoQry_Tmp.fieldbyname('UomName').asstring;

    AdoQry_Tmp.Close;
    AdoQry_Tmp.SQL.Text:='Select SP2Price,sp2notaxPrice'
      +' From SalePrice2'
      +' Where CustomerCode='''+VendorCode+''''
      +' And ItemCode='''+TEdit(Sender).Text+''''
      +' And SP2StArtDate<='''+Billdate+''''
      +' And SP2endDate>'''+Billdate+'''';
    AdoQry_Tmp.Open;
    if AdoQry_Tmp.fieldbyname('SP2Price').AsString<>'' then
    begin
      if edt_taxPrice.Text='0' then
      begin
        Edt_taxPrice.Text:=AdoQry_Tmp.fieldbyname('SP2Price').AsString;
        Edt_NotaxPrice.Text:=AdoQry_Tmp.fieldbyname('SP2notaxPrice').AsString;
      end;
    end
    else
    begin
      DispInfo('没有定义该物料的销售价格,不允许销售出库!',3);
      TWinControl(Sender).SetFocus;
      Abort;
    end;
    Edt_TmpField.ReadOnly:=True;
    if PriceType=0 then
    begin
      AdoQry_Tmp.Close;
      AdoQry_Tmp.SQL.Text:='Select AveragePrice From AveragePrice'
        +' Where WHCode='''+whCode+''''
        +' And ItemCode='''+TEdit(Sender).Text+'''';
      AdoQry_Tmp.Open;
      Edt_TmpField.Text:=AdoQry_Tmp.fieldbyname('AveragePrice').AsString;
    end;
    if Edt_TmpField.Text='' then
      Edt_TmpField.Text:='0';
  end;
end;

function TFrm_Inv_OpOutSale_D.ItemCheckRepeat(ItemCode,POLineNo,pono:string): boolean;
var
  i:integer;
  sql_Txt:string;
begin
  sql_txt:='select * from opItemList '+
           ' where ItemCode='''+ItemCode+''' and '+
           '       pono='''+pono+''' and '+
           '       polineno='''+polineno+'''';
  with AdoQry_Tmp do
  begin
    Close;
    sql.clear;
    sql.Add(sql_txt);
    open;
  end;
  if AdoQry_Tmp.IsEmpty then
  begin
    AdoQry_Body.First;
    for i:=0 to AdoQry_Body.recordCount-1 do
    begin
      if (AdoQry_Body.fieldbyname('ItemCode').asstring=ItemCode) and
      (AdoQry_Body.fieldbyname('PoLIneNo').asstring=PoLIneNo) then
      begin
        Result:=True;
        exit;
      end;
      AdoQry_Body.next;
    end;
    Result:=False;
  end
  else
  Result:=True;
end;

procedure TFrm_Inv_OpOutSale_D.Edit_BatchNoKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  inherited;
  If Key=VK_F9 then
    Edit_BatchNo.text:=BatchHint(AdoQry_Tmp.Connection,ExtEdt_ItemCode.Text,
                                '',WhCode,Position);
end;

procedure TFrm_Inv_OpOutSale_D.Edit_BatchNoExit(Sender: TObject);
begin
  inherited;
  if not BatchNoCheck(AdoQry_Tmp,Edit_BatchNo.Text,ExtEdt_ItemCode.text,'',
                      BillDate)then
  begin
    Edit_BatchNo.setfocus;
    Abort;
  end;
  if not BatchInvCheck(AdoQry_Tmp,Edit_BatchNo.text,'c',WhCode,Position,strtofloat(Edt_PoOutQty.text)) then
  begin
    Edit_BatchNo.setfocus;
    Abort;
  end;
end;

procedure TFrm_Inv_OpOutSale_D.Edt_PoLineNoKeyDown(Sender: TObject;
  var Key: Word; Shift: TShiftState);
begin
  inherited;
  if(Key=120)then
  begin
    with TFrm_Inv_PoHint.Create(Self) do
    begin
      InitForm(DBConnect,Lbl_PoNo.Caption,TEdit(Sender).Text,
        now-10000,now+10000,1+100000/100);
      if ShowModal=mrOk then
        TEdit(Sender).Text:=POLineNo;
      Release;
    end;
    TWinControl(Sender).SetFocus;
  end;
end;

procedure TFrm_Inv_OpOutSale_D.SetUserParam(Param1, Param2, Param3, Param4,
  Param5, Param6: string);
begin
  inherited;
  If UpperCase(Param1)='OverSalE' then
    IsOverPlan:=True
  Else If UpperCase(Param1)='INSalE' then
    IsOverPlan:=False
  Else
  begin
    DispInfo('系统参数传入不正确,请与系统管理员联系!',1);
    Abort;
  end;
  BillLines:=StrToInt(Param4);
  FPoNo:=Param2;
  VendorCode:=Param3;
  WhCode:=Param5;
  Position:=Param6;
end;

procedure TFrm_Inv_OpOutSale_D.edt_taxPriceExit(Sender: TObject);
begin
  inherited;
//  edt_taxAmount.Caption:=floattostr(str)
end;

procedure TFrm_Inv_OpOutSale_D.Edt_PoOutQtyChange(Sender: TObject);
begin
  inherited;
  if LockFlag=0 then
  begin
    LockFlag:=1;
    try
      AllChange(Sender);
      Edt_taxAmount.Text:=FormatFloat('#0.00',StrToFloat(Edt_PooutQty.Text)
        *StrToFloat(Edt_taxPrice.Text));
      Edt_NoTaxAmount.Text:=FormatFloat('#0.00',StrToFloat(Edt_PooutQty.Text)
        *StrToFloat(Edt_NoTaxPrice.Text));
    except
      LockFlag:=0;
    end;
    LockFlag:=0;
  end;

end;

procedure TFrm_Inv_OpOutSale_D.edt_taxPriceChange(Sender: TObject);
begin
  inherited;
  if LockFlag=0 then
  begin
    LockFlag:=1;
    try
      AllChange(Sender);
      Edt_NoTaxPrice.Text:=FloatToStr((StrToFloat(Edt_taxPrice.Text)/
        (1+taxpercent/100)));
      Edt_taxAmount.Text:=FormatFloat('#0.00',StrToFloat(Edt_PooutQty.Text)
        *StrToFloat(Edt_taxPrice.Text));
      Edt_NoTaxAmount.Text:=FormatFloat('#0.00',StrToFloat(Edt_PooutQty.Text)
        *StrToFloat(Edt_NoTaxPrice.Text));
    except
      LockFlag:=0;
    end;
    LockFlag:=0;
  end;

end;

procedure TFrm_Inv_OpOutSale_D.edt_taxAmountChange(Sender: TObject);
begin
  inherited;
  if LockFlag=0 then
  begin
    LockFlag:=1;
    try
      AllChange(Sender);
      if StrToFloat(Edt_PooutQty.Text)<>0 then
      Edt_taxPrice.Text:=FloatToStr(StrToFloat(Edt_taxAmount.Text)
        /StrToFloat(Edt_PooutQty.Text));
      Edt_NoTaxPrice.Text:=FloatToStr((StrToFloat(Edt_taxPrice.Text)/
        (1+taxpercent/100)));
      Edt_NoTaxAmount.Text:=FormatFloat('#0.00',StrToFloat(Edt_PooutQty.Text)
        *StrToFloat(Edt_NoTaxPrice.Text));
    except
      LockFlag:=0;
    end;
    LockFlag:=0;
  end;

end;

procedure TFrm_Inv_OpOutSale_D.edt_NotaxPriceChange(Sender: TObject);
begin
  inherited;
  if LockFlag=0 then
  begin
    LockFlag:=1;
    try
      AllChange(Sender);
      Edt_taxPrice.Text:=FloatToStr((StrToFloat(Edt_NoTaxPrice.Text)*
        (1+taxpercent/100)));
      Edt_taxAmount.Text:=FormatFloat('#0.##',StrToFloat(Edt_PooutQty.Text)
        *StrToFloat(Edt_taxPrice.Text));
      Edt_NoTaxAmount.Text:=FormatFloat('#0.##',StrToFloat(Edt_PooutQty.Text)
        *StrToFloat(Edt_NoTaxPrice.Text));
    except
      LockFlag:=0;
    end;
    LockFlag:=0;
  end;

end;

procedure TFrm_Inv_OpOutSale_D.edt_NotaxAmountChange(Sender: TObject);
begin
  inherited;
  if LockFlag=0 then
  begin
    LockFlag:=1;
    try
      AllChange(Sender);
      if StrToFloat(Edt_PooutQty.Text)<>0 then
      Edt_NoTaxPrice.Text:=FloatToStr(StrToFloat(Edt_NoTaxAmount.Text)
        /StrToFloat(Edt_PooutQty.Text));
      Edt_taxPrice.Text:=FloatToStr((StrToFloat(Edt_NoTaxPrice.Text)*
        (1+taxpercent/100)));
      Edt_taxAmount.Text:=FormatFloat('#0.##',StrToFloat(Edt_PooutQty.Text)
        *StrToFloat(Edt_taxPrice.Text));
    except
      LockFlag:=0;
    end;
    LockFlag:=0;
  end;

end;

end.

⌨️ 快捷键说明

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