Пример #1
0
        /// <summary>
        /// คัดลอกค่าที่เป็น Header ของ Model ไปเก็บไว้ใน DTO
        /// </summary>
        /// <param name="model"></param>
        /// <param name="dto"></param>
        private void AssignHeaderToDTO(ReceivingEntryUIDM model, InventoryTransactionDTO dto)
        {
            dto.TRANS_DATE  = model.RECEIVE_DATE;
            dto.SLIP_NO     = model.RECEIVE_NO;
            dto.TRANS_CLS   = model.RECEIVE_TYPE;
            dto.REF_SLIP_NO = model.PO_NO;
            dto.OTHER_DL_NO = model.INVOICE_NO;
            dto.REMARK      = model.REMARK;
            dto.LOC_CD      = model.STORED_LOC;
            dto.DEALING_NO  = model.DEALING_NO;
            dto.SCREEN_TYPE = DataDefine.ScreenType.ReceivingEntry.ToNZString();

            dto.REF_SLIP_CLS.Value = DataDefine.Convert2ClassCode(DataDefine.eREF_SLIP_CLS.PurchseOrder);

            if (dto.TRANS_CLS.StrongValue == DataDefine.Convert2ClassCode(DataDefine.eTRANS_TYPE.Receiving))
            {
                dto.IN_OUT_CLS.Value = DataDefine.Convert2ClassCode(DataDefine.eIN_OUT_CLASS.In);
            }
            else
            {
                dto.IN_OUT_CLS.Value = DataDefine.Convert2ClassCode(DataDefine.eIN_OUT_CLASS.Out);
            }

            if (dto.REF_NO.IsNull)
            {
                RunningNumberBIZ runningNumberBIZ = new RunningNumberBIZ();
                NZString         runningNo        = runningNumberBIZ.GetCompleteRunningNo(DataDefine.RECEIVE_REF_NO.ToNZString(), DataDefine.TRANSACTION_TABLE_NAME.ToNZString());
                dto.REF_NO = runningNo;
            }
        }
Пример #2
0
        public InventoryTransactionDTO ConvertUIDMToDTO(AdjustmentEntryUIDM model)
        {
            InventoryTransactionDTO dto = new InventoryTransactionDTO();

            dto.TRANS_ID        = model.TransactionID;
            dto.ITEM_CD         = model.ItemCode;
            dto.LOC_CD          = model.StoredLoc;
            dto.LOT_NO          = (model.LotNo.IsNull || model.LotNo.StrongValue.Trim() == string.Empty) ? new NZString() : model.LotNo;
            dto.TRANS_DATE      = model.AdjustDate;
            dto.TRANS_CLS.Value = DataDefine.Convert2ClassCode(DataDefine.eTRANS_TYPE.Adjustment);
            dto.IN_OUT_CLS      = model.AdjustType;
            dto.QTY             = model.AdjustQty;
            dto.WEIGHT          = model.AdjustWeight;
            dto.PACK_NO         = model.PackNo;
            dto.FG_NO           = model.FGNo;
            dto.EXTERNAL_LOT_NO = model.ExternalLotNo;
            dto.SLIP_NO         = model.AdjustNo;
            dto.GROUP_TRANS_ID  = model.GroupTransID;
            //dto.OBJ_ITEM_CD =
            //dto.REF_NO =
            //dto.REF_SLIP_NO =
            //dto.REF_SLIP_CLS =
            //dto.OTHER_DL_NO =
            dto.REMARK       = model.Remark;
            dto.TRAN_SUB_CLS = model.ReasonCode;
            dto.SCREEN_TYPE  = DataDefine.ScreenType.AdjustmentEntry.ToNZString();
            dto.EFFECT_STOCK = DataDefine.Convert2ClassCode(DataDefine.eIN_OUT_CLASS.In).ToString().Equals(model.AdjustType.StrongValue) ? new NZInt(null, (int)DataDefine.eEFFECT_STOCK.In) : new NZInt(null, (int)DataDefine.eEFFECT_STOCK.Out);
            dto.CRT_BY       = CommonLib.Common.CurrentUserInfomation.UserCD;
            dto.CRT_MACHINE  = CommonLib.Common.CurrentUserInfomation.Machine;
            dto.UPD_BY       = CommonLib.Common.CurrentUserInfomation.UserCD;
            dto.UPD_MACHINE  = CommonLib.Common.CurrentUserInfomation.Machine;
            dto.OLD_DATA     = new NZInt(null, 0);
            return(dto);
        }
Пример #3
0
        private InventoryTransactionDTO CreateDTOForConsumption(MultiWorkResultEntryUIDM model, MultiWorkResultEntryViewDTO line)
        {
            InventoryTransactionDTO dto = new InventoryTransactionDTO();

            dto.TRANS_ID            = line.CONSUMPTION_TRANSACTION_ID;
            dto.ITEM_CD             = model.ChildItemCode;
            dto.LOC_CD              = model.OrderLoc;
            dto.LOT_NO              = line.LOT_NO;
            dto.TRANS_DATE          = model.WorkResultDate;
            dto.TRANS_CLS.Value     = DataDefine.Convert2ClassCode(DataDefine.eTRANS_TYPE.Consumption);
            dto.IN_OUT_CLS.Value    = DataDefine.Convert2ClassCode(DataDefine.eIN_OUT_CLASS.Out);
            dto.QTY.Value           = line.GOOD_QTY.NVL(0) + line.NG_QTY.NVL(0) + line.RESERVE_QTY.NVL(0);
            dto.OBJ_ITEM_CD         = model.ItemCode;
            dto.OBJ_ORDER_QTY.Value = line.GOOD_QTY.NVL(0) + line.NG_QTY.NVL(0) + line.RESERVE_QTY.NVL(0);
            dto.REMARK              = model.Remark;
            dto.REF_SLIP_CLS.Value  = DataDefine.Convert2ClassCode(DataDefine.eREF_SLIP_CLS.WorkResult);
            dto.CRT_BY              = Common.CurrentUserInfomation.UserCD;
            dto.CRT_MACHINE         = Common.CurrentUserInfomation.Machine;
            dto.UPD_BY              = Common.CurrentUserInfomation.UserCD;
            dto.UPD_MACHINE         = Common.CurrentUserInfomation.Machine;
            dto.SHIFT_CLS           = model.ShiftClass;
            dto.SCREEN_TYPE         = DataDefine.ScreenType.WorkResultEntry.ToNZString();
            dto.GROUP_TRANS_ID      = model.WorkResultGroupNo;
            return(dto);
        }
