Ejemplo n.º 1
0
        public ActionResult CTS054()
        {
            ObjectResultData res  = new ObjectResultData();
            CommonUtil       util = new CommonUtil();

            try
            {
                CTS054_ScreenParameter session = GetScreenObject <CTS054_ScreenParameter>();
                ViewBag.ContractCode  = util.ConvertContractCode(session.ContractCode, CommonUtil.CONVERT_TYPE.TO_SHORT);
                ViewBag.ImportantFlag = false;
                HasAuthority_CTS054(session.ScreenParameter.ContractCode.Trim());
                if (ViewBag.Permission == true && ViewBag.IsSystemSuspending == false && ViewBag.HasAuthorityContract == true && ViewBag.HasAuthorityOperation == true)
                {
                    InitialScreen_CTS054(session.ScreenParameter.ContractCode.Trim());
                }

                return(View("CTS054"));
            }
            catch (Exception ex)
            {
                res.AddErrorMessage(ex);
            }

            return(Json(res));
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Set import data to screen
 /// </summary>
 /// <param name="import"></param>
 /// <param name="key"></param>
 private void CTS054_SetImportData(CTS054_ScreenParameter import, string key = null)
 {
     try
     {
         UpdateScreenObject(import, key);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Initial session of screen
        /// </summary>
        /// <returns></returns>
        public CTS054_ScreenParameter InitialScreenSession_CTS054()
        {
            try
            {
                CTS054_ScreenParameter importData = new CTS054_ScreenParameter()
                {
                    DORegisterData     = new CTS054_DOValidateBusiness(),
                    DOValidateBusiness = new CTS054_DOValidateBusiness(),
                    ScreenParameter    = new CTS054_Parameter()
                };

                CTS054_SetImportData(importData);
                return(importData);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Check system suspending, user’s permission and user’s authority of screen
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public ActionResult CTS054_Authority(CTS054_ScreenParameter param)
        {
            ObjectResultData res = new ObjectResultData();

            try
            {
                CommonUtil              util          = new CommonUtil();
                ISaleContractHandler    salehandler   = ServiceContainer.GetService <ISaleContractHandler>() as ISaleContractHandler;
                ICommonHandler          commonHandler = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
                IRentralContractHandler renderHandler = ServiceContainer.GetService <IRentralContractHandler>() as IRentralContractHandler;
                //return InitialScreenEnvironment("CTS054", session);

                // Natthavat S., 2012/01/30
                // Check Authority Here

                //1.1 Check suspending
                if (commonHandler.IsSystemSuspending())
                {
                    res.AddErrorMessage("Common", MessageUtil.MessageList.MSG0049, null, null);
                    return(Json(res));
                }

                //1.2 Check user's permission
                if (!CheckUserPermission(ScreenID.C_SCREEN_ID_CP12_CHANGE_EXPECTED_OPR_DATE, FunctionID.C_FUNC_ID_OPERATE))
                {
                    res.AddErrorMessage("Common", MessageUtil.MessageList.MSG0053, null, null);
                    return(Json(res));
                }

                //if (String.IsNullOrEmpty(param.ContractCode) && !String.IsNullOrEmpty(CommonUtil.dsTransData.dtCommonSearch.ContractCode))
                //{
                //    param.ContractCode = CommonUtil.dsTransData.dtCommonSearch.ContractCode;
                //}
                if (String.IsNullOrEmpty(param.ContractCode) && param.CommonSearch != null)
                {
                    if (CommonUtil.IsNullOrEmpty(param.CommonSearch.ContractCode) == false)
                    {
                        param.ContractCode = param.CommonSearch.ContractCode;
                    }
                }

                // Check parameter
                if ((param == null) ||
                    (String.IsNullOrEmpty(param.ContractCode)))
                {
                    // Not valid
                    //res.AddErrorMessage("Common", MessageUtil.MessageList.MSG0011, new string[] { "Contract Code" }, null);
                    res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0147, null, null);
                    return(Json(res));
                }

                //Comment by Jutarat A. on 08082012
                //var saleExists = salehandler.IsContractExist(util.ConvertContractCode(param.ContractCode, CommonUtil.CONVERT_TYPE.TO_LONG));
                //if (saleExists.Count > 0 && saleExists[0].GetValueOrDefault())
                //{
                //    res.AddErrorMessage(MessageUtil.MODULE_CONTRACT, MessageUtil.MessageList.MSG3278, null, null);
                //    return Json(res);
                //}

                // Check is contact exists
                var contractObj = renderHandler.GetTbt_RentalContractBasic(util.ConvertContractCode(param.ContractCode, CommonUtil.CONVERT_TYPE.TO_LONG), null);
                if ((contractObj == null) ||
                    (contractObj.Count == 0))
                {
                    // Not found
                    //res.AddErrorMessage("Common", MessageUtil.MessageList.MSG0011, new string[] { String.Format("Contract Code: {0}", param.ContractCode) }, null);
                    res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0124, null, null);
                    return(Json(res));
                }

                //1.3 Check user's authority to view data

                /*
                 * if (CommonUtil.dsTransData.dtOfficeData.Where(x => x.OfficeCode == contractObj[0].ContractOfficeCode).Count() == 0)
                 * {
                 *  //if (CommonUtil.dsTransData.dtOfficeData.FindAll(delegate(OfficeDataDo s) { return s.OfficeCode == listRentalContractBasic[0].ContractOfficeCode; }).Count == 0)
                 *  res.AddErrorMessage("Common", MessageUtil.MessageList.MSG0063, null, null);
                 *  return Json(res);
                 * }
                 *
                 * if (CommonUtil.dsTransData.dtOfficeData.Where(x => x.OfficeCode == contractObj[0].OperationOfficeCode).Count() == 0)
                 * {
                 *  //if (CommonUtil.dsTransData.dtOfficeData.FindAll(delegate(OfficeDataDo s) { return s.OfficeCode == listRentalContractBasic[0].OperationOfficeCode; }).Count == 0)
                 *  res.AddErrorMessage("Common", MessageUtil.MessageList.MSG0063, null, null);
                 *  return Json(res);
                 * }*/

                var existsContarctOffice = CommonUtil.dsTransData.dtOfficeData.Where(x => x.OfficeCode == contractObj[0].ContractOfficeCode);
                var existsOperateOffice  = CommonUtil.dsTransData.dtOfficeData.Where(x => x.OfficeCode == contractObj[0].OperationOfficeCode);

                if ((contractObj[0].ContractStatus == ContractStatus.C_CONTRACT_STATUS_BEF_START &&
                     (existsContarctOffice.Count() <= 0) && (existsOperateOffice.Count() <= 0)) ||
                    (contractObj[0].ContractStatus == ContractStatus.C_CONTRACT_STATUS_AFTER_START &&
                     (existsOperateOffice.Count() <= 0))
                    )
                {
                    res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0063, null, null);
                    //res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;
                    return(Json(res));
                }

                string lastOCC = "";
                lastOCC = renderHandler.GetLastUnimplementedOCC(util.ConvertContractCode(param.ContractCode, CommonUtil.CONVERT_TYPE.TO_LONG));
                if (String.IsNullOrEmpty(lastOCC))
                {
                    res.AddErrorMessage(MessageUtil.MODULE_CONTRACT, MessageUtil.MessageList.MSG3053, null, null);
                    //res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;
                    return(Json(res));
                }

                CTS054_ScreenParameter session = InitialScreenSession_CTS054();
                session.ScreenParameter.ContractCode = util.ConvertContractCode(param.ContractCode, CommonUtil.CONVERT_TYPE.TO_LONG);
                //session.ScreenParameter.ContractCode = param.ContractCode;
                session.ContractCode = session.ScreenParameter.ContractCode;
                session.CommonSearch = param.CommonSearch;

                return(InitialScreenEnvironment <CTS054_ScreenParameter>("CTS054", session, res));
            }
            catch (Exception ex)
            {
                res.AddErrorMessage(ex);
            }

            return(Json(res));
        }