/// <summary>
        /// Get Site Information and Contract with same site.
        /// </summary>
        /// <param name="strSiteCode"></param>
        /// <returns></returns>
        public dsSiteInfoForView GetSiteInfoForView(string strSiteCode)
        {
            try
            {
                dsSiteInfoForView     SiteInfoForView = new dsSiteInfoForView();
                ISiteMasterHandler    handSite        = ServiceContainer.GetService <ISiteMasterHandler>() as ISiteMasterHandler;
                doSiteSearchCondition doSiteSeachCond = new doSiteSearchCondition();
                doSiteSeachCond.SiteCode = strSiteCode;
                List <dtSiteData> dtSiteData = handSite.GetSiteDataForSearch(doSiteSeachCond);

                CommonUtil.MappingObjectLanguage <dtSiteData>(dtSiteData);


                if (dtSiteData.Count <= 0)
                {
                    throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0001);
                }
                else
                {
                    SiteInfoForView.dtSiteData = dtSiteData;
                }

                IViewContractHandler       handView       = ServiceContainer.GetService <IViewContractHandler>() as IViewContractHandler;
                List <dtContractsSameSite> dtContSameSite = handView.GetContractsListForViewSite(strSiteCode);

                SiteInfoForView.dtContractsSameSite = dtContSameSite;
                return(SiteInfoForView);
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Get site data by search condition
        /// </summary>
        /// <param name="cond"></param>
        /// <returns></returns>
        public ActionResult CMS260_SearchResponse(doSiteSearchCondition cond)
        {
            ObjectResultData res = new ObjectResultData();

            res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;

            List <View_dtSiteData> nlst = new List <View_dtSiteData>();

            // Create string Customer status with commar separate. like ,xx,yy,zz,
            List <string> lstCustStatus = new List <string>();

            lstCustStatus.Add(cond.chkExistingCustomer);
            lstCustStatus.Add(cond.chkNewCustomer);
            cond.CustStatus = CommonUtil.CreateCSVString(lstCustStatus);

            CommonUtil c = new CommonUtil();



            try
            {
                // Convert search condition to long format
                cond.CustomerCode = c.ConvertCustCode(cond.CustomerCode, CommonUtil.CONVERT_TYPE.TO_LONG);
                cond.SiteCode     = c.ConvertSiteCode(cond.SiteCode, CommonUtil.CONVERT_TYPE.TO_LONG);

                string[] strs = { "Counter" };

                if (CommonUtil.IsNullAllField(cond, strs))
                {
                    res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0006);
                }
                else
                {
                    // check require field
                    if (cond.isSearchByRealCust)
                    {
                        if (CommonUtil.IsNullOrEmpty(cond.CustStatus) == true)
                        {
                            res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0054);
                        }
                    }

                    //if (cond.Counter == 0)
                    //{
                    //    res.ResultData = CommonUtil.ConvertToXml<View_dtSiteData>(nlst, "Common\\CMS260", CommonUtil.GRID_EMPTY_TYPE.SEARCH);
                    //    return Json(res);
                    //}

                    ISiteMasterHandler handler = ServiceContainer.GetService <ISiteMasterHandler>() as ISiteMasterHandler;
                    List <dtSiteData>  list    = handler.GetSiteDataForSearch(cond);


                    foreach (dtSiteData l in list)
                    {
                        nlst.Add(CommonUtil.CloneObject <dtSiteData, View_dtSiteData>(l));
                    }
                }
            }
            catch (Exception ex)
            {
                res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION;
                nlst            = new List <View_dtSiteData>();
                res.AddErrorMessage(ex);
            }

            res.ResultData = CommonUtil.ConvertToXml <View_dtSiteData>(nlst, "Common\\CMS260", CommonUtil.GRID_EMPTY_TYPE.SEARCH);
            return(Json(res));
        }