/// <summary>
        /// Validate search criteria in case user choose search contract by code
        /// </summary>
        /// <param name="searchCondition"></param>
        /// <returns></returns>
        public ActionResult CMS070_ValidateContractSearchByCode(CMS070_ContractByCode searchCondition)
        {
            ObjectResultData    res  = new ObjectResultData();
            List <MessageModel> wLst = new List <MessageModel>();

            try
            {
                //3.1	Validate require field
                res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;
                ValidatorUtil.BuildErrorMessage(res, this, new object[] { searchCondition });

                if (res.IsError)
                {
                    return(Json(res));
                }

                res.ResultData = "P";
                return(Json(res));
            }
            catch (Exception ex)
            {
                res.AddErrorMessage(ex);
                return(Json(res));
            }
        }
Exemple #2
0
    public static bool IsValidItemFields(string itemCode, string categoryName, string description, string reorderLevel, string reorderQty, string UOM, string bin)
    {
        bool sucesss = true;
        int  level, qty;

        if (string.IsNullOrEmpty(itemCode) || string.IsNullOrEmpty(categoryName) || string.IsNullOrEmpty(description) || string.IsNullOrEmpty(UOM) || string.IsNullOrEmpty(reorderLevel) || string.IsNullOrEmpty(reorderQty))
        {
            sucesss = false;
        }
        else if (!(int.TryParse(reorderLevel, out level) && int.TryParse(reorderQty, out qty)))
        {
            sucesss = false;
        }
        else if (ValidatorUtil.IsInvalidfieldLength(itemCode, 10) || ValidatorUtil.IsInvalidfieldLength(categoryName, 10) || ValidatorUtil.IsInvalidfieldLength(description, 50) || ValidatorUtil.IsInvalidfieldLength(UOM, 10) || ValidatorUtil.IsInvalidfieldLength(bin, 10))
        {
            sucesss = false;
        }
        else
        {
            Item i = EFBroker_Item.GetItembyDescription(description);
            if (i != null && !itemCode.Equals(i.ItemCode))
            {
                sucesss = false;
            }
        }

        return(sucesss);
    }
Exemple #3
0
        /// <summary>
        /// Validate data of permission type individual.
        /// </summary>
        /// <param name="permission"></param>
        /// <returns></returns>
        public ActionResult MAS080_ValidateTypeInidividual(MAS080_InsertIndividual permission)
        {
            ObjectResultData res = new ObjectResultData();

            try
            {
                res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;
                if (false == ModelState.IsValid)
                {
                    ValidatorUtil.BuildErrorMessage(res, this);
                }

                if (res.IsError)
                {
                    return(Json(res));
                }

                res.ResultData = "P";
            }
            catch (Exception ex)
            {
                res.AddErrorMessage(ex);
            }

            return(Json(res));
        }
        public ActionResult ICS140_SaveInput(doDebtTracingInput input)
        {
            ObjectResultData res = new ObjectResultData();

            try
            {
                if (ModelState.IsValid == false)
                {
                    ValidatorUtil.BuildErrorMessage(res, this);
                    res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;
                    if (res.IsError)
                    {
                        return(Json(res));
                    }
                }

                var handler = ServiceContainer.GetService <IIncomeHandler>() as IIncomeHandler;
                var sparam  = this.GetScreenObject <ICS140_ScreenParameter>();

                // Comment scope by Jirawat Jannet on 2016-10-31
                //using (var scope = new TransactionScope())
                //{
                handler.SaveDebtTracingInput(input, sparam.IsHQUser);
                //scope.Complete(); // Comment scope by Jirawat Jannet on 2016-10-31

                res.ResultData = true;
                //}
            }
            catch (Exception ex)
            {
                res.AddErrorMessage(ex);
            }

            return(Json(res));
        }
        public ActionResult IVS170_GenerateReport(IVS170_doGetStockCheckingList cond)
        {
            List <dtStockCheckingList> list = new List <dtStockCheckingList>();

            ObjectResultData res = new ObjectResultData();

            res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;

            try
            {
                // Model validation
                if (ModelState.IsValid == false)
                {
                    ValidatorUtil.BuildErrorMessage(res, this);
                    if (res.IsError)
                    {
                        return(Json(res));
                    }
                }

                //Validate #1
                //if (CommonUtil.IsNullAllField(cond))
                //{
                //    res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0006);
                //    return Json(res);
                //}

                //Validate #2
                if ((!CommonUtil.IsNullOrEmpty(cond.ShelfNoFrom)) &&
                    (!CommonUtil.IsNullOrEmpty(cond.ShelfNoTo)) &&
                    (String.Compare(cond.ShelfNoFrom, cond.ShelfNoTo) > 0))
                {
                    res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4015, null, new string[] { "ShelfNoFrom", "ShelfNoTo" });
                    return(Json(res));
                }

                IInventoryHandler handler = ServiceContainer.GetService <IInventoryHandler>() as IInventoryHandler;
                list = handler.GetStockCheckingList(cond);

                if (list == null || list.Count <= 0)
                {
                    res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0001, null, null);
                    return(Json(res));
                }

                IVS170_ScreenParameter    param      = GetScreenObject <IVS170_ScreenParameter>();
                IInventoryDocumentHandler docService = ServiceContainer.GetService <IInventoryDocumentHandler>() as IInventoryDocumentHandler;
                param.PendingDownloadFilePath = docService.GenerateIVS170StockTakingResult(list, cond);
                param.PendingDownloadFileName = "StockDifferenceList.xlsx";

                res.ResultData = true;
            }
            catch (Exception ex)
            {
                res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION;
                res.AddErrorMessage(ex);
            }
            return(Json(res));
        }
