Exemplo n.º 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)));
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="model"></param>
        /// <exception cref="!:EVOFramework.ValidateException"><c>ValidateException</c>.</exception>
        public void Save(ReceivingEntryUIDM model, Common.eScreenMode Mode)
        {
            try
            {
                Common.CurrentDatabase.KeepConnection = true;
                Common.CurrentDatabase.BeginTransaction(IsolationLevel.Serializable);

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

                #region Validate Data
                //== Validate Header, contain: Receive Date, Stored Loc.
                ReceivingValidator receivingValidator = new ReceivingValidator();
                DealingValidator   locationValidator  = new DealingValidator();
                ItemValidator      itemValidator      = new ItemValidator();
                CommonBizValidator commonVal          = new CommonBizValidator();

                ValidateException.ThrowErrorItem(receivingValidator.CheckReceiveDate(model.RECEIVE_DATE));
                ValidateException.ThrowErrorItem(locationValidator.CheckEmptyLocationCode(model.STORED_LOC));
                ValidateException.ThrowErrorItem(locationValidator.CheckNotExistsLocationCode(model.STORED_LOC));
                // Check for Supplier Type
                ValidateException.ThrowErrorItem(receivingValidator.CheckForSupplierType(model.DEALING_NO));

                //== If data not has to processing.
                if (model.DATA_VIEW == null || model.DATA_VIEW.Rows.Count == 0)
                {
                    ValidateException.ThrowErrorItem(new ErrorItem(null, TKPMessages.eValidate.VLM0055.ToString()));
                }

                DataTable dtNonDelete = model.DATA_VIEW.GetChanges(DataRowState.Unchanged | DataRowState.Added | DataRowState.Modified);
                List <InventoryTransactionViewDTO> listData = DTOUtility.ConvertDataTableToList <InventoryTransactionViewDTO>(dtNonDelete);

                //== Validate Item cannot duplicate on ITEM_CD and LOT_NO
                List <string> listCheckKeyDuplicate = new List <string>();
                for (int i = 0; i < listData.Count; i++)
                {
                    BusinessException err = itemValidator.CheckItemNotExist(listData[i].ITEM_CD);
                    if (err != null)
                    {
                        ValidateException.ThrowErrorItem(err.Error);
                    }
                    string strKey = listData[i].ITEM_CD.NVL(String.Empty)
                                    + listData[i].LOT_NO.NVL(String.Empty)
                                    + listData[i].EXTERNAL_LOT_NO.NVL(String.Empty)
                    ;

                    if (listCheckKeyDuplicate.Contains(strKey))
                    {
                        ValidateException.ThrowErrorItem(new ErrorItem(null, TKPMessages.eValidate.VLM0096.ToString(), new object[] { listData[i].ITEM_CD.NVL(String.Empty), listData[i].LOT_NO.NVL(String.Empty), listData[i].EXTERNAL_LOT_NO.NVL(String.Empty) }));
                    }

                    listCheckKeyDuplicate.Add(strKey);
                }



                for (int i = 0; i < listData.Count; i++)
                {
                    InventoryTransactionViewDTO viewDTO = listData[i];

                    //== Check LotNo If item use lot control class.
                    ValidateException.ThrowErrorItem(commonVal.CheckInputLot(viewDTO.ITEM_CD, new NZString(), viewDTO.LOT_NO, false));
                }
                #endregion


                DataTable dtData = model.DATA_VIEW;

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

                List <InventoryTransactionDTO> listAdd    = null;
                List <InventoryTransactionDTO> listUpdate = null;
                List <InventoryTransactionDTO> listDelete = null;


                //มีการปรับให้ทำคำสั่งทีละ set ของ add , update , delete เลย
                //ที่เริ่มจาก delete ก่อนเพราะ consumption จะได้มีการเอาไปใช้สำหรับตัวที่ add ได้เลย ไม่ต้องค้างไว้ lot หน้า
                //== Delete process.
                if (dtDelete != null && dtDelete.Rows.Count > 0)
                {
                    listDelete = DTOUtility.ConvertDataTableToList <InventoryTransactionDTO>(dtDelete);

                    List <InventoryTransactionDTO> listDeleteConsumption = null;
                    for (int i = 0; i < listDelete.Count; i++)
                    {
                        InventoryTransactionDTO dto = listDelete[i];

                        listDeleteConsumption = bizTrans.LoadConsumptionItemByRefNo(dto.REF_NO);
                        biz.ReceivingItems(Common.CurrentDatabase, null, null, listDeleteConsumption);
                    }
                }
                biz.ReceivingItems(Common.CurrentDatabase, null, null, listDelete);



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

                    //ถ้ากรณี receiving ให้แตกเป็น lot ย่อยตาม lot size ให้
                    if (model.RECEIVE_TYPE.StrongValue.Equals(DataDefine.eTRANS_TYPE_string.Receiving))
                    {
                        listAdd = SplitBoxSize(model, DTOUtility.ConvertDataTableToList <InventoryTransactionViewDTO>(dtAdd));
                    }
                    else
                    {
                        listAdd = DTOUtility.ConvertDataTableToList <InventoryTransactionDTO>(dtAdd);
                    }
                    NZString         runningNo        = null;
                    RunningNumberBIZ runningNumberBIZ = new RunningNumberBIZ();

                    if (model.RECEIVE_NO.IsNull)
                    {
                        runningNo = runningNumberBIZ.GetCompleteRunningNo(DataDefine.RECEIVE_SLIP_NO.ToNZString(), DataDefine.TRANSACTION_TABLE_NAME.ToNZString());
                    }
                    else
                    {
                        runningNo = model.RECEIVE_NO;
                    }

                    List <InventoryTransactionDTO> listAddEachDetail = null;

                    for (int i = 0; i < listAdd.Count; i++)
                    {
                        listAddEachDetail = new List <InventoryTransactionDTO>();

                        InventoryTransactionDTO dto = listAdd[i];

                        // Copy ค่า Header จาก Model ไปยัง DTO แต่ละตัว
                        AssignHeaderToDTO(model, dto);

                        //ถ้า 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));
                        //}

                        //dto.TRANS_ID = runningNumberBIZ.GetCompleteRunningNo(DataDefine.TRANS_ID.ToNZString(), DataDefine.TRANSACTION_TABLE_NAME.ToNZString());
                        dto.SLIP_NO     = runningNo;
                        dto.CRT_BY      = Common.CurrentUserInfomation.UserCD;
                        dto.CRT_MACHINE = Common.CurrentUserInfomation.Machine;
                        dto.UPD_BY      = Common.CurrentUserInfomation.UserCD;
                        dto.UPD_MACHINE = Common.CurrentUserInfomation.Machine;

                        // Check all lines.
                        receivingValidator.ValidateBeforeSaveAdd(dto);

                        //add header ใส่ list
                        listAddEachDetail.Add(dto);
                        #region Do Consumption if Item Process Type is SP and Receive Type is Receiving
                        if (model.RECEIVE_TYPE.StrongValue == DataDefine.Convert2ClassCode(DataDefine.eTRANS_TYPE.Receiving))
                        {
                            // load for item process type
                            ItemBIZ        bizItem = new ItemBIZ();
                            ItemProcessDTO dtoItem = bizItem.LoadItemProcess(dto.ITEM_CD);
                            //if (dtoItem.ORDER_PROCESS_CLS.StrongValue == DataDefine.ORDER_PROCESS_CLS_SUBCONTACT)
                            //{
                            //    List<InventoryTransactionDTO> dtoConsumptionTr = CreateConsumptionDTO(dto);
                            //    if (dtoConsumptionTr != null && dtoConsumptionTr.Count > 0)
                            //    {
                            //        listAddEachDetail.AddRange(dtoConsumptionTr);

                            //        //for (int j = 0; j < dtoConsumptionTr.Count; j++)
                            //        //{
                            //        //    listAddEachDetail.Add(dtoConsumptionTr[j]);
                            //        //}
                            //    }

                            //}
                        }
                        #endregion

                        biz.ReceivingItems(Common.CurrentDatabase, listAddEachDetail, null, null);
                    }
                }

                //== Update process.
                if (dtModify != null && dtModify.Rows.Count > 0)
                {
                    listUpdate = DTOUtility.ConvertDataTableToList <InventoryTransactionDTO>(dtModify);


                    List <InventoryTransactionDTO> listUpdateDetail      = null;
                    List <InventoryTransactionDTO> listAddConsumption    = null;
                    List <InventoryTransactionDTO> listDeleteConsumption = null;

                    for (int i = 0; i < listUpdate.Count; i++)
                    {
                        listUpdateDetail      = new List <InventoryTransactionDTO>();
                        listAddConsumption    = new List <InventoryTransactionDTO>();
                        listDeleteConsumption = new List <InventoryTransactionDTO>();

                        InventoryTransactionDTO dto = listUpdate[i];

                        // Copy ค่า Header จาก Model ไปยัง DTO แต่ละตัว
                        AssignHeaderToDTO(model, dto);

                        dto.CRT_BY      = Common.CurrentUserInfomation.UserCD;
                        dto.CRT_MACHINE = Common.CurrentUserInfomation.Machine;
                        dto.UPD_BY      = Common.CurrentUserInfomation.UserCD;
                        dto.UPD_MACHINE = Common.CurrentUserInfomation.Machine;

                        // Check all lines.
                        receivingValidator.ValidateBeforeSaveAdd(dto);


                        //Clear consumption เดิมก่อน
                        listDeleteConsumption = bizTrans.LoadConsumptionItemByRefNo(dto.REF_NO);
                        biz.ReceivingItems(Common.CurrentDatabase, null, null, listDeleteConsumption);

                        //add header ใส่ list
                        listUpdateDetail.Add(dto);

                        #region Do Consumption if Item Process Type is SP
                        if (model.RECEIVE_TYPE.StrongValue == DataDefine.Convert2ClassCode(DataDefine.eTRANS_TYPE.Receiving))
                        {
                            // load for item process type
                            ItemBIZ        bizItem = new ItemBIZ();
                            ItemProcessDTO dtoItem = bizItem.LoadItemProcess(dto.ITEM_CD);
                            //if (dtoItem.ORDER_PROCESS_CLS.StrongValue == DataDefine.ORDER_PROCESS_CLS_SUBCONTACT)
                            //{
                            //    List<InventoryTransactionDTO> dtoConsumptionTr = CreateConsumptionDTO(dto);
                            //    if (dtoConsumptionTr != null && dtoConsumptionTr.Count > 0)
                            //    {
                            //        listAddConsumption.AddRange(dtoConsumptionTr);
                            //        //for (int j = 0; j < dtoConsumptionTr.Count; j++)
                            //        //{
                            //        //    listConsumption.Add(dtoConsumptionTr[j]);
                            //        //}
                            //    }
                            //}
                        }
                        #endregion


                        biz.ReceivingItems(Common.CurrentDatabase, listAddConsumption, listUpdateDetail, null);
                    }
                }


                //ปรับให้ไปสั่ง add delete แต่ละตัวไป เพราะว่ากรณีที่ตัด consumption
                //จะมีโอกาสข้าม lot  ถ้าคำนวณ โดยไม่ตัด mat ก่อน มันจะตัด lot เดิมตลอด
                //biz.ReceivingItems(Common.CurrentDatabase, listAdd, listUpdate, listDelete, listConsumption);
                //biz.ReceivingItems(Common.CurrentDatabase, null, listUpdate, null, null);



                //Update Header for Edit Case
                if (Mode == Common.eScreenMode.EDIT && dtData != null && dtData.Rows.Count > 0)
                {
                    listUpdate = DTOUtility.ConvertDataTableToList <InventoryTransactionDTO>(dtData);

                    for (int i = 0; i < listUpdate.Count; i++)
                    {
                        InventoryTransactionDTO dto = listUpdate[i];

                        // Copy ค่า Header จาก Model ไปยัง DTO แต่ละตัว
                        AssignHeaderToDTO(model, dto);

                        dto.CRT_BY      = Common.CurrentUserInfomation.UserCD;
                        dto.CRT_MACHINE = Common.CurrentUserInfomation.Machine;
                        dto.UPD_BY      = Common.CurrentUserInfomation.UserCD;
                        dto.UPD_MACHINE = Common.CurrentUserInfomation.Machine;

                        biz.UpdateReceiveHeader(Common.CurrentDatabase, dto);
                    }
                }

                Common.CurrentDatabase.Commit();
            }
            catch (Exception)
            {
                Common.CurrentDatabase.Rollback();
                throw;
            }
        }
