Ejemplo n.º 1
0
        //public ErrorItem CheckShipDate(NZDateTime ShipDate)
        //{
        //    if (ShipDate.IsNull)
        //        return new ErrorItem(ShipDate.Owner, TKPMessages.eValidate.VLM0031.ToString());

        //    InventoryPeriodBIZ biz = new InventoryPeriodBIZ();
        //    NZString YearMonth = new NZString(ShipDate.Owner, ShipDate.StrongValue.ToString("yyyyMM"));
        //    InventoryPeriodDTO dto = biz.LoadByPK(YearMonth);
        //    if (dto == null)
        //        return new ErrorItem(ShipDate.Owner, TKPMessages.eValidate.VLM0032.ToString());
        //    if (dto.PERIOD_BEGIN_DATE.StrongValue > ShipDate.StrongValue
        //        || dto.PERIOD_END_DATE.StrongValue < ShipDate.StrongValue)
        //        return new ErrorItem(ShipDate.Owner, TKPMessages.eValidate.VLM0032.ToString());
        //    return null;
        //}
        #endregion

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

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

            errorItem = CheckShipQTY(dto.ITEM_CD, dto.LOC_CD, dto.LOT_NO, dto.QTY);
            if (errorItem != null)
            {
                validateException.AddError(errorItem);
            }

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

            validateException.ThrowIfHasError();
            #endregion
        }
Ejemplo n.º 2
0
        private void GenerateTmpDemandOrderDTOList(List <TmpDemandOrderDTO> dtoDemandOrderList)
        {
            DateTime dtmSelect = Convert.ToDateTime(dtpDemand.Value);

            for (int iRow = 0; iRow < shtView.Rows.Count; iRow++)
            {
                #region validation
                ValidateException.ThrowErrorItem(
                    PurchaseOrderEntryValidation.CheckEmptyString((NZString)Convert.ToString(shtView.Cells[iRow, (int)eColumn.ITEM_DESC].Value), Messages.eValidate.VLM0129));
                #endregion
                for (int iColumn = (int)eColumn.Day1; iColumn < DateTime.DaysInMonth(dtmSelect.Year, dtmSelect.Month) + (int)eColumn.Day1; iColumn++)
                {
                    TmpDemandOrderDTO dtoTmpDemandOrder = new TmpDemandOrderDTO
                    {
                        CRT_BY      = CommonLib.Common.CurrentUserInfomation.UserCD,
                        CRT_MACHINE = CommonLib.Common.CurrentUserInfomation.Machine,
                        CRT_DATE    = (NZDateTime)DateTime.UtcNow,
                        CUSTOMER_CD = (NZString)txtCusCD.Text,
                        DUE_DATE    = (NZDateTime)(new DateTime(dtmSelect.Year, dtmSelect.Month, (iColumn - 2))),
                        ITEM_CD     = (NZString)Convert.ToString(shtView.Cells[iRow, (int)eColumn.ITEM_CD].Value.ToString()),
                        ITEM_DESC   = (NZString)Convert.ToString(shtView.Cells[iRow, (int)eColumn.ITEM_DESC].Value),
                        ORDER_QTY   = (NZDecimal)(Convert.ToDecimal(shtView.Cells[iRow, iColumn].Value)),
                        ORDER_TYPE  = null,
                        YEAR_MONTH  = (NZDateTime)dtpDemand.Value,
                    };

                    if (dtoTmpDemandOrder.ORDER_QTY > 0)
                    {
                        dtoDemandOrderList.Add(dtoTmpDemandOrder);
                    }
                }
            }
        }