Exemple #6
0
        /// <summary>
        /// Load search result to grid
        /// </summary>
        /// <param name="cond"></param>
        /// <returns></returns>
        public ActionResult CTS030_Search(CTS030_Search cond)
        {
            List <dtSearchDraftContractResult> list = new List <dtSearchDraftContractResult>();

            ObjectResultData res = new ObjectResultData();

            res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;

            try
            {
                ValidatorUtil.BuildErrorMessage(res, this, new object[] { cond }); //AtLeast1FieldNotNullOrEmptyAttribute
                if (res.IsError)
                {
                    return(Json(res));
                }

                CTS030_ScreenParameter CTS030Param = GetScreenObject <CTS030_ScreenParameter>();
                if (CTS030Param == null)
                {
                    CTS030Param = new CTS030_ScreenParameter();
                }

                dsCTS030Data data = CTS030Param.data;
                if (data == null)
                {
                    //Save search condition value
                    dsCTS030Data dsData = new dsCTS030Data();
                    dsData.doSearchCondition = cond;

                    //Set default to some search condition
                    CommonUtil c = new CommonUtil();
                    cond.QuotationCode         = c.ConvertQuotationTargetCode(cond.QuotationCode, CommonUtil.CONVERT_TYPE.TO_LONG);
                    cond.ApproveContractStatus = ApprovalStatus.C_APPROVE_STATUS_WAITFORAPPROVE;

                    //Query for draft contract
                    IDraftContractHandler hand = ServiceContainer.GetService <IDraftContractHandler>() as IDraftContractHandler;
                    list = hand.SearchDraftContractList(cond);

                    //Save search result list
                    dsData.dtSearchResult = list;

                    //Save condition and result into session
                    CTS030Param.data = dsData;
                    UpdateScreenObject(CTS030Param);
                }
                else
                {
                    list = data.dtSearchResult;
                }
            }
            catch (Exception ex)
            {
                res.AddErrorMessage(ex);
            }

            res.ResultData = CommonUtil.ConvertToXml <dtSearchDraftContractResult>(list, "Contract\\CTS030", CommonUtil.GRID_EMPTY_TYPE.SEARCH);
            return(Json(res));
        }
        public ActionResult ISS100_ExportExcelDataMonthly(doInstallationReportMonthly dtInstallation)
        {
            ISS100_ScreenParameter param = GetScreenObject <ISS100_ScreenParameter>();

            ObjectResultData res = new ObjectResultData();

            res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;

            try
            {
                if (!this.ModelState.IsValid)
                {
                    res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;
                    ValidatorUtil.BuildErrorMessage(res, this);
                    return(Json(res));
                }

                if (dtInstallation == null || CommonUtil.IsNullAllField(dtInstallation))
                {
                    res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0006);
                }
                else
                {
                    IInstallationHandler handler  = ServiceContainer.GetService <IInstallationHandler>() as IInstallationHandler;
                    ICommonHandler       chandler = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
                    var lst = handler.GetInstallationReportMonthlyExcelFile(dtInstallation);

                    if (lst == null || lst.Count == 0)
                    {
                        res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0001);
                        res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION;
                        return(Json(res));
                    }

                    IInstallationDocumentHandler docService = ServiceContainer.GetService <IInstallationDocumentHandler>() as IInstallationDocumentHandler;

                    if (dtInstallation.ReportType == "0")
                    {
                        param.PendingDownloadFilePath = docService.GenerateISR130Report(lst, dtInstallation);
                        param.PendingDownloadFileName = "ISR130NewReport.xlsx";
                    }
                    else
                    {
                        param.PendingDownloadFilePath = docService.GenerateISR140Report(lst, dtInstallation);
                        param.PendingDownloadFileName = "ISR140ClaimReport.xlsx";
                    }
                    res.ResultData = true;
                }
            }
            catch (Exception ex)
            {
                res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION;
                res.AddErrorMessage(ex);
            }

            return(Json(res));
        }
Exemple #8
0
        /// <summary>
        /// Validate business when click [Register] button in ‘Action button’ section
        /// </summary>
        /// <param name="doCancalReason"></param>
        /// <returns></returns>
        public ActionResult CTS090_RegisterCancelData(CTS090_doCancelReason doCancalReason)
        {
            ObjectResultData res = new ObjectResultData();

            try
            {
                //CheckSystemStatus
                if (CheckIsSuspending(res) == true)
                {
                    return(Json(res));
                }

                //Check screen permission
                if (CheckUserPermission(ScreenID.C_SCREEN_ID_CANCEL_SALE_CONTRACT, FunctionID.C_FUNC_ID_OPERATE) == false)
                {
                    res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0053);
                    return(Json(res));
                }


                //CheckMandatory
                res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;
                if (ModelState.IsValid == false)
                {
                    ValidatorUtil.BuildErrorMessage(res, this);
                }

                if (res.IsError)
                {
                    return(Json(res));
                }

                //ValidateScreenBusiness
                if (doCancalReason.CancelDate > DateTime.Now.Date)
                {
                    res.AddErrorMessage(MessageUtil.MODULE_CONTRACT, MessageUtil.MessageList.MSG3154, null, new string[] { "dpCancelDate" });
                    return(Json(res));
                }

                //ValidateDataBusiness
                res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION;
                ValidateDataBusiness_CTS090(res);
                if (res.IsError)
                {
                    return(Json(res));
                }

                res.ResultData = true;
            }
            catch (Exception ex)
            {
                res.AddErrorMessage(ex);
            }

            return(Json(res));
        }
