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

📄 matbalain.~pas

📁 文件包含程序源原文件
💻 ~PAS
📖 第 1 页 / 共 4 页
字号:
    lcP^.TTL_PRICE := RoundTo(lcP^.UNT_PRICE,-2) * RoundTo(lcP^.QUANTITY,-2);
    lblTPrice.Caption := FormatFloat('#,##0.00', RoundTo(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.ISS_PAPERNO)-Longint(@View) then
    StrPCopy(PChar(CtrlList^.Address), (CtrlList^.Target as TCustomEdit).Text)
  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.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.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.NOTE)-Longint(@View) then
    StrPCopy(PChar(CtrlList^.Address), (CtrlList^.Target as TCustomEdit).Text);
  ///////////////////////////////////////////////////////////////////
end;

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

  edtIssPaperNO.Text    := lcp^.ISS_PAPERNO;
  edtInPaperNo.Text     := lcp^.PaperNo;
  edtStkID.Text         := lcp^.STK_ID;
  edtStkName.Text       := dm_Inventory.GetStockName(trim(edtStkID.Text));
  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);
  lblUType.Caption      := dm_Inventory.GetUnitTypeName(lcP^.MAT_RID);
  lblTPrice.Caption     := FormatFloat('#,##0.00', RoundTo(lcP^.TTL_PRICE,-2));

  edtNote.Text        := lcP^.NOTE;
end;

procedure TfrmMatBalaIn.SetNull;
begin
  Selected := nil;
  edtInPaperNo.Text     := '';
  edtStkID.Text         := IniData.matstkid;
  edtDate.Text          := '';
  edtIssPaperNO.Text    := '';
  edtMatCode.Text       := '';
  edtMatName.Text       := '';
  edtGuageID.Value      := 0;
  edtGuageName.Text     := '';
  edtPrice.Value        := 0;
  edtWeight.Value       := 0;
  lblUType.Caption      := '';
  lblTPrice.Caption     := '0';
  edtNote.Text          := '';
end;

function  TfrmMatBalaIn.ErrorCheck(Item: PINVENTORY): Integer;
var
  lcP: PINVENTORY;
  ErrNo: integer;
  ErrMsg: string;
begin
  Result := 0;
  ErrNo  := 0;
  lcP := Selected;
  if (lcp <> nil) and (trim(edtIssPaperNO.Text)='') then ErrNo := -6;
  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
    Result := -1;
    case ErrNo of
      -1: ErrMsg := GetMultiLingalMsg(90207, 'this Material Code is not Exists!');
      -2: ErrMsg := GetMultiLingalMsg(90208, 'None Input Paper NO!');
      -3: ErrMsg := GetMultiLingalMsg(90209, 'None Input IN Type!');
      -4: ErrMsg := GetMultiLingalMsg(90210, 'None Input IN Man!');
      -5: ErrMsg := GetMultiLingalMsg(90211, 'IN Quantity is Zero!');
      -6: ErrMsg := GetMultiLingalMsg(90237, 'None Input Customer Issure Paper NO!');
    end;
    MessageDlg(ErrMsg, mtWarning, [mbOK], 0);
  end;
end;

function  TfrmMatBalaIn.UpdateProc(UpdateListList: TList): Boolean;
var List: TList;
    lcP:  PUPDATE_LIST;
    lcInvP: PINVENTORY;
    IX_1, IX_2, Recid, Error: LongInt;
    ReReadFlg: Boolean;
    ErrMsg: string;
begin
  Result := False;
  Screen.Cursor  := crSqlWait;
  RecIdType := 0;
  try
    for IX_1:=0 to UpdateListList.Count-1 do begin
      List  := UpdateListList[IX_1];
      lcP   := List[0];
      Recid := lcP^.REC_ID;
      ReReadFlg := (Recid < 0);
      Error := dm_Inventory.UpdateDatabase('inventory_sheet', Recid, List);
      if Error < 0 then begin
        Screen.Cursor := crDefault;
        ErrMsg := GetMultiLingalMsg(1917, 'Update Database is Error!');
        MessageDlg(ErrMsg, mtError, [mbOk], 0);
        Exit;
      end;
      lcInvP := nil;
      for IX_2:=0 to List.Count-1 do begin
        lcInvP := PUPDATE_LIST(List[IX_2])^.Parent;
        if lcInvP^.REC_ID <> Recid then lcInvP^.REC_ID := Recid;
      end;
      Inc(ReRead_Cnt);
      SetLength(ReRead_RID, ReRead_Cnt);
      ReRead_RID[ReRead_Cnt-1] := lcInvP^.REC_ID;
      if not(ReReadFlg) then begin
        Inc(Delete_Cnt);
        SetLength(Delete_RID, Delete_Cnt);
        Delete_RID[Delete_Cnt-1] := lcInvP^.REC_ID;
      end;
    end;
  finally
    RecIdType := 1;
    Screen.Cursor := crDefault;
  end;
  for IX_1:=0 to FUpdateList.Count-1 do Dispose(FUpdateList[IX_1]);
  FUpdateList.Clear;
  Result := True;