Exemplo n.º 5
0
        public override void OnSaveAndClose()
        {
            DealingUIDM model     = dmcLocation.SaveData(new DealingUIDM());
            string      ADDRESS01 = txtAddr1Address1.Text + System.Environment.NewLine + txtAddr1Address2.Text + System.Environment.NewLine + txtAddr1Address3.Text;

            model.ADDRESS1 = ADDRESS01.ToNZString();
            string ADDRESS02 = txtAddr2Address1.Text + System.Environment.NewLine + txtAddr2Address2.Text + System.Environment.NewLine + txtAddr2Address3.Text;

            model.ADDRESS2 = ADDRESS02.ToNZString();
            string ADDRESS03 = txtAddr3Address1.Text + System.Environment.NewLine + txtAddr3Address2.Text + System.Environment.NewLine + txtAddr3Address3.Text;

            model.ADDRESS3 = ADDRESS03.ToNZString();
            try
            {
                DealingValidator validator = new DealingValidator();
                // Mandatory check
                #region
                ErrorItem errorItem = null;
                errorItem = validator.CheckEmptyLocationCode(new NZString(txtDealingCode, txtDealingCode.Text));
                if (null != errorItem)
                {
                    ValidateException.ThrowErrorItem(errorItem);
                }

                errorItem = validator.CheckEmptyLocationName(new NZString(txtDealingName, txtDealingName.Text));
                if (null != errorItem)
                {
                    ValidateException.ThrowErrorItem(errorItem);
                }

                errorItem = validator.CheckEmptyLocationType(new NZString(cboDealingType, cboDealingType.SelectedValue));
                if (null != errorItem)
                {
                    ValidateException.ThrowErrorItem(errorItem);
                }

                errorItem = validator.CheckEmptyTermOfPayment(new NZString(cboTermOfPayment, cboTermOfPayment.SelectedValue));
                if (null != errorItem)
                {
                    ValidateException.ThrowErrorItem(errorItem);
                }

                errorItem = validator.CheckInvoicePattern(new NZString(cboInvoicePattern, cboInvoicePattern.SelectedValue), new NZString(cboDealingType, cboDealingType.SelectedValue));
                if (null != errorItem)
                {
                    ValidateException.ThrowErrorItem(errorItem);
                }
                #endregion

                // Confirm to save.
                MessageDialogResult dr = MessageDialog.ShowConfirmation(this, new EVOFramework.Message(Messages.eConfirm.CFM9001.ToString()));
                if (dr == MessageDialogResult.Cancel || dr == MessageDialogResult.No)
                {
                    return;
                }

                //if (dr == MessageDialogResult.No)
                //{
                //    DialogResult = m_dummyDialogResult;
                //    return;
                //}

                if (eMode.ADD == m_screenMode)
                {
                    m_locationController.SaveNew(model);
                }
                else
                {
                    m_locationController.SaveUpdate(model);
                }

                MessageDialog.ShowInformation(this, null, new EVOFramework.Message(Messages.eInformation.INF9003.ToString()).MessageDescription);

                m_dummyDialogResult = DialogResult.OK;
                DialogResult        = m_dummyDialogResult;
                this.Close();
            }
            catch (BusinessException err)
            {
                MessageDialog.ShowBusiness(this, err.Error.Message);
                err.Error.FocusOnControl();
            }
            catch (ValidateException err)
            {
                MessageDialog.ShowBusiness(this, err.ErrorResults[0].Message);
                err.ErrorResults[0].FocusOnControl();
            }
        }