Exemple #9
0
        /// <summary>
        /// Search instrument information
        /// </summary>
        /// <param name="Cond">Search condition object</param>
        /// <returns></returns>
        public ActionResult IVS210_SearchInventoryInstrument(IVS210SearchCond Cond)
        {
            ObjectResultData res = new ObjectResultData();

            try
            {    //Valid Cond
                ValidatorUtil.BuildErrorMessage(res, this, new object[] { Cond });
                if (res.IsError)
                {
                    res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;
                    return(Json(res));
                }

                if (!string.IsNullOrEmpty(Cond.ShelfNoFrom) && !string.IsNullOrEmpty(Cond.ShelfNoTo) &&
                    Cond.ShelfNoFrom.CompareTo(Cond.ShelfNoTo) > 0)
                {
                    res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4015, null, new string[] { "ShelfNoFrom", "ShelfNoTo" });
                    res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;
                    return(Json(res));
                }

                IInventoryHandler InvH = ServiceContainer.GetService <IInventoryHandler>() as IInventoryHandler;

                IVS210_ScreenParameter param = GetScreenObject <IVS210_ScreenParameter>();

                doSearchInstrumentListCondition searchCon = new doSearchInstrumentListCondition();
                searchCon.OfficeCode     = Cond.Office;
                searchCon.LocationCode   = Cond.Location;
                searchCon.AreaCode       = Cond.InstArea;
                searchCon.StartShelfNo   = Cond.ShelfNoFrom;
                searchCon.EndShelfNo     = Cond.ShelfNoTo;
                searchCon.Instrumentcode = Cond.InstCode;
                searchCon.InstrumentName = Cond.InstName;

                List <dtSearchInstrumentListResult> lstResult = InvH.SearchInventoryInstrumentListAllShelf(searchCon);

                if (lstResult.Count <= 0)
                {
                    res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION;
                    return(Json(res));
                }
                else if (lstResult.Count > 1000)
                {
                    res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4004);
                    res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION;
                    return(Json(res));
                }

                res.ResultData = CommonUtil.ConvertToXml <dtSearchInstrumentListResult>(lstResult, "inventory\\IVS210_Instrument", CommonUtil.GRID_EMPTY_TYPE.SEARCH);
                return(Json(res));
            }
            catch (Exception ex)
            {
                res.AddErrorMessage(ex); return(Json(res));
            }
        }
Exemple #10
0
        public ActionResult ICS150_ExportExcelData(doMatchRReport dtIncome)
        {
            ICS150_ScreenParameter param = GetScreenObject <ICS150_ScreenParameter>();

            ObjectResultData res = new ObjectResultData();

            res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;


            try
            {
                ValidatorUtil validator = new ValidatorUtil();

                ICS150_ValidateBusiness(validator, dtIncome);
                ValidatorUtil.BuildErrorMessage(res, validator, null);
                if (res.IsError)
                {
                    return(Json(res));
                }

                if (dtIncome == null || CommonUtil.IsNullAllField(dtIncome))
                {
                    res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0006);
                }
                else
                {
                    IIncomeHandler handler  = ServiceContainer.GetService <IIncomeHandler>() as IIncomeHandler;
                    ICommonHandler chandler = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
                    if (string.IsNullOrEmpty(dtIncome.CreateBy) && CommonUtil.dsTransData != null)
                    {
                        dtIncome.CreateBy = CommonUtil.dsTransData.dtUserData.EmpNo;
                    }
                    var lst = handler.GetListIRC050(dtIncome);

                    if (lst.Count != 0)
                    {
                        IIncomeDocumentHandler docService = ServiceContainer.GetService <IIncomeDocumentHandler>() as IIncomeDocumentHandler;
                        param.PendingDownloadFilePath = docService.GenerateICR050Report(lst, dtIncome);
                        param.PendingDownloadFileName = "ICR050Report.xlsx";
                        res.ResultData = true;
                    }
                    else
                    {
                        res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0001);
                    }
                }
            }
            catch (Exception ex)
            {
                res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION;
                res.AddErrorMessage(ex);
            }

            return(Json(res));
        }
