Пример #1
0
    void BindrepList()
    {
        int allCount;
        Model.QueryBehalf query = new Model.QueryBehalf();
        query.IsLikeSearch = true;
        if (!string.IsNullOrEmpty(this.txtPhone.Text))
        {
            query.Phone = this.txtPhone.Text;
        }

        if (!string.IsNullOrEmpty(this.txtUserName.Text))
        {
            query.UserName = this.txtUserName.Text;
        }

        if (this.ddBehalfLevel.SelectedValue != "-1")
        {
            query.BehalfLevel = Convert.ToInt32(this.ddBehalfLevel.SelectedValue);
        }
        if (this.ddIsVoted.SelectedValue != "-1")
        {
            query.IsVoted = Convert.ToInt32(this.ddIsVoted.SelectedValue);
        }

        this.repList.DataSource = BLL.Behalf.bll.GetList(query, this.AspNetPager1.PageSize, this.AspNetPager1.CurrentPageIndex, out allCount);
        this.repList.DataBind();
        this.AspNetPager1.RecordCount = allCount;
    }
Пример #2
0
        /// <summary>
        /// 添加代表
        /// </summary>
        /// <param name="behalf">代表对象</param>
        /// <returns>结果对象</returns>
        public Model.ResultModel Add(Model.T_Behalf behalf)
        {
            ResultModel rm = new ResultModel();
            Model.QueryBehalf qb = new QueryBehalf()
            {
                Phone = behalf.Phone
            };

            var list = dal.Get(qb);
            if (list.Count > 0)
            {
                rm.Result = false;
                rm.Message = "代表手机号不能重复";
            }
            else
            {
                if (dal.Add(behalf))
                {
                    rm.Result = true;
                    rm.Message = "代表添加成功";
                }
                else
                {
                    rm.Result = false;
                    rm.Message = "代表添加失败";
                }
            }
            return rm;
        }
Пример #3
0
 void BindrepList()
 {
     int allCount;
     Model.QueryBehalf query = new Model.QueryBehalf();
     this.repList.DataSource = BLL.Behalf.bll.GetList(query, this.AspNetPager1.PageSize, this.AspNetPager1.CurrentPageIndex, out allCount);
     this.repList.DataBind();
     this.AspNetPager1.RecordCount = allCount;
 }
Пример #4
0
 /// <summary>
 /// 根据条件获取代表列表
 /// </summary>
 /// <param name="query">条件查询对象</param>
 /// <returns>代表列表</returns>
 public List<T_Behalf> Get(QueryBehalf query)
 {
     db.Refresh(System.Data.Objects.RefreshMode.ClientWins, db.T_Behalf);
     var queryable = (from behalf in db.T_Behalf
                      where ((behalf.IsDel.Equals(null) || behalf.IsDel == false)
                              && (string.IsNullOrEmpty(query.UserName) || behalf.UserName == query.UserName || (query.IsLikeSearch == true && behalf.UserName.Contains(query.UserName)))
                              && (string.IsNullOrEmpty(query.Phone) || behalf.Telephone == query.Phone || (query.IsLikeSearch == true && behalf.Phone.Contains(query.Phone)))
                              && ((query.BehalfLevel == null) || behalf.BehalfLevel == query.BehalfLevel)
                              && ((query.IsVoted == null || query.IsVoted == 0) || (behalf.IsVoted.Value == query.IsVoted)))
                      select behalf);
     return queryable.ToList();
 }
Пример #5
0
 /// <summary>
 /// 根据条件获取代表列表
 /// </summary>
 /// <param name="query">条件查询对象</param>
 /// <param name="pageSize">每页条数</param>
 /// <param name="currentIndex">当前页数</param>
 /// <param name="AllCount">所有记录数</param>
 /// <returns>代表列表</returns>
 public List<Model.T_Behalf> GetList(QueryBehalf query, int pageSize, int currentIndex, out int AllCount)
 {
     AllCount = 0;
     var list = Get(query);
     if (list != null)
     {
         if (pageSize == 0)
         {
             AllCount = 0;
             return list;
         }
         AllCount = list.Count();
         return list.Skip((currentIndex - 1) * pageSize).Take(pageSize).ToList();
     }
     return new List<T_Behalf>();
 }
Пример #6
0
        /// <summary>
        /// 更新代表
        /// </summary>
        /// <param name="model">代表对象</param>
        /// <returns>结果对象</returns>
        public Model.ResultModel Update(Model.T_Behalf dept)
        {
            ResultModel rm = new ResultModel();
            Model.QueryBehalf qb = new QueryBehalf()
            {
                TelePhone = dept.Telephone
            };

            var list = dal.Get(qb);
            if (list.Count > 0 && !list.Exists(l => l.Id != dept.Id))
            {
                rm.Result = false;
                rm.Message = "代表手机号不能重复";
            }
            else
            {

                if (dal.Update(dept))
                {
                    rm.Result = true;
                    rm.Message = "代表更新成功";
                }
                else
                {
                    rm.Result = false;
                    rm.Message = "代表更新失败";
                }
            }
            return rm;
        }
Пример #7
0
 /// <summary>
 /// 根据条件获取代表列表
 /// </summary>
 /// <param name="query">条件查询对象</param>
 /// <param name="pageSize">每页条数</param>
 /// <param name="currentIndex">当前页数</param>
 /// <param name="AllCount">所有记录数</param>
 /// <returns>代表列表</returns>
 public List<Model.T_Behalf> GetList(QueryBehalf query, int pageSize, int currentIndex, out int AllCount)
 {
     return dal.GetList(query, pageSize, currentIndex, out AllCount);
 }