Example #1
0
        /// <summary>
        /// 查询客户分页
        /// </summary>
        /// <returns></returns>
        public ActionResult GetPage()
        {
            string         CompanyID = WebUtil.GetFormValue <string>("CompanyID");
            int            PageIndex = WebUtil.GetFormValue <int>("PageIndex", 1);
            int            PageSize  = WebUtil.GetFormValue <int>("PageSize", 10);
            string         CusNum    = WebUtil.GetFormValue <string>("CusNum", string.Empty);
            string         CusName   = WebUtil.GetFormValue <string>("CusName", string.Empty);
            string         Phone     = WebUtil.GetFormValue <string>("Phone", string.Empty);
            int            CusType   = WebUtil.GetFormValue <int>("CusType", 0);
            CustomerEntity entity    = new CustomerEntity();

            entity.CusNum  = CusNum;
            entity.CusName = CusName;
            entity.Phone   = Phone;
            entity.CusType = CusType;
            PageInfo pageInfo = new PageInfo();

            pageInfo.PageIndex = PageIndex;
            pageInfo.PageSize  = PageSize;
            CustomerProvider                provider = new CustomerProvider(CompanyID);
            List <CustomerEntity>           list     = provider.GetCustomerList(entity, ref pageInfo);
            DataListResult <CustomerEntity> result   = new DataListResult <CustomerEntity>()
            {
                Code = (int)EResponseCode.Success, Message = "响应成功", Result = list, PageInfo = pageInfo
            };

            return(Content(JsonHelper.SerializeObject(result)));
        }
        public ActionResult GetCustomerList()
        {
            int    pageIndex = WebUtil.GetFormValue <int>("pageIndex", 1);
            int    pageSize  = WebUtil.GetFormValue <int>("pageSize", 15);
            string CusNum    = WebUtil.GetFormValue <string>("CusNum", string.Empty);
            int    CusType   = WebUtil.GetFormValue <int>("CusType", 0);

            CustomerProvider provider = new CustomerProvider();
            CustomerEntity   entity   = new CustomerEntity();
            PageInfo         pageInfo = new PageInfo()
            {
                PageIndex = pageIndex, PageSize = pageSize
            };

            if (!CusNum.IsEmpty())
            {
                entity.Begin <CustomerEntity>()
                .Where <CustomerEntity>("CusNum", ECondition.Like, "%" + CusNum + "%")
                .Or <CustomerEntity>("CusName", ECondition.Like, "%" + CusNum + "%")
                .End <CustomerEntity>();
            }
            if (CusType != 0)
            {
                entity.Where <CustomerEntity>(a => a.CusType == CusType);
            }

            List <CustomerEntity> listResult = provider.GetCustomerList(entity, ref pageInfo);
            string json = ConvertJson.ListToJson <CustomerEntity>(listResult, "List");

            this.ReturnJson.AddProperty("Data", new JsonObject(json));
            this.ReturnJson.AddProperty("RowCount", pageInfo.RowCount);
            return(Content(this.ReturnJson.ToString()));
        }
Example #3
0
        /// <summary>
        /// 得到客户信息
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        public ActionResult GetCustomerList(CustomerSearchDTO dto)
        {
            ResultData <List <CustomerInfoModel> > result = new ResultData <List <CustomerInfoModel> >();

            result = CustomerProvider.GetCustomerList(dto);

            return(Json(new { total = result.Count, rows = result.Object }, JsonRequestBehavior.AllowGet));
        }
Example #4
0
        /// <summary>
        /// 导出客户信息
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        public ActionResult ExportCustomer(CustomerSearchDTO dto)
        {
            dto.page = 1;
            dto.rows = 10000000;
            string result = null;

            List <CustomerInfoModel> pp = null;

            pp = CustomerProvider.GetCustomerList(dto).Object;

            string        strTemplateFile = Server.MapPath(@"~/TempLate/CustomerInfoTemplate.xlsx");
            string        strGenarateDir  = Server.MapPath(@"~/TempFile");
            string        strGenarateFile = Guid.NewGuid().ToString("N") + ".xlsx";
            string        strExportFile   = strGenarateDir + "\\" + strGenarateFile;
            List <object> ratelist        = new List <object>();

            pp.ForEach(g =>
            {
                Models.Model.Excel.ExcelCustomerInfo er = new Models.Model.Excel.ExcelCustomerInfo();
                er.状态         = g.Status;
                er.省份         = g.Province;
                er.城市         = g.City;
                er.新增时间       = g.CreateTime.HasValue ? g.CreateTime.Value.ToString("yyyy-MM-dd HH:mm:ss") : null;
                er.Oracle号    = g.OracleNO;
                er.OracleName = g.OracleName;
                er.经销商提交客户名称  = g.CustomerName;
                er.携手网编号      = g.XSWNO;
                er.经销商名称      = g.DistributorName;
                er.审批人        = g.Auditor;
                er.最后修改人      = g.ModifyUser;
                ratelist.Add(er);
            });

            if (Common.ExcelHelper.Export(strTemplateFile, strGenarateDir, strGenarateFile, ratelist, "Sheet1"))
            {
                result = strGenarateFile;
            }

            return(Json(result));
        }
Example #5
0
        private bool CheckCustomer(object obj)
        {
            bool result           = true;
            CustomerSearchDTO dto = new CustomerSearchDTO();

            dto.rows = 100000000;
            string strimporter = ((UserLoginDTO)Session["UserLoginInfo"]).FullName;

            dto.page = 1;
            var CustomerList       = CustomerProvider.GetCustomerList(dto);
            var ProvinceRegionList = AreaRegionProvider.GetProvinceRegionList();
            List <ExcelCustomerInfoDTO> exceldto = (List <ExcelCustomerInfoDTO>)obj;

            foreach (var p in exceldto)
            {
                StringBuilder sb = new StringBuilder();
                if (String.IsNullOrEmpty(p.CustomerName))
                {
                    sb.Append("客户名称不能为空");
                }
                else
                {
                    var CustomerID = CustomerList.Object.Where(m => m.CustomerName == p.CustomerName).Select(m => m.CustomerID).FirstOrDefault();
                    if (CustomerID != null)
                    {
                        p.CustomerID = CustomerID;
                        p.UpLogic    = 2;
                    }
                    else
                    {
                        p.UpLogic = 1;
                    }
                }
                if (string.IsNullOrEmpty(p.XSWNO))
                {
                    sb.Append("携手网编号不可为空!");
                }
                if (string.IsNullOrEmpty(p.Province))
                {
                    sb.Append("省份不能为空!");
                }
                else
                {
                    var exist = ProvinceRegionList.Where(m => m.RegionName == p.Province).FirstOrDefault();
                    if (exist != null)
                    {
                        p.Province = exist.RegionName;
                    }
                    else
                    {
                        sb.Append("注册省份不存在!");
                    }
                }
                if (string.IsNullOrEmpty(p.City))
                {
                    sb.Append("城市不能为空!");
                }
                else
                {
                    var nextArea = GlobalStaticData.RegionList.Where(m => m.RegionName == p.City).FirstOrDefault();
                    if (nextArea == null)
                    {
                        sb.Append("注册城市" + p.City + "不存在!");
                    }
                    else
                    {
                    }
                }
                p.Importer = strimporter;
                if (sb.Length > 0)
                {
                    p.CheckInfo = sb.ToString();
                    result      = false;
                }
            }
            return(result);
        }