Exemple #11
0
        /// <summary>
        /// Check user permission for screen CMS150 and check all parameter must have value.
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public ActionResult CMS150_Authority(CMS150_ScreenParameter param)
        {
            ObjectResultData res = new ObjectResultData();

            try
            {
                if (ModelState.IsValid == false)
                {
                    ValidatorUtil.BuildErrorMessage(res, this);
                    if (res.IsError)
                    {
                        return(Json(res));
                    }
                }

                //1. Check permission
                if (!CheckUserPermission(ScreenID.C_SCREEN_ID_VIEW_HISTORY_DIGEST, FunctionID.C_FUNC_ID_OPERATE))
                {
                    res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0053);
                    return(Json(res));
                }

                //2. Check parameter is OK ?
                if (CommonUtil.IsNullOrEmpty(param.ContractCode) || CommonUtil.IsNullOrEmpty(param.ServiceTypeCode))
                {
                    res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0040);
                    return(Json(res));
                }

                CommonUtil ComUtil             = new CommonUtil();
                string     strLongContractCode = ComUtil.ConvertContractCode(param.ContractCode, CommonUtil.CONVERT_TYPE.TO_LONG);


                // ---- Wrong !! -- You must get these data when pass check Authority !!!
                //dsRentalBasicForHistDigestView dsRentBasicForHDView;
                //dsSaleBasicForHistDigestView dsSaleBasicForHDView;
                //if (param.ServiceTypeCode == ServiceType.C_SERVICE_TYPE_RENTAL)
                //{
                //    dsRentBasicForHDView = GetRentalBasicForHistoryDigestView(strLongContractCode);
                //    param.dsRentBasicForHDView = dsRentBasicForHDView;
                //}
                //else
                //{
                //    dsSaleBasicForHDView = GetSaleBasicForHistoryDigestView(ComUtil.ConvertContractCode(param.ContractCode, CommonUtil.CONVERT_TYPE.TO_LONG), param.OCC);
                //    param.dsSaleBasicForHDView = dsSaleBasicForHDView;
                //}
            }
            catch (Exception ex)
            {
                res.AddErrorMessage(ex);
                return(Json(res));
            }

            return(InitialScreenEnvironment <CMS150_ScreenParameter>("CMS150", param, res));
        }
Exemple #12
0
        /// <summary>
        /// Event when click register button
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public ActionResult ICS010_cmdRegister(ICS010_ScreenParameter param)
        {
            ObjectResultData res = new ObjectResultData();

            res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;

            try
            {
                if (IsSuspend(res))
                {
                    return(Json(res));
                }

                if (!ICS010_IsAllowOperate(res))
                {
                    return(Json(res));
                }

                ICS010_ScreenParameter screenObject = GetScreenObject <ICS010_ScreenParameter>();

                //Validate only Existing Payment List
                ValidatorUtil validator = new ValidatorUtil();
                ICS010_ValidateIsExistingPaymentList(validator);
                ValidatorUtil.BuildErrorMessage(res, validator, null);
                if (res.IsError)
                {
                    return(Json(res));
                }

                // Validate business
                List <tbt_Payment> paymentList = screenObject.PaymentList;
                foreach (var item in paymentList)
                {
                    ICS010_ValidatePaymentBusiness(validator, item);
                }

                ValidatorUtil.BuildErrorMessage(res, validator, null);
                //Have Error Message
                if (res.IsError)
                {
                    return(Json(res));
                }


                //Result flag  1 = Success
                res.ResultData = "1";
            }
            catch (Exception ex)
            {
                res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION;
                res.AddErrorMessage(ex);
            }
            return(Json(res));
        }
Exemple #13
0
        /// <summary>
        /// Retrieve invoice information of specific invoice no.
        /// </summary>
        /// <param name="param">invoice no.</param>
        /// <returns></returns>
        public ActionResult ICS050_GetInvoice(ICS050_ScreenParameter param)
        {
            ObjectResultData res = new ObjectResultData();

            res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;
            doInvoice doInvoice;

            try
            {
                ValidatorUtil validator = new ValidatorUtil();

                // Check required field.
                if (CommonUtil.IsNullOrEmpty(param) || string.IsNullOrEmpty(param.InvoiceNo))
                {
                    validator.AddErrorMessage(MessageUtil.MODULE_INCOME, "ICS050"
                                              , MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0007
                                              , "InvoiceNo", "lblInvoiceNo", "InvoiceNo");
                    ValidatorUtil.BuildErrorMessage(res, validator, null);
                    return(Json(res));
                }

                //Get Invoice Data
                var billingHandler = ServiceContainer.GetService <IBillingHandler>() as IBillingHandler;
                doInvoice = billingHandler.GetInvoice(param.InvoiceNo);
                if (doInvoice == null)
                {
                    validator.AddErrorMessage(MessageUtil.MODULE_INCOME, "ICS050"
                                              , MessageUtil.MODULE_INCOME, MessageUtil.MessageList.MSG7003
                                              , "InvoiceNo", "lblInvoiceNo", "InvoiceNo");
                    ValidatorUtil.BuildErrorMessage(res, validator, null);
                    res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION;
                    return(Json(res));
                }

                //Validate business
                ICS050_ValidateInvoiceBusiness(doInvoice, validator);
                ValidatorUtil.BuildErrorMessage(res, validator, null);
                if (res.IsError)
                {
                    return(Json(res));
                }

                //Pass
                res.ResultData = doInvoice;
                return(Json(res));
            }
            catch (Exception ex)
            {
                res             = new ObjectResultData();
                res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION;
                res.AddErrorMessage(ex);
                return(Json(res));
            }
        }
Exemple #14
0
        protected string GetValidationErrors <TQuery>(TQuery query)
        {
            string result = "";
            List <ValidationResult> errors;

            if (!ValidatorUtil.TryValidate(this, out errors))
            {
                string.Join(Environment.NewLine, errors.Select(e => e.ErrorMessage));
            }
            return(result);
        }