Пример #4
0
        private void miDeleteGroup_Click(object sender, EventArgs e)
        {
            if (shtCustomerOrderList.RowCount > 0)
            {
                int                     rowIndex = shtCustomerOrderList.ActiveRowIndex;
                InventoryBIZ            biz      = new InventoryBIZ();
                InventoryTransactionDTO dto      = new InventoryTransactionDTO();
                dto.REF_NO    = shtCustomerOrderList.GetValue(rowIndex, (int)eColView.ORDER_NO).ToString().ToNZString();
                dto.TRANS_CLS = DataDefine.eTRANS_TYPE_string.Shipment.ToNZString();
                //CustomerOrderDDTO LoadCustomerOrderDetail(String Order_No, NZString Order_Detail_No)
                List <InventoryTransactionDTO> listDTO = biz.LoadInventoryTrans(dto);
                decimal ShipQTY = 0;
                foreach (InventoryTransactionDTO dtos in listDTO)
                {
                    if (!dtos.QTY.IsNull && dtos.QTY.StrongValue > 0)
                    {
                        ShipQTY += dtos.QTY.StrongValue;
                    }
                }
                if (ShipQTY > 0)
                {
                    MessageDialog.ShowBusiness(this, Message.LoadMessage(TKPMessages.eValidate.VLM0205.ToString()));
                    return;
                }
            }

            OnDeleteGroup();
        }
Пример #5
0
        //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
        }
Пример #6
0
        /// <summary>
        /// คัดลอกค่าที่เป็น Header ของ Model ไปเก็บไว้ใน DTO
        /// </summary>
        /// <param name="model"></param>
        /// <param name="dto"></param>
        ///
        private void AssignHeaderToDTO(IssueByOrderUIDM model, InventoryTransactionDTO dto, DataDefine.eIN_OUT_CLASS in_out)
        {
            dto.TRANS_DATE = model.TRANS_DATE;
            //dto.REF_SLIP_NO = model.SLIP_NO;
            dto.TRANS_CLS = DataDefine.Convert2ClassCode(DataDefine.eTRANS_TYPE.Issuing).ToNZString();//model.TRANS_CLS;
            //dto.REF_SLIP_NO = model.INVOICE_NO;
            //dto.OTHER_DL_NO = model.INVOICE_NO;
            dto.REMARK        = model.REMARK;
            dto.OBJ_ITEM_CD   = model.OBJ_ITEM_CD;
            dto.OBJ_ORDER_QTY = model.OBJ_ORDER_QTY;
            dto.REF_SLIP_CLS  = (NZString)DataDefine.Convert2ClassCode(DataDefine.eREF_SLIP_CLS.Issue);
            dto.FOR_CUSTOMER  = model.FOR_CUSTOMER;
            dto.FOR_MACHINE   = model.FOR_MACHINE;
            dto.REF_SLIP_NO2  = model.REF_SLIP_NO2;
            dto.REF_SLIP_NO   = model.REF_SLIP_NO;
            dto.TRAN_SUB_CLS  = model.TRAN_SUB_CLS;
            dto.SCREEN_TYPE   = DataDefine.ScreenType.IssueByOrder.ToNZString();

            if (in_out == DataDefine.eIN_OUT_CLASS.In)
            {
                dto.REF_SLIP_NO      = model.SLIP_NO;
                dto.LOC_CD           = model.TO_LOC_CD;
                dto.IN_OUT_CLS.Value = DataDefine.Convert2ClassCode(DataDefine.eIN_OUT_CLASS.In);
            }
            else
            {
                dto.SLIP_NO          = model.SLIP_NO;
                dto.LOC_CD           = model.FROM_LOC_CD;
                dto.IN_OUT_CLS.Value = DataDefine.Convert2ClassCode(DataDefine.eIN_OUT_CLASS.Out);
            }
        }
Пример #7
0
        private void AssignHeaderToDTO(ReturnEntryUIDM model, InventoryTransactionDTO dto, Common.eScreenMode Mode)
        {
            //dto.TRANS_DATE = model.TRANS_DATE;
            //dto.SLIP_NO = model.SLIP_NO;
            dto.TRANS_CLS          = DataDefine.eTRANS_TYPE_string.Shipment_Return.ToNZString();
            dto.IN_OUT_CLS         = DataDefine.eIN_OUT_CLASS.In.ToString().ToNZString();
            dto.EFFECT_STOCK.Value = (int)DataDefine.eEFFECT_STOCK.In;
            dto.REMARK             = model.REMARK;
            dto.LOC_CD             = model.LOC_CD;
            dto.REF_SLIP_CLS.Value = DataDefine.Convert2ClassCode(DataDefine.eREF_SLIP_CLS.Shipment);
            dto.SCREEN_TYPE        = DataDefine.ScreenType.ReturnEntry.ToNZString();
            dto.DEALING_NO         = model.DEALING_NO;
            if (Mode == Common.eScreenMode.ADD)
            {
                dto.OLD_DATA.Value = 0;
            }
            //dto.CURRENCY = model.CURRENCY;
            dto.TRANS_DATE = model.TRANS_DATE;


            if (dto.TRANS_CLS.StrongValue == DataDefine.Convert2ClassCode(DataDefine.eTRANS_TYPE.Shipment))
            {
                dto.IN_OUT_CLS.Value = DataDefine.Convert2ClassCode(DataDefine.eIN_OUT_CLASS.Out);
            }
            else
            {
                dto.IN_OUT_CLS.Value = DataDefine.Convert2ClassCode(DataDefine.eIN_OUT_CLASS.In);
            }
        }
