示例#1
0
 public int Add(PotentialMember c)
 {
     YogaEntities ey = new YogaEntities();
     c.CreateTime = DateTime.Now;
     c.LastContact = DateTime.Now;
     ey.AddToPotentialMember(c);
     return ey.SaveChanges() == 1 ? c.Id:-1;
 }
示例#2
0
        public PotentialMember[] Search(PotentialMember c,bool includeNULLAid, ref int page, int pageSize, out int totalPages)
        {
            YogaEntities ey = new YogaEntities();
            var query = from cc in ey.PotentialMember where cc.Name.Contains(c.Name) select cc;
            if (c.Id > 0) query = query.Where((cc) => cc.Id == c.Id);
            if (c.AdviserId.ToString().Length < 1) query = query.Where((cc) => cc.AdviserId == null);
            else if (c.AdviserId > 0 && includeNULLAid) query = query.Where((cc) => cc.AdviserId == c.AdviserId || cc.AdviserId==null);
            else if (c.AdviserId > 0 && !includeNULLAid) query = query.Where((cc) => cc.AdviserId == c.AdviserId);

            totalPages = (int)Math.Ceiling(query.Count() * 1.0 / pageSize);
            if (totalPages < 1)
            {
                page = 0;
                return null;
            }
            if (page == -1 || page > totalPages) page = totalPages;
            else if (page < 1) page = 1;
            return query.OrderBy((cc) => cc.Id).Skip((page - 1) * pageSize).Take(pageSize).ToArray();
        }
示例#3
0
 /// <summary>
 /// Deprecated Method for adding a new object to the PotentialMember EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToPotentialMember(PotentialMember potentialMember)
 {
     base.AddObject("PotentialMember", potentialMember);
 }
示例#4
0
 public string Update(PotentialMember c)
 {
     YogaEntities ey = new YogaEntities();
     PotentialMember cc = ey.PotentialMember.FirstOrDefault((ccc) => ccc.Id == c.Id);
     if (cc == null) return string.Format("编号为{0}的潜在客户不存在", c.Id);
     cc.AdviserId = c.AdviserId;
     cc.CustomerChannel = c.CustomerChannel;
     cc.Gender = c.Gender;
     cc.Mobilephone = c.Mobilephone;
     cc.Name = c.Name;
     cc.Remarks = c.Remarks;
     return ey.SaveChanges() == 1 ? "成功" : "失败";
 }
示例#5
0
 /// <summary>
 /// Create a new PotentialMember object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 /// <param name="lastContact">Initial value of the LastContact property.</param>
 /// <param name="mobilephone">Initial value of the Mobilephone property.</param>
 /// <param name="gender">Initial value of the Gender property.</param>
 /// <param name="customerChannel">Initial value of the CustomerChannel property.</param>
 /// <param name="createTime">Initial value of the CreateTime property.</param>
 public static PotentialMember CreatePotentialMember(global::System.Int32 id, global::System.String name, global::System.DateTime lastContact, global::System.String mobilephone, global::System.String gender, global::System.String customerChannel, global::System.DateTime createTime)
 {
     PotentialMember potentialMember = new PotentialMember();
     potentialMember.Id = id;
     potentialMember.Name = name;
     potentialMember.LastContact = lastContact;
     potentialMember.Mobilephone = mobilephone;
     potentialMember.Gender = gender;
     potentialMember.CustomerChannel = customerChannel;
     potentialMember.CreateTime = createTime;
     return potentialMember;
 }