Exemple #15
0
        /// <summary>
        /// Search instrument information
        /// </summary>
        /// <param name="Cond">Search condition object</param>
        /// <returns></returns>
        public ActionResult IVS100_SearchInventoryInstrument(IVS100SearchCond Cond)
        {
            IInventoryDocumentHandler handler = ServiceContainer.GetService <IInventoryDocumentHandler>() as IInventoryDocumentHandler;

            ObjectResultData res = new ObjectResultData();

            try
            {    //Valid Cond
                ValidatorUtil.BuildErrorMessage(res, this, new object[] { Cond });
                if (res.IsError)
                {
                    res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;
                    return(Json(res));
                }

                IInventoryHandler InvH = ServiceContainer.GetService <IInventoryHandler>() as IInventoryHandler;

                IVS100_ScreenParameter param = GetScreenObject <IVS100_ScreenParameter>();

                List <dtSearchInstrumentListResult> lstResult =

                    InvH.SearchInventoryInstrumentList(param.office.OfficeCode,
                                                       Cond.SourceLoc,
                                                       Cond.InstArea,
                                                       ShelfType.C_INV_SHELF_TYPE_NORMAL,
                                                       null,
                                                       null,
                                                       Cond.InstName,
                                                       Cond.InstCode,
                                                       new string[] { InstrumentArea.C_INV_AREA_SE_LENDING_DEMO }
                                                       );

                if (lstResult.Count == 0)
                {
                    //res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0001);
                    res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION;
                    return(Json(res));
                }
                else if (lstResult.Count > 1000)
                {
                    res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4004);
                    res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION;
                    return(Json(res));
                }

                res.ResultData = CommonUtil.ConvertToXml <dtSearchInstrumentListResult>(lstResult, "inventory\\IVS100_Instrument", CommonUtil.GRID_EMPTY_TYPE.SEARCH);
                return(Json(res));
            }
            catch (Exception ex)
            {
                res.AddErrorMessage(ex); return(Json(res));
            }
        }
Exemple #16
0
        public LoginModelValidator()
        {
            CascadeMode = CascadeMode.StopOnFirstFailure;

            RuleFor(x => x.Username)
            .NotEmpty()
            .Must((username) => ValidatorUtil.IsValidEmail(username))
            .WithMessage("Username must be an email");

            RuleFor(x => x.Password)
            .NotEmpty();
        }
Exemple #17
0
        /// <summary>
        /// Validate payment list
        /// </summary>
        /// <param name="validator"></param>
        private void ICS010_ValidateIsExistingPaymentList(ValidatorUtil validator)
        {
            ICS010_ScreenParameter session = GetScreenObject <ICS010_ScreenParameter>();

            if (CommonUtil.IsNullOrEmpty(session) || CommonUtil.IsNullOrEmpty(session.PaymentList) ||
                session.PaymentList.Count == 0)
            {
                validator.AddErrorMessage(MessageUtil.MODULE_INCOME, "ICS010"
                                          , MessageUtil.MODULE_INCOME, MessageUtil.MessageList.MSG7071
                                          , "Payment");
            }
        }
        /// <summary>
        /// Validate user input.
        /// </summary>
        /// <returns></returns>
        public ActionResult MAS030_ValidateData()
        {
            ObjectResultData res = new ObjectResultData();

            res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;

            try
            {
                doBillingClient custDo = null;

                MAS030_ScreenParameter custData = GetScreenObject <MAS030_ScreenParameter>();
                if (custData != null)
                {
                    if (custData.InputData != null)
                    {
                        custDo = custData.InputData;
                    }
                }

                if (custDo != null)
                {
                    //IMasterHandler mhandler = ServiceContainer.GetService<IMasterHandler>() as IMasterHandler;
                    ICommonHandler chandler = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;

                    #region Set Misc Data

                    MiscTypeMappingList miscList = new MiscTypeMappingList();
                    miscList.AddMiscType(custDo);
                    chandler.MiscTypeMappingList(miscList);

                    #endregion
                }

                MAS030_ValidateCombo validate = CommonUtil.CloneObject <doBillingClient, MAS030_ValidateCombo>(custDo);
                ValidatorUtil.BuildErrorMessage(res, new object[] { validate });

                if (custDo != null)
                {
                    if (custDo.ValidateBillingClient == true)
                    {
                        MAS030_CheckReqField vq = CommonUtil.CloneObject <doBillingClient, MAS030_CheckReqField>(custDo);
                        ValidatorUtil.BuildErrorMessage(res, new object[] { vq });
                    }
                }
            }
            catch (Exception ex)
            {
                res.AddErrorMessage(ex);
            }

            return(Json(res));
        }
Exemple #19
0
 protected bool IsValid <TQuery>(TQuery query)
     where TQuery : class
 {
     try
     {
         ValidatorUtil.Validate(query);
         return(true);
     }
     catch (ValidationException)
     {
         return(false);
     }
 }
Exemple #20
0
        /// <summary>
        /// Retrieve billing detail list of specific customer code.
        /// </summary>
        /// <param name="custCode">Customer Code</param>
        /// <returns></returns>
        public ActionResult ICS081_SearchBillingbyCustomerCode(string customerCode) //Add by Jutarat A. on 09042013
        {
            ObjectResultData res = new ObjectResultData();

            res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;
            ValidatorUtil validator = new ValidatorUtil();

            try
            {
                //Validate business
                if (CommonUtil.IsNullOrEmpty(customerCode))
                {
                    validator.AddErrorMessage(MessageUtil.MODULE_INCOME, "ICS081"
                                              , MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0007
                                              , "ics081CutomerCode", "lblCustomerCode", "ics081CutomerCode");
                    ValidatorUtil.BuildErrorMessage(res, validator, null);
                    return(Json(res));
                }

                //Get invoice
                CommonUtil c = new CommonUtil();
                string     longCustomerCode = c.ConvertCustCode(customerCode, CommonUtil.CONVERT_TYPE.TO_LONG);

                var masterHandler = ServiceContainer.GetService <IMasterHandler>() as IMasterHandler;
                var doCustomer    = masterHandler.GetTbm_Customer(longCustomerCode);
                if (doCustomer == null || doCustomer.Count == 0)
                {
                    validator.AddErrorMessage(MessageUtil.MODULE_INCOME, "ICS081"
                                              , MessageUtil.MODULE_INCOME, MessageUtil.MessageList.MSG7003
                                              , "ics081CutomerCode", "lblCustomerCode", "ics081CutomerCode");
                    ValidatorUtil.BuildErrorMessage(res, validator, null);
                    res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION;
                    return(Json(res));
                }

                //Get unpaidbilling, retun result
                var incomeHandler = ServiceContainer.GetService <IIncomeHandler>() as IIncomeHandler;
                List <doGetUnpaidBillingTargetByCodeWithExchange> unpaidList = incomeHandler.GetUnpaidBillingTargetByCustomerCodeWithExchange(longCustomerCode);
                ICS081_ValidateDisplayBillingTargetSearchResult(res, unpaidList, true);
                res.ResultData = CommonUtil.ConvertToXml <doGetUnpaidBillingTargetByCodeWithExchange>(unpaidList, "Income\\ICS081", CommonUtil.GRID_EMPTY_TYPE.SEARCH);
                return(Json(res));
            }
            catch (Exception ex)
            {
                res             = new ObjectResultData();
                res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION;
                res.AddErrorMessage(ex);
                return(Json(res));
            }
        }
    protected void BtnAddItem_Click(object sender, EventArgs e)
    {
        try
        {
            PriceList pl = new PriceList();
            pl.SupplierCode = code;
            pl.ItemCode     = DDLItem.SelectedValue;
            if (!ValidatorUtil.isEmpty(TxtAddNewItem.Text.Trim()))
            {
                pl.Price = decimal.Parse(TxtAddNewItem.Text.Trim());
            }
            if (!(DDLPriorityRank.SelectedValue == "NA"))
            {
                pl.SupplierRank = int.Parse(DDLPriorityRank.SelectedValue);
            }
            if (!ValidatorUtil.isEmpty(TxtTenderYear.Text.Trim()))
            {
                pl.TenderYear = (TxtTenderYear.Text.Trim());
            }

            PriceList verifiPL = mplc.GetPriceListGivenItemCodeRankNTenderYear(pl.ItemCode, int.Parse(DDLPriorityRank.SelectedValue), pl.TenderYear);
            if (verifiPL == null)
            {
                mplc.AddPriceListItem(pl);
                DefaultDropDownListRestore();
                PopulateTenderSupplyList();
                Utility.DisplayAlertMessage(Message.SuccessfulItemAdd);
            }
            else
            {
                Utility.DisplayAlertMessage(Message.PriceListExistsForGivenTenderYear);
            }
        }
        catch (InvalidOperationException)
        {
            Utility.DisplayAlertMessage(Message.InvalidEntry);
        }
        catch (DbUpdateException)
        {
            Utility.DisplayAlertMessage(Message.ValidationError);
        }
        catch (DbEntityValidationException)
        {
            Utility.DisplayAlertMessage(Message.ValidationError);
        }
        catch (Exception)
        {
            Utility.DisplayAlertMessage(Message.GeneralError);
        }
    }