Пример #8
0
        public void DeleteItem(NZString transactionID)
        {
            try
            {
                InventoryBIZ biz = new InventoryBIZ();

                // for Consumtion item it must delete too
                InventoryTransBIZ bizTran = new InventoryTransBIZ();

                // Delete
                InventoryTransactionDTO        dto        = bizTran.LoadByTransactionID(transactionID);
                List <InventoryTransactionDTO> listConDTO = bizTran.LoadByRefNo(dto.REF_NO);

                Common.CurrentDatabase.KeepConnection = true;
                Common.CurrentDatabase.BeginTransaction();

                biz.DeleteInventoryTransactions(Common.CurrentDatabase, listConDTO);

                Common.CurrentDatabase.Commit();
            }
            catch (Exception ex)
            {
                Common.CurrentDatabase.Rollback();
                throw ex;
            }
            //biz.DeleteInventoryTransaction(Common.CurrentDatabase, transactionID);
        }
Пример #9
0
        private InventoryTransactionDTO CreateDTOForWorkResult(WorkResultEntryUIDM model)
        {
            InventoryTransactionDTO dto = new InventoryTransactionDTO();

            //dto.TRANS_ID = model.TransactionID;
            //dto.ITEM_CD = model.ItemCode;
            //dto.LOC_CD = model.StoredLoc;
            //dto.LOT_NO = model.LotNo;
            //dto.TRANS_DATE = model.WorkResultDate;
            //dto.TRANS_CLS.Value = DataDefine.Convert2ClassCode(DataDefine.eTRANS_TYPE.WorkResult);
            //dto.IN_OUT_CLS.Value = DataDefine.Convert2ClassCode(DataDefine.eIN_OUT_CLASS.In);
            //dto.QTY = model.GoodQty;
            //dto.NG_QTY = model.NGQty;
            //dto.RESERVE_QTY = model.ReserveQty;
            //dto.REMARK = model.Remark;
            //dto.REF_SLIP_NO = model.WorkOrderNo;
            //dto.SLIP_NO = model.WorkResultNo;
            ////dto.REF_SLIP_NO2 = model.WorkOrderNo2;
            //dto.REF_SLIP_CLS.Value = DataDefine.Convert2ClassCode(DataDefine.eREF_SLIP_CLS.WorkOrder);
            //dto.CRT_BY = Common.CurrentUserInfomation.UserCD;
            //dto.CRT_MACHINE = Common.CurrentUserInfomation.Machine;
            //dto.UPD_BY = Common.CurrentUserInfomation.UserCD;
            //dto.UPD_MACHINE = Common.CurrentUserInfomation.Machine;
            //dto.SHIFT_CLS = model.ShipClass;
            //dto.FOR_MACHINE = model.ForMachine;
            //dto.SCREEN_TYPE = DataDefine.ScreenType.WorkResultEntry.ToNZString();
            //dto.NG_REASON = model.NGReason;
            //dto.TRAN_SUB_CLS = DataDefine.eTRAN_SUB_CLS.WR.ToString().ToNZString();
            return(dto);
        }
Пример #10
0
        private bool CheckCanEditOrDelete(int row)
        {
            if (shtPackingList.RowCount <= 0)
            {
                return(false);
            }
            NZString transID         = new NZString(null, shtPackingList.Cells[row, (int)eColView.TRANS_ID].Value);
            bool     canEditOrDelete = m_transactionValidator.TransactionCanEditOrDelete(transID);

            if (canEditOrDelete)
            {
                //Unpack Cannot Delete and Modify
                InventoryTransBIZ       biz = new InventoryTransBIZ();
                InventoryTransactionDTO dto = biz.LoadByTransactionID(transID);
                if (dto != null)
                {
                    if (DataDefine.Convert2ClassCode(DataDefine.eTRANS_TYPE.Unpack).Equals(dto.TRANS_CLS.StrongValue) ||
                        DataDefine.Convert2ClassCode(DataDefine.eTRANS_TYPE.Unpack_Consumption).Equals(dto.TRANS_CLS.StrongValue)
                        )
                    {
                        canEditOrDelete = false;
                    }
                }
            }

            return(canEditOrDelete);
        }
Пример #11
0
        private InventoryTransactionDTO CreateDTOForReserveResult(MultiWorkResultEntryUIDM modelHeader
                                                                  , MultiWorkResultEntryViewDTO dtoDetailEntry)
        {
            InventoryTransactionDTO dto = new InventoryTransactionDTO();

            dto.TRANS_ID         = dtoDetailEntry.RESERVE_TRANSACTION_ID;
            dto.ITEM_CD          = modelHeader.ItemCode;
            dto.LOC_CD           = modelHeader.StoredLoc;
            dto.LOT_NO.Value     = dtoDetailEntry.LOT_NO + DataDefine.LOT_RESERVE_POSTFIX;
            dto.TRANS_DATE       = modelHeader.WorkResultDate;
            dto.TRANS_CLS.Value  = DataDefine.Convert2ClassCode(DataDefine.eTRANS_TYPE.ReserveResult);
            dto.IN_OUT_CLS.Value = DataDefine.Convert2ClassCode(DataDefine.eIN_OUT_CLASS.In);
            dto.QTY                = dtoDetailEntry.RESERVE_QTY;
            dto.RESERVE_QTY        = dtoDetailEntry.RESERVE_QTY;
            dto.REMARK             = modelHeader.Remark;
            dto.REF_SLIP_NO        = modelHeader.WorkOrderNo;
            dto.SLIP_NO            = dtoDetailEntry.WORK_RESULT_NO;
            dto.REF_SLIP_CLS.Value = DataDefine.Convert2ClassCode(DataDefine.eREF_SLIP_CLS.WorkOrder);
            dto.CRT_BY             = Common.CurrentUserInfomation.UserCD;
            dto.CRT_MACHINE        = Common.CurrentUserInfomation.Machine;
            dto.UPD_BY             = Common.CurrentUserInfomation.UserCD;
            dto.UPD_MACHINE        = Common.CurrentUserInfomation.Machine;
            dto.SHIFT_CLS          = modelHeader.ShiftClass;
            dto.SCREEN_TYPE        = DataDefine.ScreenType.WorkResultEntry.ToNZString();
            dto.GROUP_TRANS_ID     = modelHeader.WorkResultGroupNo;
            return(dto);
        }
