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

📄 matin.pas

📁 文件包含程序源原文件
💻 PAS
📖 第 1 页 / 共 5 页
字号:
      lcp^.MAT_RID := WRID;
      edtGuageName.Text := dm_Inventory.Get_GuageName(WRID,Trunc(edtGuageID.Value));
      SetTabCaption(lcP);

      if StrToInt(IniData.InPrice) = 1 then
        edtPrice.Value := dm_inventory.GetStdUnitPrice(WRID);  //-- material master information price
    end;

  if Sender = edtGuageID then begin
    edtGuageName.Text := dm_Inventory.Get_GuageName(lcp^.MAT_RID,Trunc(edtGuageID.Value));
  end;

  if Sender = edtSuplierCode then
    lblSupplierNM.Text := dm_Inventory.GetShigenName(Trunc(edtSuplierCode.Value));

  if Sender = edtMakerCode then
    lblMakerNM.Text := dm_Inventory.GetShigenName(Trunc(edtMakerCode.Value));

  /////////////////////////////////
  if (Sender = edtPrice)or(Sender = edtWeight)or(Sender = edtMakPrice) then
  begin
    T_price := (RoundTo(edtPrice.Value,-2)*RoundTo(edtWeight.Value,-2)+RoundTo(edtMakPrice.Value,-2));
    lblTPrice.Caption := FormatFloat('#,##0.00', UserDecimalDefine(T_price, 2));
  end;

  /////////////////////////////////
end;

procedure TfrmMatIN.ControlExit(Sender: TObject);
var CtrlList: PCONTROL_LIST;
    lcP: Pointer;
begin
  if FExitSkip then Exit;
  if Selected = nil then Exit;
  lcP := Selected;
  try
    CtrlList := GetCtrlListTarget(Sender as TWinControl);
  except
    Exit;
  end;

  if (CtrlList = nil)or((CtrlList<>nil)and(CtrlList^.Address=nil)) then Exit;
  if not ReturnValueToVariable(lcP, CtrlList, True) then
  begin
    ReturnValueFromTag(CtrlList);
    try
      CtrlList^.Target.SetFocus;
    except
      Exit;
    end;
  end;
end;

procedure TfrmMatIN.edtDateKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
var WDate: TDateTime;
begin
  if (Key=VK_RETURN)and(ssShift in Shift)then
    if not(dm_Inventory.DateErrorCheck(edtDate.Text, WDate)) then begin
      Key := 0;
      edtNote.SetFocus;
      Exit;
    end;
  ControlKeyDown(Sender, Key, Shift);
end;

procedure TfrmMatIN.edtNoteKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
var WK: Word;
begin
  WK := Key;
  ControlKeyDown(Sender, Key, Shift);
  if (WK=VK_RETURN)and not(ssShift in Shift) then
    if ckbNew.Checked then begin
      FExitSkip := True;
      try
        btnNewClick(Sender);
      finally
        FExitSkip := False;
      end;
    end;
end;

procedure TfrmMatIN.TabControlChanging(Sender: TObject;
  var AllowChange: Boolean);
begin
  inherited;
  AllowChange := True;
  if ErrorCheck(Selected) <> 0 then AllowChange := False
  else UpdateCheck;
end;

{**********************************************************************************}
{**********************************************************************************}
function  TfrmMatIN.ReturnValueToVariable(lcP: PINVENTORY; CtrlList: PCONTROL_LIST; Msg: Boolean): Boolean;
procedure TotalPriceProc;
  var View: TINVENTORY;
  begin
    Double(CtrlList^.Address^):=(CtrlList^.Target as TEx2NumEdit).Value;
    lcP^.TTL_PRICE := RoundTo(lcP^.UNT_PRICE,-2)*RoundTo(lcP^.QUANTITY,-2)+RoundTo(lcp^.MAK_PRICE,-2);
    lblTPrice.Caption := FormatFloat('#,##0.00', UserDecimalDefine(lcP^.TTL_PRICE, 2));
    SetUpdateList(lcP^.REC_ID, @lcP^.TTL_PRICE, LongInt(@View.TTL_PRICE)-LongInt(@View), 0, lcP);
  end;
var View: TINVENTORY;
    WDate: TDateTime;
    WRID:  LongInt;
    WCD:   Integer;
    WTmpStr: string;