Exemple #22
0
 /// <summary>
 /// Check mandatory field
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <typeparam name="R"></typeparam>
 /// <param name="obj"></param>
 /// <param name="validator"></param>
 /// <param name="param"></param>
 public static void CheckMandatoryField <T, R>(T obj, ValidatorUtil validator, MessageParameter param = null)
     where T : class
     where R : new()
 {
     try
     {
         R cond = CommonUtil.CloneObject <T, R>(obj);
         CheckMandatoryField(cond, validator, param);
     }
     catch (Exception)
     {
         throw;
     }
 }
        /// <summary>
        /// Search AR by criteria when click [Search] button on AR list by role section
        /// </summary>
        /// <param name="condition"></param>
        /// <returns></returns>
        public ActionResult CTS360_SearchAR(SearchARCondition condition)
        {
            ObjectResultData res = new ObjectResultData();

            try {
                res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;
                ValidatorUtil.BuildErrorMessage(res, this, new object[] { condition });

                if (condition.SpecfyPeriod == null && (condition.SpecifyPeriodFrom.HasValue || condition.SpecifyPeriodTo.HasValue))
                {
                    res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0116, null, new string[] { "cboSearchSpecifyPeriod" });
                }

                if (condition.SpecfyPeriod != null &&
                    condition.SpecifyPeriodFrom.HasValue && condition.SpecifyPeriodTo.HasValue &&
                    condition.SpecifyPeriodFrom.Value.CompareTo(condition.SpecifyPeriodTo.Value) > 0)
                {
                    res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0090, null, new string[] { "dateSearchPeriodFrom", "dateSearchPeriodTo" });
                }

                if (res.IsError)
                {
                    return(Json(res));
                }

                CommonUtil c = new CommonUtil();
                condition.ContractCode        = c.ConvertContractCode(condition.ContractCode, CommonUtil.CONVERT_TYPE.TO_LONG);
                condition.QuotationTargetCode = c.ConvertQuotationTargetCode(condition.QuotationTargetCode, CommonUtil.CONVERT_TYPE.TO_LONG);
                IARHandler      hand = ServiceContainer.GetService <IARHandler>() as IARHandler;
                List <dtARList> list = hand.SearchARList(condition);
                CommonUtil.MappingObjectLanguage <dtARList>(list);

                MiscTypeMappingList miscMapList = new MiscTypeMappingList();
                miscMapList.AddMiscType(list.ToArray());
                ICommonHandler comh = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
                comh.MiscTypeMappingList(miscMapList);

                foreach (var ar in list)
                {
                    setColStyle(ar);
                }

                string xml = CommonUtil.ConvertToXml <dtARList>(list, "Contract\\CTS360", CommonUtil.GRID_EMPTY_TYPE.SEARCH);
                res.ResultData = xml;
            } catch (Exception ex) {
                res.AddErrorMessage(ex);
            }

            return(Json(res));
        }
        /// <summary>
        /// Confirm data user input.<br />
        /// - Generate customer full address.<br />
        /// - Check is site change.
        /// </summary>
        /// <param name="doSite"></param>
        /// <returns></returns>
        public ActionResult MAS040_ConfirmData(MAS040_CheckRequiredField doSite)
        {
            ObjectResultData res = new ObjectResultData();

            res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;

            try
            {
                if (ModelState.IsValid == false)
                {
                    ValidatorUtil.BuildErrorMessage(res, this);
                    return(Json(res));
                }

                #region Create Customer Address Full

                doCustomer     cust     = CommonUtil.CloneObject <doSite, doCustomer>(doSite);
                IMasterHandler mhandler = ServiceContainer.GetService <IMasterHandler>() as IMasterHandler;
                mhandler.CreateAddressFull(cust);

                doSite.AddressFullEN = cust.AddressFullEN;
                doSite.AddressFullLC = cust.AddressFullLC;

                #endregion
                #region Check is changed

                if (doSite != null)
                {
                    if (MAS040_IsSiteChanged(doSite) == true)
                    {
                        doSite.SiteCode = null;
                    }
                    else
                    {
                        CommonUtil cmm = new CommonUtil();
                        doSite.SiteCode = cmm.ConvertSiteCode(doSite.SiteCode, CommonUtil.CONVERT_TYPE.TO_LONG);
                    }
                }
                #endregion

                res.ResultData = doSite;
            }
            catch (Exception ex)
            {
                res.AddErrorMessage(ex);
            }

            return(Json(res));
        }
 private void CMS490_ValidateData(ValidatorUtil validator, string DocNo, string DocType)
 {
     if (CommonUtil.IsNullOrEmpty(DocType))
     {
         validator.AddErrorMessage(MessageUtil.MODULE_COMMON, "CMS490"
                                   , MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0007
                                   , "txtDocType", "lblDocType", "txtDocType"); // id, message, id that color is changed
     }
     if (CommonUtil.IsNullOrEmpty(DocNo))
     {
         validator.AddErrorMessage(MessageUtil.MODULE_COMMON, "CMS490"
                                   , MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0007
                                   , "txtDocNo", "lblDocNo", "txtDocNo"); // id, message, id that color is changed
     }
 }
        /// <summary>
        /// Search stock checking list.
        /// </summary>
        /// <param name="cond"></param>
        /// <returns></returns>
        public ActionResult IVS170_SearchResponse(IVS170_doGetStockCheckingList cond)
        {
            List <dtStockCheckingList> list = new List <dtStockCheckingList>();

            ObjectResultData res = new ObjectResultData();

            res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;

            try
            {
                // Model validation
                if (ModelState.IsValid == false)
                {
                    ValidatorUtil.BuildErrorMessage(res, this);
                    if (res.IsError)
                    {
                        return(Json(res));
                    }
                }

                //Validate #1
                //if (CommonUtil.IsNullAllField(cond))
                //{
                //    res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0006);
                //    return Json(res);
                //}

                //Validate #2
                if ((!CommonUtil.IsNullOrEmpty(cond.ShelfNoFrom)) &&
                    (!CommonUtil.IsNullOrEmpty(cond.ShelfNoTo)) &&
                    (String.Compare(cond.ShelfNoFrom, cond.ShelfNoTo) > 0))
                {
                    res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4015, null, new string[] { "ShelfNoFrom", "ShelfNoTo" });
                    return(Json(res));
                }

                IInventoryHandler handler = ServiceContainer.GetService <IInventoryHandler>() as IInventoryHandler;
                list = handler.GetStockCheckingList(cond);
            }
            catch (Exception ex)
            {
                res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION;
                res.AddErrorMessage(ex);
            }

            res.ResultData = CommonUtil.ConvertToXml <dtStockCheckingList>(list, "Inventory\\IVS170", CommonUtil.GRID_EMPTY_TYPE.VIEW);
            return(Json(res));
        }