Пример #12
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="dt"></param>
        /// <returns></returns>
        private List <InventoryTransactionDTO> ConvertDataTableToList(DataTable dt, DataDefine.eIN_OUT_CLASS in_out)
        {
            List <InventoryTransactionDTO> list = new List <InventoryTransactionDTO>();

            foreach (DataRow dr in dt.Rows)
            {
                InventoryTransactionDTO dto       = new InventoryTransactionDTO();
                DataRowVersion          drVersion = DataRowVersion.Current;
                if (dr.RowState == DataRowState.Deleted)
                {
                    drVersion = DataRowVersion.Original;
                }
                dto.ITEM_CD.Value = dr[(int)eColView.ITEM_CODE, drVersion];       // PART_NO,
                dto.LOT_NO.Value  = dr[eColView.LOT_NO.ToString(), drVersion];    //LOT_NO,
                dto.QTY.Value     = dr[eColView.ISSUE_QTY.ToString(), drVersion]; //ISSUE_QTY,
                if (in_out == DataDefine.eIN_OUT_CLASS.Out)
                {
                    dto.TRANS_ID.Value = dr[eColView.TRANS_ID.ToString(), drVersion];
                    dto.REF_NO.Value   = dr[eColView.REF_NO.ToString(), drVersion];
                }
                else
                {
                    dto.REF_NO.Value   = dr[eColView.TRANS_ID.ToString(), drVersion];
                    dto.TRANS_ID.Value = dr[eColView.REF_NO.ToString(), drVersion];
                }
                list.Add(dto);
            }
            return(list);
        }
Пример #13
0
        /// <summary>
        /// Check On hand Inventory function follow business rule
        /// </summary>
        /// <param name="eOperation"></param>
        /// <param name="eInoutCls"></param>
        /// <param name="QTY"></param>
        /// <param name="ItemCD"></param>
        /// <param name="LocationCD"></param>
        /// <param name="LotNo"></param>
        /// <param name="strTranID">in case of Update, this value must be sent, the others send null.</param>
        /// <returns></returns>
        public ErrorItem CheckOnhandQty(DataDefine.eOperationClass eOperation, DataDefine.eIN_OUT_CLASS eInoutCls, NZDecimal QTY, NZString ItemCD, NZString LocationCD, NZString LotNo, NZString strTranID)
        {
            // FIRST CHECK FOR LOCATION IF IT ALLOW NEGATIVE STOCK
            DealingBIZ bizLoc = new DealingBIZ();
            DealingDTO dtoLoc = bizLoc.LoadLocation(LocationCD);

            if (!dtoLoc.ALLOW_NEGATIVE.IsNull && dtoLoc.ALLOW_NEGATIVE.StrongValue == DataDefine.Convert2ClassCode(DataDefine.eALLOW_NEGATIVE.Yes))
            {
                // IF THE LOCATION IS ALLOW FOR NEGATIVE THEN NOT CHECK ONHAND
                return(null);
            }

            //Operation Class
            switch (eOperation)
            {
            case DataDefine.eOperationClass.Add:
                //Do notting
                break;

            case DataDefine.eOperationClass.Update:
                //Find Diff Qty
                InventoryTransBIZ       biz = new InventoryTransBIZ();
                InventoryTransactionDTO dto = biz.LoadByTransactionID(strTranID);
                if (dto != null)
                {
                    QTY = (QTY - dto.QTY).ToNZDecimal();
                }
                break;

            case DataDefine.eOperationClass.Delete:
                //Delete Inverse Qty
                QTY = (-1 * QTY.StrongValue).ToNZDecimal();
                break;
            }

            //inout Class
            if (eInoutCls == DataDefine.eIN_OUT_CLASS.Out)
            {
                QTY = (-1 * QTY.StrongValue).ToNZDecimal();
            }

            // CHECK FOR ONHAND WITH ACTUAL INVENTORY ONHAND
            InventoryBIZ        bizInv             = new InventoryBIZ();
            ActualOnhandViewDTO dtoActOnhand       = bizInv.LoadActualInventoryOnHand(ItemCD, LocationCD, LotNo);
            decimal             decActualOnhandQty = 0;

            if (dtoActOnhand != null && !dtoActOnhand.ONHAND_QTY.IsNull)
            {
                decActualOnhandQty = dtoActOnhand.ONHAND_QTY.StrongValue;
            }

            decActualOnhandQty = decActualOnhandQty + QTY;

            if (decActualOnhandQty < 0)
            {
                return(new ErrorItem(QTY.Owner, TKPMessages.eValidate.VLM0063.ToString(), new[] { ItemCD, LocationCD }));
            }
            return(null);
        }
Пример #14
0
        public InventoryTransactionDTO LoadReserveResult(NZString workResultNo)
        {
            InventoryBIZ            bizInventory = new InventoryBIZ();
            InventoryTransactionDAO dao          = new InventoryTransactionDAO(CommonLib.Common.CurrentDatabase);
            InventoryTransactionDTO dto          = dao.LoadReserveResult(null, workResultNo);

            return(dto);
        }
Пример #15
0
        private void GetShipNo(NZString TranId)
        {
            InventoryTransBIZ       bizInv = new InventoryTransBIZ();
            InventoryTransactionDTO dto    =
                bizInv.LoadShip(TranId);
            NZString shipno = (NZString)dto.SLIP_NO.ToString();

            LoadIssueListForEdit(shipno);
        }
