?? matout.pas
字號:
edtMatName.Text := lcP^.MAT_NM;
edtIssGuageID.Value := lcp^.GUAGE_ID;
edtIssGuageName.Text := dm_Inventory.Get_GuageName(lcp^.MAT_RID,lcp^.GUAGE_ID);
edtPrice.Value := RoundTo(lcP^.UNT_PRICE,-2);
edtUPID.Value := default_OutUnitPriceID;
edtIssWeight.Value := abs(RoundTo(lcP^.QUANTITY,-2));
lblUType.Caption := dm_Inventory.GetUnitTypeName(lcP^.MAT_RID);
lblTPrice.Caption := FormatFloat('#,##0.00', abs(UserDecimalDefine(lcP^.TTL_PRICE,2)));
cbxUseGuage.Text := lcp^.USE_GUAGE;
edtUseQuantity.Value := abs(RoundTo(lcp^.USE_QUANTITY,-2));
lblUseAmount.Caption := FormatFloat('#,##0.00', abs(RoundTo(lcP^.USE_AMOUNT,-2)));
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]);
edtHatCode.Text := lcp^.HAT_CODE;
edtSuplierCode.Value := lcP^.SUP_CD;
lblSupplierNM.Text := dm_Inventory.GetShigenName(lcP^.SUP_CD);
edtMakerCode.Value := lcP^.MAK_CD;
lblMakerNM.Text := dm_Inventory.GetShigenName(lcP^.MAK_CD);
edtMakerPrice.Value := RoundTo(lcp^.MAK_PRICE,-2);
edtNote.Text := lcP^.NOTE;
////////////-- get Inventory material qty
SetInventoryCnt(lcP^.REC_ID,lcP^.MAT_RID,lcp^.GUAGE_ID,lcp^.STK_ID,lcP^.DATE,InvCnt);
lblCurrQty.Caption := FormatFloat('#,##0.00',InvCnt);
end;
procedure TfrmMatOUT.SetNull;
begin
Selected := nil;
edtStkID.Text := default_stkid;
edtIssPaperNO.Text := '';
edtMatOutID.Text := '';
edtOutIDName.Text := '';
cbxMatOut.Text := '';
edtInputEmpID.Text := '';
edtInputEmpName.Text := '';
cbxInput.Text := '';
edtRecEmpID.Text := '';
edtRecEmpName.Text := '';
cbxRec.Text := '';
edtPaperNo.Text := '';
edtDate.Text := '';
edtMatCode.Text := '';
edtMatName.Text := '';
edtIssGuageID.Value := 0;
edtIssGuageName.Text := '';
cbxOutGuage.Text := '';
edtPrice.Value := 0;
edtUPID.Value := 0;
edtIssWeight.Value := 0;
lblUType.Caption := '';
lblTPrice.Caption := '0';
cbxUseGuage.Text := '';
edtUseQuantity.Value := 0;
lblUseAmount.Caption := '';
edtMoldID.Text := '';
edtPartID.Text := '';
edtSequalNo.Text := '';
edtOrderSerial.Text := '';
edtHatCode.Text := '';
edtSuplierCode.Value := 0;
lblSupplierNM.Text := '';
cbxSuplier.Text := '';
edtMakerCode.Value := 0;
lblMakerNM.Text := '';
cbxMaker.Text := '';
edtMakerPrice.Value := 0;
edtNote.Text := '';
lblCurrQty.Caption := '0';
end;
function TfrmMatOUT.ErrorCheck(Item: PINVENTORY): Integer;
var
lcP: PINVENTORY;
ErrNo: integer;
ErrMsg: string;
begin
Result := 0;
ErrNo := 0;
lcP := Selected;
if (lcP <> nil) and (GetTabCaption(Selected)='') then ErrNo := -1;
if (lcp <> nil) and (trim(edtPaperNo.Text)='') then ErrNo := -3;
if (lcp <> nil) and (trim(edtMatOutID.Text)='') then ErrNo := -4;
if (lcp <> nil) and (trim(edtRecEmpID.Text)='') then ErrNo := -5;
if (lcp <> nil) and (trim(edtInputEmpID.Text)='') then ErrNo := -6;
if (lcp <> nil) and (trim(edtIssPaperNO.Text)='') then ErrNo := -10;
if ErrNo = 0 then begin
if (lcp <> nil) and (Abs(RoundTo(lcP^.QUANTITY,-2))> (RoundTo(InvCnt,-2)+0.0001)) then ErrNo := -2;
if (lcp <> nil) and (Abs(lcP^.QUANTITY) = 0) then ErrNo := -7;
if (lcp <> nil) and (abs(RoundTo(lcp^.USE_QUANTITY,-2)) > abs(RoundTo(lcp^.QUANTITY,-2))) then ErrNo := -8;
if (lcp <> nil) and (abs(lcp^.USE_QUANTITY) = 0) then ErrNo := -9;
end;
//-- 檢查日期是否有效
if ErrNo = 0 then begin
if lcP^.DATE <= 2 then ErrNo := -12;
end;
//-- 檢查輸入的日期是否在已月結關帳區間
if ErrNo = 0 then begin
if dm_Inventory.is_DateInAccountedMonth(trim(lcp^.STK_ID),lcp^.DATE) then ErrNo := -11;
end;
if ErrNo<>0 then begin
Result := -1;
case ErrNo of
-1: ErrMsg := GetMultiLingalMsg(90207, 'this Material Code is not Exists!');
-2: ErrMsg := GetMultiLingalMsg(90218, 'Out Quantity > Inventory Quantity!');
-3: ErrMsg := GetMultiLingalMsg(90219, 'None Input Out Paper NO!');
-4: ErrMsg := GetMultiLingalMsg(90220, 'None Input Out Type!');
-5: ErrMsg := GetMultiLingalMsg(90221, 'None Input Receive Man!');
-6: ErrMsg := GetMultiLingalMsg(90222, 'None Input Input Man!');
-7: ErrMsg := GetMultiLingalMsg(90223, 'Out Quantity is Zero!');
-8: ErrMsg := GetMultiLingalMsg(90224, 'Use Quantity > Out Quantity!');
-9: ErrMsg := GetMultiLingalMsg(90225, 'Use Quantity is Zero!');
-10: ErrMsg := GetMultiLingalMsg(90237, 'None Input Customer Issure Paper NO!');
-11: ErrMsg := '該日期已月結結帳,已結帳區間不能再輸入入庫數據!';
-12: ErrMsg := '該入庫數據的入庫日期無效!';
end;
MessageDlg(ErrMsg, mtWarning, [mbOK], 0);
end;
end;
function TfrmMatOUT.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 TfrmMatOUT.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 dm_inventory.ReadInventory(False, FList);
end;
end;
procedure TfrmMatOUT.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,1));
lcNewP^.UNT_PRICE := 0;
lcNewP^.QUANTITY := 0;
lcNewP.MAK_PRICE := 0;
lcNewP^.TTL_PRICE := 0;
lcNewP^.USE_QUANTITY := 0;
lcNewP^.USE_AMOUNT := 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^.QUANTITY, LongInt(@View.QUANTITY)-LongInt(@View), 0, lcNewP);
SetUpdateList(lcNewP^.REC_ID, @lcNewP^.MAK_PRICE,LongInt(@View.MAK_PRICE)-LongInt(@View), 0, lcNewP);
SetUpdateList(lcNewP^.REC_ID, @lcNewP^.UNT_PRICE,LongInt(@View.UNT_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^.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^.inout_ID, LongInt(@View.inout_ID)-LongInt(@View), 0, lcNewP);
SetUpdateList(lcNewP^.REC_ID, @lcNewP^.recieve_empid,LongInt(@View.recieve_empid)-LongInt(@View), 0, lcNewP);
SetUpdateList(lcNewP^.REC_ID, @lcNewP^.input_empid, LongInt(@View.input_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^.SEQUAL_NO, LongInt(@View.SEQUAL_NO)-LongInt(@View), 0, lcNewP);
SetUpdateList(lcNewP^.REC_ID, @lcNewP^.HAT_RID, LongInt(@View.HAT_RID)-LongInt(@View), 0, lcNewP);
SetUpdateList(lcNewP^.REC_ID, @lcNewP^.HAT_CODE, LongInt(@View.HAT_CODE)-LongInt(@View), 0, lcNewP);
SetUpdateList(lcNewP^.REC_ID, @lcNewP^.invoice_no, LongInt(@View.invoice_no)-LongInt(@View), 0, lcNewP);
SetUpdateList(lcNewP^.REC_ID, @lcNewP^.ISS_PAPERNO, LongInt(@View.ISS_PAPERNO)-LongInt(@View), 0, lcNewP);
SetUpdateList(lcNewP^.REC_ID, @lcNewP^.NOTE, LongInt(@View.NOTE)-LongInt(@View), 0, lcNewP);
end;
{**********************************************************************************}
{**********************************************************************************}
procedure TfrmMatOUT.set_tmpdata(i: integer; lcp: PINVENTORY; agp: PAllReadyInOrder);
var iGuage_ID: Integer;
tmp_wghpcs: Double;
tmp_qty: Double;
View: TINVENTORY;
begin
//-- process guage_id use guage_name
if agp=nil then exit;
iGuage_ID := dm_Inventory.Get_GuageID(agp^.material_rec_id, agp^.guage_name);
tmp_wghpcs := dm_inventory.Get_MatGuageWgtPcs(agp^.material_rec_id,agp^.guage_id);
if tmp_wghpcs<=0 then tmp_wghpcs := 1;
//if agp^.quantity > tmp_wghpcs then tmp_qty := tmp_wghpcs
//else
tmp_qty := agp^.quantity;
case i of
1: begin
lcp^.MAT_RID := agp^.material_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^.supplier_code;
SetUpdateList(lcP^.REC_ID, @lcP^.SUP_CD, LongInt(@View.SUP_CD)-LongInt(@View), 0, lcP);
lcp^.MAK_CD := agp^.maker_code;
SetUpdateList(lcP^.REC_ID, @lcP^.MAK_CD, LongInt(@View.MAK_CD)-LongInt(@View), 0, lcP);
lcp^.MAK_PRICE := RoundTo(agp^.MAK_PRICE,-2);
SetUpdateList(lcP^.REC_ID, @lcP^.MAK_PRICE, LongInt(@View.MAK_PRICE)-LongInt(@View), 0, lcP);
lcp^.UNT_PRICE := RoundTo(agp^.unit_price,-2);
SetUpdateList(lcP^.REC_ID, @lcP^.UNT_PRICE, LongInt(@View.UNT_PRICE)-LongInt(@View), 0, lcP);
lcp^.QUANTITY := abs(RoundTo(tmp_qty,-2))*-1;
SetUpdateList(lcP^.REC_ID, @lcP^.QUANTITY, LongInt(@View.QUANTITY)-LongInt(@View), 0, lcP);
lcp^.TTL_PRICE := abs(RoundTo(agp^.unit_price,-2))*abs(RoundTo(lcp^.quantity,-2))*-1;
SetUpdateList(lcP^.REC_ID, @lcP^.TTL_PRICE, LongInt(@View.TTL_PRICE)-LongInt(@View), 0, lcP);
strPCopy(lcp^.USE_GUAGE, agp^.guage_name);
SetUpdateList(lcP^.REC_ID, @lcP^.USE_GUAGE, LongInt(@View.USE_GUAGE)-LongInt(@View), 0, lcP);
lcp^.USE_QUANTITY := abs(RoundTo(lcp^.quantity,-2))*-1;
SetUpdateList(lcP^.REC_ID, @lcP^.USE_QUANTITY, LongInt(@View.USE_QUANTITY)-LongInt(@View), 0, lcP);
lcp^.USE_AMOUNT := abs(RoundTo(lcp^.UNT_PRICE,-2))*abs(RoundTo(lcp^.quantity,-2))*-1;
SetUpdateList(lcP^.REC_ID, @lcP^.USE_AMOUNT, LongInt(@View.USE_AMOUNT)-LongInt(@View), 0, lcP);
lcp^.ODR_RID := agp^.order_rec_id;
SetUpdateList(lcP^.REC_ID, @lcP^.ODR_RID, LongInt(@View.ODR_RID)-LongInt(@View), 0, lcP);
lcp^.PAT_RID := agp^.parts_rec_id;
SetUpdateList(lcP^.REC_ID, @lcP^.PAT_RID, LongInt(@View.PAT_RID)-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);
lcp^.HAT_RID := agp^.order_no;
SetUpdateList(lcP^.REC_ID, @lcP^.HAT_RID, LongInt(@View.HAT_RID)-LongInt(@View), 0, lcP);
strPCopy(lcp^.HAT_CODE, agp^.HAT_CODE);
SetUpdateList(lcP^.REC_ID, @lcP^.HAT_CODE, LongInt(@View.HAT_CODE)-LongInt(@View), 0, lcP);
SetData(lcP);
ControlChange(edtMatCode);
ControlChange(edtIssGuageID);
end;
2: begin
setNew(-1);
lcp := selected;
lcp^.MAT_RID := agp^.material_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^.supplier_code;
SetUpdateList(lcP^.REC_ID, @lcP^.SUP_CD, LongInt(@View.SUP_CD)-LongInt(@View), 0, lcP);
lcp^.MAK_CD := agp^.maker_code;
SetUpdateList(lcP^.REC_ID, @lcP^.MAK_CD, LongInt(@View.MAK_CD)-LongInt(@View), 0, lcP);
lcp^.MAK_PRICE := RoundTo(agp^.MAK_PRICE,-2);
SetUpdateList(lcP^.REC_ID, @lcP^.MAK_PRICE, LongInt(@View.MAK_PRICE)-LongInt(@View), 0, lcP);
lcp^.UNT_PRICE := RoundTo(agp^.unit_price,-2);
SetUpdateList(lcp^.REC_ID, @lcp^.UNT_PRICE, LongInt(@View.UNT_PRICE)-LongInt(@View), 0, lcP);
lcp^.QUANTITY := abs(RoundTo(tmp_qty,-2))*-1;
SetUpdateList(lcP^.REC_ID, @lcP^.QUANTITY, LongInt(@View.QUANTITY)-LongInt(@View), 0, lcP);
lcp^.TTL_PRICE := abs(RoundTo(agp^.unit_price,-2))*abs(RoundTo(lcp^.quantity,-2))*-1;
SetUpdateList(lcP^.REC_ID, @lcP^.TTL_PRICE, LongInt(@View.TTL_PRICE)-LongInt(@View), 0, lcP);
strPCopy(lcp^.USE_GUAGE, agp^.guage_name);
SetUpdateList(lcP^.REC_ID, @lcP^.USE_GUAGE, LongInt(@View.USE_GUAGE)-LongInt(@View), 0, lcP);
lcp^.USE_QUANTITY := abs(RoundTo(lcp^.quantity,-2))*-1;
SetUpdateList(lcP^.REC_ID, @lcP^.USE_QUANTITY, LongInt(@View.USE_QUANTITY)-LongInt(@View), 0, lcP);
lcp^.USE_AMOUNT := abs(RoundTo(lcp^.UNT_PRICE,-2))*abs(RoundTo(agp^.quantity,-2))*-1;
SetUpdateList(lcP^.REC_ID, @lcP^.USE_AMOUNT, LongInt(@View.USE_AMOUNT)-LongInt(@View), 0, lcP);
lcp^.ODR_RID := agp^.order_rec_id;
SetUpdateList(lcP^.REC_ID, @lcP^.ODR_RID, LongInt(@View.ODR_RID)-LongInt(@View), 0, lcP);
lcp^.PAT_RID := agp^.parts_rec_id;
SetUpdateList(lcP^.REC_ID, @lcP^.PAT_RID, LongInt(@View.PAT_RID)-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);
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -