示例#1
0
        private void ValidateBeforeSave()
        {
            AdjustmentValidator  adjustmentValidator = new AdjustmentValidator();
            ItemValidator        itemValidator       = new ItemValidator();
            DealingValidator     locationValidator   = new DealingValidator();
            TransactionValidator valTran             = new TransactionValidator();
            CommonBizValidator   commonVal           = new CommonBizValidator();

            ValidateException.ThrowErrorItem(adjustmentValidator.CheckEmptyAdjustDate(new NZDateTime(dtAdjustDate, dtAdjustDate.Value)));
            ValidateException.ThrowErrorItem(adjustmentValidator.CheckEmptyReasonCode(new NZString(cboReasonCode, cboReasonCode.SelectedValue)));
            ValidateException.ThrowErrorItem(valTran.DateIsInCurrentPeriod(new NZDateTime(dtAdjustDate, dtAdjustDate.Value)));
            ValidateException.ThrowErrorItem(itemValidator.CheckEmptyItemCode(new NZString(txtMasterNo, txtMasterNo.Text.Trim())));
            ValidateException.ThrowErrorItem(locationValidator.CheckEmptyLocationCode(new NZString(cboStoredLoc, cboStoredLoc.SelectedValue)));

            if (cboStoredLoc.SelectedValue == null)
            {
                return;
            }

            string strProcess = cboStoredLoc.SelectedValue.ToString();
            DealingConstraintDTO constriant = bizConstraint.LoadDealingConstraint(strProcess.ToNZString());

            AdjustmentValidator validator = new AdjustmentValidator();
            ErrorItem           errorItem = null;

            //if (constriant != null && constriant.ENABLE_PACK_FLAG.StrongValue == 1)
            //{
            //    errorItem = validator.CheckEmptyPackNo(txtPackNo.ToNZString());
            //    if (null != errorItem)
            //        ValidateException.ThrowErrorItem(errorItem);//error.AddError(errorItem);
            //}

            if (rdoDecrease.Checked && constriant != null && constriant.ENABLE_PACK_FLAG.StrongValue == 1)
            {
                errorItem = validator.CheckEmptyPackNo(txtPackNo.ToNZString());
                if (null != errorItem)
                {
                    ValidateException.ThrowErrorItem(errorItem);
                }
            }

            if (constriant != null && constriant.ENABLE_LOT_FLAG.StrongValue == 1)
            {
                errorItem = validator.CheckEmptyLotNo(txtLotNo.ToNZString());
                if (null != errorItem)
                {
                    ValidateException.ThrowErrorItem(errorItem);//error.AddError(errorItem);
                }
                FormatUtil.CheckFormatLotNo(new NZString(txtLotNo, txtLotNo.Text.Trim()));

                //errorItem = validator.CheckEmptyCustomerLotNo(txtCustomerLotNo.ToNZString());
                //if (null != errorItem)
                //    ValidateException.ThrowErrorItem(errorItem);//error.AddError(errorItem);
            }

            ValidateException.ThrowErrorItem(adjustmentValidator.CheckEmptyAdjustQty(new NZDecimal(txtAdjustQty, txtAdjustQty.Decimal)));
            ValidateException.ThrowErrorItem(adjustmentValidator.CheckIsZeroAdjustQty(new NZDecimal(txtAdjustQty, txtAdjustQty.Decimal)));
        }
示例#2
0
        private void ValidateBeforeSave()
        {
            ItemValidator itemValidator = new ItemValidator();

            ValidateException.ThrowErrorItem(itemValidator.CheckEmptyItemCode(txtMasterNo.Text.ToNZString()));

            //PackingValidator validator = new PackingValidator();
            //ValidateException.ThrowErrorItem(validator.CheckEmptyFGNo(txtFGNo.Text.ToNZString()));
        }
示例#3
0
        protected virtual void OnSave()
        {
            // Validate data
            try {
                ItemValidator itemValidator = new ItemValidator();
                ValidateException.ThrowErrorItem(itemValidator.CheckEmptyItemCode(txtItemCode.ToNZString()));
                BusinessException itemException = itemValidator.CheckItemNotExist(txtItemCode.ToNZString());
                if (itemException != null)
                {
                    ValidateException.ThrowErrorItem(itemException.Error);
                }

                if (txtUpperQty.Decimal == 0)
                {
                    ValidateException.ThrowErrorItem(new ErrorItem(txtUpperQty, string.Empty, "Can't input zero"));
                }

                if (txtLowerQty.Decimal == 0)
                {
                    ValidateException.ThrowErrorItem(new ErrorItem(txtLowerQty, string.Empty, "Can't input zero"));
                }

                ItemController controller = new ItemController();
                ItemUIDM       uidm       = controller.LoadItem(txtItemCode.Text.Trim().ToNZString());

                BOMRegisterUIDM model = new BOMRegisterUIDM();
                model.ITEM_CD   = uidm.ITEM_CD;
                model.ITEM_DESC = uidm.ITEM_DESC;
                //model.ITEM_CLS = uidm.ITEM_CLS;
                //model.LOT_CONTROL_CLS = uidm.LOT_CONTROL_CLS;
                //model.ORDER_LOC_CD = uidm.ORDER_LOC_CD;
                //model.STORE_LOC_CD = uidm.STORE_LOC_CD;
                //model.ORDER_PROCESS_CLS = uidm.ORDER_PROCESS_CLS;
                //model.CONSUMTION_CLS = uidm.CONSUMTION_CLS;
                //model.PACK_SIZE = uidm.PACK_SIZE;
                //model.INV_UM_CLS = uidm.INV_UM_CLS;
                //model.ORDER_UM_CLS = uidm.ORDER_UM_CLS;
                //model.INV_UM_RATE = uidm.INV_UM_RATE;
                //model.ORDER_UM_RATE = uidm.ORDER_UM_RATE;
                model.LOWER_QTY.Value          = txtLowerQty.Decimal;
                model.UPPER_QTY.Value          = txtUpperQty.Decimal;
                model.CHILD_ORDER_LOC_CD.Value = (chkChildOrderLoc.Checked ? null : (string)cboOrderLoc.SelectedValue);
                model.MRP_FLAG.Value           = (chkMRPFlag.Checked ? null : (string)cboMRPFlag.SelectedValue);

                m_model = model;

                this.Close();
            }
            catch (ValidateException err) {
                MessageDialog.ShowBusiness(this, err.ErrorResults[0].Message);
                err.ErrorResults[0].FocusOnControl();
            }
        }
示例#4
0
        private bool ValidateData()
        {
            NZString      ItemCD = new NZString(txtPartNo, txtPartNo.Text.Trim());
            ItemValidator val    = new ItemValidator();
            ErrorItem     err;

            err = val.CheckEmptyItemCode(ItemCD);
            if (err != null)
            {
                ValidateException.ThrowErrorItem(err);
            }
            BusinessException bizErr = val.CheckItemNotExist(ItemCD);

            if (bizErr != null)
            {
                ValidateException.ThrowErrorItem(bizErr.Error);
            }

            if (txtNumberofCopies.Text.Trim() == string.Empty || txtNumberofCopies.Double == 0)
            {
                txtNumberofCopies.Double = 1;
            }
            return(true);
        }
示例#5
0
        public bool SaveData(MultiWorkResultEntryUIDM model)
        {
            ItemBIZ             bizItem      = new ItemBIZ();
            ClassListBIZ        bizClassList = new ClassListBIZ();
            InventoryBIZ        biz          = new InventoryBIZ();
            IssueEntryValidator valLot       = new IssueEntryValidator();

            #region Validate data

            MultiWorkResultEntryValidator workResultEntryValidator = new MultiWorkResultEntryValidator();
            ItemValidator      itemValidator     = new ItemValidator();
            DealingValidator   locationValidator = new DealingValidator();
            CommonBizValidator commonVal         = new CommonBizValidator();
            ValidateException.ThrowErrorItem(workResultEntryValidator.CheckWorkResultDate(model.WorkResultDate));
            ValidateException.ThrowErrorItem(itemValidator.CheckEmptyItemCode(model.ItemCode));
            ValidateException.ThrowErrorItem(itemValidator.CheckEmptyItemCode(model.ChildItemCode));
            ValidateException.ThrowErrorItem(workResultEntryValidator.CheckEmptyShiftType(model.ShiftClass));

            BusinessException itemFound = itemValidator.CheckItemNotExist(model.ItemCode);
            if (itemFound != null)
            {
                ValidateException.ThrowErrorItem(itemFound.Error);
            }

            ValidateException.ThrowErrorItem(locationValidator.CheckEmptyLocationCode(model.OrderLoc));
            ValidateException.ThrowErrorItem(locationValidator.CheckNotExistsLocationCode(model.OrderLoc));

            ValidateException.ThrowErrorItem(locationValidator.CheckEmptyLocationCode(model.StoredLoc));
            ValidateException.ThrowErrorItem(locationValidator.CheckNotExistsLocationCode(model.StoredLoc));

            #endregion

            DataTable dtData = null;
            if (model.DataView == null)
            {
                MultiWorkResultEntryViewDTO dto = new MultiWorkResultEntryViewDTO();
                dto.CreateDataTableSchema(out dtData);
            }
            else
            {
                dtData = model.DataView;
            }


            DataTable dtAdd    = dtData.GetChanges(DataRowState.Added);
            DataTable dtUpdate = dtData.GetChanges(DataRowState.Modified);
            DataTable dtDelete = dtData.GetChanges(DataRowState.Deleted);

            DataTable dtUnChanged = dtData.GetChanges(DataRowState.Unchanged);

            List <InventoryTransactionDTO> listAdd    = new List <InventoryTransactionDTO>();
            List <InventoryTransactionDTO> listUpdate = new List <InventoryTransactionDTO>();
            List <InventoryTransactionDTO> listDelete = new List <InventoryTransactionDTO>();

            List <MultiWorkResultEntryViewDTO> listViewAdd    = DTOUtility.ConvertDataTableToList <MultiWorkResultEntryViewDTO>(dtAdd);
            List <MultiWorkResultEntryViewDTO> listViewUpdate = DTOUtility.ConvertDataTableToList <MultiWorkResultEntryViewDTO>(dtUpdate);
            List <MultiWorkResultEntryViewDTO> listViewDelete = DTOUtility.ConvertDataTableToList <MultiWorkResultEntryViewDTO>(dtDelete);
            List <MultiWorkResultEntryViewDTO> listUnchanged  = DTOUtility.ConvertDataTableToList <MultiWorkResultEntryViewDTO>(dtUnChanged);



            Database db = null;
            try
            {
                db = Common.CurrentDatabase;
                db.KeepConnection = true;
                db.BeginTransaction();

                NZString runningNo            = new NZString();
                NZString strWorkResultGroupNo = new NZString();

                InventoryTransactionDTO dtoWorkResult    = null;
                InventoryTransactionDTO dtoNGResult      = null;
                InventoryTransactionDTO dtoReserveResult = null;
                InventoryTransactionDTO dtoConsumption   = null;


                InventoryTransBIZ bizTran = new InventoryTransBIZ();
                SysConfigBIZ      bizSYS  = new SysConfigBIZ();

                SysConfigDTO dtoSYS = bizSYS.LoadByPK(DataDefine.eSYSTEM_CONFIG.TRN080.SYS_GROUP_ID, (NZString)DataDefine.eSYSTEM_CONFIG.TRN080.SYS_KEY.NG_LOC_CD.ToString());

                //SysConfigDTO dtoSupplyLot = bizSYS.LoadByPK((NZString)"SUPPLY", (NZString)"SUPP_LOT");

                NZString strNGLocation = null;
                if (dtoSYS == null || dtoSYS.CHAR_DATA.IsNull || dtoSYS.CHAR_DATA.StrongValue == "ORDER_LOC")
                {
                    strNGLocation = model.OrderLoc;
                }
                else
                {
                    strNGLocation = dtoSYS.CHAR_DATA;
                }

                RunningNumberBIZ runningNumberBIZ = new RunningNumberBIZ();

                //set Work Result Group No ให้กับทุกตัว
                //ถ้าheader ยังไม่มีก็ genใหม่
                //ถ้าheader มีแล้ว ก็ใช้ตัวนั้น
                if (model.WorkResultGroupNo.IsNull)
                {
                    strWorkResultGroupNo    = runningNumberBIZ.GetCompleteRunningNo((NZString)"WORK_RESULT_GROUP_NO", (NZString)"TB_INV_TRANS_TR");
                    model.WorkResultGroupNo = strWorkResultGroupNo;
                }

                foreach (MultiWorkResultEntryViewDTO dtoAdd in listViewAdd)
                {
                    runningNo = runningNumberBIZ.GetCompleteRunningNo((NZString)"WORK_RESULT_SLIP_NO", (NZString)"TB_INV_TRANS_TR");

                    //ถ้าใส่จำนวนใดจำนวนหนึ่งมา ก็จะ save ได้
                    if (dtoAdd.GOOD_QTY.NVL(0) + dtoAdd.NG_QTY.NVL(0) + dtoAdd.RESERVE_QTY.NVL(0) > 0)
                    {
                        dtoWorkResult         = CreateDTOForWorkResult(model, dtoAdd);
                        dtoWorkResult.SLIP_NO = runningNo;
                        listAdd.Add(dtoWorkResult);

                        if (dtoAdd.NG_QTY.NVL(0) > 0)
                        {
                            dtoNGResult         = CreateDTOForNGResult(model, dtoAdd, strNGLocation);
                            dtoNGResult.SLIP_NO = runningNo;
                            listAdd.Add(dtoNGResult);
                        }

                        //เฉพาะ work result ที่จะมี reserve ได้
                        if (DataDefine.eTRAN_SUB_CLS.WR.ToString().Equals(model.TRAN_SUB_CLS))
                        {
                            if (dtoAdd.RESERVE_QTY.NVL(0) > 0)
                            {
                                dtoReserveResult         = CreateDTOForReserveResult(model, dtoAdd);
                                dtoReserveResult.SLIP_NO = runningNo;
                                listAdd.Add(dtoReserveResult);
                            }
                        }

                        dtoConsumption        = CreateDTOForConsumption(model, dtoAdd);
                        dtoConsumption.REF_NO = dtoWorkResult.SLIP_NO;
                        listAdd.Add(dtoConsumption);
                    }
                }

                foreach (MultiWorkResultEntryViewDTO dtoUnchanged in listUnchanged)
                {
                    dtoWorkResult = CreateDTOForWorkResult(model, dtoUnchanged);
                    listUpdate.Add(dtoWorkResult);
                }


                foreach (MultiWorkResultEntryViewDTO dtoUpdate in listViewUpdate)
                {
                    dtoWorkResult = CreateDTOForWorkResult(model, dtoUpdate);
                    listUpdate.Add(dtoWorkResult);

                    if (dtoUpdate.NG_QTY.NVL(0) > 0)
                    {
                        dtoNGResult = CreateDTOForNGResult(model, dtoUpdate, strNGLocation);

                        if (dtoNGResult.TRANS_ID.IsNull)
                        {
                            listAdd.Add(dtoNGResult);
                        }
                        else
                        {
                            listUpdate.Add(dtoNGResult);
                        }
                    }

                    //เฉพาะ work result ที่จะมี reserve ได้
                    if (DataDefine.eTRAN_SUB_CLS.WR.ToString().Equals(model.TRAN_SUB_CLS))
                    {
                        if (dtoUpdate.RESERVE_QTY.NVL(0) > 0)
                        {
                            dtoReserveResult = CreateDTOForReserveResult(model, dtoUpdate);

                            if (dtoReserveResult.TRANS_ID.IsNull)
                            {
                                listAdd.Add(dtoReserveResult);
                            }
                            else
                            {
                                listUpdate.Add(dtoReserveResult);
                            }
                        }
                    }

                    dtoConsumption        = CreateDTOForConsumption(model, dtoUpdate);
                    dtoConsumption.REF_NO = dtoWorkResult.SLIP_NO;
                    //consumption ใช้การ add เพราะ ใช้การ clear แล้ว insert ใหม่ เลยต้อง add consumption ใหม่ตลอด
                    listAdd.Add(dtoConsumption);

                    biz.ClearConsumption(Common.CurrentDatabase, dtoWorkResult);
                }



                foreach (MultiWorkResultEntryViewDTO dtoDelete in listViewDelete)
                {
                    dtoWorkResult = CreateDTOForWorkResult(model, dtoDelete);
                    listDelete.Add(dtoWorkResult);

                    if (dtoDelete.NG_QTY.NVL(0) > 0)
                    {
                        dtoNGResult = CreateDTOForNGResult(model, dtoDelete, strNGLocation);
                        listDelete.Add(dtoNGResult);
                    }

                    //เฉพาะ work result ที่จะมี reserve ได้
                    if (DataDefine.eTRAN_SUB_CLS.WR.ToString().Equals(model.TRAN_SUB_CLS))
                    {
                        if (dtoDelete.RESERVE_QTY.NVL(0) > 0)
                        {
                            dtoReserveResult = CreateDTOForReserveResult(model, dtoDelete);
                            listDelete.Add(dtoReserveResult);
                        }
                    }

                    dtoConsumption = CreateDTOForConsumption(model, dtoDelete);
                    listDelete.Add(dtoConsumption);
                }


                biz.WorkResultItems(Common.CurrentDatabase, listAdd, listUpdate, listDelete);

                db.Commit();
            }
            catch (Exception ex)
            {
                db.Rollback();
                throw ex;
            }
            finally
            {
                if (db.DBConnectionState == ConnectionState.Open)
                {
                    db.Close();
                }
            }

            return(true);
        }