begin
  Result := True;
  //-- Get Field Text
  if CtrlList^.UpdateIndex = Longint(@View.SUP_CD)-Longint(@View) then begin
    WCD := Trunc((CtrlList^.Target as TEx2NumEdit).Value);
    Result := dm_Inventory.MasterProc(WCD, lblSupplierNM);
    if not(Result) then Exit;
    LongInt(CtrlList^.Address^) := WCD;
  end else
  if CtrlList^.UpdateIndex = Longint(@View.ISS_PAPERNO)-Longint(@View) then
    StrPCopy(PChar(CtrlList^.Address), (CtrlList^.Target as TCustomEdit).Text)
  else
  if CtrlList^.UpdateIndex = Longint(@View.Inout_id)-Longint(@View) then
  begin
    WTmpStr := (CtrlList^.Target as TCustomEdit).Text;
    Result := dm_Inventory.InOut_IDProc(WTmpStr,1, edtInIDName);
    if not(Result) then Exit;
    StrPCopy(PChar(CtrlList^.Address), WTmpStr)
  end else
  if CtrlList^.UpdateIndex=Longint(@View.input_empid)-Longint(@View) then
  begin
    WTmpStr := (CtrlList^.Target as TCustomEdit).Text;
    Result := dm_Inventory.Emp_IDProc(WTmpStr, edtInputEmpName);
    if not(Result) then Exit;
    StrPCopy(PChar(CtrlList^.Address), WTmpStr)
  end else
  if CtrlList^.UpdateIndex = Longint(@View.STK_ID)-Longint(@View) then
  begin
    WTmpStr := (CtrlList^.Target as TCustomEdit).Text;
    Result := dm_Inventory.Get_StockCheck(WTmpStr,edtStkName);
    if not(Result) then Exit;
    StrPCopy(PChar(CtrlList^.Address), WTmpStr);
  end else
  if CtrlList^.UpdateIndex = Longint(@View.PAPERNO)-Longint(@View) then
    StrPCopy(PChar(CtrlList^.Address), (CtrlList^.Target as TCustomEdit).Text)
  else
  if CtrlList^.UpdateIndex = Longint(@View.DATE)-Longint(@View) then
  begin
    Result := dm_Inventory.DateProc((CtrlList^.Target as TEdit), WDate);
    if not(Result) then Exit;
    TDateTime(CtrlList^.Address^) := WDate;
  end else
  if CtrlList^.UpdateIndex = Longint(@View.MAT_RID)-Longint(@View) then begin
    Result := dm_Inventory.REC_IDProc(0, (CtrlList^.Target as TEdit), WRID, -1);
    if not(Result) then Exit;
    LongInt(CtrlList^.Address^) := WRID;
    MatRID := WRID;
    SetTabCaption(lcP);
    edtMatName.Text     := dm_Inventory.GetMaterialName(WRID);
    lblUType.Caption    := dm_Inventory.GetUnitTypeName(WRID);
    if StrComp(lcP^.MAT_NM, PChar(edtMatName.Text)) = 0 then Exit;
    StrPCopy(lcP^.MAT_NM, edtMatName.Text);
    SetUpdateList(lcP^.REC_ID, @lcP^.MAT_NM, LongInt(@View.MAT_NM)-LongInt(@View), 0, lcP);
  end else
  if CtrlList^.UpdateIndex = Longint(@View.GUAGE_ID)-Longint(@View) then begin
    WCD := Trunc((CtrlList^.Target as TEx2NumEdit).Value);
    MatRID := dm_inventory.GetMaterialRID(trim(edtMatCode.Text));
    Result := dm_Inventory.Get_GuageCheck(MatRID,WCD, edtGuageName);
    if not(Result) then Exit;
    LongInt(CtrlList^.Address^) := WCD;
  end else
  if CtrlList^.UpdateIndex = Longint(@View.UNT_PRICE)-Longint(@View) then
    TotalPriceProc()
  else
  if CtrlList^.UpdateIndex = Longint(@View.QUANTITY)-Longint(@View) then
    TotalPriceProc()
  else
  if CtrlList^.UpdateIndex = Longint(@View.MAK_PRICE)-Longint(@View) then
    TotalPriceProc()
  else
  if CtrlList^.UpdateIndex = Longint(@View.MAK_CD)-Longint(@View) then begin
    WCD := Trunc((CtrlList^.Target as TEx2NumEdit).Value);
    Result := dm_Inventory.MasterProc(WCD, lblMakerNM);
    if not(Result) then Exit;
    LongInt(CtrlList^.Address^) := WCD;
  end else
  if CtrlList^.UpdateIndex=Longint(@View.ODR_RID)-Longint(@View) then begin
    Result := dm_Inventory.REC_IDProc(1, (CtrlList^.Target as TEdit), WRID, -1);
    if not(Result) then Exit;
    LongInt(CtrlList^.Address^) := WRID;
  end else
  if CtrlList^.UpdateIndex=Longint(@View.PAT_RID)-Longint(@View) then begin
      Result := dm_Inventory.REC_IDProc(2, (CtrlList^.Target as TEdit), WRID, lcP^.ODR_RID);
      if not(Result) then Exit;
      LongInt(CtrlList^.Address^) := WRID;
  end else //--
  if CtrlList^.UpdateIndex=Longint(@View.SEQUAL_NO)-Longint(@View) then
    StrPCopy(PChar(CtrlList^.Address), (CtrlList^.Target as TCustomEdit).Text)
  else
  if CtrlList^.UpdateIndex=Longint(@View.HAT_RID)-Longint(@View) then begin
      Result := dm_Inventory.REC_IDProc(3, (CtrlList^.Target as TEdit), WRID, -1);
      if not(Result) then Exit;
      LongInt(CtrlList^.Address^) := WRID;
  end else
  if CtrlList^.UpdateIndex=Longint(@View.HAT_CODE)-Longint(@View) then
    StrPCopy(PChar(CtrlList^.Address), (CtrlList^.Target as TCustomEdit).Text)
  else
  if CtrlList^.UpdateIndex=Longint(@View.invoice_no)-Longint(@View) then
    StrPCopy(PChar(CtrlList^.Address), (CtrlList^.Target as TCustomEdit).Text)
  else
  if CtrlList^.UpdateIndex = Longint(@View.NOTE)-Longint(@View) then
    StrPCopy(PChar(CtrlList^.Address), (CtrlList^.Target as TCustomEdit).Text);
  ///////////////////////////////////////////////////////////////////