Exemple #27
0
        /// <summary>
        /// Retrieve billing detail list of specific receipt no.
        /// </summary>
        /// <param name="receiptNo">receipt no.</param>
        /// <returns></returns>
        public ActionResult ICS081_SearchBillingbyReceiptNo(string receiptNo)
        {
            ObjectResultData res = new ObjectResultData();

            res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;
            ValidatorUtil validator = new ValidatorUtil();

            try
            {
                //Validate business
                if (CommonUtil.IsNullOrEmpty(receiptNo))
                {
                    validator.AddErrorMessage(MessageUtil.MODULE_INCOME, "ICS081"
                                              , MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0007
                                              , "ics081ReceiptNo", "lblReceiptNo", "ics081ReceiptNo");
                    ValidatorUtil.BuildErrorMessage(res, validator, null);
                    return(Json(res));
                }

                var handler = ServiceContainer.GetService <IIncomeHandler>() as IIncomeHandler;

                //Get receipt
                doReceipt doReceipt = handler.GetReceipt(receiptNo);
                if (doReceipt == null)
                {
                    validator.AddErrorMessage(MessageUtil.MODULE_INCOME, "ICS081"
                                              , MessageUtil.MODULE_INCOME, MessageUtil.MessageList.MSG7003
                                              , "ics081ReceiptNo", "lblReceiptNo", "ics081ReceiptNo");
                    ValidatorUtil.BuildErrorMessage(res, validator, null);
                    res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION;
                    return(Json(res));
                }

                //Get unpaid, return result
                List <doGetUnpaidBillingTargetByCodeWithExchange> unpaidList = handler.GetUnpaidBillingTargetByReceiptNoWithExchange(receiptNo);
                ICS081_ValidateDisplayBillingTargetSearchResult(res, unpaidList, true);
                res.ResultData = CommonUtil.ConvertToXml <doGetUnpaidBillingTargetByCodeWithExchange>(unpaidList, "Income\\ICS081", CommonUtil.GRID_EMPTY_TYPE.SEARCH);
                return(Json(res));
            }
            catch (Exception ex)
            {
                res             = new ObjectResultData();
                res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION;
                res.AddErrorMessage(ex);
                return(Json(res));
            }
        }
        /// <summary>
        /// Validate data before add system product
        /// </summary>
        /// <param name="Cond"></param>
        /// <returns></returns>
        public ActionResult CTS230_CheckBeforeAddSystemProduct(CTS230_SystemProduct Cond)
        {
            ObjectResultData res = new ObjectResultData();

            res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION;


            try
            {      //Valid Cond
                ValidatorUtil.BuildErrorMessage(res, this, null);
                if (res.IsError)
                {
                    res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;
                    return(Json(res));
                }

                bool IsSysProdExists = false;
                if (!CommonUtil.IsNullOrEmpty(Cond.lstSystemProductName))
                {
                    for (int i = 0; i < Cond.lstSystemProductName.Length; i++)
                    {
                        if (Cond.SystemProductName.ToUpper() == Cond.lstSystemProductName[i].ToUpper())
                        {
                            IsSysProdExists = true;
                            break;
                        }
                    }
                }

                if (IsSysProdExists)
                {
                    res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;
                    res.AddErrorMessage(MessageUtil.MODULE_CONTRACT, MessageUtil.MessageList.MSG3187, new string[] { Cond.SystemProductName });
                    return(Json(res));
                }
            }
            catch (Exception ex)
            {
                res.AddErrorMessage(ex);
                return(Json(res));
            }


            return(Json(true));
        }
        /// <summary>
        /// Retrieve invoice information of specific invoice no.
        /// </summary>
        /// <param name="invoiceNo">invoice no.</param>
        /// <param name="res"></param>
        /// <returns></returns>
        private doInvoice ICS040_GetInvoice(string invoiceNo, ObjectResultData res)
        {
            IBillingHandler billingHandler = ServiceContainer.GetService <IBillingHandler>() as IBillingHandler;
            ValidatorUtil   validator      = new ValidatorUtil();
            doInvoice       doInvoice      = billingHandler.GetInvoice(invoiceNo);

            if (doInvoice == null)
            {
                validator.AddErrorMessage(MessageUtil.MODULE_INCOME, "ICS040"
                                          , MessageUtil.MODULE_INCOME, MessageUtil.MessageList.MSG7003
                                          , "InvoiceNo", "lblInvoiceNo", "InvoiceNo");

                ValidatorUtil.BuildErrorMessage(res, validator, null);
                res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION;
                return(null);
            }
            return(doInvoice);
        }
Exemple #30
0
        /// <summary>
        /// Validate Contract information condition.
        /// </summary>
        /// <param name="Cond"></param>
        /// <returns></returns>
        public ActionResult CMS150Valid(doContractInfoCondition Cond)
        {
            ObjectResultData res = new ObjectResultData();

            try
            {
                if (ModelState.IsValid == false)
                {
                    ValidatorUtil.BuildErrorMessage(res, this);
                }
                res.ResultData = true;
            }
            catch (Exception ex)
            {
                return(Json(ex));
            }
            return(Json(res));
        }