Ejemplo n.º 3
0
        public int UpdateConsumption(List <InventoryTransactionDTO> dtoInvTrnsList)
        {
            try
            {
                InventoryTransactionDAO InventoryTransaction = new InventoryTransactionDAO(CommonLib.Common.CurrentDatabase);

                for (int i = 0; i < dtoInvTrnsList.Count; i++)
                {
                    #region Validate Mandatory
                    IssueEntryValidator valIssue = new IssueEntryValidator();

                    ErrorItem errorItem = null;

                    errorItem = valIssue.CheckIssueDate(dtoInvTrnsList[i].TRANS_DATE);
                    if (null != errorItem)
                    {
                        ValidateException.ThrowErrorItem(errorItem);
                    }

                    #endregion
                    InventoryTransaction.UpdateWithoutPK(null, dtoInvTrnsList[i]);
                }
            }
            catch (Exception)
            {
                //CommonLib.Common.CurrentDatabase.Rollback();
                throw;
            }

            return(1);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// SQLs the error handling. This method convert System.Data.SqlClient.SqlError to Exceptions:
        /// LongFieldException,NotUniqueException,ExceptionParentObjectNotExists,ChildObjectExistsException
        /// </summary>
        /// <param name="exception">The exception.</param>
        /// <param name="err">The SQL Error.</param>
        /// <returns></returns>
        private DbException SqlErrorHandling(DbException exception, System.Data.SqlClient.SqlError err)
        {
            DbException result = null;

            switch (err.Number)
            {
            case (int)ErrorsCode.TruncateData:
                result = new LongFieldException();
                break;

            case (int)ErrorsCode.InsertDuplicatedKey:
            case (int)ErrorsCode.ConstraintInsertDuplicatedKey:
                var sp   = err.Message.Split('\'');
                var name = (sp.Length > 3) ? sp[1] + '.' + sp[3] : "";
                result = new NotUniqueException(name, exception);
                break;

            case (int)ErrorsCode.ConstraintStatementConflicted:
                result = ParseConstraintStatementConflicted(err.Message);
                break;

            case (int)ErrorsCode.InputParameterDBNull:
                result = new SPParameterNullException("Some SP parameters is DbNull");
                break;

            case (int)ErrorsCode.CannotInsertDBNull:
                var m = _messageParser.CannotInsertNULLParser.Match(err.Message);
                if (m.Success == false)
                {
                    return(null);
                }

                var column    = m.Groups["COLUMN"].Value;
                var tableName = Parser.ParseTableName(m.Groups["NAME"].Value);

                result = new MandatoryFieldEmptyException(tableName, column, exception);
                break;

            case (int)ErrorsCode.StoredProcedureNotFind:
                result = new SPNotFindException(err.Message, exception);
                break;

            case (int)ErrorsCode.StoredProcedureNotFindParrameter:
            case (int)ErrorsCode.StoredProcedureExpectParrameter:
                result = new SPIncorrectCountParameters(err.Message, exception);
                break;

            case (int)ErrorsCode.UserDefinedValidateException:
                result = new ValidateException(err.Message);
                break;

            default:
                if (err.Number > 50001)
                {
                    result = new UserDefinedSqlException(err);
                }
                break;
            }
            return(result);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Do action after change record , such as set default and validate data.
        /// </summary>
        private void CheckChangingInRecord()
        {
            if (shtView.Rows.Count > 0)
            {
                // ตรวจว่าข้อมูลใน PO ซ้ำหรือไม่
                ValidateException.ThrowErrorItem(ValidateDupplicateItem());

                int iRow = shtView.ActiveRowIndex;
                int iCol = shtView.ActiveColumnIndex;

                NZDecimal decQty        = new NZDecimal(null, shtView.GetValue(iRow, (int)eColumn.PO_QTY));
                NZDecimal decUnitPrice  = new NZDecimal(null, shtView.GetValue(iRow, (int)eColumn.UNIT_PRICE));
                NZDecimal decReceiveQty = new NZDecimal(null, shtView.GetValue(iRow, (int)eColumn.RECEIVE_QTY));
                NZDecimal decRate       = new NZDecimal(null, shtView.GetValue(iRow, (int)eColumn.RATE));

                // เซ็ต Amount
                if ((iCol == (int)eColumn.PO_QTY || iCol == (int)eColumn.UNIT_PRICE))
                {
                    shtView.Cells[iRow, (int)eColumn.AMOUNT].Value = (decQty.IsNull ? 0 : decQty.StrongValue) *
                                                                     (decUnitPrice.IsNull ? 0 : decUnitPrice.StrongValue);
                }

                // กำหนด Formula + value ให้ Inventory Qty
                shtView.Cells[iRow, (int)eColumn.INV_QTY].Formula = shtView.Cells[iRow, (int)eColumn.PO_QTY].ToString() + "*" + shtView.Cells[iRow, (int)eColumn.RATE].ToString();
                shtView.Cells[iRow, (int)eColumn.INV_QTY].Value   = (decQty.IsNull ? 0 : decQty.StrongValue) *
                                                                    (decRate.IsNull ? 0 : decRate.StrongValue);

                // กำหนด modifystate = edit (กรณีที่ไม่ใช่ record ที่เพิ่ง add มาใหม่)
                if (Convert.ToInt32(shtView.Cells[iRow, (int)eColumn.ModifyState].Value) != (int)eModifyState.Add)
                {
                    shtView.Cells[iRow, (int)eColumn.ModifyState].Value = (int)eModifyState.Edit;
                }
            }
        }
Ejemplo n.º 6
0
        private void mnuDelete_Click(object sender, EventArgs e)
        {
            try
            {
                string MACHINE_CD = shtView.GetValue(shtView.ActiveRowIndex, (int)eColView.MACHINE_CD).ToString();

                MachineValidator validator = new MachineValidator();
                ErrorItem        errorItem = null;
                errorItem = validator.ValidateBeforeDelete(MACHINE_CD.ToNZString());
                if (null != errorItem)
                {
                    ValidateException.ThrowErrorItem(errorItem);
                }

                MessageDialogResult dr = MessageDialog.ShowConfirmation(this, new Message(Messages.eConfirm.CFM9002.ToString()), MessageDialogButtons.YesNo);
                if (dr == MessageDialogResult.No)
                {
                    return;
                }


                m_machineController.DeleteMachine(MACHINE_CD.ToNZString());
                LoadData(false);

                MessageDialog.ShowInformation(this, null, new Message(Messages.eInformation.INF9003.ToString()).MessageDescription);
            }
            catch (ValidateException err)
            {
                MessageDialog.ShowBusiness(this, err.ErrorResults[0].Message);
                err.ErrorResults[0].FocusOnControl();
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Check data before save add.
        /// </summary>
        /// <param name="menuSubCD"></param>
        /// <param name="menuSubName"></param>
        /// <exception cref="EVOFramework.ValidateException"><c>ValidateException</c>.</exception>
        /// <exception cref="BusinessException"><c>BusinessException</c>.</exception>
        public void ValidateBeforeSaveAdd(NZString menuSubCD, NZString menuSubName)
        {
            ValidateException validateException = new ValidateException();
            ErrorItem         errorItem         = null;

            errorItem = CheckMenuSubCode(menuSubCD);
            if (errorItem != null)
            {
                validateException.AddError(errorItem);
            }

            errorItem = CheckMenuSubName(menuSubName);
            if (errorItem != null)
            {
                validateException.AddError(errorItem);
            }

            validateException.ThrowIfHasError();

            //~~~~~~~~~~~~~~~

            MenuSubMaintenanceBIZ biz = new MenuSubMaintenanceBIZ();

            if (biz.ExistMenuSub(menuSubCD))
            {
                errorItem = new ErrorItem(menuSubCD.Owner, Messages.eValidate.VLM9016.ToString());
                throw new BusinessException(errorItem);
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="userCD"></param>
        /// <param name="username"></param>
        /// <param name="oldPassword"></param>
        /// <param name="newPassword"></param>
        /// <param name="confirmNewPassword"></param>
        /// <param name="dateFormat"></param>
        /// <param name="langCD"></param>
        /// <returns></returns>
        /// <exception cref="EVOFramework.ValidationException"><c>ValidateException</c>.</exception>
        /// <exception cref="EVOFramework.BusinessException"><c>BusinessException</c>.</exception>
        public bool ValidateChangeUserProfile(NZString userCD, NZString username, NZString oldPassword, NZString newPassword, NZString confirmNewPassword, NZInt dateFormat, NZInt langCD)
        {
            ValidateException validateException = new ValidateException();
            ErrorItem         errorItem         = null;

            errorItem = CheckRequireUsername(username);
            if (errorItem != null)
            {
                validateException.AddError(errorItem);
            }

            errorItem = CheckRequireDefaultDateFormat(dateFormat);
            if (errorItem != null)
            {
                validateException.AddError(errorItem);
            }

            errorItem = CheckRequireDefaultLanguage(langCD);
            if (errorItem != null)
            {
                validateException.AddError(errorItem);
            }

            validateException.ThrowIfHasError();


            //==== Business Checker
            BizCheckChangePassword(userCD, oldPassword, newPassword, confirmNewPassword);

            return(true);
        }
Ejemplo n.º 9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="data"></param>
        /// <exception cref="ValidateException"><c>ValidateException</c>.</exception>
        /// <exception cref="BusinessException"><c>BusinessException</c>.</exception>
        public void ValidateBeforeSaveNew(DealingDTO data)
        {
            ValidateException validateException = new ValidateException();
            ErrorItem         errorItem         = null;

            #region mandatory check
            errorItem = CheckEmptyLocationCode(data.LOC_CD);
            if (errorItem != null)
            {
                validateException.AddError(errorItem);
            }

            errorItem = CheckEmptyLocationName(data.LOC_DESC);
            if (errorItem != null)
            {
                validateException.AddError(errorItem);
            }

            errorItem = CheckEmptyLocationType(data.LOC_CLS);
            if (errorItem != null)
            {
                validateException.AddError(errorItem);
            }

            validateException.ThrowIfHasError();
            #endregion

            DealingDAO dao = new DealingDAO(CommonLib.Common.CurrentDatabase);
            if (dao.Exist(null, data.LOC_CD))
            {
                errorItem = new ErrorItem(data.LOC_CD.Owner, TKPMessages.eValidate.VLM0005.ToString());
                BusinessException businessException = new BusinessException(errorItem);
                throw businessException;
            }
        }
Ejemplo n.º 10
0
        private void ValidateRequireField()
        {
            SalesUnitPriceValidator validator = new SalesUnitPriceValidator();

            ErrorItem errorItem = null;

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

            errorItem = validator.CheckEmptyStartEffeciveDate(new NZDateTime(dtStartEffDate, dtStartEffDate.Value));
            if (null != errorItem)
            {
                ValidateException.ThrowErrorItem(errorItem);
            }

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

            errorItem = validator.CheckEmptyPrice(numPrice.ToNZDecimal());
            if (null != errorItem)
            {
                ValidateException.ThrowErrorItem(errorItem);
            }
        }
Ejemplo n.º 11
0
        private void DeletePO()
        {
            int iActive = shtView.ActiveRowIndex;
            List <PurchaseOrderDDTO> dDTOPurchaseOrderList = new List <PurchaseOrderDDTO>();

            ValidateException.ThrowErrorItem(
                PurchaseOrderEntryValidation.CheckEmptyString(
                    (NZString)Convert.ToString(shtView.Cells[iActive, (int)eColumn.PO_LINE].Value),
                    Messages.eValidate.VLM0142));

            dDTOPurchaseOrderList.Add(new PurchaseOrderDDTO
            {
                PO_NO = (NZString)Convert.ToString(shtView.Cells[iActive, (int)eColumn.PO_NO].Value),

                PO_LINE = (NZDecimal)Convert.ToDecimal(shtView.Cells[iActive, (int)eColumn.PO_LINE].Value),

                RECEIVE_QTY = (NZDecimal)Convert.ToDecimal(shtView.Cells[iActive, (int)eColumn.RECEIVE_QTY].Value),
                ITEM_CD     = (NZString)Convert.ToString(shtView.Cells[iActive, (int)eColumn.ITEM_CD].Value),
                DUE_DATE    = (NZDateTime)Convert.ToDateTime(shtView.Cells[iActive, (int)eColumn.DUE_DATE].Value)
            });
            new PurchaseOrderBIZ().DeletePOLine(GeneratePurchaseOrderHDTO(), dDTOPurchaseOrderList);

            MessageDialog.ShowInformation(this, "Information", new EVOFramework.Message(Messages.eInformation.INF9003.ToString()).MessageDescription);
            OnRefresh();
        }
Ejemplo n.º 12
0
        public bool ValidateBeforeUpdate(UserDTO userDTO)
        {
            ValidateException validateException = new ValidateException();
            ErrorItem         errorItem         = null;

            //errorItem = CheckPassword(userDTO.PASS);
            //if (errorItem != null)
            //{
            //    validateException.AddError(errorItem);
            //    throw validateException;
            //}

            errorItem = CheckDefaultDateFormat(userDTO.DATE_FORMAT);
            if (errorItem != null)
            {
                validateException.AddError(errorItem);
                throw validateException;
            }

            errorItem = CheckDefaultLang(userDTO.LANG_CD);
            if (errorItem != null)
            {
                validateException.AddError(errorItem);
                throw validateException;
            }

            errorItem = CheckGroupCD(userDTO.GROUP_CD);
            if (errorItem != null)
            {
                validateException.AddError(errorItem);
                throw validateException;
            }
            return(true);
        }
Ejemplo n.º 13
0
        private void ValidateBeforeSave(UnPackingEntryUIDM model)
        {
            PackingValidator validator = new PackingValidator();

            ValidateException.ThrowErrorItem(validator.CheckUnpackingDate(model.UNPACKING_DATE));
            ValidateException.ThrowErrorItem(validator.CheckEmptyShiftType(model.SHIFT_CLS));
            ValidateException.ThrowErrorItem(validator.CheckEmptyMasterNo(model.ITEM_CD));

            if (shtView.RowCount == 0)
            {
                ValidateException.ThrowErrorItem(new ErrorItem(null, TKPMessages.eValidate.VLM0186.ToString()));
            }

            int count = 0;

            for (int i = 0; i < shtView.RowCount; i++)
            {
                Boolean Flag = Convert.ToBoolean(shtView.Cells[i, (int)eColView.CHECKBOX].Value);
                if (Flag == false)
                {
                    count += 1;
                }
            }
            if (count == shtView.RowCount)
            {
                ValidateException.ThrowErrorItem(new ErrorItem(null, TKPMessages.eValidate.VLM0201.ToString()));
            }
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Set Default Value into selected cell, will be used when select Item Code.
        /// </summary>
        private void SetItemCDandItemDesc()
        {
            eItemType[]    itemTypeEnum = { eItemType.All };
            ItemFindDialog dialog       = new ItemFindDialog(eSqlOperator.Equal, itemTypeEnum);

            dialog.ShowDialog(this);
            if (dialog.IsSelected)
            {
                shtView.Cells[shtView.ActiveRowIndex, (int)eColumn.ITEM_CD].Value = dialog.SelectedItem.ITEM_CD.StrongValue;

                // set default into ItemCode, ItemDesc, Unit, InventoryU/M and Rate of unit.
                ErrorItem errItem = ValidateDupplicateItem();
                if (errItem != null)
                {
                    shtView.Cells[shtView.ActiveRowIndex, (int)eColumn.ITEM_CD].Value   = string.Empty;
                    shtView.Cells[shtView.ActiveRowIndex, (int)eColumn.ITEM_DESC].Value = string.Empty;
                    ValidateException.ThrowErrorItem(errItem);
                }
                ValidateException.ThrowErrorItem(errItem);

                shtView.Cells[shtView.ActiveRowIndex, (int)eColumn.ITEM_DESC].Value = dialog.SelectedItem.ITEM_DESC.StrongValue;
                //shtView.Cells[shtView.ActiveRowIndex, (int)eColumn.UNIT].Value = dialog.SelectedItem.ORDER_UM_CLS.StrongValue;
                //shtView.Cells[shtView.ActiveRowIndex, (int)eColumn.INV_UM].Value = dialog.SelectedItem.INV_UM_CLS.StrongValue;
                //shtView.Cells[shtView.ActiveRowIndex, (int)eColumn.RATE].Value = dialog.SelectedItem.INV_UM_RATE.StrongValue / dialog.SelectedItem.ORDER_UM_RATE.StrongValue;
            }
        }
Ejemplo n.º 15
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)));
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Load Item Description and other description into SpreadSheet require ItemCode from SpreadSheet for do operation.
        /// </summary>
        /// <param name="iRow">Selected row , load description for this row.</param>
        private void LoadItem(int iRow)
        {
            try
            {
                if (shtView.Cells[iRow, (int)eColumn.ITEM_CD].Value != null)
                {
                    #region validateion
                    List <string> strItemCDList = new List <string>();
                    for (int i = 0; i < shtView.Rows.Count; i++)
                    {
                        if (i != iRow)
                        {
                            strItemCDList.Add(Convert.ToString(shtView.Cells[i, (int)eColumn.ITEM_CD].Value));
                        }
                    }
                    ErrorItem errItem = ValidateDupplicateItem();
                    if (errItem != null)
                    {
                        shtView.Cells[shtView.ActiveRowIndex, (int)eColumn.ITEM_CD].Value   = string.Empty;
                        shtView.Cells[shtView.ActiveRowIndex, (int)eColumn.ITEM_DESC].Value = string.Empty;
                        ValidateException.ThrowErrorItem(errItem);
                    }
                    #endregion

                    shtView.Cells[iRow, (int)eColumn.KeptStatus].Value = shtView.Cells[iRow, (int)eColumn.STATUS].Value;
                    ItemBIZ bizItem = new ItemBIZ();
                    ItemDTO dtoItem = bizItem.LoadItem((NZString)Convert.ToString(shtView.Cells[shtView.ActiveRowIndex, (int)eColumn.ITEM_CD].Value));

                    if (dtoItem != null)
                    {
                        shtView.Cells[iRow, (int)eColumn.ITEM_DESC].Value = dtoItem.ITEM_DESC.StrongValue;
                        //shtView.Cells[iRow, (int)eColumn.UNIT].Value = dtoItem.ORDER_UM_CLS.StrongValue;
                        //shtView.Cells[iRow, (int)eColumn.INV_UM].Value = dtoItem.INV_UM_CLS.StrongValue;
                        //shtView.Cells[iRow, (int)eColumn.RATE].Value = dtoItem.INV_UM_RATE.StrongValue / dtoItem.ORDER_UM_RATE.StrongValue;
                        shtView.Cells[iRow, (int)eColumn.INV_QTY].Value = Convert.ToDecimal(shtView.Cells[iRow, (int)eColumn.PO_QTY].Value) * Convert.ToDecimal(shtView.Cells[iRow, (int)eColumn.RATE].Value);
                    }
                    else
                    {
                        shtView.Cells[iRow, (int)eColumn.ITEM_DESC].Value = null;
                        shtView.Cells[iRow, (int)eColumn.UNIT].Value      = null;
                        shtView.Cells[iRow, (int)eColumn.INV_UM].Value    = null;
                        shtView.Cells[iRow, (int)eColumn.RATE].Value      = null;
                        shtView.Cells[iRow, (int)eColumn.INV_QTY].Value   = null;
                    }
                }
            }
            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();
            }
        }
Ejemplo n.º 17
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()));
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Generate PO Header.
        /// </summary>
        /// <param name="strPONo">PO No of PO Header.</param>
        /// <returns>PO Header</returns>
        private PurchaseOrderHDTO GeneratePurchaseOrderHDTO(NZString strPONo)
        {
            NZDateTime dtmPO         = new NZDateTime(dtmPODate, dtmPODate.Value);
            NZString   strSupplierCD = new NZString(cboSupplierCode, cboSupplierCode.SelectedValue);
            NZString   strDeliveryTo = chkOurFactory.Checked ? new NZString(cboDelivery, cboDelivery.Text) : new NZString(cboDelivery, cboDelivery.SelectedValue);
            NZString   strCurrency   = new NZString(cboCurrency, cboCurrency.SelectedValue);
            NZString   strVatRate    = new NZString(txtVatRate, txtVatRate.Text);
            string     strVatType    = (Convert.ToInt32(strVatRate) > 0) ? "02" : "01";

            #region validation

            ValidateException.ThrowErrorItem(PurchaseOrderEntryValidation.CheckDateTimeValue(dtmPO, Messages.eValidate.VLM0116));
            ValidateException.ThrowErrorItem(PurchaseOrderEntryValidation.CheckEmptyString(strSupplierCD, Messages.eValidate.VLM0118));
            if (!chkOurFactory.Checked)
            {
                ValidateException.ThrowErrorItem(PurchaseOrderEntryValidation.CheckEmptyString((NZString)strDeliveryTo, Messages.eValidate.VLM0119));
            }
            ValidateException.ThrowErrorItem(PurchaseOrderEntryValidation.CheckEmptyString((NZString)strCurrency, Messages.eValidate.VLM0121));
            if (this.m_ScreenStateEnum == eScreenState.Add)
            {
                ValidateException.ThrowErrorItem(PurchaseOrderEntryValidation.CheckPurchaseOrderItem((NZInt)shtView.Rows.Count));
            }

            #endregion


            PurchaseOrderHDTO hDTO = new PurchaseOrderHDTO
            {
                CRT_BY      = CommonLib.Common.CurrentUserInfomation.UserCD,
                CRT_DATE    = (NZDateTime)DateTime.UtcNow,
                CRT_MACHINE = CommonLib.Common.CurrentUserInfomation.Machine,
                UPD_BY      = CommonLib.Common.CurrentUserInfomation.UserCD,
                UPD_DATE    = (NZDateTime)DateTime.UtcNow,
                UPD_MACHINE = CommonLib.Common.CurrentUserInfomation.Machine,

                PO_NO     = strPONo,
                PO_DATE   = (NZDateTime)dtmPO,
                IS_ACTIVE = (NZBoolean)m_bIsActived, //(NZBoolean)((m_iPOStatus == 1) ? true : false),
                PO_TYPE   = (NZString)"01",          //(NZString)(cboPOType.SelectedValue.ToString()),

                IS_EXPORT = (NZBoolean)false,        //(NZBoolean)chkExport.Checked,
                ADDRESS   = (NZString)"",            // (NZString)txtAddress.Text,

                SUPPLIER_CD     = (NZString)strSupplierCD,
                DELIVERY_TO     = (NZString)strDeliveryTo,
                TERM_OF_PAYMENT = (NZString)(Convert.ToString(cboTermOfPayment.SelectedValue)),

                STATUS   = (NZString)"0",
                VAT_TYPE = (NZString)strVatType,
                VAT_RATE = (NZDecimal)Convert.ToDecimal(strVatRate),
                CURRENCY = (NZString)(cboCurrency.SelectedValue.ToString()),

                REMARK = (NZString)txtRemark.Text,
            };

            return(hDTO);
        }
Ejemplo n.º 19
0
        public void ValidateBeforeSaveNew(ItemDTO dtoItem, ItemProcessDTO dtoItemProcess)
        {
            ValidateException validateException = new ValidateException();

            //ErrorItem errorItem = null;

            #region mandatory check
            //errorItem = CheckEmptyItemCode(dtoItem.ITEM_CD);
            //if (errorItem != null)
            //    validateException.AddError(errorItem);

            //errorItem = CheckEmptyItemDesc(dtoItem.ITEM_DESC);
            //if (errorItem != null)
            //    validateException.AddError(errorItem);

            //validateException.ThrowIfHasError();

            //errorItem = CheckEmptyItemType(dtoItem.ITEM_CLS);
            //if (errorItem != null)
            //    validateException.AddError(errorItem);

            //errorItem = CheckEmptyLotControlType(dtoItem.LOT_CONTROL_CLS);
            //if (errorItem != null)
            //    validateException.AddError(errorItem);

            //errorItem = CheckEmptyStoreLoc(dtoItemProcess.STORE_LOC_CD);
            //if (errorItem != null)
            //    validateException.AddError(errorItem);

            //errorItem = CheckEmptyInventoryUM(dtoItem.INV_UM_CLS);
            //if (null != errorItem) ValidateException.ThrowErrorItem(errorItem);
            //errorItem = CheckEmptyOrderUM(dtoItem.ORDER_UM_CLS);
            //if (null != errorItem) ValidateException.ThrowErrorItem(errorItem);
            //errorItem = CheckEmptyOrderUMRate(dtoItem.ORDER_UM_RATE);
            //if (null != errorItem) ValidateException.ThrowErrorItem(errorItem);

            //errorItem = CheckEmptyUnitConvert(dtoItem.INV_UM_RATE, dtoItem.ORDER_UM_RATE);
            //if (null != errorItem) ValidateException.ThrowErrorItem(errorItem);

            //errorItem = CheckEmptyOrderProcess(dtoItemProcess.ORDER_PROCESS_CLS);
            //if (errorItem != null)
            //    validateException.AddError(errorItem);

            //errorItem = CheckEmptyConsumptionClass(dtoItemProcess.CONSUMTION_CLS);
            //if (null != errorItem) ValidateException.ThrowErrorItem(errorItem);

            BusinessException businessException = CheckItemExist(dtoItem.ITEM_CD);
            if (businessException != null)
            {
                throw businessException;
            }

            #endregion
        }
Ejemplo n.º 20
0
        public void ThrowException()
        {
            var exp = new ValidateException();

            foreach (var item in this)
            {
                exp.Execptions.Add(item.GetException());
            }

            throw exp;
        }
Ejemplo n.º 21
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();
            }
        }