示例#6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="model"></param>
        /// <returns>If save data operation completed will return true. Otherwise return false.</returns>
        public bool SaveData(WorkResultEntryUIDM model, DataDefine.eCONSUMPTION_CLS ConsumptionClass)
        {
            ItemBIZ             bizItem      = new ItemBIZ();
            ClassListBIZ        bizClassList = new ClassListBIZ();
            InventoryBIZ        biz          = new InventoryBIZ();
            IssueEntryValidator valLot       = new IssueEntryValidator();
            // Load default over consumption checking.
            ClassListDTO dtoOverConsumptionCheck = bizClassList.LoadByPK((NZString)DataDefine.OVER_CONSUME_CHK, (NZString)DataDefine.Convert2ClassCode(DataDefine.eOVER_CONSUME_CHK.DEFAULT));
            bool         bOverConsumeChk         = false;

            if (dtoOverConsumptionCheck != null && dtoOverConsumptionCheck.CLS_DESC.NVL(String.Empty) == "1")
            {
                bOverConsumeChk = true;
            }


            //string mode = "UPD";
            //if (model.WorkOrderNo.IsNull)
            //{
            //    mode = "ADD";
            //}

            #region Validate data
            //== Validate Header, contain: ItemCode, Order Location and Qty.
            #region Validate mandatory
            WorkResultEntryValidator workResultEntryValidator = new WorkResultEntryValidator();
            ItemValidator            itemValidator            = new ItemValidator();
            DealingValidator         locationValidator        = new DealingValidator();
            CommonBizValidator       commonVal = new CommonBizValidator();
            ValidateException.ThrowErrorItem(workResultEntryValidator.CheckWorkResultDate(model.WorkResultDate));
            ValidateException.ThrowErrorItem(itemValidator.CheckEmptyItemCode(model.ItemCode));
            ValidateException.ThrowErrorItem(workResultEntryValidator.CheckEmptyShiftType(model.ShipClass));
            ValidateException.ThrowErrorItem(workResultEntryValidator.CheckDifferentLocationOfItem(model.DataView));

            BusinessException itemFound = itemValidator.CheckItemNotExist(model.ItemCode);
            if (itemFound != null)
            {
                ValidateException.ThrowErrorItem(itemFound.Error);
            }
            if (ConsumptionClass != DataDefine.eCONSUMPTION_CLS.No)
            {
                ValidateException.ThrowErrorItem(locationValidator.CheckEmptyLocationCode(model.OrderLoc));
                ValidateException.ThrowErrorItem(locationValidator.CheckNotExistsLocationCode(model.OrderLoc));
            }

            ValidateException.ThrowErrorItem(locationValidator.CheckEmptyLocationCode(model.StoredLoc));
            ValidateException.ThrowErrorItem(locationValidator.CheckNotExistsLocationCode(model.StoredLoc));
            ValidateException.ThrowErrorItem(workResultEntryValidator.CheckWorkResultQty(model.WorkResultQty));
            ValidateException.ThrowErrorItem(workResultEntryValidator.CheckWorkResultGoodQty((NZDecimal)(model.WorkResultQty.StrongValue - model.NGQty.StrongValue)));

            // Check LotNo
            ValidateException.ThrowErrorItem(commonVal.CheckInputLot(model.ItemCode, new NZString(), model.LotNo, false));
            #endregion

            //== Validate Detail list.
            if (ConsumptionClass == DataDefine.eCONSUMPTION_CLS.Manual)
            {
                List <WorkResultEntryViewDTO> listItems = DTOUtility.ConvertDataTableToList <WorkResultEntryViewDTO>(model.DataView);

                #region Validate detail list.
                // Check ItemCD & LotNo
                List <string> listInvalidLotNo          = new List <string>();
                List <string> listInvalidConsumptionQty = new List <string>();

                for (int i = 0; i < listItems.Count; i++)
                {
                    BusinessException itemChildNotFound = itemValidator.CheckItemNotExist(listItems[i].ITEM_CD);
                    if (itemChildNotFound != null)
                    {
                        ValidateException.ThrowErrorItem(itemChildNotFound.Error);
                    }

                    ItemDTO dtoItem             = bizItem.LoadItem(listItems[i].ITEM_CD);
                    WorkResultEntryViewDTO line = listItems[i];
                    //line.LOT_CONTROL_CLS = dtoItem.LOT_CONTROL_CLS;

                    if (line.LOT_CONTROL_CLS.StrongValue == DataDefine.Convert2ClassCode(DataDefine.eLOT_CONTROL_CLS.Yes) &&
                        (line.LOT_NO.IsNull || line.LOT_NO.StrongValue.Trim() == string.Empty))
                    {
                        if (listInvalidLotNo.Contains(line.ITEM_CD.StrongValue))
                        {
                            continue;
                        }
                        listInvalidLotNo.Add(line.ITEM_CD.StrongValue);
                    }

                    if (bOverConsumeChk)
                    {
                        if (line.CONSUMPTION_QTY.StrongValue > line.ON_HAND_QTY.StrongValue)
                        {
                            if (listInvalidConsumptionQty.Contains(line.ITEM_CD.StrongValue))
                            {
                                continue;
                            }
                            listInvalidConsumptionQty.Add(line.ITEM_CD.StrongValue);
                        }
                    }
                    ValidateException.ThrowErrorItem(commonVal.CheckInputLot(line.ITEM_CD, line.LOC_CD, line.LOT_NO, true));
                }

                // Generate item doesn't input LOT_NO
                if (listInvalidLotNo.Count > 0)
                {
                    listInvalidLotNo.Sort();

                    string errorItems = string.Empty;
                    for (int i = 0; i < listInvalidLotNo.Count; i++)
                    {
                        if (i != 0)
                        {
                            errorItems += ", ";
                        }
                        errorItems += listInvalidLotNo[i];
                    }

                    ValidateException.ThrowErrorItem(new ErrorItem(null, TKPMessages.eValidate.VLM0050.ToString(), new object[] { errorItems }));
                    return(false);
                }


                // Generate list item that input consumption qty more than stock onhand qty.
                if (listInvalidConsumptionQty.Count > 0)
                {
                    listInvalidConsumptionQty.Sort();

                    string errorItems = string.Empty;
                    for (int i = 0; i < listInvalidConsumptionQty.Count; i++)
                    {
                        if (i != 0)
                        {
                            errorItems += ", ";
                        }
                        errorItems += listInvalidConsumptionQty[i];
                    }

                    ValidateException.ThrowErrorItem(new ErrorItem(null, TKPMessages.eValidate.VLM0051.ToString(), new object[] { errorItems }));
                    return(false);
                }
                #endregion

                // Validate Child Item to support Parent Item.
                #region Validate Child Item to support Parent item.
                // Summary Consumption Qty by Item (not include LotNo) and then check compare with RequestQty.
                InventoryBIZ bizInventory = new InventoryBIZ();
                List <WorkResultEntryViewDTO> listSourceChildItems = bizInventory.LoadConsumptionListFromItemCode(model.ItemCode, model.OrderLoc, model.WorkResultQty);
                for (int i = 0; i < listSourceChildItems.Count; i++)
                {
                    object objSumByItem = model.DataView.Compute(
                        String.Format("SUM({0})", WorkResultEntryViewDTO.eColumns.CONSUMPTION_QTY),
                        String.Format("{0} = '{1}'", WorkResultEntryViewDTO.eColumns.ITEM_CD, listSourceChildItems[i].ITEM_CD.StrongValue)
                        );



                    decimal sumConsumptionQty = 0;
                    if (objSumByItem != null && objSumByItem != DBNull.Value)
                    {
                        sumConsumptionQty = Convert.ToDecimal(objSumByItem);
                    }

                    decimal diffQty = Math.Abs(sumConsumptionQty - listSourceChildItems[i].CONSUMPTION_QTY.StrongValue);
                    if (sumConsumptionQty < listSourceChildItems[i].REQUEST_QTY.StrongValue)  // Total of ConsumtpionQty < RequestQty
                    {
                        // Confirmation to continue save.
                        MessageDialogResult dr = MessageDialog.ShowConfirmation(null, Message.LoadMessage(TKPMessages.eConfirm.CFM0001.ToString(),
                                                                                                          new object[]
                        {
                            listSourceChildItems[i].ITEM_CD.StrongValue,
                            model.ItemCode.StrongValue,
                            diffQty.ToString(DataDefine.DEFAULT_FORMAT_NUMBER)
                        }),
                                                                                MessageDialogButtons.YesNo);

                        if (dr == MessageDialogResult.No)
                        {
                            return(false);
                        }
                    }
                    else if (sumConsumptionQty > listSourceChildItems[i].REQUEST_QTY.StrongValue)  // Total of ConsumtpionQty > RequestQty
                    {
                        // Confirmation to continue save.
                        MessageDialogResult dr = MessageDialog.ShowConfirmation(null, Message.LoadMessage(TKPMessages.eConfirm.CFM0002.ToString(),
                                                                                                          new object[]
                        {
                            listSourceChildItems[i].ITEM_CD.StrongValue,
                            model.ItemCode.StrongValue,
                            diffQty.ToString(DataDefine.DEFAULT_FORMAT_NUMBER)
                        }),
                                                                                MessageDialogButtons.YesNo);

                        if (dr == MessageDialogResult.No)
                        {
                            return(false);
                        }
                    }
                }
                #endregion
            }

            #endregion
            DataTable dtData;
            if (model.DataView == null)
            {
                WorkResultEntryViewDTO dto = new WorkResultEntryViewDTO();
                dto.CreateDataTableSchema(out dtData);
            }
            else
            {
                dtData = model.DataView;
            }


            DataTable dtAdd    = dtData.GetChanges(DataRowState.Added);
            DataTable dtUpdate = dtData.GetChanges(DataRowState.Modified);
            DataTable dtDelete = dtData.GetChanges(DataRowState.Deleted);

            List <InventoryTransactionDTO> listAdd    = new List <InventoryTransactionDTO>();
            List <InventoryTransactionDTO> listUpdate = new List <InventoryTransactionDTO>();
            List <InventoryTransactionDTO> listDelete = new List <InventoryTransactionDTO>();
            Database db = null;
            try
            {
                db = Common.CurrentDatabase;
                db.KeepConnection = true;
                db.BeginTransaction();

                //TransactionValidator valTran = new TransactionValidator();
                //InventoryTransBIZ bizTran = new InventoryTransBIZ();
                //bizTran.l

                #region Header
                NZString runningNo = new NZString();

                //ให้ generate lot ใหม่อีกครั้ง กรณีกรอกพร้อมกัน 2 เครื่อง ไม่งั้นมันจะ insert ข้อมูลมั่ว
                // ที่ใส่ตรงนี้เพราะว่า จะได้แก้ model.LotNo ก่อนที่จะสร้าง  object dto
                //เนื่องจาก reserve ก็มีดึง lot no ไปใช้
                if (model.WorkResultNo.IsNull)
                {
                    RunningNumberBIZ runnningBiz      = new RunningNumberBIZ();
                    NZString         strCompleteLotNo = runnningBiz.GetCompleteLotNo(new NZDateTime(null, model.WorkResultDate.StrongValue), model.StoredLoc, model.ItemCode, new NZInt(null, 0));
                    model.LotNo = strCompleteLotNo;
                }

                InventoryTransactionDTO dtoWorkResult    = CreateDTOForWorkResult(model);
                InventoryTransactionDTO dtoNGResult      = CreateDTOForNGResult(model);
                InventoryTransactionDTO dtoReserveResult = CreateDTOForReserveResult(model);

                InventoryTransBIZ bizTran = new InventoryTransBIZ();
                bizTran.LockRefSlipNumber(dtoWorkResult.REF_SLIP_NO);

                if (model.WorkResultNo.IsNull)
                {
                    RunningNumberBIZ runningNumberBIZ = new RunningNumberBIZ();
                    runningNo = runningNumberBIZ.GetCompleteRunningNo((NZString)"WORK_RESULT_SLIP_NO", (NZString)"TB_INV_TRANS_TR");

                    // Create new transaction.
                    dtoWorkResult.SLIP_NO    = runningNo;
                    dtoNGResult.SLIP_NO      = runningNo;
                    dtoReserveResult.SLIP_NO = runningNo;

                    listAdd.Add(dtoWorkResult);
                    if (model.NGQty.NVL(0) > 0)
                    {
                        listAdd.Add(dtoNGResult);
                    }

                    if (model.ReserveQty.NVL(0) > 0)
                    {
                        listAdd.Add(dtoReserveResult);
                    }
                }
                else
                {
                    // Update old transaction
                    runningNo = model.WorkResultNo;

                    listUpdate.Add(dtoWorkResult);

                    if (!model.NGTransactionID.IsNull) // UPDATE NG IF IT ALREADY HAS NG QTY
                    {
                        listUpdate.Add(dtoNGResult);
                    }
                    else if (model.NGQty.NVL(0) > 0) // ADD NEW NG TRANS IF NEW NG IS INPUT
                    {
                        //dtoNGResult.SLIP_NO = dtoWorkResult.SLIP_NO;
                        listAdd.Add(dtoNGResult);
                    }

                    if (!model.ReserveTransactionID.IsNull) // UPDATE Reserve IF IT ALREADY HAS Reserve QTY
                    {
                        listUpdate.Add(dtoReserveResult);
                    }
                    else if (model.ReserveQty.NVL(0) > 0) // ADD NEW Reserve TRANS IF NEW NG IS INPUT
                    {
                        //dtoReserveResult.SLIP_NO = dtoWorkResult.SLIP_NO;
                        listAdd.Add(dtoNGResult);
                    }
                }

                #endregion

                #region Detail

                #region Do Auto Consumption
                if (ConsumptionClass == DataDefine.eCONSUMPTION_CLS.Auto)
                {
                    // WHEN CONSUMPTION IS AUTO
                    // DELETE ALL OLD TRANSACTION FIRST THEN ADD NEW

                    //Modify by Bunyapat L.
                    //28 Apr 2011
                    //ให้สั่ง ClearConsumption ไปเลย
                    List <WorkResultEntryViewDTO>  listTMPDelete = null;
                    List <InventoryTransactionDTO> listTmpDelete = null;

                    if (dtData != null && dtData.Rows.Count > 0)
                    {
                        listTMPDelete = DTOUtility.ConvertDataTableToList <WorkResultEntryViewDTO>(dtData);
                        listTmpDelete = new List <InventoryTransactionDTO>();
                        for (int i = 0; i < listTMPDelete.Count; i++)
                        {
                            WorkResultEntryViewDTO  line = listTMPDelete[i];
                            InventoryTransactionDTO dto  = CreateDTOForConsumption(model, line);
                            dto.REF_NO = runningNo;

                            listTmpDelete.Add(dto);
                        }

                        // Move to delete below section
                        //biz.WorkResultItems(Common.CurrentDatabase, null, null, listTmpDelete);
                    }

                    biz.ClearConsumption(Common.CurrentDatabase, dtoWorkResult);

                    if (dtData != null && dtData.Rows.Count > 0)
                    {
                        List <WorkResultEntryViewDTO> listTMPAdd = DTOUtility.ConvertDataTableToList <WorkResultEntryViewDTO>(dtData);

                        // GET LOCATION INFORMATION
                        DealingBIZ bizLoc = new DealingBIZ();
                        for (int i = 0; i < listTMPAdd.Count; i++)
                        {
                            DealingDTO dtoLoc        = bizLoc.LoadLocation(listTMPAdd[i].LOC_CD);
                            bool       AllowNegative = dtoLoc.ALLOW_NEGATIVE.StrongValue == "01";


                            // GET CONSUMPTION ITEM FROM FIFO PROCESS WRITE BY KIMMIK.
                            List <ActualOnhandViewDTO> dtoListActOnhand = biz.FifoListingProcess(Common.CurrentDatabase
                                                                                                 , listTMPAdd[i].ITEM_CD.StrongValue, listTMPAdd[i].LOC_CD.StrongValue
                                                                                                 , listTMPAdd[i].CONSUMPTION_QTY.StrongValue
                                                                                                 , !AllowNegative, AllowNegative);
                            if (dtoListActOnhand != null && dtoListActOnhand.Count > 0)
                            {
                                for (int j = 0; j < dtoListActOnhand.Count; j++)
                                {
                                    InventoryTransactionDTO dto = CreateDTOForConsumption(model, dtoListActOnhand[j]);
                                    dto.REF_NO = runningNo;

                                    listAdd.Add(dto);
                                }
                            }
                        }
                    }
                    biz.WorkResultItems(Common.CurrentDatabase, listAdd, listUpdate, listDelete);
                }
                #endregion

                #region Do Manual Consumption
                if (ConsumptionClass == DataDefine.eCONSUMPTION_CLS.Manual)
                {
                    List <InventoryTransactionDTO> listTmpDelete = new List <InventoryTransactionDTO>();
                    //== Update process.
                    //Modify by Bunyapat L.
                    //28 Apr 2011
                    //Manual consumption ให้ใช้การ insert เข้า Delete ทุกตัวที่เป็นตัวเก่า
                    //แล้วค่อย Add ตัวใหม่แทน เพราะข้างใน function มันจะทำการ clear consumption ทั้งหมด ไม่งั้นจะเกิด bug ตอน update
                    if (dtUpdate != null && dtUpdate.Rows.Count > 0)
                    {
                        List <WorkResultEntryViewDTO> listViewUpdate = DTOUtility.ConvertDataTableToList <WorkResultEntryViewDTO>(dtUpdate);


                        for (int i = 0; i < listViewUpdate.Count; i++)
                        {
                            WorkResultEntryViewDTO line = listViewUpdate[i];

                            // Copy ค่า Header จาก Model ไปยัง DTO แต่ละตัว
                            InventoryTransactionDTO dto = CreateDTOForConsumption(model, line);
                            dto.REF_NO = runningNo;

                            //listUpdate.Add(dto);
                            listAdd.Add(dto);
                            listTmpDelete.Add((InventoryTransactionDTO)dto.Clone());
                        }
                    }

                    //== Insert process.
                    if (dtAdd != null && dtAdd.Rows.Count > 0)
                    {
                        List <WorkResultEntryViewDTO> listViewAdd = DTOUtility.ConvertDataTableToList <WorkResultEntryViewDTO>(dtAdd);

                        for (int i = 0; i < listViewAdd.Count; i++)
                        {
                            WorkResultEntryViewDTO  line = listViewAdd[i];
                            InventoryTransactionDTO dto  = CreateDTOForConsumption(model, line);
                            dto.REF_NO = runningNo;

                            listAdd.Add(dto);
                        }
                    }


                    //== Delete process.
                    if (dtDelete != null && dtDelete.Rows.Count > 0)
                    {
                        List <WorkResultEntryViewDTO> listViewDelete = DTOUtility.ConvertDataTableToList <WorkResultEntryViewDTO>(dtDelete);
                        for (int i = 0; i < dtDelete.Rows.Count; i++)
                        {
                            WorkResultEntryViewDTO line = listViewDelete[i];

                            // Copy ค่า Header จาก Model ไปยัง DTO แต่ละตัว
                            InventoryTransactionDTO dto = CreateDTOForConsumption(model, line);
                            dto.REF_NO = runningNo;

                            listDelete.Add(dto);
                        }
                    }
                    biz.WorkResultItems(Common.CurrentDatabase, null, null, listTmpDelete);
                    biz.WorkResultItems(Common.CurrentDatabase, listAdd, listUpdate, listDelete);
                }
                #endregion

                #region Do No Consumption
                if (ConsumptionClass == DataDefine.eCONSUMPTION_CLS.No)
                {
                    biz.WorkResultItems(Common.CurrentDatabase, listAdd, listUpdate, listDelete);
                }
                #endregion
                #endregion

                db.Commit();
            }
            catch (Exception)
            {
                db.Rollback();
                throw;
            }
            finally
            {
                if (db.DBConnectionState == ConnectionState.Open)
                {
                    db.Close();
                }
            }

            return(true);
        }
示例#7
0
        public void SaveNewPacking(PackingEntryUIDM data, int NumberOfBox)
        {
            try
            {
                #region Validate

                ItemValidator itemValidator = new ItemValidator();
                ValidateException.ThrowErrorItem(itemValidator.CheckEmptyItemCode(data.MASTER_NO));

                BusinessException businessException = itemValidator.CheckItemNotExist(data.MASTER_NO);
                if (businessException != null)
                {
                    ValidateException.ThrowErrorItem(businessException.Error);
                }

                #endregion

                InventoryBIZ biz = new InventoryBIZ();

                SysConfigBIZ sysBiz                = new SysConfigBIZ();
                SysConfigDTO defaultSourceLoc      = sysBiz.LoadByPK(DataDefine.eSYSTEM_CONFIG.TRN320.SYS_GROUP_ID, (NZString)DataDefine.eSYSTEM_CONFIG.TRN320.SYS_KEY.SOURCE_LOC.ToString());
                SysConfigDTO defaultDestinationLoc = sysBiz.LoadByPK(DataDefine.eSYSTEM_CONFIG.TRN320.SYS_GROUP_ID, (NZString)DataDefine.eSYSTEM_CONFIG.TRN320.SYS_KEY.DEST_LOC.ToString());

                InventoryTransactionDTO        Source          = new InventoryTransactionDTO();
                List <InventoryTransactionDTO> DestinationList = new List <InventoryTransactionDTO>();

                #region Destination

                foreach (DataRow dr in data.DATA_VIEW.Rows)
                {
                    InventoryTransactionDTO dto = new InventoryTransactionDTO();
                    dto.CRT_BY = Common.CurrentUserInfomation.UserCD;
                    //dto.CRT_DATE
                    dto.CRT_MACHINE = Common.CurrentUserInfomation.Machine;
                    dto.UPD_BY      = Common.CurrentUserInfomation.UserCD;
                    //dto.UPD_DATE
                    dto.UPD_MACHINE = Common.CurrentUserInfomation.Machine;
                    //dto.TRANS_ID
                    dto.ITEM_CD         = data.MASTER_NO;
                    dto.LOC_CD          = defaultDestinationLoc.CHAR_DATA;
                    dto.LOT_NO          = new NZString(null, dr[(int)PackingEntryUIDM.eColView.LOT_NO]);
                    dto.FG_NO           = data.FG_NO;
                    dto.PACK_NO         = data.PACK_NO;
                    dto.EXTERNAL_LOT_NO = new NZString(null, dr[(int)PackingEntryUIDM.eColView.EXTERNAL_LOT_NO]);
                    dto.TRANS_DATE      = data.PACKING_DATE;
                    dto.TRANS_CLS       = DataDefine.Convert2ClassCode(DataDefine.eTRANS_TYPE.Packing).ToNZString();
                    dto.IN_OUT_CLS      = DataDefine.Convert2ClassCode(DataDefine.eIN_OUT_CLASS.In).ToNZString();
                    dto.FG_NO           = data.FG_NO;

                    if (dr[(int)PackingEntryUIDM.eColView.QTY] == null ||
                        dr[(int)PackingEntryUIDM.eColView.QTY] == (object)DBNull.Value)
                    {
                        dto.QTY = new NZDecimal(null, 0);
                    }
                    else
                    {
                        dto.QTY = new NZDecimal(null, dr[(int)PackingEntryUIDM.eColView.QTY]);
                    }

                    //dto.WEIGHT
                    //dto.OBJ_ITEM_CD
                    //dto.OBJ_ORDER_QTY
                    //dto.REF_NO
                    //dto.REF_SLIP_NO
                    //dto.REF_SLIP_CLS
                    //dto.OTHER_DL_NO
                    //dto.SLIP_NO
                    dto.REMARK = data.REMARK;
                    //dto.DEALING_NO
                    //dto.PRICE
                    //dto.AMOUNT
                    //dto.FOR_CUSTOMER
                    //dto.FOR_MACHINE
                    dto.SHIFT_CLS = data.SHIFT_CLS;
                    //dto.REF_SLIP_NO2
                    //dto.NG_QTY
                    //dto.NG_WEIGHT
                    //dto.TRAN_SUB_CLS =
                    dto.SCREEN_TYPE = DataDefine.ScreenType.PackingEntry.ToNZString();
                    //dto.GROUP_TRANS_ID
                    //dto.RESERVE_QTY
                    //dto.RETURN_QTY
                    //dto.NG_REASON
                    dto.EFFECT_STOCK = new NZInt(null, (int)DataDefine.eEFFECT_STOCK.In);
                    //dto.LOT_REMARK
                    dto.PERSON_IN_CHARGE = data.PERSON_IN_CHARGE;
                    //dto.CURRENCY
                    //dto.REWORK_FLAG
                    dto.OLD_DATA = new NZInt(null, 0);
                    //dto.TIME_STAMP

                    DestinationList.Add(dto);
                }

                #endregion

                #region Pack

                Source.CRT_BY = Common.CurrentUserInfomation.UserCD;
                //Source.CRT_DATE
                Source.CRT_MACHINE = Common.CurrentUserInfomation.Machine;
                Source.UPD_BY      = Common.CurrentUserInfomation.UserCD;
                //Source.UPD_DATE
                Source.UPD_MACHINE = Common.CurrentUserInfomation.Machine;
                //Source.TRANS_ID
                Source.ITEM_CD = data.MASTER_NO;
                Source.LOC_CD  = defaultSourceLoc.CHAR_DATA;
                //Source.LOT_NO
                Source.FG_NO   = data.FG_NO;
                Source.PACK_NO = data.PACK_NO;
                //Source.EXTERNAL_LOT_NO
                Source.TRANS_DATE = data.PACKING_DATE;
                Source.TRANS_CLS  = DataDefine.Convert2ClassCode(DataDefine.eTRANS_TYPE.Packing_Consumption).ToNZString();
                Source.IN_OUT_CLS = DataDefine.Convert2ClassCode(DataDefine.eIN_OUT_CLASS.Out).ToNZString();
                Source.QTY        = data.TOTAL_QTY;
                //Source.WEIGHT
                //Source.OBJ_ITEM_CD
                //Source.OBJ_ORDER_QTY
                //Source.REF_NO
                //Source.REF_SLIP_NO
                //Source.REF_SLIP_CLS
                //Source.OTHER_DL_NO
                //Source.SLIP_NO
                Source.REMARK = data.REMARK;
                //Source.DEALING_NO
                //Source.PRICE
                //Source.AMOUNT
                //Source.FOR_CUSTOMER
                //Source.FOR_MACHINE
                Source.SHIFT_CLS = data.SHIFT_CLS;
                //Source.REF_SLIP_NO2
                //Source.NG_QTY
                //Source.NG_WEIGHT
                //Source.TRAN_SUB_CLS =
                Source.SCREEN_TYPE = DataDefine.ScreenType.PackingEntry.ToNZString();
                //Source.GROUP_TRANS_ID
                //Source.RESERVE_QTY
                //Source.RETURN_QTY
                //Source.NG_REASON
                Source.EFFECT_STOCK = new NZInt(null, (int)DataDefine.eEFFECT_STOCK.Out);
                //Source.LOT_REMARK
                Source.PERSON_IN_CHARGE = data.PERSON_IN_CHARGE;
                //Source.CURRENCY
                //Source.REWORK_FLAG
                Source.OLD_DATA = new NZInt(null, 0);
                //Source.TIME_STAMP

                #endregion

                biz.AddPacking(DestinationList, Source, NumberOfBox);
            }
            catch (Exception)
            {
                throw;
            }
        }