Пример #16
0
        private InventoryTransactionDTO CreateDTOForWorkResult(MultiWorkResultEntryUIDM modelHeader
                                                               , MultiWorkResultEntryViewDTO dtoDetailEntry)
        {
            InventoryTransactionDTO dtoTrans = new InventoryTransactionDTO();

            dtoTrans.TRANS_ID = dtoDetailEntry.GOOD_TRANSACTION_ID;
            dtoTrans.ITEM_CD  = modelHeader.ItemCode;
            dtoTrans.LOC_CD   = modelHeader.StoredLoc;
            if (DataDefine.eTRAN_SUB_CLS.WR.ToString().Equals(modelHeader.TRAN_SUB_CLS))
            {
                dtoTrans.LOT_NO       = dtoDetailEntry.LOT_NO;
                dtoTrans.TRAN_SUB_CLS = DataDefine.eTRAN_SUB_CLS.WR.ToString().ToNZString();
            }
            else if (DataDefine.eTRAN_SUB_CLS.RW.ToString().Equals(modelHeader.TRAN_SUB_CLS))
            {
                if (dtoDetailEntry.LOT_NO.ToString().EndsWith(DataDefine.LOT_RESERVE_POSTFIX))
                {
                    dtoTrans.LOT_NO.Value = dtoDetailEntry.LOT_NO.ToString().Remove(dtoDetailEntry.LOT_NO.ToString().Length - 2);
                }
                else
                {
                    dtoTrans.LOT_NO = dtoDetailEntry.LOT_NO;
                }

                dtoTrans.TRAN_SUB_CLS = DataDefine.eTRAN_SUB_CLS.RW.ToString().ToNZString();
            }
            else
            {
                //ใช้เหมือน WorkResult
                dtoTrans.LOT_NO       = dtoDetailEntry.LOT_NO;
                dtoTrans.TRAN_SUB_CLS = DataDefine.eTRAN_SUB_CLS.WR.ToString().ToNZString();
            }
            dtoTrans.TRANS_DATE       = modelHeader.WorkResultDate;
            dtoTrans.TRANS_CLS.Value  = DataDefine.Convert2ClassCode(DataDefine.eTRANS_TYPE.WorkResult);
            dtoTrans.IN_OUT_CLS.Value = DataDefine.Convert2ClassCode(DataDefine.eIN_OUT_CLASS.In);
            dtoTrans.QTY.Value        = dtoDetailEntry.GOOD_QTY.NVL(0);
            dtoTrans.NG_QTY.Value     = dtoDetailEntry.NG_QTY.NVL(0);
            dtoTrans.REMARK           = modelHeader.Remark;
            dtoTrans.REF_SLIP_NO      = modelHeader.WorkOrderNo;
            dtoTrans.SLIP_NO          = dtoDetailEntry.WORK_RESULT_NO;
            //dtoTrans.REF_SLIP_NO2 = model.WorkOrderNo2; // ไม่มี
            dtoTrans.REF_SLIP_CLS.Value = DataDefine.Convert2ClassCode(DataDefine.eREF_SLIP_CLS.WorkOrder);
            dtoTrans.CRT_BY             = Common.CurrentUserInfomation.UserCD;
            dtoTrans.CRT_MACHINE        = Common.CurrentUserInfomation.Machine;
            dtoTrans.UPD_BY             = Common.CurrentUserInfomation.UserCD;
            dtoTrans.UPD_MACHINE        = Common.CurrentUserInfomation.Machine;
            dtoTrans.SHIFT_CLS          = modelHeader.ShiftClass;
            dtoTrans.FOR_MACHINE        = modelHeader.ForMachine;
            dtoTrans.SCREEN_TYPE        = DataDefine.ScreenType.WorkResultEntry.ToNZString();
            dtoTrans.GROUP_TRANS_ID     = modelHeader.WorkResultGroupNo;
            dtoTrans.RESERVE_QTY.Value  = dtoDetailEntry.RESERVE_QTY.NVL(0);
            dtoTrans.NG_REASON          = dtoDetailEntry.NG_REASON;

            return(dtoTrans);
        }
Пример #17
0
        public NZString GetConsumptionTransID(NZString transID)
        {
            InventoryTransBIZ       biz = new InventoryTransBIZ();
            InventoryTransactionDTO dto = biz.LoadByRefNoAndTransType(transID, DataDefine.Convert2ClassCode(DataDefine.eTRANS_TYPE.Consumption).ToNZString());

            if (dto != null)
            {
                return(dto.TRANS_ID);
            }
            return(new NZString());
        }
Пример #18
0
        /// <summary>
        /// Check exist before manipulate data. If found record will update data. Otherwise insert new data.
        /// </summary>
        /// <param name="database"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        public int AddNewOrUpdate(Database database, InventoryTransactionDTO data)
        {
            Database db = UseDatabase(database);

            if (Exist(database, data.TRANS_ID))
            {
                return(UpdateWithoutPK(db, data));
            }

            return(AddNew(db, data));
        }
Пример #19
0
        private decimal GetIssueQtyFromTransID(NZString TransID)
        {
            InventoryTransBIZ       biz = new InventoryTransBIZ();
            InventoryTransactionDTO dto = biz.LoadByTransactionID(TransID);

            if (dto != null)
            {
                return(dto.QTY.StrongValue);
            }
            return(0);
        }
Пример #20
0
        public AdjustmentEntryUIDM LoadData(NZString transactionID)
        {
            InventoryTransBIZ       dao = new InventoryTransBIZ();
            InventoryTransactionDTO dto = dao.LoadByTransactionID(transactionID);

            if (dto == null)
            {
                return(new AdjustmentEntryUIDM());
            }

            return(ConvertDTOToUIDM(dto));
        }