end;

procedure TfrmMatIN.SetData(Item: Pointer);
var lcP: PINVENTORY;
begin
  lcP := Item;
  Selected := Item;

  edtSuplierCode.Value  := lcP^.SUP_CD;
  lblSupplierNM.text    := dm_Inventory.GetShigenName(lcP^.SUP_CD);
  edtIssPaperNO.Text  := lcp^.ISS_PAPERNO;
  edtMatInID.Text       := lcp^.Inout_ID;
  edtInIDName.Text      := dm_Inventory.Get_IOIDName(trim(edtMatInID.Text),1);
  edtInputEmpID.Text    := lcp^.input_empid;
  edtInputEmpName.Text  := dm_Inventory.Get_EmpName(trim(edtInputEmpID.Text));

  edtStkID.Text         := lcp^.STK_ID;
  edtStkName.Text       := dm_Inventory.GetStockName(trim(edtStkID.Text));
  edtInPaperNo.Text     := lcp^.PaperNo;
  if (lcP^.DATE<=2) then
    edtDate.Text        := FormatDatetime('yy/mm/dd',Now)
  else
    edtDate.Text        := FormatDateTime('yy/mm/dd', lcP^.DATE);


  edtMatCode.Text       := dm_Inventory.GetMaterialCode(lcP^.MAT_RID);
  edtMatName.Text       := lcP^.MAT_NM;
  edtGuageID.Value      := lcp^.GUAGE_ID;
  edtGuageName.Text     := dm_Inventory.Get_GuageName(lcp^.MAT_RID,lcp^.GUAGE_ID);
  edtPrice.Value        := RoundTo(lcP^.UNT_PRICE,-2);
  edtWeight.Value       := RoundTo(lcP^.QUANTITY,-2);
  edtMakPrice.Value     := RoundTo(lcp^.MAK_PRICE,-2);
  lblUType.Caption      := dm_Inventory.GetUnitTypeName(lcP^.MAT_RID);
  lblTPrice.Caption     := FormatFloat('#,##0.00', UserDecimalDefine(lcP^.TTL_PRICE, 2));
  edtMakerCode.Value    := lcP^.MAK_CD;
  lblMakerNM.Text       := dm_Inventory.GetShigenName(lcP^.MAK_CD);


  edtMoldID.Text        := dm_Inventory.GetOrderNo(lcP^.ODR_RID);
  edtPartID.Text        := dm_Inventory.GetPartCode(lcP^.ODR_RID, lcP^.PAT_RID);
  edtSequalNo.Text      := lcp^.SEQUAL_NO;
  if lcP^.HAT_RID <= 0 then edtOrderSerial.Text := ''
  else edtOrderSerial.Text  := Format('%d', [lcP^.HAT_RID]);
  edtOrderCode.Text     := lcp^.HAT_CODE;
  edtInvoiceNo.Text     := lcp^.invoice_no;
  edtNote.Text          := lcP^.NOTE;