示例#8
0
        public void SaveNewUnPacking(UnPackingEntryUIDM data)
        {
            try
            {
                #region Validate

                ItemValidator itemValidator = new ItemValidator();
                ValidateException.ThrowErrorItem(itemValidator.CheckEmptyItemCode(data.ITEM_CD));

                BusinessException businessException = itemValidator.CheckItemNotExist(data.ITEM_CD);
                if (businessException != null)
                {
                    ValidateException.ThrowErrorItem(businessException.Error);
                }

                #endregion

                InventoryBIZ biz = new InventoryBIZ();

                SysConfigBIZ sysBiz                = new SysConfigBIZ();
                SysConfigDTO defaultSourceLoc      = sysBiz.LoadByPK(DataDefine.eSYSTEM_CONFIG.TRN330.SYS_GROUP_ID, (NZString)DataDefine.eSYSTEM_CONFIG.TRN330.SYS_KEY.SOURCE_LOC.ToString());
                SysConfigDTO defaultDestinationLoc = sysBiz.LoadByPK(DataDefine.eSYSTEM_CONFIG.TRN330.SYS_GROUP_ID, (NZString)DataDefine.eSYSTEM_CONFIG.TRN330.SYS_KEY.DEST_LOC.ToString());

                List <InventoryTransactionDTO> SourceList  = new List <InventoryTransactionDTO>();
                InventoryTransactionDTO        Destination = new InventoryTransactionDTO();

                #region source
                data.TOTAL_QTY = new NZDecimal(null, 0);
                foreach (DataRow dr in data.DATA_VIEW.Rows)
                {
                    InventoryTransactionDTO dto = new InventoryTransactionDTO();
                    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.ITEM_CD         = data.ITEM_CD;
                    dto.LOC_CD          = defaultSourceLoc.CHAR_DATA;
                    dto.PACK_NO         = new NZString(null, dr[(int)UnPackingEntryUIDM.eColView.PACK_NO]);
                    dto.FG_NO           = new NZString(null, dr[(int)UnPackingEntryUIDM.eColView.FG_NO]);
                    dto.LOT_NO          = new NZString(null, dr[(int)UnPackingEntryUIDM.eColView.LOT_NO]);
                    dto.EXTERNAL_LOT_NO = new NZString(null, dr[(int)UnPackingEntryUIDM.eColView.EXTERNAL_LOT_NO]);
                    dto.TRANS_DATE      = data.UNPACKING_DATE;
                    dto.TRANS_CLS       = DataDefine.Convert2ClassCode(DataDefine.eTRANS_TYPE.Unpack_Consumption).ToNZString();
                    dto.IN_OUT_CLS      = DataDefine.Convert2ClassCode(DataDefine.eIN_OUT_CLASS.Out).ToNZString();

                    if (dr[(int)UnPackingEntryUIDM.eColView.ONHAND_QTY] == null ||
                        dr[(int)UnPackingEntryUIDM.eColView.ONHAND_QTY] == (object)DBNull.Value)
                    {
                        dto.QTY = new NZDecimal(null, 0);
                    }
                    else
                    {
                        dto.QTY         = new NZDecimal(null, dr[(int)UnPackingEntryUIDM.eColView.ONHAND_QTY]);
                        data.TOTAL_QTY += dto.QTY;
                    }

                    dto.REMARK           = data.REMARK;
                    dto.SHIFT_CLS        = data.SHIFT_CLS;
                    dto.PERSON_IN_CHARGE = data.PERSON_IN_CHARGE;
                    dto.SCREEN_TYPE      = DataDefine.ScreenType.UnPackingEntry.ToNZString();
                    dto.EFFECT_STOCK     = new NZInt(null, (int)DataDefine.eEFFECT_STOCK.Out);
                    dto.OLD_DATA         = new NZInt(null, 0);
                    //dto.TIME_STAMP

                    SourceList.Add(dto);
                }

                #endregion

                #region Destination (Unpack)

                Destination.CRT_BY           = Common.CurrentUserInfomation.UserCD;
                Destination.CRT_MACHINE      = Common.CurrentUserInfomation.Machine;
                Destination.UPD_BY           = Common.CurrentUserInfomation.UserCD;
                Destination.UPD_MACHINE      = Common.CurrentUserInfomation.Machine;
                Destination.ITEM_CD          = data.ITEM_CD;
                Destination.LOC_CD           = defaultDestinationLoc.CHAR_DATA;
                Destination.TRANS_DATE       = data.UNPACKING_DATE;
                Destination.TRANS_CLS        = DataDefine.Convert2ClassCode(DataDefine.eTRANS_TYPE.Unpack).ToNZString();
                Destination.IN_OUT_CLS       = DataDefine.Convert2ClassCode(DataDefine.eIN_OUT_CLASS.In).ToNZString();
                Destination.QTY              = data.TOTAL_QTY;
                Destination.REMARK           = data.REMARK;
                Destination.SHIFT_CLS        = data.SHIFT_CLS;
                Destination.SCREEN_TYPE      = DataDefine.ScreenType.UnPackingEntry.ToNZString();
                Destination.EFFECT_STOCK     = new NZInt(null, (int)DataDefine.eEFFECT_STOCK.In);
                Destination.PERSON_IN_CHARGE = data.PERSON_IN_CHARGE;
                Destination.OLD_DATA         = new NZInt(null, 0);

                #endregion

                biz.AddUnPacking(SourceList, Destination);
            }
            catch (Exception)
            {
                throw;
            }
        }
