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

📄 matin.~pas

📁 文件包含程序源原文件
💻 ~PAS
📖 第 1 页 / 共 5 页
字号:
  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!');
      -8: ErrMsg := '订货已入库量大于采购订货量!';
      -7: ErrMsg := '该日期已月结结帐,已结帐区间不能再输入入库数据!';
      -9: ErrMsg := '该入库数据的入库日期无效!';
    end;
    MessageDlg(ErrMsg, mtWarning, [mbOK], 0);
  end;
end;

function  TfrmMatIN.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 TfrmMatIN.UpdateCheck;
var UpdateListList: TList;
begin
  UpdateListList := GetUpdateListList;
  if (UpdateListList.Count>0)then begin
    if ErrorCheck(Selected) <> 0 then Exit;
    UpdateProc(UpdateListList);
    //if ReRead_Cnt > 0 then frmInvHistory.ReReadProc(False);
  end;
end;

procedure TfrmMatIN.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;

  iPaper := strToIntDef(frmMain.IniData.PaperNo,20);
  StrPCopy(lcNewP^.PAPERNO, dm_Inventory.Get_PaperNO(lcp^.SUP_CD, lcp^.DATE, iPaper,0));

  lcNewP^.UNT_PRICE     := 0;
  lcNewP^.QUANTITY      := 0;
  lcNewP.MAK_PRICE      := 0;
  lcNewP^.TTL_PRICE     := 0;
  lcNewP^.USE_GUAGE     := '';
  lcNewP^.USE_QUANTITY  := 0;
  lcNewP^.USE_AMOUNT    := 0;
  lcNewP^.ODR_RID       := 0;
  lcNewP^.PAT_RID       := 0;
  lcNewP^.HAT_RID       := 0;

  SetData(lcNewP);
  AddTab(lcNewP);
  SetUpdateList(lcNewP^.REC_ID, @lcNewP^.STK_ID, LongInt(@View.STK_ID)-LongInt(@View),     0, lcNewP);
  SetUpdateList(lcNewP^.REC_ID, @lcNewP^.KIND,   LongInt(@View.KIND)-LongInt(@View),       0, lcNewP);
  SetUpdateList(lcNewP^.REC_ID, @lcNewP^.DATE,   LongInt(@View.DATE)-LongInt(@View),       0, lcNewP);
  SetUpdateList(lcNewP^.REC_ID, @lcNewP^.PAPERNO,LongInt(@View.PAPERNO)-LongInt(@View),    0, lcNewP);
  SetUpdateList(lcNewP^.REC_ID, @lcNewP^.MAT_RID,LongInt(@View.MAT_RID)-LongInt(@View),    0, lcNewP);
  SetUpdateList(lcNewP^.REC_ID, @lcNewP^.MAT_NM, LongInt(@View.MAT_NM)-LongInt(@View),     0, lcNewP);
  SetUpdateList(lcNewP^.REC_ID, @lcNewP^.GUAGE_ID, LongInt(@View.GUAGE_ID)-LongInt(@View),   0, lcNewP);
  SetUpdateList(lcNewP^.REC_ID, @lcNewP^.SUP_CD,   LongInt(@View.SUP_CD)-LongInt(@View),     0, lcNewP);
  SetUpdateList(lcNewP^.REC_ID, @lcNewP^.MAK_CD,   LongInt(@View.MAK_CD)-LongInt(@View),     0, lcNewP);
  SetUpdateList(lcNewP^.REC_ID, @lcNewP^.QUANTITY, LongInt(@View.QUANTITY)-LongInt(@View),   0, lcNewP);
  SetUpdateList(lcNewP^.REC_ID, @lcNewP^.UNT_PRICE,LongInt(@View.UNT_PRICE)-LongInt(@View),  0, lcNewP);
  SetUpdateList(lcNewP^.REC_ID, @lcNewP^.MAK_PRICE,LongInt(@View.MAK_PRICE)-LongInt(@View),  0, lcNewP);
  SetUpdateList(lcNewP^.REC_ID, @lcNewP^.TTL_PRICE,LongInt(@View.TTL_PRICE)-LongInt(@View),  0, lcNewP);
  SetUpdateList(lcNewP^.REC_ID, @lcNewP^.USE_GUAGE,LongInt(@View.USE_GUAGE)-LongInt(@View),  0, lcNewP);
  SetUpdateList(lcNewP^.REC_ID, @lcNewP^.USE_QUANTITY, LongInt(@View.USE_QUANTITY)-LongInt(@View),  0, lcNewP);
  SetUpdateList(lcNewP^.REC_ID, @lcNewP^.USE_AMOUNT,   LongInt(@View.USE_AMOUNT)-LongInt(@View),  0, lcNewP);
  SetUpdateList(lcNewP^.REC_ID, @lcNewP^.INOUT_ID,     LongInt(@View.INOUT_ID)-LongInt(@View),   0, lcNewP);
  SetUpdateList(lcNewP^.REC_ID, @lcNewP^.input_empid,  LongInt(@View.input_empid)-LongInt(@View),       0, lcNewP);
  SetUpdateList(lcNewP^.REC_ID, @lcNewP^.INVOICE_NO,   LongInt(@View.INVOICE_NO)-LongInt(@View),       0, lcNewP);
  SetUpdateList(lcNewP^.REC_ID, @lcNewP^.recieve_empid,LongInt(@View.recieve_empid)-LongInt(@View),       0, lcNewP);
  SetUpdateList(lcNewP^.REC_ID, @lcNewP^.ODR_RID,      LongInt(@View.ODR_RID)-LongInt(@View),    0, lcNewP);
  SetUpdateList(lcNewP^.REC_ID, @lcNewP^.PAT_RID,      LongInt(@View.PAT_RID)-LongInt(@View),    0, lcNewP);
  SetUpdateList(lcNewP^.REC_ID, @lcNewP^.HAT_RID,      LongInt(@View.HAT_RID)-LongInt(@View),    0, lcNewP);
  SetUpdateList(lcNewP^.REC_ID, @lcNewP^.ISS_PAPERNO,  LongInt(@View.ISS_PAPERNO)-LongInt(@View),    0, lcNewP);
  SetUpdateList(lcNewP^.REC_ID, @lcNewP^.SEQUAL_NO,    LongInt(@View.SEQUAL_NO)-LongInt(@View),    0, lcNewP);
  SetUpdateList(lcNewP^.REC_ID, @lcNewP^.HAT_CODE,     LongInt(@View.HAT_CODE)-LongInt(@View),    0, lcNewP);
  //SetUpdateList(lcNewP^.REC_ID, @lcNewP^.IS_CLOSE,     LongInt(@View.IS_CLOSE)-LongInt(@View),    0, lcNewP);
  SetUpdateList(lcNewP^.REC_ID, @lcNewP^.NOTE,         LongInt(@View.NOTE)-LongInt(@View),       0, lcNewP);