end;

procedure TfrmMatIN.SetNull;
begin
  Selected := nil;

  edtSuplierCode.Value  := 0;
  lblSupplierNM.text    := '';
  edtIssPaperNO.Text    := '';
  edtMatInID.Text       := '';
  edtInIDName.Text      := '';
  edtInputEmpID.Text    := '';
  edtInputEmpName.Text  := '';

  edtStkID.Text         := '';
  edtInPaperNo.Text     := '';
  edtDate.Text          := '';
  edtMatCode.Text       := '';
  edtMatName.Text       := '';
  edtGuageID.Value      := 0;
  edtGuageName.Text     := '';
  edtPrice.Value        := 0;
  edtWeight.Value       := 0;
  edtMakPrice.Value     := 0;
  lblUType.Caption      := '';
  lblTPrice.Caption     := '0.00';
  edtMakerCode.Value    := 0;
  lblMakerNM.Text       := '';

  edtMoldID.Text        := '';
  edtPartID.Text        := '';
  edtSequalNo.Text      := '';
  edtOrderSerial.Text   := '';
  edtOrderCode.Text     := '';
  edtInvoiceNo.Text     := '';
  edtNote.Text          := '';
  cbxReportID.ItemIndex := 0;
end;

function  TfrmMatIN.ErrorCheck(Item: PINVENTORY): Integer;
var
  lcP: PINVENTORY;
  ErrNo: integer;
  ErrMsg: string;
  iOrdQty, iOrdWeight,
  orderamount,isinQty: Double;
begin
  Result := 0;
  ErrNo  := 0;
  lcP := Selected;
  if (lcp <> nil) and (trim(edtIssPaperNO.Text)='') then ErrNo := -6;
  if (lcp <> nil) and (trim(edtInputEmpID.Text)='') then ErrNo := -4;
  if (lcp <> nil) and (trim(edtMatInID.Text)='')    then ErrNo := -3;
  if (lcp <> nil) and (trim(edtINPaperNo.Text)='')  then ErrNo := -2;
  if (lcP <> nil) and (GetTabCaption(Selected)='')  then ErrNo := -1;

  if ErrNo = 0 then begin
    if Abs(lcP^.QUANTITY) = 0 then ErrNo := -5;
  end;

  //--  检查日期是否有效
  if ErrNo = 0 then begin
    if lcP^.DATE <= 2 then ErrNo := -9;
  end;
  
  //--  检查输入的日期是否在已月结关帐区间
  if ErrNo = 0 then begin
    if dm_Inventory.is_DateInAccountedMonth(trim(lcp^.STK_ID),lcp^.DATE) then ErrNo := -7;
  end;

  //-- 检查入库不能超出订货量
  iOrdQty     := 0.00;
  iOrdWeight  := 0.00;
  orderamount := 0.00;
  isinQty     := 0.00;

  if (lcp^.REC_ID<0) then
  begin
    if lcp^.HAT_RID>0 then //-- 订单入库
    begin
      orderamount := dm_Inventory.get_orderedQty_fromOrderNo(lcp^.HAT_RID, iOrdQty, iOrdWeight);                  //-- 订货的量
      isinQty     := dm_Inventory.get_stkDeliveriedQty_fromOrderNo(lcp^.HAT_RID)+roundto(Abs(lcP^.QUANTITY),-2);  //-- 已入库的量
      if roundto(iOrdWeight,-2)>0.00 then begin
        iOrdQty := iOrdWeight;
        if (Abs(roundto(isinQty,-2))>(iOrdQty+0.0001)) then ErrNo := -8;
      end;
    end;
  end
  else begin
    if lcp^.HAT_RID>0 then //-- 订单入库
    begin
      orderamount := dm_Inventory.get_orderedQty_fromOrderNo(lcp^.HAT_RID, iOrdQty, iOrdWeight);   //-- 订货的量
      isinQty     := dm_Inventory.get_stkDeliveriedQty_fromOrderNo(lcp^.HAT_RID);;                 //-- 已入库的量
      if roundto(iOrdWeight,-2)>0.00 then begin
        iOrdQty := iOrdWeight;
        if (Abs(roundto(isinQty,-2))>(iOrdQty+0.0001)) then ErrNo := -8;
      end;
    end;
  end;

⌨️ 快捷键说明

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