示例#9
0
        public void SaveUpdatePacking(PackingEntryUIDM data)
        {
            try
            {
                #region Validate

                ItemValidator itemValidator = new ItemValidator();
                ValidateException.ThrowErrorItem(itemValidator.CheckEmptyItemCode(data.MASTER_NO));

                BusinessException businessException = itemValidator.CheckItemNotExist(data.MASTER_NO);
                if (businessException != null)
                {
                    ValidateException.ThrowErrorItem(businessException.Error);
                }

                #endregion

                InventoryBIZ      biz         = new InventoryBIZ();
                InventoryTransBIZ bizInvTrans = new InventoryTransBIZ();

                //SysConfigBIZ sysBiz = new SysConfigBIZ();
                //SysConfigDTO defaultSourceLoc = sysBiz.LoadByPK(DataDefine.eSYSTEM_CONFIG.TRN320.SYS_GROUP_ID, (NZString)DataDefine.eSYSTEM_CONFIG.TRN320.SYS_KEY.SOURCE_LOC.ToString());
                //SysConfigDTO defaultDestinationLoc = sysBiz.LoadByPK(DataDefine.eSYSTEM_CONFIG.TRN320.SYS_GROUP_ID, (NZString)DataDefine.eSYSTEM_CONFIG.TRN320.SYS_KEY.DEST_LOC.ToString());

                InventoryTransactionDTO        Source        = null;
                List <InventoryTransactionDTO> NewLotList    = null;
                List <InventoryTransactionDTO> ModifyLotList = null;
                List <InventoryTransactionDTO> DeleteLotList = null;

                DataTable dt = data.DATA_VIEW;

                DataTable dtNew    = dt.GetChanges(DataRowState.Added);
                DataTable dtDelete = dt.GetChanges(DataRowState.Deleted);
                DataTable dtModify = dt.GetChanges(DataRowState.Modified);

                ModifyLotList = new List <InventoryTransactionDTO>();

                #region Pack

                Source = bizInvTrans.LoadByTransactionID(data.TRANS_ID);

                //Source.CRT_BY = Common.CurrentUserInfomation.UserCD;
                //Source.CRT_DATE
                //Source.CRT_MACHINE = Common.CurrentUserInfomation.Machine;
                Source.UPD_BY = Common.CurrentUserInfomation.UserCD;
                //Source.UPD_DATE
                Source.UPD_MACHINE = Common.CurrentUserInfomation.Machine;
                //Source.TRANS_ID
                //Source.ITEM_CD = data.MASTER_NO;
                //Source.LOC_CD = data.SOURCE_LOC;
                //Source.LOT_NO
                Source.FG_NO = data.FG_NO;
                //Source.PACK_NO = data.PACK_NO;
                //Source.EXTERNAL_LOT_NO
                //Source.TRANS_DATE = data.PACKING_DATE;
                //Source.TRANS_CLS = DataDefine.Convert2ClassCode(DataDefine.eTRANS_TYPE.Packing_Consumption).ToNZString();
                //Source.IN_OUT_CLS = DataDefine.Convert2ClassCode(DataDefine.eIN_OUT_CLASS.Out).ToNZString();
                Source.QTY = data.TOTAL_QTY;
                //Source.WEIGHT
                //Source.OBJ_ITEM_CD
                //Source.OBJ_ORDER_QTY
                //Source.REF_NO
                //Source.REF_SLIP_NO
                //Source.REF_SLIP_CLS
                //Source.OTHER_DL_NO
                //Source.SLIP_NO
                Source.REMARK = data.REMARK;
                //Source.DEALING_NO
                //Source.PRICE
                //Source.AMOUNT
                //Source.FOR_CUSTOMER
                //Source.FOR_MACHINE
                Source.SHIFT_CLS = data.SHIFT_CLS;
                //Source.REF_SLIP_NO2
                //Source.NG_QTY
                //Source.NG_WEIGHT
                //Source.TRAN_SUB_CLS =
                Source.SCREEN_TYPE = DataDefine.ScreenType.PackingEntry.ToNZString();
                //Source.GROUP_TRANS_ID
                //Source.RESERVE_QTY
                //Source.RETURN_QTY
                //Source.NG_REASON
                Source.EFFECT_STOCK = new NZInt(null, (int)DataDefine.eEFFECT_STOCK.Out);
                //Source.LOT_REMARK
                Source.PERSON_IN_CHARGE = data.PERSON_IN_CHARGE;
                //Source.CURRENCY
                //Source.REWORK_FLAG
                Source.OLD_DATA = new NZInt(null, 0);
                //Source.TIME_STAMP

                ModifyLotList.Add(Source);
                #endregion

                #region Destination : Modify Record

                if (dtModify != null)
                {
                    foreach (DataRow dr in dtModify.Rows)
                    {
                        InventoryTransactionDTO dto = bizInvTrans.LoadByTransactionID(new NZString(null, dr[(int)PackingEntryUIDM.eColView.TRANS_ID]));
                        //dto.CRT_BY = Common.CurrentUserInfomation.UserCD;
                        //dto.CRT_DATE
                        //dto.CRT_MACHINE = Common.CurrentUserInfomation.Machine;
                        dto.UPD_BY = Common.CurrentUserInfomation.UserCD;
                        //dto.UPD_DATE
                        dto.UPD_MACHINE = Common.CurrentUserInfomation.Machine;
                        //dto.TRANS_ID
                        //dto.ITEM_CD = data.MASTER_NO;
                        //dto.LOC_CD = defaultDestinationLoc.CHAR_DATA;
                        //dto.LOT_NO = new NZString(null, dr[(int)PackingEntryUIDM.eColView.LOT_NO]);
                        dto.FG_NO = data.FG_NO;
                        //dto.PACK_NO = data.PACK_NO;
                        dto.EXTERNAL_LOT_NO = new NZString(null, dr[(int)PackingEntryUIDM.eColView.EXTERNAL_LOT_NO]);
                        //dto.TRANS_DATE = data.PACKING_DATE;
                        //dto.TRANS_CLS = DataDefine.Convert2ClassCode(DataDefine.eTRANS_TYPE.Packing).ToNZString();
                        //dto.IN_OUT_CLS = DataDefine.Convert2ClassCode(DataDefine.eIN_OUT_CLASS.In).ToNZString();

                        if (dr[(int)PackingEntryUIDM.eColView.QTY] == null ||
                            dr[(int)PackingEntryUIDM.eColView.QTY] == (object)DBNull.Value)
                        {
                            dto.QTY = new NZDecimal(null, 0);
                        }
                        else
                        {
                            dto.QTY = new NZDecimal(null, dr[(int)PackingEntryUIDM.eColView.QTY]);
                        }

                        //dto.WEIGHT
                        //dto.OBJ_ITEM_CD
                        //dto.OBJ_ORDER_QTY
                        //dto.REF_NO
                        //dto.REF_SLIP_NO
                        //dto.REF_SLIP_CLS
                        //dto.OTHER_DL_NO
                        //dto.SLIP_NO
                        dto.REMARK = data.REMARK;
                        //dto.DEALING_NO
                        //dto.PRICE
                        //dto.AMOUNT
                        //dto.FOR_CUSTOMER
                        //dto.FOR_MACHINE
                        dto.SHIFT_CLS = data.SHIFT_CLS;
                        //dto.REF_SLIP_NO2
                        //dto.NG_QTY
                        //dto.NG_WEIGHT
                        //dto.TRAN_SUB_CLS =
                        dto.SCREEN_TYPE = DataDefine.ScreenType.PackingEntry.ToNZString();
                        //dto.GROUP_TRANS_ID
                        //dto.RESERVE_QTY
                        //dto.RETURN_QTY
                        //dto.NG_REASON
                        dto.EFFECT_STOCK = new NZInt(null, (int)DataDefine.eEFFECT_STOCK.In);
                        //dto.LOT_REMARK
                        dto.PERSON_IN_CHARGE = data.PERSON_IN_CHARGE;
                        //dto.CURRENCY
                        //dto.REWORK_FLAG
                        dto.OLD_DATA = new NZInt(null, 0);
                        //dto.TIME_STAMP

                        ModifyLotList.Add(dto);
                    }
                }

                #endregion

                #region Destination : New Record

                if (dtNew != null)
                {
                    NewLotList = new List <InventoryTransactionDTO>();

                    foreach (DataRow dr in dtNew.Rows)
                    {
                        InventoryTransactionDTO dto = new InventoryTransactionDTO();
                        dto.CRT_BY = Common.CurrentUserInfomation.UserCD;
                        //dto.CRT_DATE
                        dto.CRT_MACHINE = Common.CurrentUserInfomation.Machine;
                        dto.UPD_BY      = Common.CurrentUserInfomation.UserCD;
                        //dto.UPD_DATE
                        dto.UPD_MACHINE = Common.CurrentUserInfomation.Machine;
                        //dto.TRANS_ID
                        dto.ITEM_CD         = data.MASTER_NO;
                        dto.LOC_CD          = data.DEST_LOC;
                        dto.LOT_NO          = new NZString(null, dr[(int)PackingEntryUIDM.eColView.LOT_NO]);
                        dto.FG_NO           = data.FG_NO;
                        dto.PACK_NO         = data.PACK_NO;
                        dto.EXTERNAL_LOT_NO = new NZString(null, dr[(int)PackingEntryUIDM.eColView.EXTERNAL_LOT_NO]);
                        dto.TRANS_DATE      = data.PACKING_DATE;
                        dto.TRANS_CLS       = DataDefine.Convert2ClassCode(DataDefine.eTRANS_TYPE.Packing).ToNZString();
                        dto.IN_OUT_CLS      = DataDefine.Convert2ClassCode(DataDefine.eIN_OUT_CLASS.In).ToNZString();

                        if (dr[(int)PackingEntryUIDM.eColView.QTY] == null ||
                            dr[(int)PackingEntryUIDM.eColView.QTY] == (object)DBNull.Value)
                        {
                            dto.QTY = new NZDecimal(null, 0);
                        }
                        else
                        {
                            dto.QTY = new NZDecimal(null, dr[(int)PackingEntryUIDM.eColView.QTY]);
                        }

                        //dto.WEIGHT
                        //dto.OBJ_ITEM_CD
                        //dto.OBJ_ORDER_QTY
                        //dto.REF_NO
                        //dto.REF_SLIP_NO
                        //dto.REF_SLIP_CLS
                        //dto.OTHER_DL_NO
                        dto.SLIP_NO = data.PACKING_NO;
                        dto.REMARK  = data.REMARK;
                        //dto.DEALING_NO
                        //dto.PRICE
                        //dto.AMOUNT
                        //dto.FOR_CUSTOMER
                        //dto.FOR_MACHINE
                        dto.SHIFT_CLS = data.SHIFT_CLS;
                        //dto.REF_SLIP_NO2
                        //dto.NG_QTY
                        //dto.NG_WEIGHT
                        //dto.TRAN_SUB_CLS =
                        dto.SCREEN_TYPE    = DataDefine.ScreenType.PackingEntry.ToNZString();
                        dto.GROUP_TRANS_ID = Source.GROUP_TRANS_ID;
                        //dto.RESERVE_QTY
                        //dto.RETURN_QTY
                        //dto.NG_REASON
                        dto.EFFECT_STOCK = new NZInt(null, (int)DataDefine.eEFFECT_STOCK.In);
                        //dto.LOT_REMARK
                        dto.PERSON_IN_CHARGE = data.PERSON_IN_CHARGE;
                        //dto.CURRENCY
                        //dto.REWORK_FLAG
                        dto.OLD_DATA = new NZInt(null, 0);
                        //dto.TIME_STAMP

                        NewLotList.Add(dto);
                    }
                }
                #endregion

                #region Destination : Delete Record

                if (dtDelete != null)
                {
                    DeleteLotList = new List <InventoryTransactionDTO>();

                    List <InventoryTransactionDTO> listDelete = DTOUtility.ConvertDataTableToList <InventoryTransactionDTO>(dtDelete);

                    foreach (InventoryTransactionDTO dtoDelete in listDelete)
                    {
                        if (dtoDelete.TRANS_ID == null || dtoDelete.TRANS_ID == (object)DBNull.Value)
                        {
                            continue;
                        }

                        InventoryTransactionDTO dto = bizInvTrans.LoadByTransactionID(new NZString(null, dtoDelete.TRANS_ID));

                        DeleteLotList.Add(dto);
                    }
                }

                #endregion

                biz.UpdatePacking(NewLotList, ModifyLotList, DeleteLotList);
            }
            catch (Exception)
            {
                throw;
            }
        }