Ejemplo n.º 22
0
        private void DeleteItem()
        {
            try
            {
                if (shtItemView.Rows.Count == 0)
                {
                    return;
                }
                if (shtItemView.ActiveRowIndex < 0)
                {
                    return;
                }

                NZString ItemCD = new NZString(null, shtItemView.Cells[shtItemView.ActiveRowIndex, (int)eColView.ITEM_CD].Text);

                ItemValidator validator = new ItemValidator();
                ErrorItem     errorItem = validator.ValidateBeforeDelete(ItemCD);
                if (errorItem != null)
                {
                    ValidateException.ThrowErrorItem(errorItem);
                }

                errorItem = validator.CheckExistsTransactionByItem(ItemCD);
                if (errorItem != null)
                {
                    MessageDialog.ShowBusiness(this, errorItem.Message);
                }


                MessageDialogResult dr = MessageDialog.ShowConfirmation(this, new EVOFramework.Message(SystemMaintenance.Messages.eConfirm.CFM9002.ToString()).MessageDescription);
                switch (dr)
                {
                case MessageDialogResult.Cancel:
                    return;

                case MessageDialogResult.No:
                    return;

                case MessageDialogResult.Yes:
                    break;
                }

                ItemController ctlItem = new ItemController();
                ctlItem.DeleteItem(ItemCD);

                shtItemView.RemoveRows(shtItemView.ActiveRowIndex, 1);
            }
            catch (ValidateException err)
            {
                MessageDialog.ShowBusiness(this, err.ErrorResults[0].Message);
                err.ErrorResults[0].FocusOnControl();
            }
        }