Пример #21
0
        private List <InventoryTransactionDTO> CreateConsumptionDTO(InventoryTransactionDTO dto)
        {
            List <InventoryTransactionDTO> dtoConList = new List <InventoryTransactionDTO>();
            InventoryTransactionDTO        dtoCon;

            InventoryBIZ biz = new InventoryBIZ();

            // GET LOCATION INFORMATION
            DealingBIZ bizLoc        = new DealingBIZ();
            DealingDTO dtoLoc        = bizLoc.LoadLocation(dto.DEALING_NO);
            bool       AllowNegative = dtoLoc.ALLOW_NEGATIVE.StrongValue == "01";

            //WorkResultController ctrlWR=new WorkResultController ();
            List <WorkResultEntryViewDTO> dtoChildItem = biz.LoadConsumptionListFromItemCode(dto.ITEM_CD, dto.DEALING_NO, dto.QTY);

            for (int j = 0; j < dtoChildItem.Count; j++)
            {
                // GET CONSUMPTION ITEM FROM FIFO PROCESS WRITE BY KIMMIK.
                List <ActualOnhandViewDTO> dtoListActOnhand = biz.FifoListingProcess(Common.CurrentDatabase
                                                                                     , dtoChildItem[j].ITEM_CD.StrongValue, dtoChildItem[j].LOC_CD.StrongValue, dtoChildItem[j].CONSUMPTION_QTY.StrongValue
                                                                                     , !AllowNegative, AllowNegative);
                if (dtoListActOnhand != null && dtoListActOnhand.Count > 0)
                {
                    for (int i = 0; i < dtoListActOnhand.Count; i++)
                    {
                        dtoCon                  = new InventoryTransactionDTO();
                        dtoCon.ITEM_CD          = dtoListActOnhand[i].ITEM_CD;
                        dtoCon.LOC_CD           = dtoListActOnhand[i].LOC_CD;
                        dtoCon.LOT_NO           = dtoListActOnhand[i].LOT_NO;
                        dtoCon.DEALING_NO       = dto.DEALING_NO;
                        dtoCon.TRANS_DATE       = dto.TRANS_DATE;
                        dtoCon.TRANS_CLS.Value  = DataDefine.Convert2ClassCode(DataDefine.eTRANS_TYPE.Consumption);
                        dtoCon.IN_OUT_CLS.Value = DataDefine.Convert2ClassCode(DataDefine.eIN_OUT_CLASS.Out);
                        dtoCon.QTY              = dtoListActOnhand[i].ONHAND_QTY;
                        dtoCon.OBJ_ORDER_QTY    = dto.QTY;
                        dtoCon.OBJ_ITEM_CD      = dto.ITEM_CD;
                        dtoCon.REMARK           = dto.REMARK;
                        dtoCon.CRT_BY           = Common.CurrentUserInfomation.UserCD;
                        dtoCon.CRT_MACHINE      = Common.CurrentUserInfomation.Machine;
                        dtoCon.UPD_BY           = Common.CurrentUserInfomation.UserCD;
                        dtoCon.UPD_MACHINE      = Common.CurrentUserInfomation.Machine;
                        dtoCon.SCREEN_TYPE      = DataDefine.ScreenType.ReceivingEntry.ToNZString();
                        dtoCon.REF_NO           = dto.REF_NO;

                        dtoConList.Add(dtoCon);
                    }
                }
            }



            return(dtoConList);
        }
Пример #22
0
        public AdjustmentEntryUIDM ConvertDTOToUIDM(InventoryTransactionDTO dto)
        {
            AdjustmentEntryUIDM model = new AdjustmentEntryUIDM();

            model.TransactionID = dto.TRANS_ID;
            model.AdjustNo      = dto.SLIP_NO;
            model.AdjustDate    = dto.TRANS_DATE;
            model.AdjustType    = dto.IN_OUT_CLS;
            model.ItemCode      = dto.ITEM_CD;

            model.StoredLoc     = dto.LOC_CD;
            model.LotNo         = dto.LOT_NO;
            model.PackNo        = dto.PACK_NO;
            model.FGNo          = dto.FG_NO;
            model.ExternalLotNo = dto.EXTERNAL_LOT_NO;
            model.AdjustWeight  = dto.WEIGHT;
            model.AdjustQty     = dto.QTY;
            model.Remark        = dto.REMARK;
            model.ReasonCode    = dto.TRAN_SUB_CLS;

            //== Get Item Description.
            ItemBIZ biz     = new ItemBIZ();
            ItemDTO itemDTO = biz.LoadItem(dto.ITEM_CD);

            model.ItemDesc = itemDTO.SHORT_NAME;

            //-- Get Customer Name
            DealingBIZ bizCust = new DealingBIZ();
            DealingDTO dtoCust = bizCust.LoadLocation(itemDTO.CUSTOMER_CD);

            model.CustomerName = dtoCust.LOC_DESC;

            //== Get OnHand.
            InventoryBIZ       inventoryBIZ       = new InventoryBIZ();
            InventoryPeriodBIZ inventoryPeriodBIZ = new InventoryPeriodBIZ();

            InventoryPeriodDTO inventoryPeriodDTO = inventoryPeriodBIZ.LoadCurrentPeriod();
            InventoryOnhandDTO inventoryOnhandDTO = inventoryBIZ.LoadInventoryOnHandByDate(inventoryPeriodDTO.YEAR_MONTH, dto.TRANS_DATE, dto.ITEM_CD, dto.LOC_CD, dto.LOT_NO, dto.PACK_NO);

            if (inventoryOnhandDTO == null)
            {
                model.OnHandQty.Value = 0;
            }
            else
            {
                model.OnHandQty = inventoryOnhandDTO.ON_HAND_QTY;
            }

            return(model);
        }
Пример #23
0
        //public ErrorItem CheckExistReceiveItem(NZString itemCode, NZString lotNo)
        //{
        //    InventoryTransBIZ biz = new InventoryTransBIZ();
        //    InventoryTransactionDTO dto = biz.LoadReceiveItemByLot(itemCode, lotNo);
        //    if (dto != null)
        //    {
        //        return new ErrorItem(null,TKPMessages.eValidate.VLM0064.ToString(), new[] { itemCode.StrongValue, lotNo.StrongValue });
        //    }
        //    return null;
        //}
        public ErrorItem CheckExistReceiveItem(NZString itemCode, NZString lotNo, NZString locCode)
        {
            InventoryTransBIZ biz = new InventoryTransBIZ();

            if (lotNo == null || lotNo.StrongValue == string.Empty)
            {
                return(null);
            }

            InventoryTransactionDTO dto = biz.LoadReceiveItemByLot(itemCode, lotNo, locCode);

            if (dto != null)
            {
                return(new ErrorItem(null, TKPMessages.eValidate.VLM0064.ToString(), new[] { itemCode.StrongValue, lotNo.StrongValue }));
            }
            return(null);
        }