示例#10
0
        public void SaveNewProductionReport(ProductionReportEntryUIDM data)
        {
            try
            {
                ItemValidator itemValidator = new ItemValidator();
                ValidateException.ThrowErrorItem(itemValidator.CheckEmptyItemCode(data.MASTER_NO));

                BusinessException businessException = itemValidator.CheckItemNotExist(data.MASTER_NO);
                if (businessException != null)
                {
                    ValidateException.ThrowErrorItem(businessException.Error);
                }

                InventoryBIZ         bizInv        = new InventoryBIZ();
                DealingConstraintBIZ bizConstraint = new DealingConstraintBIZ();
                DealingConstraintDTO constriant    = bizConstraint.LoadDealingConstraint(data.PROCESS);

                InventoryTransactionDTO dtoInvMainTransIn  = new InventoryTransactionDTO();
                InventoryTransactionDTO dtoInvMainTransOut = null;

                #region Main Transaction : for good qty
                dtoInvMainTransIn.CRT_BY = Common.CurrentUserInfomation.UserCD;
                //dtoInvMainTransIn.CRT_DATE =
                dtoInvMainTransIn.CRT_MACHINE = Common.CurrentUserInfomation.Machine;
                dtoInvMainTransIn.UPD_BY      = Common.CurrentUserInfomation.UserCD;
                //dtoInvMainTransIn.UPD_DATE =
                dtoInvMainTransIn.UPD_MACHINE = Common.CurrentUserInfomation.Machine;
                //dtoInvMainTransIn.TRANS_ID =
                dtoInvMainTransIn.ITEM_CD = data.MASTER_NO;
                dtoInvMainTransIn.LOC_CD  = data.PROCESS;
                //dtoInvMainTransIn.LOT_NO =
                //dtoInvMainTransIn.PACK_NO =
                dtoInvMainTransIn.EXTERNAL_LOT_NO = data.CUST_LOT_NO;
                dtoInvMainTransIn.TRANS_DATE      = data.PRODUCTION_REPORT_DATE;
                dtoInvMainTransIn.TRANS_CLS       = DataDefine.Convert2ClassCode(DataDefine.eTRANS_TYPE.WorkResult).ToNZString();
                dtoInvMainTransIn.IN_OUT_CLS      = DataDefine.Convert2ClassCode(DataDefine.eIN_OUT_CLASS.In).ToNZString();
                dtoInvMainTransIn.QTY             = data.QTY;
                dtoInvMainTransIn.WEIGHT          = data.WEIGHT;
                //dtoInvMainTransIn.OBJ_ITEM_CD =
                //dtoInvMainTransIn.OBJ_ORDER_QTY =
                //dtoInvMainTransIn.REF_NO =
                //dtoInvMainTransIn.REF_SLIP_NO =
                //dtoInvMainTransIn.REF_SLIP_CLS =
                //dtoInvMainTransIn.OTHER_DL_NO =
                //dtoInvMainTransIn.SLIP_NO =
                dtoInvMainTransIn.REMARK     = data.REMARK;
                dtoInvMainTransIn.DEALING_NO = data.SUPPLIER;
                //dtoInvMainTransIn.PRICE =
                //dtoInvMainTransIn.AMOUNT =
                //dtoInvMainTransIn.FOR_CUSTOMER =
                dtoInvMainTransIn.FOR_MACHINE = data.MACHINE_NO;
                dtoInvMainTransIn.SHIFT_CLS   = data.SHIFT;
                //dtoInvMainTransIn.REF_SLIP_NO2 =
                dtoInvMainTransIn.NG_QTY = data.NG_QTY;
                //dtoInvMainTransIn.NG_WEIGHT =
                //dtoInvMainTransIn.TRAN_SUB_CLS = new NZString(null, data.REWORK.StrongValue);
                dtoInvMainTransIn.TRAN_SUB_CLS = Convert.ToInt32(data.REWORK.StrongValue) == (int)DataDefine.eTRAN_SUB_CLS.RW ?
                                                 new NZString(null, DataDefine.eTRAN_SUB_CLS.RW.ToString()) :
                                                 new NZString(null, DataDefine.eTRAN_SUB_CLS.WR.ToString());
                dtoInvMainTransIn.REWORK_FLAG = new NZInt(data.REWORK.Owner, Convert.ToInt32(data.REWORK));//(data.REWORK.NVL("WR") == DataDefine.eTRAN_SUB_CLS.RW.ToString() ? 1 : 0).ToNZInt();

                dtoInvMainTransIn.SCREEN_TYPE = DataDefine.ScreenType.WorkResultEntry.ToNZString();
                //dtoInvMainTransIn.GROUP_TRANS_ID =
                //dtoInvMainTransIn.RESERVE_QTY =
                //dtoInvMainTransIn.NG_REASON =
                dtoInvMainTransIn.EFFECT_STOCK     = new NZInt(null, (int)DataDefine.eEFFECT_STOCK.In);
                dtoInvMainTransIn.LOT_REMARK       = data.LOT_NO;
                dtoInvMainTransIn.PERSON_IN_CHARGE = data.PERSON_IN_CHARGE;
                //dtoInvMainTransIn.CURRENCY =
                dtoInvMainTransIn.OLD_DATA = new NZInt(null, 0);

                #endregion

                if (constriant == null || constriant.NO_CONSUMPTION_FLAG.StrongValue == 0)
                {
                    dtoInvMainTransOut = new InventoryTransactionDTO();

                    #region Main Transaction for used qty(qty + ng)
                    dtoInvMainTransOut.CRT_BY = Common.CurrentUserInfomation.UserCD;
                    //dtoInvMainTransOut.CRT_DATE =
                    dtoInvMainTransOut.CRT_MACHINE = Common.CurrentUserInfomation.Machine;
                    dtoInvMainTransOut.UPD_BY      = Common.CurrentUserInfomation.UserCD;
                    //dtoInvMainTransOut.UPD_DATE =
                    dtoInvMainTransOut.UPD_MACHINE = Common.CurrentUserInfomation.Machine;
                    //dtoInvMainTransOut.TRANS_ID =
                    dtoInvMainTransOut.ITEM_CD = data.MASTER_NO;
                    dtoInvMainTransOut.LOC_CD  = data.PROCESS;
                    //dtoInvMainTransOut.LOT_NO =
                    //dtoInvMainTransOut.PACK_NO =
                    dtoInvMainTransOut.EXTERNAL_LOT_NO = data.CUST_LOT_NO;
                    dtoInvMainTransOut.TRANS_DATE      = data.PRODUCTION_REPORT_DATE;
                    dtoInvMainTransOut.TRANS_CLS       = DataDefine.Convert2ClassCode(DataDefine.eTRANS_TYPE.Consumption).ToNZString();
                    dtoInvMainTransOut.IN_OUT_CLS      = DataDefine.Convert2ClassCode(DataDefine.eIN_OUT_CLASS.Out).ToNZString();
                    dtoInvMainTransOut.QTY             = new NZDecimal(null, data.QTY.StrongValue + data.NG_QTY.StrongValue);
                    dtoInvMainTransOut.WEIGHT          = data.WEIGHT;
                    //dtoInvMainTransOut.OBJ_ITEM_CD =
                    //dtoInvMainTransOut.OBJ_ORDER_QTY =
                    //dtoInvMainTransOut.REF_NO =
                    //dtoInvMainTransOut.REF_SLIP_NO =
                    //dtoInvMainTransOut.REF_SLIP_CLS =
                    //dtoInvMainTransOut.OTHER_DL_NO =
                    //dtoInvMainTransOut.SLIP_NO =
                    dtoInvMainTransOut.REMARK     = data.REMARK;
                    dtoInvMainTransOut.DEALING_NO = data.SUPPLIER;
                    //dtoInvMainTransOut.PRICE =
                    //dtoInvMainTransOut.AMOUNT =
                    //dtoInvMainTransOut.FOR_CUSTOMER =
                    dtoInvMainTransOut.FOR_MACHINE = data.MACHINE_NO;
                    dtoInvMainTransOut.SHIFT_CLS   = data.SHIFT;
                    //dtoInvMainTransOut.REF_SLIP_NO2 =
                    //dtoInvMainTransOut.NG_QTY = data.NG_QTY;
                    //dtoInvMainTransOut.NG_WEIGHT =
                    //dtoInvMainTransOut.TRAN_SUB_CLS = new NZString(null, DataDefine.eTRAN_SUB_CLS.WR.ToString());
                    dtoInvMainTransOut.SCREEN_TYPE = DataDefine.ScreenType.WorkResultEntry.ToNZString();
                    //dtoInvMainTransOut.GROUP_TRANS_ID =
                    //dtoInvMainTransOut.RESERVE_QTY =
                    //dtoInvMainTransOut.NG_REASON =
                    dtoInvMainTransOut.EFFECT_STOCK     = new NZInt(null, (int)DataDefine.eEFFECT_STOCK.Out);
                    dtoInvMainTransOut.LOT_REMARK       = data.LOT_NO;
                    dtoInvMainTransOut.PERSON_IN_CHARGE = data.PERSON_IN_CHARGE;
                    //dtoInvMainTransOut.CURRENCY =
                    dtoInvMainTransOut.OLD_DATA = new NZInt(null, 0);

                    #endregion
                }

                #region NG Transaction

                List <InventoryTransactionDTO> listNG = new List <InventoryTransactionDTO>();

                DataTable dtData = data.DataView;
                foreach (DataRow dr in dtData.Rows)
                {
                    InventoryTransactionDTO dtoNG = new InventoryTransactionDTO();
                    dtoNG.CRT_BY = Common.CurrentUserInfomation.UserCD;
                    //dtoNG.CRT_DATE =
                    dtoNG.CRT_MACHINE = Common.CurrentUserInfomation.Machine;
                    dtoNG.UPD_BY      = Common.CurrentUserInfomation.UserCD;
                    //dtoNG.UPD_DATE =
                    dtoNG.UPD_MACHINE = Common.CurrentUserInfomation.Machine;
                    //dtoNG.TRANS_ID =
                    dtoNG.ITEM_CD = data.MASTER_NO;
                    dtoNG.LOC_CD  = data.PROCESS;
                    //dtoNG.LOT_NO =
                    //dtoNG.PACK_NO =
                    dtoNG.EXTERNAL_LOT_NO = data.CUST_LOT_NO;
                    dtoNG.TRANS_DATE      = data.PRODUCTION_REPORT_DATE;
                    dtoNG.TRANS_CLS       = DataDefine.Convert2ClassCode(DataDefine.eTRANS_TYPE.NGWorkResult).ToNZString();
                    dtoNG.IN_OUT_CLS      = DataDefine.Convert2ClassCode(DataDefine.eIN_OUT_CLASS.None).ToNZString();
                    if (dr[(int)ProductionReportEntryViewDTO.eColumns.NG_QTY] == null || dr[(int)ProductionReportEntryViewDTO.eColumns.NG_QTY] == (object)DBNull.Value)
                    {
                        dtoNG.QTY    = new NZDecimal(null, 0);
                        dtoNG.NG_QTY = new NZDecimal(null, 0);
                    }
                    else
                    {
                        dtoNG.QTY    = new NZDecimal(null, dr[(int)ProductionReportEntryViewDTO.eColumns.NG_QTY]);
                        dtoNG.NG_QTY = new NZDecimal(null, dr[(int)ProductionReportEntryViewDTO.eColumns.NG_QTY]);
                    }
                    dtoNG.WEIGHT = new NZDecimal(null, dr[(int)ProductionReportEntryViewDTO.eColumns.NG_WEIGHT]);
                    //dtoNG.OBJ_ITEM_CD =
                    //dtoNG.OBJ_ORDER_QTY =
                    //dtoNG.REF_NO =
                    //dtoNG.REF_SLIP_NO =
                    //dtoNG.REF_SLIP_CLS =
                    //dtoNG.OTHER_DL_NO =
                    //dtoNG.SLIP_NO =
                    dtoNG.REMARK     = data.REMARK;
                    dtoNG.DEALING_NO = data.SUPPLIER;
                    //dtoNG.PRICE =
                    //dtoNG.AMOUNT =
                    //dtoNG.FOR_CUSTOMER =
                    dtoNG.FOR_MACHINE = data.MACHINE_NO;
                    dtoNG.SHIFT_CLS   = data.SHIFT;
                    //dtoNG.REF_SLIP_NO2 =
                    //dtoNG.NG_QTY = new NZDecimal(null, dr[(int)ProductionReportEntryViewDTO.eColumns.NG_QTY]);
                    dtoNG.NG_WEIGHT    = new NZDecimal(null, dr[(int)ProductionReportEntryViewDTO.eColumns.NG_WEIGHT]);
                    dtoNG.TRAN_SUB_CLS = new NZString(null, dr[(int)ProductionReportEntryViewDTO.eColumns.NG_CRITERIA_CD]);
                    dtoNG.SCREEN_TYPE  = DataDefine.ScreenType.WorkResultEntry.ToNZString();
                    //dtoNG.GROUP_TRANS_ID =
                    //dtoNG.RESERVE_QTY =
                    //dtoNG.NG_REASON =
                    dtoNG.EFFECT_STOCK     = new NZInt(null, (int)DataDefine.eEFFECT_STOCK.None);
                    dtoNG.LOT_REMARK       = data.LOT_NO;
                    dtoNG.PERSON_IN_CHARGE = data.PERSON_IN_CHARGE;
                    //dtoNG.CURRENCY =
                    dtoNG.OLD_DATA = new NZInt(null, 0);

                    //save only qty > 0
                    if (dtoNG.QTY > 0)
                    {
                        listNG.Add(dtoNG);
                    }
                }

                #endregion

                bizInv.AddProductionReport(dtoInvMainTransIn, dtoInvMainTransOut, listNG);
            }
            catch (Exception)
            {
                throw;
            }
        }
