private void txtItemCode_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e) { if (e.KeyChar != (char)Keys.Return) { return; } NZString ItemCD = new NZString(txtItemCode, txtItemCode.Text.Trim()); NZString LocCD = new NZString(cboFromLoc, cboFromLoc.SelectedValue); LoadLotNo(ItemCD, LocCD); //if (txtItemCode.SelectedItemData != null) // cboInventoryUM.SelectedValue = txtItemCode.SelectedItemData.INV_UM_CLS.StrongValue; //else // cboInventoryUM.SelectedIndex = -1; cboFromLoc.Focus(); // get onhand qty NZDecimal onhandQTY = GetOnHandQty(); if (onhandQTY.IsNull == false) { txtOnHandQty.Text = CommonLib.CtrlUtil.GetCompleteNumberFormatValue(txtOnHandQty.MaxDecimalPlaces, onhandQTY); } else { txtOnHandQty.Text = "0"; } }
private NZDecimal GetOnHandQty() { NZDecimal dOnHandQty = new NZDecimal(); try { IssueByItemUIDM uidm = dmcIssueByItem.SaveData(new IssueByItemUIDM()); if (uidm.ITEM_CD.IsNull || uidm.FROM_LOC_CD.IsNull) { return(new NZDecimal()); } IssueConsumptionController ctlIssue = new IssueConsumptionController(); dOnHandQty = ctlIssue.GetOnHandQty(uidm); if (dOnHandQty.IsNull) { return(new NZDecimal()); } return(dOnHandQty); } catch (Exception ex) { MessageDialog.ShowBusiness(this, ex.Message); } return(new NZDecimal()); }
private void OnDelete() { try { NZString transID = new NZString(null, shtReturnProductList.GetValue(shtReturnProductList.ActiveRowIndex, (int)eColView.RETURN_TRANS_ID)); NZDecimal ReturnQTY = new NZDecimal(null, shtReturnProductList.GetValue(shtReturnProductList.ActiveRowIndex, (int)eColView.RETURN_QTY)); MessageDialogResult dr = MessageDialog.ShowConfirmation(this, new Message(Messages.eConfirm.CFM9002.ToString()), MessageDialogButtons.YesNo); if (dr == MessageDialogResult.No) { return; } ctrl_Shipment.DeleteItem_Return(transID); shtReturnProductList.RemoveRows(shtReturnProductList.ActiveRowIndex, 1); LoadData(dtPeriodBegin.NZValue, dtPeriodEnd.NZValue); MessageDialog.ShowInformation(this, null, new Message(Messages.eInformation.INF9003.ToString()).MessageDescription); } catch (BusinessException err) { MessageDialog.ShowBusiness(this, err.Error.Message); err.Error.FocusOnControl(); } catch (ValidateException err) { MessageDialog.ShowBusiness(this, err.ErrorResults[0].Message); err.ErrorResults[0].FocusOnControl(); } catch (Exception err) { MessageDialog.ShowBusiness(this, err.Message); } }
//public ErrorItem CheckShipDate(NZDateTime ShipDate) //{ // if (ShipDate.IsNull) // return new ErrorItem(ShipDate.Owner, TKPMessages.eValidate.VLM0031.ToString()); // InventoryPeriodBIZ biz = new InventoryPeriodBIZ(); // NZString YearMonth = new NZString(ShipDate.Owner, ShipDate.StrongValue.ToString("yyyyMM")); // InventoryPeriodDTO dto = biz.LoadByPK(YearMonth); // if (dto == null) // return new ErrorItem(ShipDate.Owner, TKPMessages.eValidate.VLM0032.ToString()); // if (dto.PERIOD_BEGIN_DATE.StrongValue > ShipDate.StrongValue // || dto.PERIOD_END_DATE.StrongValue < ShipDate.StrongValue) // return new ErrorItem(ShipDate.Owner, TKPMessages.eValidate.VLM0032.ToString()); // return null; //} #endregion public void ValidateBeforeSaveNew(InventoryTransactionDTO dto, NZDecimal OnhandQty) { ValidateException validateException = new ValidateException(); ErrorItem errorItem = null; #region mandatory check errorItem = CheckEmptyItemCode(dto.ITEM_CD); if (errorItem != null) { validateException.AddError(errorItem); } errorItem = CheckShipQTY(dto.ITEM_CD, dto.LOC_CD, dto.LOT_NO, dto.QTY); if (errorItem != null) { validateException.AddError(errorItem); } errorItem = CheckShipDate(dto.TRANS_DATE); if (errorItem != null) { validateException.AddError(errorItem); } validateException.ThrowIfHasError(); #endregion }
/// <summary> /// Do action after change record , such as set default and validate data. /// </summary> private void CheckChangingInRecord() { if (shtView.Rows.Count > 0) { // ตรวจว่าข้อมูลใน PO ซ้ำหรือไม่ ValidateException.ThrowErrorItem(ValidateDupplicateItem()); int iRow = shtView.ActiveRowIndex; int iCol = shtView.ActiveColumnIndex; NZDecimal decQty = new NZDecimal(null, shtView.GetValue(iRow, (int)eColumn.PO_QTY)); NZDecimal decUnitPrice = new NZDecimal(null, shtView.GetValue(iRow, (int)eColumn.UNIT_PRICE)); NZDecimal decReceiveQty = new NZDecimal(null, shtView.GetValue(iRow, (int)eColumn.RECEIVE_QTY)); NZDecimal decRate = new NZDecimal(null, shtView.GetValue(iRow, (int)eColumn.RATE)); // เซ็ต Amount if ((iCol == (int)eColumn.PO_QTY || iCol == (int)eColumn.UNIT_PRICE)) { shtView.Cells[iRow, (int)eColumn.AMOUNT].Value = (decQty.IsNull ? 0 : decQty.StrongValue) * (decUnitPrice.IsNull ? 0 : decUnitPrice.StrongValue); } // กำหนด Formula + value ให้ Inventory Qty shtView.Cells[iRow, (int)eColumn.INV_QTY].Formula = shtView.Cells[iRow, (int)eColumn.PO_QTY].ToString() + "*" + shtView.Cells[iRow, (int)eColumn.RATE].ToString(); shtView.Cells[iRow, (int)eColumn.INV_QTY].Value = (decQty.IsNull ? 0 : decQty.StrongValue) * (decRate.IsNull ? 0 : decRate.StrongValue); // กำหนด modifystate = edit (กรณีที่ไม่ใช่ record ที่เพิ่ง add มาใหม่) if (Convert.ToInt32(shtView.Cells[iRow, (int)eColumn.ModifyState].Value) != (int)eModifyState.Add) { shtView.Cells[iRow, (int)eColumn.ModifyState].Value = (int)eModifyState.Edit; } } }
private void cboFromLoc_SelectedValueChanged(object sender, EventArgs e) { if (cboFromLoc.SelectedValue == null) { return; } NZString ItemCD = new NZString(txtItemCode, txtItemCode.Text.Trim()); NZString LocCD = new NZString(cboFromLoc, cboFromLoc.SelectedValue); if (ItemCD.IsNull) { return; } LoadLotNo(ItemCD, LocCD); // get onhand qty NZDecimal onhandQTY = GetOnHandQty(); if (onhandQTY.IsNull == false) { txtOnHandQty.Text = CommonLib.CtrlUtil.GetCompleteNumberFormatValue(txtOnHandQty.MaxDecimalPlaces, onhandQTY); } else { txtOnHandQty.Text = "0"; } }
private bool ValidateQTY(int row) { //Check item string itemCode = shtIssueList.Cells[row, (int)eColView.ITEM_CODE].Text; NZString LocCD = new NZString(cboFromLoc, cboFromLoc.SelectedValue); NZString LotNo = new NZString(null, shtIssueList.Cells[row, (int)eColView.LOT_NO].Value); // check lot no IssueEntryValidator valIssue = new IssueEntryValidator(); CommonBizValidator commonVal = new CommonBizValidator(); ErrorItem err = commonVal.CheckInputLot((NZString)itemCode, LocCD, LotNo, true); if (err != null) { MessageDialog.ShowBusiness(this, err.Message); return(false); } // Check ReceiveQty NZDecimal qty = GetIssueQtyFromSpread(itemCode);// new NZDecimal(null, shtIssueList.Cells[row, (int)eColView.ISSUE_QTY].Value); if (qty.IsNull || qty.StrongValue == decimal.Zero) { ErrorItem error = new ErrorItem(null, TKPMessages.eValidate.VLM0027.ToString()); MessageDialog.ShowBusiness(this, error.Message); return(false); } return(true); }
public ErrorItem CheckWorkResultGoodQty(NZDecimal qty) { if (qty.IsNull || qty.StrongValue < 0) { return(new ErrorItem(qty.Owner, TKPMessages.eValidate.VLM0048.ToString())); } return(null); }
public ErrorItem CheckEmptyAdjustQty(NZDecimal adjustQty) { if (adjustQty.IsNull || adjustQty.StrongValue < decimal.Zero) { return(new ErrorItem(adjustQty.Owner, TKPMessages.eValidate.VLM0035.ToString())); } return(null); }
public ErrorItem CheckIsZeroAdjustQty(NZDecimal adjustQty) { if (adjustQty.NVL(0) == 0) { return(new ErrorItem(adjustQty.Owner, TKPMessages.eValidate.VLM0035.ToString())); } return(null); }
public ErrorItem CheckProductionQty(NZDecimal qty) { if (qty.IsNull || qty.StrongValue <= 0) { return(new ErrorItem(qty.Owner, TKPMessages.eValidate.VLM0048.ToString())); } return(null); }
/// <summary> /// Validate เมื่อ Cell มีการแก้ไขเรียบร้อย และค่าที่แก้ไขเป็นค่าใหม่ /// </summary> /// <param name="row"></param> /// <param name="column"></param> private bool ValidateCellEdited(int row, int column) { if (column == (int)eColView.ITEM_CD) { ItemValidator itemValidator = new ItemValidator(); object objItemCode = shtView.GetValue(row, column); if (objItemCode != null) { NZString itemCode = new NZString(null, objItemCode); bool bLoadItem = LoadItemIntoRow(row, itemCode); if (!bLoadItem) { return(false); } } } else if (column == (int)eColView.ORDER_QTY) { try { NZDecimal orderRate = new NZDecimal(null, shtView.Cells[row, (int)eColView.ORDER_UM_RATE].Value); NZDecimal invRate = new NZDecimal(null, shtView.Cells[row, (int)eColView.INV_UM_RATE].Value); NZDecimal orderQty = new NZDecimal(null, shtView.Cells[row, (int)eColView.ORDER_QTY].Value); NZDecimal price = new NZDecimal(null, shtView.Cells[row, (int)eColView.PRICE].Value); decimal invQty = (invRate.NVL(0) / orderRate.NVL(1)) * orderQty.NVL(0); decimal amount = price.NVL(0) * orderQty.NVL(0); shtView.Cells[row, (int)eColView.QTY].Value = invQty; shtView.Cells[row, (int)eColView.AMOUNT].Value = amount; } catch { shtView.Cells[row, (int)eColView.AMOUNT].Value = 0; shtView.Cells[row, (int)eColView.QTY].Value = 0; } } else if (column == (int)eColView.PRICE) { try { NZDecimal orderQty = new NZDecimal(null, shtView.Cells[row, (int)eColView.ORDER_QTY].Value); NZDecimal price = new NZDecimal(null, shtView.Cells[row, (int)eColView.PRICE].Value); decimal amount = price.NVL(0) * orderQty.NVL(0); shtView.Cells[row, (int)eColView.AMOUNT].Value = amount; } catch { shtView.Cells[row, (int)eColView.AMOUNT].Value = 0; } } return(true); }
public ErrorItem CheckEmptyOrderUMRate(NZDecimal OrderUMRate) { if (OrderUMRate.IsNull || OrderUMRate.StrongValue == 0) { return(new ErrorItem(OrderUMRate.Owner, TKPMessages.eValidate.VLM0060.ToString())); } return(null); }
public ErrorItem CheckEmptyLeadTime(NZDecimal nZDecimal) { if (nZDecimal == 0) { return(new ErrorItem(nZDecimal.Owner, Messages.eValidate.VLM0145.ToString())); } return(null); }
public ErrorItem CheckReorderPoint(NZDecimal dReorderPoint, NZDecimal dSafetyStock) { if (dReorderPoint < dSafetyStock) { return(new ErrorItem(dReorderPoint.Owner, Messages.eValidate.VLM0148.ToString())); } return(null); }
public ErrorItem CheckEmptyUnitConvert(NZDecimal InventoryUM, NZDecimal OrderUM) { if (InventoryUM / OrderUM == 0) { return(new ErrorItem(InventoryUM.Owner, TKPMessages.eValidate.VLM0059.ToString())); } return(null); }
/// <summary> /// Generate PO Detail List with selected status. /// </summary> /// <param name="strPONo">PO No of PO Details.</param> /// <param name="modifyState">status that want to selected.</param> /// <returns>List of PO Detail with selected status.</returns> private List <PurchaseOrderDDTO> GeneratePurchaseOrderDDTO(NZString strPONo, eModifyState modifyState) { if (modifyState == eModifyState.Delete) { return(m_DDTOListForDelete); } else { List <PurchaseOrderDDTO> dDTOPurchaseOrderList = new List <PurchaseOrderDDTO>(); for (int iRow = 0; iRow < shtView.Rows.Count; iRow++) { if (Convert.ToInt32(shtView.Cells[iRow, (int)eColumn.ModifyState].Value) == (int)modifyState) { NZString strItemCD = new NZString(null, shtView.Cells[iRow, (int)eColumn.ITEM_CD].Value, null); NZString strItemDesc = new NZString(null, shtView.Cells[iRow, (int)eColumn.ITEM_DESC].Value, null); NZDateTime dtmRequireDate = new NZDateTime(null, shtView.Cells[iRow, (int)eColumn.DUE_DATE].Value, null); NZDecimal decUnitPrice = new NZDecimal(null, shtView.Cells[iRow, (int)eColumn.UNIT_PRICE].Value, null); NZDecimal decQty = new NZDecimal(null, shtView.Cells[iRow, (int)eColumn.PO_QTY].Value, null); NZString strUnit = new NZString(null, shtView.Cells[iRow, (int)eColumn.UNIT].Value, null); NZDecimal decAmount = new NZDecimal(null, shtView.Cells[iRow, (int)eColumn.AMOUNT].Value, null); NZDecimal decReceiveQty = new NZDecimal(null, shtView.Cells[iRow, (int)eColumn.RECEIVE_QTY].Value, 0); NZString strStatus = new NZString(null, shtView.Cells[iRow, (int)eColumn.STATUS].Value, null); PurchaseOrderDDTO dDTO = new PurchaseOrderDDTO { #region tmp data CRT_BY = CommonLib.Common.CurrentUserInfomation.UserCD, CRT_DATE = (NZDateTime)DateTime.UtcNow, CRT_MACHINE = CommonLib.Common.CurrentUserInfomation.Machine, UPD_BY = CommonLib.Common.CurrentUserInfomation.UserCD, UPD_DATE = (NZDateTime)DateTime.UtcNow, UPD_MACHINE = CommonLib.Common.CurrentUserInfomation.Machine, IS_ACTIVE = (NZBoolean)true, PO_NO = strPONo, #endregion PO_LINE = new NZDecimal(null, shtView.Cells[iRow, (int)eColumn.PO_LINE].Value, 0), ITEM_CD = strItemCD, ITEM_DESC = strItemDesc, DUE_DATE = dtmRequireDate, UNIT_PRICE = decUnitPrice, PO_QTY = decQty, UNIT = strUnit, AMOUNT = decAmount, RECEIVE_QTY = (decReceiveQty.IsNull ? new NZDecimal(null, 0) : decReceiveQty), //BACK_ORDER_QTY = (NZDecimal)0, //LAST_RECEIVE_ID = (NZString)string.Empty, //LAST_RECEIVE_DATE = (NZDateTime)DateTime.UtcNow, STATUS = strStatus }; dDTOPurchaseOrderList.Add(dDTO); } } return(dDTOPurchaseOrderList); } }
public static ErrorItem CheckZeroQty(NZDecimal dCheck) { if (dCheck > 0) { return(new ErrorItem(dCheck.Owner, Messages.eValidate.VLM0124.ToString())); } else { return(null); } }
public static ErrorItem CheckDecimalValue(NZDecimal decCheckedValue, Messages.eValidate eValidateMsg) { if (decCheckedValue.IsNull) { return(new ErrorItem(decCheckedValue.Owner, eValidateMsg.ToString())); } else { return(null); } }
public ItemWeightDTO ConvertPCStoKG(NZString MasterNo, NZString ProcessNo, NZDecimal QtyPCS, NZInt processCount) { //ถ้า convert จาก PCS เป็น KG จะ default เป็น 0 ItemWeightDTO weightDTO = new ItemWeightDTO(); weightDTO.ItemCD = MasterNo; weightDTO.ProcessCD = ProcessNo; weightDTO.QtyPCS = QtyPCS; return(null); }
public ErrorItem CheckIssueQTY(NZDecimal IssueQTY) { if (IssueQTY.IsNull || IssueQTY.StrongValue == 0) { return(new ErrorItem(IssueQTY.Owner, TKPMessages.eValidate.VLM0027.ToString())); } //if (OnhandQTY.IsNull || OnhandQTY.StrongValue == 0) // return new ErrorItem(OnhandQTY.Owner, TKPMessages.eValidate.VLM0029.ToString()); return(null); }
public ErrorItem CheckEmptyPrice(NZDecimal Price) { if (Price.IsNull) { return(new ErrorItem(Price.Owner, TKPMessages.eValidate.VLM0169.ToString())); } if (Price.NVL(0) == 0) { return(new ErrorItem(Price.Owner, TKPMessages.eValidate.VLM0220.ToString())); } return(null); }
private void txtItemCode_TextChanged(object sender, EventArgs e) { NZDecimal onhandQTY = GetOnHandQty(); if (onhandQTY.IsNull == false) { txtOnHandQty.Text = CommonLib.CtrlUtil.GetCompleteNumberFormatValue(txtOnHandQty.MaxDecimalPlaces, onhandQTY); } else { txtOnHandQty.Text = "0"; } }
public void UpdateReturnQTY(NZString TransID, NZDecimal DiffQTY, NZString UpdateBy, NZString UpdateMachine) { Database db = m_db; DataRequest req = new DataRequest("S_TRN270_UpdateReturnQTY"); req.CommandType = CommandType.StoredProcedure; req.Parameters.Add("@pVar_TRANS_ID", DataType.NVarChar, CheckNull(TransID.Value)); req.Parameters.Add("@pNum_DiffQty", DataType.Default, CheckNull(DiffQTY.StrongValue)); req.Parameters.Add("@pVar_UpdateBy", DataType.NVarChar, CheckNull(UpdateBy.Value)); req.Parameters.Add("@pVar_UpdateMachine", DataType.NVarChar, CheckNull(UpdateMachine.Value)); db.ExecuteNonQuery(req); }
private void txtLotNo_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == '\r') { NZDecimal onhandQTY = GetOnHandQty(); if (onhandQTY.IsNull == false) { txtOnHandQty.Text = CommonLib.CtrlUtil.GetCompleteNumberFormatValue(txtOnHandQty.MaxDecimalPlaces, onhandQTY); } else { txtOnHandQty.Text = "0"; } } }
private void txtLotNo_SelectedValueChanged(object sender, EventArgs e) { //if (txtLotNo.Text == string.Empty) return; NZDecimal onhandQTY = GetOnHandQty(); if (onhandQTY.IsNull == false) { txtOnHandQty.Text = CommonLib.CtrlUtil.GetCompleteNumberFormatValue(txtOnHandQty.MaxDecimalPlaces, onhandQTY); } else { txtOnHandQty.Text = "0"; } }
public ErrorItem CheckMoveQty(NZDecimal MoveQty, NZDecimal OnHandQty) { if (MoveQty.IsNull || MoveQty.StrongValue == 0) { return(new ErrorItem(MoveQty.Owner, TKPMessages.eValidate.VLM0175.ToString())); } if (MoveQty.StrongValue < 0) { return(new ErrorItem(MoveQty.Owner, TKPMessages.eValidate.VLM0176.ToString())); } if (MoveQty.StrongValue > OnHandQty.StrongValue) { return(new ErrorItem(MoveQty.Owner, TKPMessages.eValidate.VLM0177.ToString())); } return(null); }
public ItemWeightDTO ConvertKGtoPCS(NZString MasterNo, NZString ProcessNo, NZDecimal QtyKG, NZInt processCount) { ItemWeightDTO weightDTO = new ItemWeightDTO(); NZDecimal decQtyPCS = null; //ถ้า convert จาก KG เป็น PCS จะ ใช้น้ำหนักตาม Process ItemProcessDAO dao = new ItemProcessDAO(); ItemProcessDTO itemProcess = new ItemProcessDTO(); itemProcess.ITEM_CD = MasterNo; itemProcess.PROCESS_CD = ProcessNo; itemProcess = dao.LoadWeightByItemProcessCount(CommonLib.Common.CurrentDatabase, itemProcess, new NZInt(null, (processCount.NVL(0) <= 1 ? 1 : processCount.Value))); if (itemProcess != null) { weightDTO.ItemCD = MasterNo; weightDTO.ProcessCD = ProcessNo; weightDTO.QtyKG = QtyKG; decimal decQtyKG = QtyKG.NVL(0); if (itemProcess.WEIGHT.NVL(0) == 0) { decQtyPCS = null; } else { decQtyPCS = new NZDecimal(null, Math.Round(QtyKG / itemProcess.WEIGHT * 1000, MidpointRounding.AwayFromZero)); } if (decQtyPCS != null && decQtyPCS.NVL(0) > 10000000) { EVOFramework.ErrorItem errorItem = null; errorItem = new EVOFramework.ErrorItem(QtyKG.Owner, Rubik.TKPMessages.eValidate.VLM0184.ToString()); EVOFramework.ValidateException.ThrowErrorItem(errorItem); } weightDTO.QtyPCS = decQtyPCS; } return(weightDTO); }
public static ErrorItem CheckQty(NZDecimal nzdQty, decimal iRecieveQty) { decimal dQty = Convert.ToInt32(nzdQty); if (dQty <= 0) { return(new ErrorItem(nzdQty.Owner, Messages.eValidate.VLM0126.ToString())); } else if (dQty > 0 && dQty < iRecieveQty) { return(new ErrorItem(nzdQty.Owner, Messages.eValidate.VLM0127.ToString())); } else { return(null); } }
private bool SaveData() { IssueByEntryController ctlIssue = new IssueByEntryController(); List <IssueByOrderUIDM> uidmIssueList = new List <IssueByOrderUIDM>(); NZString FromLocCD = new NZString(cboFromLoc, cboFromLoc.SelectedValue); NZString ToLocCD = new NZString(cboToLoc, cboToLoc.SelectedValue); NZString TranSubCls = new NZString(cboSubType, cboSubType.SelectedValue); NZString RefSlipNo = new NZString(txtRefDocNo, txtRefDocNo.Text); NZString RefSlipNo2 = new NZString(txtJobOrderNo, txtJobOrderNo.Text); NZString ForCustomer = new NZString(cboForCustomer, cboForCustomer.SelectedValue); int row = shtIssueList.Rows.Count; for (int i = 0; i < row; i++) { IssueByOrderUIDM uidm = new IssueByOrderUIDM(); NZString ItemCD = new NZString(null, shtIssueList.Cells[i, (int)eColView.ITEM_CODE]. Text); NZString LotNo = new NZString(null, shtIssueList.Cells[i, (int)eColView.LOT_NO].Value); NZDecimal Qty = new NZDecimal(null, shtIssueList.Cells[i, (int)eColView.ISSUE_QTY].Value); NZString Remark = new NZString(txtRemark, txtRemark.Text.Trim()); NZDateTime TransDate = new NZDateTime(dtIssueDate, dtIssueDate.Value); uidm.ITEM_CD = ItemCD; uidm.FROM_LOC_CD = FromLocCD; uidm.TO_LOC_CD = ToLocCD; uidm.LOT_NO = LotNo; uidm.QTY = Qty; uidm.REMARK = Remark; uidm.TRANS_DATE = TransDate; uidm.TRANS_CLS = DataDefine.Convert2ClassCode(DataDefine.eTRANS_TYPE.Issuing).ToNZString();//TransCls; uidm.TRAN_SUB_CLS = TranSubCls; uidm.REF_SLIP_NO = RefSlipNo; uidm.REF_SLIP_NO2 = RefSlipNo2; uidm.FOR_CUSTOMER = ForCustomer; uidmIssueList.Add(uidm); } ctlIssue.SaveAddIssue(uidmIssueList); return(true); }