end;

{**********************************************************************************}
{**********************************************************************************}
procedure TfrmMatIN.set_tmpdata(i: integer; lcp: PINVENTORY; agp: PUnDeliveryOnTime);
var iGuage_ID,
    tmp_guageid: Integer;
    tmp_wgh: Double;
    tmp_qty: Double;
    View: TINVENTORY;
begin
  //-- process guage_id use guage_name
  if agp=nil then exit;
  if not(dm_inventory.isExists_GuageInfo(agp^.shizai_rec_id, agp^.kikaku)) then begin
    dm_inventory.Insert_MatGuageInfo(agp^.shizai_rec_id, agp^.kikaku);
    tmp_guageid := dm_Inventory.Get_GuageID(agp^.shizai_rec_id, agp^.kikaku);
    if agp^.weight <=0 then tmp_wgh := 1 else tmp_wgh := agp^.weight;
    dm_inventory.Update_MatWeightPCS(agp^.shizai_rec_id,tmp_guageid,tmp_wgh);
    dm_inventory.Read_MatGuageInfo(FGuageList);
  end;
  iGuage_ID := dm_Inventory.Get_GuageID(agp^.shizai_rec_id, agp^.kikaku);

  case i of
    1: begin
         lcp := selected;
         default_suplier := agp^.hatchu_saki;

         lcp^.MAT_RID   := agp^.shizai_rec_id;
         SetUpdateList(lcP^.REC_ID, @lcP^.MAT_RID, LongInt(@View.MAT_RID)-LongInt(@View), 0, lcP);

         strPCopy(LCP^.MAT_NM, dm_inventory.GetMaterialName(lcp^.MAT_RID));
         SetUpdateList(lcP^.REC_ID, @lcP^.MAT_NM, LongInt(@View.MAT_NM)-LongInt(@View), 0, lcP);

         lcp^.GUAGE_ID  := iGuage_ID;
         SetUpdateList(lcP^.REC_ID, @lcP^.GUAGE_ID, LongInt(@View.GUAGE_ID)-LongInt(@View), 0, lcP);

         lcp^.SUP_CD          := agp^.hatchu_saki;
         SetUpdateList(lcP^.REC_ID, @lcP^.SUP_CD, LongInt(@View.SUP_CD)-LongInt(@View), 0, lcP);

         lcp^.MAK_CD    := agp^.maker;
         SetUpdateList(lcP^.REC_ID, @lcP^.MAK_CD, LongInt(@View.MAK_CD)-LongInt(@View), 0, lcP);

         lcp^.UNT_PRICE := RoundTo(agp^.tanka,-2);
         SetUpdateList(lcP^.REC_ID, @lcP^.UNT_PRICE, LongInt(@View.UNT_PRICE)-LongInt(@View), 0, lcP);

         if agp^.weight <=0 then tmp_qty := abs(RoundTo(agp^.suryo,-2))
         else  tmp_qty := abs(RoundTo(agp^.un_deliveried_weight,-2));

         lcp^.MAK_PRICE := abs(RoundTo(agp^.mak_price,-2))*abs(RoundTo(agp^.suryo,-2));
         SetUpdateList(lcP^.REC_ID, @lcP^.MAK_PRICE, LongInt(@View.MAK_PRICE)-LongInt(@View), 0, lcP);

         lcp^.QUANTITY  := RoundTo(tmp_qty,-2);
         SetUpdateList(lcP^.REC_ID, @lcP^.QUANTITY, LongInt(@View.QUANTITY)-LongInt(@View), 0, lcP);

         lcp^.TTL_PRICE := abs(RoundTo(lcp^.UNT_PRICE,-2))*abs(RoundTo(lcp^.QUANTITY,-2))+abs(RoundTo(lcp^.MAK_PRICE,-2));
         SetUpdateList(lcP^.REC_ID, @lcP^.TTL_PRICE, LongInt(@View.TTL_PRICE)-LongInt(@View), 0, lcP);

         lcp^.ODR_RID   := agp^.seihin_rec_id;
         SetUpdateList(lcP^.REC_ID, @lcP^.ODR_RID, LongInt(@View.ODR_RID)-LongInt(@View), 0, lcP);

         lcp^.PAT_RID   := agp^.buhin_rec_id;
         SetUpdateList(lcP^.REC_ID, @lcP^.PAT_RID, LongInt(@View.PAT_RID)-LongInt(@View), 0, lcP);

         lcp^.HAT_RID   := agp^.hatchu_id;
         SetUpdateList(lcP^.REC_ID, @lcP^.HAT_RID, LongInt(@View.HAT_RID)-LongInt(@View), 0, lcP);

         strPCopy(lcp^.HAT_CODE, agp^.hatchu_code);
         SetUpdateList(lcP^.REC_ID, @lcP^.HAT_CODE, LongInt(@View.HAT_CODE)-LongInt(@View), 0, lcP);

         strPCopy(lcp^.SEQUAL_NO, agp^.sequal_no);
         SetUpdateList(lcP^.REC_ID, @lcP^.SEQUAL_NO, LongInt(@View.SEQUAL_NO)-LongInt(@View), 0, lcP);
         SetData(lcP);
       end;
    2: begin
         default_suplier := agp^.hatchu_saki;
         setNew(-1);
         lcp := selected;
         lcp^.MAT_RID   := agp^.shizai_rec_id;
         SetUpdateList(lcP^.REC_ID, @lcP^.MAT_RID, LongInt(@View.MAT_RID)-LongInt(@View), 0, lcP);

         strPCopy(LCP^.MAT_NM, dm_inventory.GetMaterialName(lcp^.MAT_RID));
         SetUpdateList(lcP^.REC_ID, @lcP^.MAT_NM, LongInt(@View.MAT_NM)-LongInt(@View), 0, lcP);

         lcp^.GUAGE_ID  := iGuage_ID;
         SetUpdateList(lcP^.REC_ID, @lcP^.GUAGE_ID, LongInt(@View.GUAGE_ID)-LongInt(@View), 0, lcP);

         lcp^.SUP_CD          := agp^.hatchu_saki;
         SetUpdateList(lcP^.REC_ID, @lcP^.SUP_CD, LongInt(@View.SUP_CD)-LongInt(@View), 0, lcP);

         lcp^.MAK_CD    := agp^.maker;
         SetUpdateList(lcP^.REC_ID, @lcP^.MAK_CD, LongInt(@View.MAK_CD)-LongInt(@View), 0, lcP);

         lcp^.UNT_PRICE := RoundTo(agp^.tanka,-2);
         SetUpdateList(lcP^.REC_ID, @lcP^.UNT_PRICE, LongInt(@View.UNT_PRICE)-LongInt(@View), 0, lcP);

         if agp^.weight <=0 then tmp_qty := abs(RoundTo(agp^.suryo,-2))
         else  tmp_qty := abs(RoundTo(agp^.un_deliveried_weight,-2));

         lcp^.MAK_PRICE := abs(RoundTo(agp^.mak_price,-2))*abs(RoundTo(agp^.suryo,-2));
         SetUpdateList(lcP^.REC_ID, @lcP^.MAK_PRICE, LongInt(@View.MAK_PRICE)-LongInt(@View), 0, lcP);

         lcp^.QUANTITY  := RoundTo(tmp_qty,-2);
         SetUpdateList(lcP^.REC_ID, @lcP^.QUANTITY, LongInt(@View.QUANTITY)-LongInt(@View), 0, lcP);

         lcp^.TTL_PRICE := abs(RoundTo(lcp^.UNT_PRICE,-2))*abs(RoundTo(lcp^.QUANTITY,-2))+abs(RoundTo(lcp^.MAK_PRICE,-2));
         SetUpdateList(lcP^.REC_ID, @lcP^.TTL_PRICE, LongInt(@View.TTL_PRICE)-LongInt(@View), 0, lcP);

         lcp^.ODR_RID   := agp^.seihin_rec_id;
         SetUpdateList(lcP^.REC_ID, @lcP^.ODR_RID, LongInt(@View.ODR_RID)-LongInt(@View), 0, lcP);

         lcp^.PAT_RID   := agp^.buhin_rec_id;
         SetUpdateList(lcP^.REC_ID, @lcP^.PAT_RID, LongInt(@View.PAT_RID)-LongInt(@View), 0, lcP);

         lcp^.HAT_RID   := agp^.hatchu_id;
         SetUpdateList(lcP^.REC_ID, @lcP^.HAT_RID, LongInt(@View.HAT_RID)-LongInt(@View), 0, lcP);

         strPCopy(lcp^.HAT_CODE, agp^.hatchu_code);
         SetUpdateList(lcP^.REC_ID, @lcP^.HAT_CODE, LongInt(@View.HAT_CODE)-LongInt(@View), 0, lcP);

         strPCopy(lcp^.SEQUAL_NO, agp^.sequal_no);
         SetUpdateList(lcP^.REC_ID, @lcP^.SEQUAL_NO, LongInt(@View.SEQUAL_NO)-LongInt(@View), 0, lcP);
         SetData(lcP);
       end;
  end;
end;

{**********************************************************************************}
procedure TfrmMatIN.SetNew(Index: Integer);
var lcP:  PINVENTORY;
    View: TINVENTORY;
    iPaper: Integer;
begin
  New(lcP);
  ZeroMemory(lcP, SizeOf(TINVENTORY));

  Dec(FNewRecid);
  lcP^.REC_ID   := FNewRecid;
  lcp^.KIND     := 0;
  if lcp^.DATE <= 2 then lcp^.DATE := NOW;
  lcp^.USE_GUAGE    := '';
  lcp^.USE_QUANTITY := 0;
  lcp^.USE_AMOUNT   := 0;
         
  lcp^.SUP_CD       := default_suplier;
  StrPCopy(lcp^.ISS_PAPERNO, default_issuepaper);
  strPCopy(lcp^.INOUT_ID,  default_IOID);
  strPCopy(lcp^.INPUT_EMPID, default_InManID);

  strPCopy(lcp^.STK_ID, default_stkid);
  SetUpdateList(lcP^.REC_ID, @lcP^.STK_ID, LongInt(@View.STK_ID)-LongInt(@View), 0, lcP);

  iPaper := strToIntDef(frmMain.IniData.PaperNo,20);
  StrPCopy(lcp^.PAPERNO, dm_Inventory.Get_PaperNO(lcp^.SUP_CD, lcp^.DATE, iPaper,0));

                
  //StrPCopy(lcp^.PAPERNO, dm_inventory.Get_AutoPaperNo('IN PAPER NO'));

  SetUpdateList(lcP^.REC_ID, @lcP^.SUP_CD,      LongInt(@View.SUP_CD)-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^.INPUT_EMPID, LongInt(@View.INPUT_EMPID)-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^.PAPERNO,     LongInt(@View.PAPERNO)-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);

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

function  TfrmMatIN.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  TfrmMatIN.GetTabCaption(Item: Pointer): string;
var lcP: PINVENTORY;
begin
  lcP := Item;
  Result := dm_Inventory.GetMaterialCode(lcP^.MAT_RID);
end;

procedure TfrmMatIN.SetKomoku(Item: Pointer);
begin
  Selected := nil;
  if Item <> nil then begin
    SetData(Item);
    Selected := Item;
  end else SetNull;
end;

{**********************************************************************************}
{**********************************************************************************}
procedure TfrmMatIN.btnNewClick(Sender: TObject);
var
  frmInSuplier: TfrmInSuplier;
begin
  if Selected <> nil then
  begin
    if ErrorCheck(Selected) = 0 then
    begin
      UpdateCheck;

      if ckbNew.Checked then

⌨️ 快捷键说明

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