Пример #1
0
        /// <summary>
        /// Reset data of screen
        /// </summary>
        /// <param name="lastOCC"></param>
        /// <returns></returns>
        public ActionResult ResetClick_CTS061(string lastOCC)
        {
            string expectedInstallCompleteDate = "";

            ObjectResultData res = new ObjectResultData();
            ObjectResultData resValidateBusiness = new ObjectResultData();
            CommonUtil       util = new CommonUtil();

            CTS061_ScreenParameter session;
            ISaleContractHandler   salehandler        = ServiceContainer.GetService <ISaleContractHandler>() as ISaleContractHandler;
            IUserControlHandler    usercontrolhandler = ServiceContainer.GetService <IUserControlHandler>() as IUserControlHandler;

            try
            {
                //Set screen to Initial state
                session = CTS061_GetImportData();
                expectedInstallCompleteDate = CommonUtil.TextDate(salehandler.GetTbt_SaleBasic(session.DSSaleContract.dtTbt_SaleBasic[0].ContractCode, lastOCC, true)[0].ExpectedInstallCompleteDate);
                var saleContractInfo = usercontrolhandler.GetSaleContractBasicInformationData(session.ContractCode, null);

                InitialScreen_CTS061(session.ContractCode);
                session = GetScreenObject <CTS061_ScreenParameter>();

                CTS061_ScreenOutputObject outObj = new CTS061_ScreenOutputObject()
                {
                    CanOperate                  = true,
                    ContractCode                = session.ContractCode,
                    ContractCodeShort           = util.ConvertContractCode(session.ContractCode, CommonUtil.CONVERT_TYPE.TO_SHORT),
                    ExpectedInstallCompleteDate = expectedInstallCompleteDate,
                    InstallationStatusCode      = saleContractInfo[0].InstallationStatusCode,
                    InstallationStatusCodeName  = saleContractInfo[0].InstallationStatusCodeName,
                    LastOCC              = salehandler.GetLastOCC(session.ContractCode),
                    ImportantFlag        = saleContractInfo[0].PurchaserCustomerImportant.GetValueOrDefault(),
                    OperationOfficeName  = CommonUtil.TextCodeName(saleContractInfo[0].OperationOfficeCode, saleContractInfo[0].OperationOfficeName),
                    PurchaserAddressEN   = saleContractInfo[0].PurchaserAddressEN,
                    PurchaserAddressLC   = saleContractInfo[0].PurchaserAddressLC,
                    PurchaserCustCode    = util.ConvertCustCode(saleContractInfo[0].PurchaserCustCode, CommonUtil.CONVERT_TYPE.TO_SHORT),
                    PurchaserNameEN      = saleContractInfo[0].PurchaserNameEN,
                    PurchaserNameLC      = saleContractInfo[0].PurchaserNameLC,
                    RealCustomerCustCode = util.ConvertCustCode(saleContractInfo[0].RealCustomerCustCode, CommonUtil.CONVERT_TYPE.TO_SHORT),
                    SiteAddressEN        = saleContractInfo[0].SiteAddressEN,
                    SiteAddressLC        = saleContractInfo[0].SiteAddressLC,
                    SiteCode             = util.ConvertSiteCode(saleContractInfo[0].SiteCode, CommonUtil.CONVERT_TYPE.TO_SHORT),
                    SiteNameEN           = saleContractInfo[0].SiteNameEN,
                    SiteNameLC           = saleContractInfo[0].SiteNameLC
                };

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

            return(Json(res));
        }
Пример #2
0
        //BackClick perform in javascript

        #endregion

        #region Method

        /// <summary>
        /// Check system suspending, user’s permission and user’s authority of screen
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public ActionResult CTS061_Authority(CTS061_ScreenParameter param)
        {
            ObjectResultData res = new ObjectResultData();

            try
            {
                CommonUtil           util          = new CommonUtil();
                ICommonHandler       commonHandler = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
                ISaleContractHandler saleHandler   = ServiceContainer.GetService <ISaleContractHandler>() as ISaleContractHandler;

                //1.1 Check suspending
                if (commonHandler.IsSystemSuspending())
                {
                    res.AddErrorMessage("Common", MessageUtil.MessageList.MSG0049, new string[] { String.Format("Contract Code: {0}", param.ContractCode) }, null);
                    return(Json(res));
                }

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

                // Check parameter
                if ((param == null) ||
                    (String.IsNullOrEmpty(param.ContractCode)))
                {
                    //if (String.IsNullOrEmpty(CommonUtil.dsTransData.dtCommonSearch.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);
                    //}
                    //else
                    //{
                    //    param.ContractCode = CommonUtil.dsTransData.dtCommonSearch.ContractCode;
                    //}

                    if (param.CommonSearch != null)
                    {
                        if (CommonUtil.IsNullOrEmpty(param.CommonSearch.ContractCode) == false)
                        {
                            param.ContractCode = param.CommonSearch.ContractCode;
                        }
                    }
                    if (String.IsNullOrEmpty(param.ContractCode))
                    {
                        res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0147, null, null);
                        return(Json(res));
                    }
                }

                // Check is contact exists
                var contractObj = saleHandler.GetTbt_SaleBasic(util.ConvertContractCode(param.ContractCode, CommonUtil.CONVERT_TYPE.TO_LONG), null, true);
                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));
                }

                string lastOCC        = saleHandler.GetLastOCC(contractObj[0].ContractCode);
                var    dsSaleContract = saleHandler.GetEntireContract(contractObj[0].ContractCode, lastOCC);

                if ((dsSaleContract != null) &&
                    (dsSaleContract.dtTbt_SaleBasic != null) &&
                    (dsSaleContract.dtTbt_SaleBasic.Count != 0))
                {
                    /*
                     * if (CommonUtil.dsTransData.dtOfficeData.FindAll(delegate(OfficeDataDo s) { return s.OfficeCode == dsSaleContract.dtTbt_SaleBasic[0].ContractOfficeCode; }).Count == 0)
                     * {
                     *  res.AddErrorMessage("Common", MessageUtil.MessageList.MSG0063, null, null);
                     *  return Json(res);
                     * }
                     *
                     * if (CommonUtil.dsTransData.dtOfficeData.FindAll(delegate(OfficeDataDo s) { return s.OfficeCode == dsSaleContract.dtTbt_SaleBasic[0].OperationOfficeCode; }).Count == 0)
                     * {
                     *  res.AddErrorMessage("Common", MessageUtil.MessageList.MSG0063, null, null);
                     *  return Json(res);
                     * }*/

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

                    if ((existsContarctOffice.Count() <= 0) && (existsOperateOffice.Count() <= 0))
                    {
                        res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0063, null, null);
                        res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;
                        return(Json(res));
                    }

                    if (dsSaleContract.dtTbt_SaleBasic[0].InstallationCompleteFlag == FlagType.C_FLAG_ON)
                    {
                        res.AddErrorMessage("Contract", MessageUtil.MessageList.MSG3058, null, null);
                        return(Json(res));
                    }
                }
                else
                {
                    res.AddErrorMessage("Common", MessageUtil.MessageList.MSG0011, new string[] { String.Format("Contract Code: {0}", param.ContractCode) }, null);
                    return(Json(res));
                }

                param.ScreenParameter = new CTS061_Parameter()
                {
                    contractCode = util.ConvertContractCode(param.ContractCode, CommonUtil.CONVERT_TYPE.TO_LONG)
                };
                param.ContractCode = param.ScreenParameter.contractCode;

                return(InitialScreenEnvironment <CTS061_ScreenParameter>("CTS061", param, res));
            }
            catch (Exception ex)
            {
                res.AddErrorMessage(ex);
            }

            return(Json(res));
        }