end;

procedure TfrmMatBalaIn.UpdateCheck;
var UpdateListList: TList;
begin
  UpdateListList := GetUpdateListList;
  if (UpdateListList.Count>0)then begin
    if ErrorCheck(Selected) <> 0 then Exit;
    UpdateProc(UpdateListList);
  end;
end;

procedure TfrmMatBalaIn.SetCopy;
var lcP, lcNewP: PINVENTORY;
    View: TINVENTORY;
    iPaper: integer;
begin
  lcP := Selected;
  New(lcNewP);

  ZeroMemory(lcNewP, SizeOf(TINVENTORY));
  CopyMemory(lcNewP, lcP, SizeOf(TINVENTORY));
  DEC(FNewRecid);
  lcNewP^.REC_ID   := FNewRecid;
  if lcNewP^.DATE <= 2  then lcNewP^.DATE  := NOW;

  lcNewP^.QUANTITY     := 0;
  lcNewP^.TTL_PRICE    := lcp^.UNT_PRICE*lcp^.QUANTITY;
  lcNewP^.USE_GUAGE    := '';
  lcNewP^.USE_QUANTITY := 0;
  lcNewP^.USE_AMOUNT   := 0;

  lcNewP^.ODR_RID      := 0;
  lcNewP^.PAT_RID      := 0;
  lcNewP^.HAT_RID      := 0;
  
  lcNewP^.INOUT_ID      := '0';
  lcNewP^.RECIEVE_EMPID := '';
  lcNewP^.INVOICE_NO    := '';
  lcNewP^.IS_ACCOUNT    := 0;
  lcNewP^.NOTE          := '';

  SetData(lcNewP);
  AddTab(lcNewP);

  strPCopy(lcNewP^.STK_ID, IniData.matstkid);
  SetUpdateList(lcNewP^.REC_ID, @lcNewP^.STK_ID, LongInt(@View.STK_ID)-LongInt(@View), 0, lcP);
  SetUpdateList(lcNewP^.REC_ID, @lcNewP^.KIND, LongInt(@View.KIND)-LongInt(@View), 0, lcP);
  SetUpdateList(lcNewP^.REC_ID, @lcNewP^.DATE, LongInt(@View.DATE)-LongInt(@View), 0, lcP);
  SetUpdateList(lcNewP^.REC_ID, @lcNewP^.MAT_RID, LongInt(@View.MAT_RID)-LongInt(@View), 0, lcP);
  SetUpdateList(lcNewP^.REC_ID, @lcNewP^.MAT_NM, LongInt(@View.MAT_NM)-LongInt(@View), 0, lcP);
  SetUpdateList(lcNewP^.REC_ID, @lcNewP^.GUAGE_ID, LongInt(@View.GUAGE_ID)-LongInt(@View), 0, lcP);

  SetUpdateList(lcNewP^.REC_ID, @lcNewP^.SUP_CD, LongInt(@View.SUP_CD)-LongInt(@View), 0, lcP);
  SetUpdateList(lcNewP^.REC_ID, @lcNewP^.MAK_CD, LongInt(@View.MAK_CD)-LongInt(@View), 0, lcP);

  SetUpdateList(lcNewP^.REC_ID, @lcNewP^.QUANTITY, LongInt(@View.QUANTITY)-LongInt(@View), 0, lcP);
  SetUpdateList(lcNewP^.REC_ID, @lcNewP^.TTL_PRICE, LongInt(@View.TTL_PRICE)-LongInt(@View), 0, lcP);

  SetUpdateList(lcNewP^.REC_ID, @lcNewP^.USE_GUAGE, LongInt(@View.USE_GUAGE)-LongInt(@View), 0, lcP);
  SetUpdateList(lcNewP^.REC_ID, @lcNewP^.USE_QUANTITY, LongInt(@View.USE_QUANTITY)-LongInt(@View), 0, lcP);
  SetUpdateList(lcNewP^.REC_ID, @lcNewP^.USE_AMOUNT, LongInt(@View.USE_AMOUNT)-LongInt(@View), 0, lcP);

  SetUpdateList(lcNewP^.REC_ID, @lcNewP^.ODR_RID, LongInt(@View.ODR_RID)-LongInt(@View), 0, lcP);
  SetUpdateList(lcNewP^.REC_ID, @lcNewP^.PAT_RID, LongInt(@View.PAT_RID)-LongInt(@View), 0, lcP);
  SetUpdateList(lcNewP^.REC_ID, @lcNewP^.HAT_RID, LongInt(@View.HAT_RID)-LongInt(@View), 0, lcP);

  SetUpdateList(lcNewP^.REC_ID, @lcNewP^.PAPERNO, LongInt(@View.PAPERNO)-LongInt(@View), 0, lcP);
  SetUpdateList(lcNewP^.REC_ID, @lcNewP^.ISS_PAPERNO, LongInt(@View.ISS_PAPERNO)-LongInt(@View), 0, lcP);

  SetUpdateList(lcNewP^.REC_ID, @lcNewP^.INOUT_ID, LongInt(@View.INOUT_ID)-LongInt(@View), 0, lcP);
  SetUpdateList(lcNewP^.REC_ID, @lcNewP^.RECIEVE_EMPID, LongInt(@View.RECIEVE_EMPID)-LongInt(@View), 0, lcP);
  SetUpdateList(lcNewP^.REC_ID, @lcNewP^.INPUT_EMPID, LongInt(@View.INPUT_EMPID)-LongInt(@View), 0, lcP);
  SetUpdateList(lcNewP^.REC_ID, @lcNewP^.INVOICE_NO, LongInt(@View.INVOICE_NO)-LongInt(@View), 0, lcP);
 // SetUpdateList(lcNewP^.REC_ID, @lcNewP^.IS_ACCOUNT, LongInt(@View.IS_ACCOUNT)-LongInt(@View), 0, lcP);
  SetUpdateList(lcNewP^.REC_ID, @lcNewP^.NOTE, LongInt(@View.NOTE)-LongInt(@View), 0, lcP);
end;

{**********************************************************************************}
{**********************************************************************************}
procedure TfrmMatBalaIn.SetNew(Index: Integer);
var lcP,lcpSel:  PINVENTORY;
    View: TINVENTORY;
    iPaper: Integer;
begin
  lcpSel := FOutSelected;
  New(lcP);
  ZeroMemory(lcP, SizeOf(TINVENTORY));
  CopyMemory(lcp, lcpSel, Sizeof(TINVENTORY));

  Dec(FNewRecid);
  lcP^.REC_ID   := FNewRecid;
  lcp^.KIND     := 4;
  if lcp^.DATE <= 2 then lcp^.DATE := NOW;

  lcp^.QUANTITY     := 0;
  lcp^.TTL_PRICE    := lcp^.UNT_PRICE*lcp^.QUANTITY;
  lcp^.USE_GUAGE    := '';
  lcp^.USE_QUANTITY := 0;
  lcp^.USE_AMOUNT   := 0;
  lcp^.MAK_PRICE     := 0;

  lcp^.ODR_RID      := 0;
  lcp^.PAT_RID      := 0;
  lcp^.HAT_RID      := 0;
  
  lcp^.INOUT_ID      := '0';
  lcp^.RECIEVE_EMPID := '';
  lcp^.INVOICE_NO    := '';
  lcp^.IS_ACCOUNT    := 0;
  lcp^.IS_CLOSE      := 0;
  lcp^.NOTE          := '';

  strPCopy(lcp^.STK_ID, IniData.matstkid);
  SetUpdateList(lcP^.REC_ID, @lcP^.STK_ID, LongInt(@View.STK_ID)-LongInt(@View), 0, lcP);
  SetUpdateList(lcP^.REC_ID, @lcP^.KIND, LongInt(@View.KIND)-LongInt(@View), 0, lcP);
  SetUpdateList(lcP^.REC_ID, @lcP^.DATE, LongInt(@View.DATE)-LongInt(@View), 0, lcP);
  SetUpdateList(lcP^.REC_ID, @lcP^.MAT_RID, LongInt(@View.MAT_RID)-LongInt(@View), 0, lcP);
  SetUpdateList(lcP^.REC_ID, @lcP^.MAT_NM, LongInt(@View.MAT_NM)-LongInt(@View), 0, lcP);
  SetUpdateList(lcP^.REC_ID, @lcP^.GUAGE_ID, LongInt(@View.GUAGE_ID)-LongInt(@View), 0, lcP);

  SetUpdateList(lcP^.REC_ID, @lcP^.SUP_CD, LongInt(@View.SUP_CD)-LongInt(@View), 0, lcP);
  SetUpdateList(lcP^.REC_ID, @lcP^.MAK_CD, LongInt(@View.MAK_CD)-LongInt(@View), 0, lcP);
  SetUpdateList(lcP^.REC_ID, @lcP^.MAK_PRICE, LongInt(@View.MAK_PRICE)-LongInt(@View), 0, lcP);

  SetUpdateList(lcP^.REC_ID, @lcP^.QUANTITY, LongInt(@View.QUANTITY)-LongInt(@View), 0, lcP);
  SetUpdateList(lcP^.REC_ID, @lcP^.TTL_PRICE, LongInt(@View.TTL_PRICE)-LongInt(@View), 0, lcP);

  SetUpdateList(lcP^.REC_ID, @lcP^.USE_GUAGE, LongInt(@View.USE_GUAGE)-LongInt(@View), 0, lcP);
  SetUpdateList(lcP^.REC_ID, @lcP^.USE_QUANTITY, LongInt(@View.USE_QUANTITY)-LongInt(@View), 0, lcP);
  SetUpdateList(lcP^.REC_ID, @lcP^.USE_AMOUNT, LongInt(@View.USE_AMOUNT)-LongInt(@View), 0, lcP);

  SetUpdateList(lcP^.REC_ID, @lcP^.ODR_RID, LongInt(@View.ODR_RID)-LongInt(@View), 0, lcP);
  SetUpdateList(lcP^.REC_ID, @lcP^.PAT_RID, LongInt(@View.PAT_RID)-LongInt(@View), 0, lcP);
  SetUpdateList(lcP^.REC_ID, @lcP^.SEQUAL_NO, LongInt(@View.SEQUAL_NO)-LongInt(@View), 0, lcP);

  SetUpdateList(lcP^.REC_ID, @lcP^.HAT_RID,  LongInt(@View.HAT_RID)-LongInt(@View), 0, lcP);
  SetUpdateList(lcP^.REC_ID, @lcP^.HAT_CODE, LongInt(@View.HAT_CODE)-LongInt(@View), 0, lcP);

  SetUpdateList(lcP^.REC_ID, @lcP^.PAPERNO, LongInt(@View.PAPERNO)-LongInt(@View), 0, lcP);
  SetUpdateList(lcP^.REC_ID, @lcP^.ISS_PAPERNO, LongInt(@View.ISS_PAPERNO)-LongInt(@View), 0, lcP);

  SetUpdateList(lcP^.REC_ID, @lcP^.INOUT_ID, LongInt(@View.INOUT_ID)-LongInt(@View), 0, lcP);
  SetUpdateList(lcP^.REC_ID, @lcP^.RECIEVE_EMPID, LongInt(@View.RECIEVE_EMPID)-LongInt(@View), 0, lcP);
  SetUpdateList(lcP^.REC_ID, @lcP^.INPUT_EMPID, LongInt(@View.INPUT_EMPID)-LongInt(@View), 0, lcP);
  SetUpdateList(lcP^.REC_ID, @lcP^.INVOICE_NO, LongInt(@View.INVOICE_NO)-LongInt(@View), 0, lcP);
  SetUpdateList(lcP^.REC_ID, @lcP^.IS_ACCOUNT, LongInt(@View.IS_ACCOUNT)-LongInt(@View), 0, lcP);
  SetUpdateList(lcP^.REC_ID, @lcP^.IS_CLOSE,   LongInt(@View.IS_CLOSE)-LongInt(@View), 0, lcP);
  SetUpdateList(lcP^.REC_ID, @lcP^.NOTE, LongInt(@View.NOTE)-LongInt(@View), 0, lcP);

  SetData(lcP);
  if Index < 0 then AddTab(lcP) else InsertTab(lcP, Index);
end;

function  TfrmMatBalaIn.RECExists(RecID: LongInt): Boolean;
var i: Integer;
    WObj: Pointer;
    lcP: PINVENTORY;
begin
  Result := False;
  for i:=0 to TabControl.Tabs.Count-1 do begin
    WObj := TabControl.Tabs.Objects[i];
    lcP  := WObj;
    if lcP^.REC_ID = RecID then begin
      Result := True;
      Exit;
    end;
  end;
end;

{**********************************************************************************}
{**********************************************************************************}
function  TfrmMatBalaIn.GetTabCaption(Item: Pointer): string;
var lcP: PINVENTORY;
begin
  lcP := Item;
  Result := dm_Inventory.GetMaterialCode(lcP^.MAT_RID);
end;

procedure TfrmMatBalaIn.SetKomoku(Item: Pointer);
begin
  Selected := nil;
  if Item <> nil then begin
    SetData(Item);

⌨️ 快捷键说明

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