Пример #24
0
        //public ErrorItem CheckLotNo(NZString ItemCD, NZString FromLoc, NZString LotNo) {
        //    ItemBIZ biz = new ItemBIZ();
        //    ItemDTO dto = biz.LoadItem(ItemCD);

        //    switch (DataDefine.ConvertValue2Enum<DataDefine.eLOT_CONTROL_CLS>(dto.LOT_CONTROL_CLS.StrongValue)) {
        //        case DataDefine.eLOT_CONTROL_CLS.No:
        //            if (!LotNo.IsNull || LotNo.StrongValue != string.Empty) {
        //                return new ErrorItem(LotNo.Owner, TKPMessages.eValidate.VLM0065.ToString());
        //            }
        //            break;
        //        case DataDefine.eLOT_CONTROL_CLS.Yes:
        //            if (LotNo.IsNull) {
        //                return new ErrorItem(LotNo.Owner, TKPMessages.eValidate.VLM0050.ToString(), new[] { ItemCD.StrongValue });
        //            }
        //            InventoryBIZ bizInv = new InventoryBIZ();
        //            List<InventoryOnhandDTO> dtolist = new List<InventoryOnhandDTO>();
        //            dtolist = bizInv.LoadLotNoByKey(ItemCD, FromLoc, LotNo);
        //            if (dtolist == null || dtolist.Count == 0) {
        //                return new ErrorItem(LotNo.Owner, TKPMessages.eValidate.VLM0054.ToString(), new[] { LotNo.StrongValue });
        //            }
        //            break;
        //    }

        //    return null;
        //}

        //public ErrorItem CheckOnhandQtyForEditMode(NZDecimal QTY, NZDecimal OnhandQTY, NZString ItemCD, NZString FromLoc)
        //{
        //    if (OnhandQTY.IsNull || OnhandQTY.StrongValue == 0)
        //        return new ErrorItem(QTY.Owner, TKPMessages.eValidate.VLM0029.ToString());

        //    if (QTY.StrongValue > OnhandQTY.StrongValue)
        //    {
        //        return new ErrorItem(QTY.Owner, TKPMessages.eValidate.VLM0063.ToString(), new[] { ItemCD, FromLoc }
        //            );
        //    }
        //    return null;
        //}
        #endregion

        public void ValidateBeforeSaveNew(InventoryTransactionDTO dto, NZDecimal OnhandQty)
        {
            ValidateException  validateException = new ValidateException();
            CommonBizValidator commonVal         = new CommonBizValidator();
            ErrorItem          errorItem         = null;

            #region mandatory check
            errorItem = CheckEmptyItemCode(dto.ITEM_CD);
            if (errorItem != null)
            {
                validateException.AddError(errorItem);
            }

            errorItem = CheckEmptyLocFrom(dto.LOC_CD);
            if (errorItem != null)
            {
                validateException.AddError(errorItem);
            }

            errorItem = CheckEmptySubType(dto.TRAN_SUB_CLS);
            if (errorItem != null)
            {
                validateException.AddError(errorItem);
            }

            errorItem = CheckIssueQTY(dto.QTY);
            if (errorItem != null)
            {
                validateException.AddError(errorItem);
            }

            errorItem = CheckIssueDate(dto.TRANS_DATE);
            if (errorItem != null)
            {
                validateException.AddError(errorItem);
            }

            errorItem = commonVal.CheckInputLot(dto.ITEM_CD, dto.LOC_CD, dto.LOT_NO, true);
            if (errorItem != null)
            {
                validateException.AddError(errorItem);
            }
            validateException.ThrowIfHasError();
            #endregion
        }
Пример #25
0
        public void ValidateBeforeSaveAdd(InventoryTransactionDTO data)
        {
            //Validate Item Code
            ItemValidator itemValidator = new ItemValidator();

            ValidateException.ThrowErrorItem(itemValidator.CheckEmptyItemCode(data.ITEM_CD));

            BusinessException itemNotFound = itemValidator.CheckItemNotExist(data.ITEM_CD);

            if (itemNotFound != null)
            {
                ValidateException.ThrowErrorItem(itemNotFound.Error);
            }
            if (data.TRANS_ID.IsNull)
            {
                if (data.TRANS_CLS.StrongValue == DataDefine.Convert2ClassCode(DataDefine.eTRANS_TYPE.Receiving))
                {
                    ValidateException.ThrowErrorItem(CheckExistReceiveItem(data.ITEM_CD, data.LOT_NO, data.LOC_CD));
                }
                else
                {
                    ValidateException.ThrowErrorItem(CheckNotExistReceiveItem(data.ITEM_CD, data.LOT_NO, data.LOC_CD));
                }


                ////ถ้า Receive ต้อง check ว่า lot นั้นไม่เคยทำ receive มาก่อน
                //if (model.RECEIVE_TYPE.StrongValue.Equals(DataDefine.eTRANS_TYPE_string.Receiving))
                //{
                //    ValidateException.ThrowErrorItem(receivingValidator.CheckExistReceiveItem(dto.ITEM_CD, dto.LOT_NO));
                //}
                //else
                //{
                //    ValidateException.ThrowErrorItem(receivingValidator.CheckNotExistReceiveItem(dto.ITEM_CD, dto.LOT_NO));
                //}
            }


            //Validate Receive Qty
            if (data.QTY.IsNull || data.QTY.StrongValue <= 0)
            {
                ValidateException.ThrowErrorItem(new ErrorItem(data.QTY.Owner, TKPMessages.eValidate.VLM0043.ToString()));
            }
        }
