Exemplo n.º 1
0
        /*City-Area*/

        /*Area-List Search*/

        public JsonResult SearchAreaList(string searchBy, string searchValue, int?page, int?rows)
        {
            var         pageNo    = page ?? 1;
            var         numOfRows = rows ?? 5;
            List <Area> areaList;

            switch (searchBy)
            {
            case "id":
                //search by id
                areaList = areaRepository.GetAll().Where(c => c.Id.ToString().Contains(searchValue) || searchValue == null).ToList();
                break;

            case "city":
                //search by city
                areaList = areaRepository.GetAll().Where(c => c.City.Name.ToLower().Contains(searchValue.ToLower()) || searchValue == null).ToList();
                break;

            default:
                //by default, search by name
                areaList = areaRepository.GetAll().Where(c => c.Name.ToLower().Contains(searchValue.ToLower()) || searchValue == null).ToList();
                break;
            }
            return(Json(areaList, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 2
0
        public ActionResult AreaList(int?page, int?rows)
        {
            var pageNo    = page ?? 1;
            var numOfRows = rows ?? 5;

            var areas = areaRepository.GetAll().OrderBy(a => a.City.Name).ToList().ToPagedList(pageNo, numOfRows);

            return(View(areas));
        }
Exemplo n.º 3
0
        public JsonResult FarmList(FarmListInput input)
        {
            CheckPermission();
            using (var result = new ResponseResult <List <FarmListOutput> >())
            {
                var predicate = PredicateBuilder.True <T_DEMONSTRATION_FARM>();
                var isAdmin   = false;
                if (!this.UserInfo.IsSuperAdmin)
                {
                    //获取用户角色信息
                    var roles = adminUserRepository.GetRoles(UserId);

                    if (roles.Any(m => m.RoleID == (int)RoleType.Admin))
                    {
                        isAdmin = true;
                    }

                    if (!isAdmin)
                    {
                        //按经销商处理
                        var areaList       = _areaService.GetManageArea("-1", UserId);
                        var provinceIdList = areaList.Where(m => m.ParentAID == "0").Select(m => m.AID).ToArray();
                        var cityIdList     = areaList.Where(m => provinceIdList.Contains(m.ParentAID)).Select(m => m.AID).ToArray();
                        var regionIdList   = areaList.Where(m => cityIdList.Contains(m.ParentAID)).Select(m => m.AID).ToArray();

                        //当地区条件未指定时
                        if (input.ProvinceAid.IsNullOrEmpty() &&
                            input.CityAid.IsNullOrEmpty() &&
                            input.RegionAid.IsNullOrEmpty()
                            )
                        {
                            predicate = predicate.And(m =>
                                                      provinceIdList.Contains(m.ProvinceAid) &&
                                                      cityIdList.Contains(m.CityAid) &&
                                                      regionIdList.Contains(m.RegionAid));
                        }
                        else
                        {
                            //省份过滤
                            if (!input.ProvinceAid.IsNullOrEmpty() && provinceIdList.Contains(input.ProvinceAid))
                            {
                                predicate = predicate.And(m => m.ProvinceAid == input.ProvinceAid);
                            }
                            else
                            {
                                predicate = predicate.And(m => provinceIdList.Contains(m.ProvinceAid));
                            }

                            //城市过滤
                            if (!input.CityAid.IsNullOrEmpty() && cityIdList.Contains(input.CityAid))
                            {
                                predicate = predicate.And(m => m.CityAid == input.CityAid);
                            }
                            else
                            {
                                predicate = predicate.And(m => cityIdList.Contains(m.CityAid));
                            }

                            //区县过滤
                            if (!input.RegionAid.IsNullOrEmpty() && regionIdList.Contains(input.RegionAid))
                            {
                                predicate = predicate.And(m => m.RegionAid == input.RegionAid);
                            }
                            else
                            {
                                predicate = predicate.And(m => regionIdList.Contains(m.RegionAid));
                            }
                        }
                    }
                }

                if (input.IsDeleted.HasValue)
                {
                    predicate = predicate.And(m => m.IsDeleted == input.IsDeleted.Value);
                }

                if (input.IsOpen.HasValue)
                {
                    predicate = predicate.And(m => m.IsOpen == input.IsOpen.Value);
                }

                if (!string.IsNullOrEmpty(input.Keywords))
                {
                    predicate = predicate.And(m => m.Name.Contains(input.Keywords));
                }

                if (this.UserInfo.IsSuperAdmin || isAdmin)
                {
                    if (input.OpenStartDate != null)
                    {
                        predicate = predicate.And(m => m.OpenStartDate >= input.OpenStartDate.Value);
                    }

                    if (input.OpenEndDate != null)
                    {
                        predicate = predicate.And(m => m.OpenEndDate <= input.OpenEndDate.Value);
                    }

                    if (!input.ProvinceAid.IsNullOrEmpty())
                    {
                        predicate = predicate.And(m => m.ProvinceAid == input.ProvinceAid);
                    }

                    if (!input.CityAid.IsNullOrEmpty())
                    {
                        predicate = predicate.And(m => m.CityAid == input.CityAid);
                    }

                    if (!input.RegionAid.IsNullOrEmpty())
                    {
                        predicate = predicate.And(m => m.RegionAid == input.RegionAid);
                    }
                }

                long totalCount;
                var  list = _farmService.GetAll <DateTime>(predicate, null, m => m.CreateTime, input.PageIndex, input.PageSize, out totalCount);
                if (list != null && list.Any())
                {
                    var areaDictionary = new Dictionary <string, string>();
                    list.Select(m =>
                    {
                        if (!string.IsNullOrEmpty(m.ProvinceAid) && !areaDictionary.ContainsKey(m.ProvinceAid))
                        {
                            areaDictionary.Add(m.ProvinceAid, string.Empty);
                        }

                        if (!string.IsNullOrEmpty(m.CityAid) && !areaDictionary.ContainsKey(m.CityAid))
                        {
                            areaDictionary.Add(m.CityAid, string.Empty);
                        }

                        if (!string.IsNullOrEmpty(m.RegionAid) && !areaDictionary.ContainsKey(m.RegionAid))
                        {
                            areaDictionary.Add(m.RegionAid, string.Empty);
                        }

                        return(m);
                    }).Count();
                    var areaIdArray = areaDictionary.Keys.ToArray();
                    var areaList    = _areaService.GetAll(m => areaIdArray.Contains(m.AID));
                    result.Entity = Mapper.Map <List <FarmListOutput> >(list);
                    foreach (var farm in result.Entity)
                    {
                        if (!string.IsNullOrEmpty(farm.Province) && areaIdArray.Contains(farm.Province))
                        {
                            var areaInfo = areaList.FirstOrDefault(m => m.AID == farm.Province);
                            if (areaInfo != null)
                            {
                                farm.Province = areaInfo.DisplayName;
                            }
                            else
                            {
                                farm.Province = "";
                            }
                        }

                        if (!string.IsNullOrEmpty(farm.City) && areaIdArray.Contains(farm.City))
                        {
                            var areaInfo = areaList.FirstOrDefault(m => m.AID == farm.City);
                            if (areaInfo != null)
                            {
                                farm.City = areaInfo.DisplayName;
                            }
                            else
                            {
                                farm.City = "";
                            }
                        }

                        if (!string.IsNullOrEmpty(farm.Region) && areaIdArray.Contains(farm.Region))
                        {
                            var areaInfo = areaList.FirstOrDefault(m => m.AID == farm.Region);
                            if (areaInfo != null)
                            {
                                farm.Region = areaInfo.DisplayName;
                            }
                            else
                            {
                                farm.Region = "";
                            }
                        }
                    }
                }

                SetJosnResult <List <FarmListOutput> >(result, input.PageIndex, input.PageSize, totalCount, "获取示范农场列表成功!");
                return(new JsonResultEx(result));
            }
        }
Exemplo n.º 4
0
        public ActionResult ExportExcelWithBusinessList(BusinessSeachModel seachModel)
        {
            CheckPermission();
            if (seachModel.pageSize > 10000)
            {
                seachModel.pageSize = 10000;
            }
            int totalCount = 0;
            var modelList  = _business.GetAll(seachModel, out totalCount).Select(model => new BusinessDemandModel
            {
                Id           = model.Id,
                Province     = model.Province,
                City         = model.City,
                Region       = model.Region,
                CreateTime   = model.CreateTime,
                CreateUser   = model.CreateUserId.ToString(),
                DemandType   = ((BusinessDemandType)model.DemandTypeId).GetDescription(),
                PublishState = ((PublishState)model.PublishStateId).GetDescription(),
                PhoneNumber  = model.PhoneNumber,
                CropId       = model.CropId ?? 0,
                Township     = model.Township,
                Village      = model.Village,
                FirstWeight  = model.FirstWeight,
                AcquisitionWeightRangeTypeId = model.AcquisitionWeightRangeTypeId,
                Brief              = model.Brief,
                ExpectedDate       = model.ExpectedDate,
                ExpectedStartPrice = model.ExpectedStartPrice,
                ExpectedEndPrice   = model.ExpectedEndPrice
            }).ToList();

            var userIdListDictionary = new Dictionary <long, string>();

            if (modelList.Count > 0)
            {
                var areaCodeDictionary = new Dictionary <string, string>();
                modelList.Select(m =>
                {
                    if (ValidatorAreaCode(m.Province) && !areaCodeDictionary.ContainsKey(m.Province))
                    {
                        areaCodeDictionary.Add(m.Province, string.Empty);
                    }

                    if (ValidatorAreaCode(m.City) && !areaCodeDictionary.ContainsKey(m.City))
                    {
                        areaCodeDictionary.Add(m.City, string.Empty);
                    }

                    if (ValidatorAreaCode(m.Region) && !areaCodeDictionary.ContainsKey(m.Region))
                    {
                        areaCodeDictionary.Add(m.Region, string.Empty);
                    }
                    var userId = int.Parse(m.CreateUser);
                    if (!userIdListDictionary.ContainsKey(userId))
                    {
                        userIdListDictionary.Add(userId, string.Empty);
                    }

                    return(m);
                }).Count();
                var areaCodeList = areaCodeDictionary.Keys.ToList();
                var areaInfoList = _areaService.GetAll(p => areaCodeList.Contains(p.AID));
                var userIdList   = userIdListDictionary.Keys.ToList();
                var userList     = _userService.GetAll(p => userIdList.Contains(p.Id));

                var cropIdList       = modelList.Select(p => p.CropId).Distinct().ToList();
                var firstWeigtIdList = modelList.Select(p => p.FirstWeight).Distinct().ToList();
                var AcquisitionWeightRangeTypeIdList = modelList.Select(p => p.AcquisitionWeightRangeTypeId).Distinct().ToList();
                var dicCodeList = new List <int>();
                dicCodeList.AddRange(cropIdList);
                dicCodeList.AddRange(firstWeigtIdList);
                dicCodeList.AddRange(AcquisitionWeightRangeTypeIdList);
                //字典信息集合
                var dicInfoList = _sysDictionary.GetAll(p => dicCodeList.Contains(p.Code));

                HSSFWorkbook workbook = new HSSFWorkbook();
                MemoryStream ms       = new MemoryStream();
                // 创建一张工作薄。
                var workSheet        = workbook.CreateSheet("产业商需求列表");
                var headerRow        = workSheet.CreateRow(0);
                var tableHeaderTexts = new string[] {
                    "需求单编号",
                    "发起人",
                    "发起人用户编号",
                    "发起人手机号",
                    "省",
                    "市",
                    "县",
                    "乡",
                    "村",
                    "农作物类型",
                    "需求类型",
                    "起购",
                    "收购区间",
                    "摘要",
                    "发起时间",
                    "期望日期",
                    "期望价格下限",
                    "期望价格上限",
                    "需求状态",
                    "应答人用户编号",
                    "应答人手机号",
                    "应答时间",
                    "提供的重量",
                    "收到的评价"
                };
                ICellStyle style = workbook.CreateCellStyle();
                style.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.Grey25Percent.Index;
                style.FillPattern         = FillPattern.SolidForeground;

                //左对齐样式
                var cellAlignLeftStyle = workbook.CreateCellStyle();
                cellAlignLeftStyle.Alignment         = HorizontalAlignment.Left;
                cellAlignLeftStyle.VerticalAlignment = VerticalAlignment.Center;

                //生成列头
                for (int i = 0; i < tableHeaderTexts.Length; i++)
                {
                    var currentCell = headerRow.CreateCell(i);
                    currentCell.SetCellValue(tableHeaderTexts[i]);
                    currentCell.CellStyle = style;
                }

                workSheet.CreateFreezePane(0, 1, 0, 1);

                var currentRowIndex  = 0;
                var dateFormatString = "yyyy.MM.dd HH:mm:ss";
                //给用地区信息赋上说明
                foreach (var demand in modelList)
                {
                    currentRowIndex++;
                    //获取应答列表
                    var responseRecordList  = _business.GetDemandReplyList(demand.Id);
                    var responseRecordCount = responseRecordList.Count;

                    //创建内容行
                    var sheetRow           = workSheet.CreateRow(currentRowIndex);//创建一行
                    var tableHeadersLength = tableHeaderTexts.Length;
                    //创建内容列
                    for (int cellIndex = 0; cellIndex < tableHeadersLength; cellIndex++)
                    {
                        var cell = sheetRow.CreateCell(cellIndex);
                        cell.SetCellType(CellType.String);
                        cell.CellStyle = cellAlignLeftStyle;

                        if (responseRecordCount > 1)
                        {
                            if (cellIndex < (tableHeadersLength - 5))
                            {
                                workSheet.AddMergedRegion(new CellRangeAddress(currentRowIndex, currentRowIndex + responseRecordCount - 1, cellIndex, cellIndex));
                            }
                        }
                    }

                    //需求单编号
                    sheetRow.Cells[0].SetCellValue(demand.Id);
                    //发起人
                    var demandCreateUserId = int.Parse(demand.CreateUser);
                    var userInfo           = userList.Where(p => p.Id == demandCreateUserId).FirstOrDefault();
                    sheetRow.Cells[1].SetCellValue(userInfo == null ? string.Empty : userInfo.UserName);
                    //发起人用户编号
                    sheetRow.Cells[2].SetCellValue(demand.CreateUser);
                    //发起人手机号
                    sheetRow.Cells[3].SetCellValue(demand.PhoneNumber);
                    //省份
                    var provinceInfo = areaInfoList.Where(p => p.AID == demand.Province).FirstOrDefault();
                    sheetRow.Cells[4].SetCellValue(provinceInfo == null ? string.Empty : provinceInfo.DisplayName);
                    //城市
                    var cityInfo = areaInfoList.Where(p => p.AID == demand.City).FirstOrDefault();
                    sheetRow.Cells[5].SetCellValue(cityInfo == null ? string.Empty : cityInfo.DisplayName);
                    //区县
                    var regionInfo = areaInfoList.Where(p => p.AID == demand.Region).FirstOrDefault();
                    sheetRow.Cells[6].SetCellValue(regionInfo == null ? string.Empty : regionInfo.DisplayName);
                    //乡镇
                    var townshipInfo = areaInfoList.Where(p => p.AID == demand.Township).FirstOrDefault();
                    sheetRow.Cells[7].SetCellValue(townshipInfo == null ? string.Empty : townshipInfo.DisplayName);
                    //村
                    var villageInfo = areaInfoList.Where(p => p.AID == demand.Village).FirstOrDefault();
                    sheetRow.Cells[8].SetCellValue(villageInfo == null ? string.Empty : villageInfo.DisplayName);
                    //农作物类型
                    var cropInfo = dicInfoList.Where(p => p.Code == demand.CropId).FirstOrDefault();
                    sheetRow.Cells[9].SetCellValue(cropInfo == null ? string.Empty : cropInfo.DisplayName);
                    //需求类型
                    sheetRow.Cells[10].SetCellValue(demand.DemandType);
                    //起购
                    var firstWeightInfo = dicInfoList.Where(p => p.Code == demand.FirstWeight).FirstOrDefault();
                    sheetRow.Cells[11].SetCellValue(firstWeightInfo == null ? string.Empty : firstWeightInfo.DisplayName);
                    //收购区间
                    var acquisitionWeightRangeInfo = dicInfoList.Where(p => p.Code == demand.AcquisitionWeightRangeTypeId).FirstOrDefault();
                    sheetRow.Cells[12].SetCellValue(acquisitionWeightRangeInfo == null ? string.Empty : acquisitionWeightRangeInfo.DisplayName);
                    //摘要
                    sheetRow.Cells[13].SetCellValue(demand.Brief ?? string.Empty);
                    //发起时间
                    sheetRow.Cells[14].SetCellValue(demand.CreateTime.ToString(dateFormatString));
                    //期望日期
                    sheetRow.Cells[15].SetCellValue(demand.ExpectedDate ?? string.Empty);
                    //期望的价格下限
                    double expectedEndPrice = demand.ExpectedEndPrice == null ? double.MinValue : (double)demand.ExpectedEndPrice.Value;
                    sheetRow.Cells[16].SetCellValue(expectedEndPrice);
                    //期望的价格上限
                    double expectedStartPrice = demand.ExpectedStartPrice == null ? double.MinValue : (double)demand.ExpectedStartPrice.Value;
                    sheetRow.Cells[17].SetCellValue(expectedStartPrice);
                    //需求状态
                    sheetRow.Cells[18].SetCellValue(demand.PublishState);
                    if (responseRecordCount > 0)
                    {
                        var responseRecord = responseRecordList[0];
                        sheetRow.Cells[19].SetCellValue(responseRecord.UserId);
                        sheetRow.Cells[20].SetCellValue(responseRecord.PhoneNumber ?? string.Empty);
                        sheetRow.Cells[21].SetCellValue(responseRecord.ReplyTime.ToString(dateFormatString));
                        sheetRow.Cells[22].SetCellValue(responseRecord.WeightRange);
                        string commentResult = string.Empty;
                        var    scoreString   = "|" + responseRecord.Score + "星";
                        if (responseRecord.Comments.IsNullOrEmpty() == false || responseRecord.Score > 0)
                        {
                            //收到的评价
                            sheetRow.Cells[23].SetCellValue(responseRecord.Comments.IsNullOrEmpty() ? "[未作评论]" + scoreString : responseRecord.Comments + scoreString);
                        }
                    }

                    if (responseRecordCount > 1)
                    {
                        for (int responseRecordIndex = 1; responseRecordIndex < responseRecordCount; responseRecordIndex++)
                        {
                            currentRowIndex++;
                            var replyRecordRow = workSheet.CreateRow(currentRowIndex);
                            //创建内容列
                            for (int cellIndex = 0; cellIndex < tableHeadersLength; cellIndex++)
                            {
                                var cell = replyRecordRow.CreateCell(cellIndex);
                                cell.SetCellType(CellType.String);
                                cell.CellStyle = cellAlignLeftStyle;
                            }

                            var responseRecord = responseRecordList[responseRecordIndex];
                            replyRecordRow.Cells[19].SetCellValue(responseRecord.UserId);
                            replyRecordRow.Cells[20].SetCellValue(responseRecord.PhoneNumber ?? string.Empty);
                            replyRecordRow.Cells[21].SetCellValue(responseRecord.ReplyTime.ToString(dateFormatString));
                            replyRecordRow.Cells[22].SetCellValue(responseRecord.WeightRange);
                            string commentResult = string.Empty;
                            var    scoreString   = "|" + responseRecord.Score + "星";
                            if (responseRecord.Comments.IsNullOrEmpty() == false || responseRecord.Score > 0)
                            {
                                //收到的评价
                                replyRecordRow.Cells[23].SetCellValue(responseRecord.Comments.IsNullOrEmpty() ? "[未作评论]" + scoreString : responseRecord.Comments + scoreString);
                            }
                        }
                    }
                }

                workbook.Write(ms);
                Response.AddHeader("Content-Disposition", string.Format("attachment;filename=BusinessDemandList" + (DateTime.Now.ToString("yyyyMMddHHmmss")) + ".xls"));
                Response.BinaryWrite(ms.ToArray()); workbook = null;
                return(File(ms, "application/ms-excel"));
            }
            else
            {
                return(Content("no data"));
            }
        }
Exemplo n.º 5
0
        public ActionResult ExportExcelWithUserList(SearchUserListInputDto input)
        {
            CheckPermission();

            WhereModel wheremodel = new WhereModel()
            {
                RoleId      = Convert.ToInt32(input.RoleId),
                Province    = input.Province,
                City        = input.City,
                Region      = input.Region,
                PhoneNumber = input.PhoneNumber,
                StartTime   = Convert.ToDateTime(input.StartTime),
                EndTime     = Convert.ToDateTime(input.EndTime)
            };

            long recordCount;
            var  modelList  = this._userService.GetUserList(input.pageIndex.Value, input.pageSize.Value, out recordCount, wheremodel);
            var  usersModel = new UserModel()
            {
                Pager            = new PagedList <string>(new string[0], input.pageIndex.Value, input.pageSize.Value, (int)recordCount),
                PendingAuditList = modelList,
                Wheremodel       = wheremodel
            };

            if (modelList != null && modelList.Count > 0)
            {
                var areaCodeDictionary = new Dictionary <string, string>();
                modelList.Select(m =>
                {
                    if (ValidatorAreaCode(m.Province) && !areaCodeDictionary.ContainsKey(m.Province))
                    {
                        areaCodeDictionary.Add(m.Province, string.Empty);
                    }

                    if (ValidatorAreaCode(m.City) && !areaCodeDictionary.ContainsKey(m.City))
                    {
                        areaCodeDictionary.Add(m.City, string.Empty);
                    }

                    if (ValidatorAreaCode(m.Region) && !areaCodeDictionary.ContainsKey(m.Region))
                    {
                        areaCodeDictionary.Add(m.Region, string.Empty);
                    }

                    if (ValidatorAreaCode(m.Township) && !areaCodeDictionary.ContainsKey(m.Township))
                    {
                        areaCodeDictionary.Add(m.Township, string.Empty);
                    }

                    if (ValidatorAreaCode(m.Village) && !areaCodeDictionary.ContainsKey(m.Village))
                    {
                        areaCodeDictionary.Add(m.Village, string.Empty);
                    }

                    return(m);
                }).Count();
                var areaCodeList = areaCodeDictionary.Keys.ToList();
                var areaInfoList = _areaRepository.GetAll(p => areaCodeList.Contains(p.AID));

                HSSFWorkbook workbook = new HSSFWorkbook();
                MemoryStream ms       = new MemoryStream();
                // 创建一张工作薄。
                var        workSheet        = workbook.CreateSheet("注册会员列表");
                var        headerRow        = workSheet.CreateRow(0);
                var        tableHeaderTexts = new string[] { "用户编号", "姓名", "电话", "省", "市", "区/县", "乡镇", "村", "亩数", "用户类型", "注册时间" };
                ICellStyle style            = workbook.CreateCellStyle();
                style.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.Grey25Percent.Index;
                style.FillPattern         = FillPattern.SolidForeground;


                //生成列头
                for (int i = 0; i < tableHeaderTexts.Length; i++)
                {
                    var currentCell = headerRow.CreateCell(i);

                    currentCell.SetCellValue(tableHeaderTexts[i]);
                    currentCell.CellStyle = style;
                }

                var currentRoeIndex = 0;
                //给用地区信息赋上说明
                foreach (var user in modelList)
                {
                    currentRoeIndex++;
                    var provinceInfo = areaInfoList.FirstOrDefault(p => p.AID == user.Province);
                    var cityInfo     = areaInfoList.FirstOrDefault(p => p.AID == user.City);
                    var regionInfo   = areaInfoList.FirstOrDefault(p => p.AID == user.Region);
                    var townshipInfo = areaInfoList.FirstOrDefault(p => p.AID == user.Township);
                    var villageInfo  = areaInfoList.FirstOrDefault(p => p.AID == user.Village);

                    if (provinceInfo != null)
                    {
                        user.Province = provinceInfo.DisplayName;
                    }
                    else
                    {
                        user.Province = string.Empty;
                    }

                    if (cityInfo != null)
                    {
                        user.City = cityInfo.DisplayName;
                    }
                    else
                    {
                        user.City = string.Empty;
                    }

                    if (regionInfo != null)
                    {
                        user.Region = regionInfo.DisplayName;
                    }
                    else
                    {
                        user.Region = string.Empty;
                    }

                    if (townshipInfo != null)
                    {
                        user.Township = townshipInfo.DisplayName;
                    }
                    else
                    {
                        user.Township = string.Empty;
                    }

                    if (villageInfo != null)
                    {
                        user.Village = villageInfo.DisplayName;
                    }
                    else
                    {
                        user.Village = string.Empty;
                    }

                    var dataRow          = workSheet.CreateRow(currentRoeIndex);
                    var userIdCell       = dataRow.CreateCell(0);
                    var userNameCell     = dataRow.CreateCell(1);
                    var phoneNumberCell  = dataRow.CreateCell(2);
                    var provinceCell     = dataRow.CreateCell(3);
                    var cityCell         = dataRow.CreateCell(4);
                    var regionCell       = dataRow.CreateCell(5);
                    var townshipCell     = dataRow.CreateCell(6);
                    var villageCell      = dataRow.CreateCell(7);
                    var landCell         = dataRow.CreateCell(8);
                    var userTypeCell     = dataRow.CreateCell(9);
                    var registryTimeCell = dataRow.CreateCell(10);

                    userIdCell.SetCellValue(user.UserId);
                    userNameCell.SetCellValue(user.UserName);
                    phoneNumberCell.SetCellValue(user.PhoneNumber);
                    provinceCell.SetCellValue(user.Province);
                    cityCell.SetCellValue(user.City);
                    regionCell.SetCellValue(user.Region);
                    townshipCell.SetCellValue(user.Township);
                    villageCell.SetCellValue(user.Village);
                    landCell.SetCellValue(Convert.ToString(user.Land));
                    userTypeCell.SetCellValue(((UserTypes)user.Type).GetDescription());
                    registryTimeCell.SetCellValue(user.CreateTime.ToString("yyyy.MM.dd"));
                }

                workbook.Write(ms);
                Response.AddHeader("Content-Disposition", string.Format("attachment;filename=MemberUserList" + (DateTime.Now.ToString("yyyyMMddHHmmss")) + ".xls"));
                Response.BinaryWrite(ms.ToArray()); workbook = null;
                return(File(ms, "application/ms-excel"));
            }
            else
            {
                return(Content("no data"));
            }
        }