Ejemplo n.º 23
0
        private bool CheckMandatory()
        {
            try
            {
                InventoryPeriodValidator val = new InventoryPeriodValidator();

                #region Mandatory check

                ErrorItem errorItem = null;
                errorItem = val.CheckEmptyYearMonth(new NZString(null, dtInventoryMonth.Value.HasValue ? dtInventoryMonth.Value.Value.ToString("yyyyMM") : null));
                if (null != errorItem)
                {
                    ValidateException.ThrowErrorItem(errorItem);
                }

                errorItem = val.CheckEmptyPeriodBeginDate(new NZDateTime(null, dtPeriodFrom.Value));
                if (null != errorItem)
                {
                    ValidateException.ThrowErrorItem(errorItem);
                }

                errorItem = val.CheckEmptyPeriodEndDate(new NZDateTime(null, dtPeriodTo.Value));
                if (null != errorItem)
                {
                    ValidateException.ThrowErrorItem(errorItem);
                }

                errorItem = val.CheckPeriodBeginToEndDate(new NZDateTime(null, dtPeriodFrom.Value),
                                                          new NZDateTime(null, dtPeriodTo.Value));
                if (null != errorItem)
                {
                    ValidateException.ThrowErrorItem(errorItem);
                }

                #endregion

                return(true);
            }
            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();
            }
            return(false);
        }
Ejemplo n.º 24
0
        internal bool ValidateBeforeAdd(SystemMaintenance.DTO.MenuSetDTO dto)
        {
            ValidateException validateException = new ValidateException();
            ErrorItem         errorItem         = null;

            errorItem = CheckExistMenuSet(dto.MENU_SET_CD);
            if (errorItem != null)
            {
                validateException.AddError(errorItem);
                throw validateException;
            }

            return(true);
        }
Ejemplo n.º 25
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="menuSubCD"></param>
        /// <exception cref="ValidateException"><c>ValidateException</c>.</exception>
        public void DeleteMenuSub(NZString menuSubCD)
        {
            MenuSubValidator validator = new MenuSubValidator();
            ErrorItem        item      = validator.CheckMenuSubCode(menuSubCD);

            if (item != null)
            {
                ValidateException validateException = new ValidateException();
                validateException.AddError(item);
                validateException.ThrowIfHasError();
            }


            m_bizMenuSub.DeleteMenuSub(menuSubCD);
        }
Ejemplo n.º 26
0
        private void EditDemandOrder()
        {
            List <TmpDemandOrderDTO> dtoListDemandOrderUpdate = new List <TmpDemandOrderDTO>();

            GenerateTmpDemandOrderDTOList(dtoListDemandOrderUpdate);

            ValidateException.ThrowErrorItem(DemandOrderSimpleValidation.CheckRecord(new NZInt(null, dtoListDemandOrderUpdate.Count)));

            DemandOrderDTO dtoDemandOrder = GenerateHeaderDemandOrderDTO();

            if (dtoListDemandOrderUpdate.Count > 0)
            {
                m_BIZDemandOrder.Update(dtoDemandOrder, dtoListDemandOrderUpdate);
            }
        }
Ejemplo n.º 27
0
        public bool ValidateBeforeAdd(UserDTO userDTO)
        {
            ValidateException validateException = new ValidateException();
            ErrorItem         errorItem         = null;

            errorItem = CheckExistUserAccount(userDTO.USER_ACCOUNT);
            if (errorItem != null)
            {
                validateException.AddError(errorItem);
                throw validateException;
            }

            errorItem = CheckUserName(userDTO.FULL_NAME);
            if (errorItem != null)
            {
                validateException.AddError(errorItem);
                throw validateException;
            }

            errorItem = CheckPassword(userDTO.PASS);
            if (errorItem != null)
            {
                validateException.AddError(errorItem);
                throw validateException;
            }

            errorItem = CheckDefaultDateFormat(userDTO.DATE_FORMAT);
            if (errorItem != null)
            {
                validateException.AddError(errorItem);
                throw validateException;
            }

            errorItem = CheckDefaultLang(userDTO.LANG_CD);
            if (errorItem != null)
            {
                validateException.AddError(errorItem);
                throw validateException;
            }

            errorItem = CheckGroupCD(userDTO.GROUP_CD);
            if (errorItem != null)
            {
                validateException.AddError(errorItem);
                throw validateException;
            }
            return(true);
        }
        public static Exception GetExceptionByStatusCode(this RemoteInvokeResultMessage message)
        {
            Exception exception = null;

            switch (message.StatusCode)
            {
            case StatusCode.BusinessError:
                exception = new BusinessException(message.ExceptionMessage);
                break;

            case StatusCode.CommunicationError:
                exception = new CommunicationException(message.ExceptionMessage);
                break;

            case StatusCode.RequestError:
            case StatusCode.CPlatformError:
            case StatusCode.UnKnownError:
                exception = new CPlatformException(message.ExceptionMessage, message.StatusCode);
                break;

            case StatusCode.DataAccessError:
                exception = new DataAccessException(message.ExceptionMessage);
                break;

            case StatusCode.UnAuthentication:
                exception = new UnAuthenticationException(message.ExceptionMessage);
                break;

            case StatusCode.UnAuthorized:
                exception = new UnAuthorizedException(message.ExceptionMessage);
                break;

            case StatusCode.UserFriendly:
                exception = new UserFriendlyException(message.ExceptionMessage);
                break;

            case StatusCode.ValidateError:
                exception = new ValidateException(message.ExceptionMessage);
                break;

            default:
                exception = new CPlatformException(message.ExceptionMessage, message.StatusCode);
                break;
            }

            return(exception);
        }