Пример #26
0
        /// <summary>
        /// Update old data.
        /// </summary>
        /// <param name="oldTransactionID"></param>
        /// <param name="newDataModel"></param>
        public void SaveEdit(NZString oldTransactionID, AdjustmentEntryUIDM newDataModel)
        {
            try
            {
                CommonLib.Common.CurrentDatabase.KeepConnection = true;
                CommonLib.Common.CurrentDatabase.BeginTransaction(System.Data.IsolationLevel.Serializable);


                ValidateException    validateException   = new ValidateException();
                AdjustmentValidator  adjustmentValidator = new AdjustmentValidator();
                TransactionValidator valTran             = new TransactionValidator();
                ItemValidator        itemValidator       = new ItemValidator();
                DealingValidator     locationValidator   = new DealingValidator();

                //validateException.AddError(adjustmentValidator.CheckEmptyAdjustDate(newDataModel.AdjustDate));
                //validateException.AddError(adjustmentValidator.CheckEmptyReasonCode(newDataModel.ReasonCode));
                //validateException.AddError(valTran.DateIsInCurrentPeriod(newDataModel.AdjustDate));
                //validateException.AddError(itemValidator.CheckEmptyItemCode(newDataModel.ItemCode));

                BusinessException businessException = itemValidator.CheckItemNotExist(newDataModel.ItemCode);
                if (businessException != null)
                {
                    validateException.AddError(businessException.Error);
                }

                //validateException.AddError(locationValidator.CheckEmptyLocationCode(newDataModel.StoredLoc));
                validateException.AddError(locationValidator.CheckNotExistsLocationCode(newDataModel.StoredLoc));
                //validateException.AddError(adjustmentValidator.CheckEmptyAdjustQty(newDataModel.AdjustQty));
                //validateException.AddError(adjustmentValidator.CheckIsZeroAdjustQty(newDataModel.AdjustQty));
                validateException.ThrowIfHasError();

                InventoryBIZ inventoryBIZ = new InventoryBIZ();

                InventoryTransactionDTO dto = ConvertUIDMToDTO(newDataModel);
                inventoryBIZ.UpdateInventoryTransaction(CommonLib.Common.CurrentDatabase, oldTransactionID, dto);
                CommonLib.Common.CurrentDatabase.Commit();
            }
            catch (System.Exception)
            {
                CommonLib.Common.CurrentDatabase.Rollback();
                throw;
            }
        }
Пример #27
0
        internal void DeleteProductionReport(NZString TransID)
        {
            InventoryBIZ      bizInv      = new InventoryBIZ();
            InventoryTransBIZ bizInvTrans = new InventoryTransBIZ();

            List <InventoryTransactionDTO> dtoList  = new List <InventoryTransactionDTO>();
            InventoryTransactionDTO        dtoTrans = null;

            ProductionReportEntryDTO dtoProduction = bizInvTrans.LoadProductionReport(TransID);

            if (dtoProduction != null)
            {
                //In
                dtoTrans          = new InventoryTransactionDTO();
                dtoTrans.TRANS_ID = dtoProduction.TRANS_ID;
                dtoList.Add(dtoTrans);

                //Out
                dtoTrans          = new InventoryTransactionDTO();
                dtoTrans.TRANS_ID = dtoProduction.REF_NO;
                dtoList.Add(dtoTrans);

                //NG
                DataTable dtNG = bizInvTrans.LoadNGTransaction(dtoProduction.TRANS_ID);
                if (dtNG != null && dtNG.Rows.Count > 0)
                {
                    foreach (DataRow dr in dtNG.Rows)
                    {
                        NZString NGTrans = new NZString(null, dr[(int)ProductionReportEntryViewDTO.eColumns.NG_TRANS_ID]);
                        if (NGTrans == null)
                        {
                            continue;
                        }

                        dtoTrans          = new InventoryTransactionDTO();
                        dtoTrans.TRANS_ID = NGTrans;
                        dtoList.Add(dtoTrans);
                    }
                }
            }

            bizInv.DeleteTransactionList(dtoList);
        }
Пример #28
0
        /// <summary>
        /// Check if Transaction can edit or delete?
        /// </summary>
        /// <param name="transactionID"></param>
        /// <returns></returns>
        public bool TransactionCanEditOrDelete(NZString transactionID)
        {
            InventoryTransBIZ bizInventoryTrans = new InventoryTransBIZ();

            InventoryTransactionDTO dtoInventoryTransaction = bizInventoryTrans.LoadByTransactionID(transactionID);

            if (dtoInventoryTransaction == null)
            {
                return(false);
            }

            ErrorItem err = DateIsInCurrentPeriod(dtoInventoryTransaction.TRANS_DATE.StrongValue);

            if (err == null)
            {
                return(true);
            }

            return(false);
        }
Пример #29
0
        internal void DeleteMovePart(NZString TransIDFrom, NZString TransIDTo)
        {
            InventoryBIZ      bizInv   = new InventoryBIZ();
            InventoryTransBIZ bizTrans = new InventoryTransBIZ();

            List <InventoryTransactionDTO> dtoList = new List <InventoryTransactionDTO>();
            InventoryTransactionDTO        dto     = bizTrans.LoadByTransactionID(TransIDFrom);

            bizInv.DeleteGroupTransaction(dto.GROUP_TRANS_ID);
            ////From
            //dto = new InventoryTransactionDTO();
            //dto.TRANS_ID = TransIDFrom;
            //dtoList.Add(dto);

            ////To
            //dto = new InventoryTransactionDTO();
            //dto.TRANS_ID = TransIDTo;
            //dtoList.Add(dto);

            //bizInv.DeleteTransactionList(dtoList);
            //bizInv.DeleteInventoryTransactions(CommonLib.Common.CurrentDatabase, dtoList);
        }
Пример #30
0
        private List <InventoryTransactionDTO> ConvertDataTableToList(DataTable dt)
        {
            List <InventoryTransactionDTO> list = new List <InventoryTransactionDTO>();

            foreach (DataRow dr in dt.Rows)
            {
                DataRowVersion drVersion = DataRowVersion.Current;
                if (dr.RowState == DataRowState.Deleted)
                {
                    drVersion = DataRowVersion.Original;
                }
                InventoryTransactionDTO dto = new InventoryTransactionDTO();
                dto.ITEM_CD.Value     = dr[(int)eColView.PART_NO, drVersion];     // PART_NO,
                dto.TRANS_ID.Value    = dr[(int)eColView.TRANS_ID, drVersion];    //PART_NAME,
                dto.LOT_NO.Value      = dr[(int)eColView.LOT_NO, drVersion];      //LOT_NO,
                dto.QTY.Value         = dr[(int)eColView.ISSUE_QTY, drVersion];   //ISSUE_QTY,
                dto.OTHER_DL_NO.Value = dr[(int)eColView.OTHER_DL_NO, drVersion]; //OTHER_DL_NO,


                list.Add(dto);
            }
            return(list);
        }