示例#11
0
        private bool Validate()
        {
            try
            {
                ItemValidator valItem   = new ItemValidator();
                NZString      ItemCD    = new NZString(this, Text);
                ErrorItem     errorItem = null;

                string[] strItemTypes = null;
                //if (ItemType != null && ItemType.Length > 0)
                //{
                //    if (ItemType.Length == 1 && ItemType[0] == eItemType.All)
                //    {
                //        strItemTypes = new string[] { "01", "02", "03", "04" };
                //    }
                //    else
                //    {
                //        strItemTypes = new string[ItemType.Length];
                //        for (int i = 0; i < ItemType.Length; i++)
                //        {
                //            strItemTypes[i] = string.Format("{0:00}", (int)ItemType[i]);
                //        }
                //    }
                //}

                if (CheckEmpty)
                {
                    errorItem = valItem.CheckEmptyItemCode(ItemCD);
                }
                if (CheckExist)
                {
                    ValidateException.ThrowErrorItem(valItem.CheckExistWithItemType(ItemCD, SqlOperator, strItemTypes));
                }
                if (CheckNotExist)
                {
                    ValidateException.ThrowErrorItem(valItem.CheckNotExistWithItemType(ItemCD, SqlOperator, strItemTypes));
                    //BusinessException businessException = valItem.CheckItemNotExist(ItemCD);
                    //if (businessException != null)
                    //{
                    //    throw businessException;
                    //}
                }


                if (CustomerCode != null && !"".Equals(CustomerCode))
                {
                    ValidateException.ThrowErrorItem(valItem.CheckItemByCustomer(ItemCD, CustomerCode.ToNZString()));
                }

                if (null != errorItem)
                {
                    ValidateException.ThrowErrorItem(errorItem);
                }
            }
            catch (ValidateException err)
            {
                for (int i = 0; i < err.ErrorResults.Count; i++)
                {
                    MessageDialog.ShowBusiness(this.FindForm(), err.ErrorResults[i].Message);
                    err.ErrorResults[i].FocusOnControl();
                }
                return(false);
            }
            catch (BusinessException err)
            {
                MessageDialog.ShowBusiness(this.FindForm(), err.Error.Message);
                err.Error.FocusOnControl();
                return(false);
            }
            catch (Exception ex)
            {
                MessageDialog.ShowBusiness(this.FindForm(), ex.Message);
                return(false);
            }
            return(true);
        }