Ejemplo n.º 29
0
        private bool ValidateMandatory()
        {
            if (!dtInvoiceDate.Value.HasValue)
            {
                ValidateException.ThrowErrorItem(new ErrorItem(null, TKPMessages.eValidate.VLM0105.ToString(), new object[] { "Delivery Date" }));
                return(false);
            }
            if (cboCustomerCode.SelectedValue == null)
            {
                ValidateException.ThrowErrorItem(new ErrorItem(null, TKPMessages.eValidate.VLM0105.ToString(), new object[] { "Customer Code" }));
                return(false);
            }

            // Validate Data before Save
            if (shtCustomerOrder.Rows.Count == 0)
            {
                ValidateException.ThrowErrorItem(new ErrorItem(null, TKPMessages.eValidate.VLM0190.ToString()));
            }

            //if (!CheckChooseLotForOrder())
            //{
            //    ValidateException.ThrowErrorItem(new ErrorItem(null, TKPMessages.eValidate.VLM0194.ToString()));
            //}
            //if (!CheckChooseLotOverRemain())
            //{
            //    ValidateException.ThrowErrorItem(new ErrorItem(null, TKPMessages.eValidate.VLM0214.ToString()));
            //}

            ShipEntryValidator       valShip   = new ShipEntryValidator();
            IssueEntryValidator      valIssue  = new IssueEntryValidator();
            InventoryOnhandValidator valINV    = new InventoryOnhandValidator();
            TransactionValidator     valTRN    = new TransactionValidator();
            CommonBizValidator       commonVal = new CommonBizValidator();
            ErrorItem errorItem;


            errorItem = valTRN.DateIsInCurrentPeriod(new NZDateTime(dtInvoiceDate, dtInvoiceDate.Value));
            if (null != errorItem)
            {
                ValidateException.ThrowErrorItem(errorItem);
            }


            NZString YearMonth = new InventoryPeriodBIZ().LoadCurrentPeriod().YEAR_MONTH;

            return(true);
        }
Ejemplo n.º 30
0
        private bool ValidateBeforeSave(PackingEntryUIDM model)
        {
            if (shtView.RowCount == 0)
            {
                ValidateException.ThrowErrorItem(new ErrorItem(null, TKPMessages.eValidate.VLM0186.ToString()));
            }

            for (int iRow = 0; iRow < shtView.RowCount; iRow++)
            {
                if (!ValidateRowSpread(iRow, true))
                {
                    return(false);
                }
            }

            return(true);
        }