public string Change(Member m, byte[] picData) { YogaEntities ye = new YogaEntities(); Member cc = ye.Member.FirstOrDefault((ccc) => ccc.Id == m.Id); if (cc == null) return string.Format("编号为{0}的会员不存在", m.Id); cc.Mobilephone = m.Mobilephone; cc.Name = m.Name; cc.Nation = m.Nation; cc.People = m.People; //cc.Picture = m.Picture; cc.Remarks = m.Remarks; //cc.Score = m.Score; cc.Telephone = m.Telephone; cc.CardNo = m.CardNo; cc.Gender = m.Gender; bool result = ye.SaveChanges() == 1; if (result && picData != null) { FileStream fs = null; try { fs = new FileStream(Server.MapPath(string.Format("Images/{0}.jpg", m.Id)), FileMode.Create, FileAccess.Write); fs.Write(picData, 0, picData.Length); } finally { if (fs != null) fs.Close(); } } return result ? "转卡成功" : "转卡失败"; }
public string Delete(int id) { YogaEntities ey = new YogaEntities(); Collect cc = ey.Collect.FirstOrDefault((ccc) => ccc.Id == id); if (cc == null) return string.Format("编号为{0}的商品不存在", id); ey.DeleteObject(cc); return ey.SaveChanges() == 1 ? "成功" : "失败"; }
public string Update(Collect c) { YogaEntities ey = new YogaEntities(); Collect cc = ey.Collect.FirstOrDefault((ccc) => ccc.Id == c.Id); if (cc == null) return string.Format("编号为{0}的商品不存在", c.Id); cc.GoodsId = c.GoodsId; return ey.SaveChanges() == 1 ? "成功" : "失败"; }
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; }
public string Delete(int id) { YogaEntities ey = new YogaEntities(); Adviser cc = ey.Adviser.FirstOrDefault((ccc) => ccc.Id == id); if (cc == null) return string.Format("顾问为{0}的教练不存在", id); ey.DeleteObject(cc); return ey.SaveChanges() == 1 ? "成功" : "失败"; }
public string Delete(int id) { YogaEntities ey = new YogaEntities(); PotentialMember cc = ey.PotentialMember.FirstOrDefault((ccc) => ccc.Id == id); if (cc == null) return string.Format("编号为{0}的潜在会员不存在", id); ey.DeleteObject(cc); return ey.SaveChanges() == 1 ? "成功" : "失败"; }
public string AddExprire(int id,DateTime exprire,string remarks) { YogaEntities ye = new YogaEntities(); Member cc = ye.Member.FirstOrDefault((ccc) => ccc.Id == id); if (cc == null) return string.Format("编号为{0}的会员不存在", id); if (cc.ExpireDate < exprire) cc.ExpireDate = exprire; cc.Remarks = remarks; return ye.SaveChanges() == 1? "延期成功" : "延期失败"; }
public string Update(Goods c) { YogaEntities ey = new YogaEntities(); Goods cc = ey.Goods.FirstOrDefault((ccc) => ccc.Id == c.Id); if (cc == null) return string.Format("编号为{0}的商品不存在", c.Id); cc.Price = c.Price; cc.Name = c.Name; return ey.SaveChanges() == 1 ? "成功" : "失败"; }
public string Update(Payment c) { YogaEntities ey = new YogaEntities(); Payment cc = ey.Payment.FirstOrDefault((ccc) => ccc.Id == c.Id); if (cc == null) return string.Format("顾问为{0}的教练不存在", c.Id); cc.Money = c.Money; cc.Date = c.Date; return ey.SaveChanges() == 1 ? "成功" : "失败"; }
public string Update(Coach c) { YogaEntities ey = new YogaEntities(); Coach cc = ey.Coach.FirstOrDefault((ccc) => ccc.Id == c.Id); if (cc == null) return string.Format("编号为{0}的教练不存在",c.Id); cc.IsPrivate = c.IsPrivate; cc.Mobilephone = c.Mobilephone; cc.Name = c.Name; return ey.SaveChanges() == 1 ? "成功" : "失败"; }
public string Allots(int[] pids, int aid) { YogaEntities ey = new YogaEntities(); PotentialMember[] cc = ey.PotentialMember.Where((ccc) => pids.Contains(ccc.Id)).ToArray(); if (cc == null || cc.Length < 1) return "指定编号的潜在客户不存在"; foreach (var item in cc) { item.AdviserId = aid; } return ey.SaveChanges() == cc.Length ? string.Format("已经成功分配给编号为{0}的顾问", aid) : "分配失败"; }
public string DeleteBatch(int[] pids) { YogaEntities ey = new YogaEntities(); PotentialMember[] cc = ey.PotentialMember.Where((ccc) => pids.Contains(ccc.Id)).ToArray(); if (cc == null || cc.Length < 1) return "指定编号的潜在客户不存在"; foreach (var item in cc) { ey.DeleteObject(item); } return ey.SaveChanges() == cc.Length ? "成功删除": "失败"; }
public string Update(Adviser c) { YogaEntities ey = new YogaEntities(); Adviser cc = ey.Adviser.FirstOrDefault((ccc) => ccc.Id == c.Id); if (cc == null) return string.Format("顾问为{0}的教练不存在", c.Id); cc.Position = c.Position; cc.Mobilephone = c.Mobilephone; cc.Name = c.Name; cc.UserId = c.UserId; return ey.SaveChanges() == 1 ? "成功" : "失败"; }
public string Import(int mid,string name,bool isTemp,int rid) { YogaEntities ye = new YogaEntities(); Member cc = ye.Member.FirstOrDefault((ccc) => ccc.Id == mid); if (cc == null) return string.Format("编号为{0}的会员不存在", mid); ImportRecord ir = new ImportRecord() { Date = DateTime.Now, IsTemp = isTemp, MemberId = mid, MemberName = name, }; ye.AddToImportRecord(ir); if (ye.SaveChanges() != 1) return "进场失败"; Rack r = ye.Rack.FirstOrDefault((rr) => rr.Id == rid && (rr.RenterId==null || rr.RentExpire<=DateTime.Now)); if (r != null) { r.RentDate = DateTime.Now; r.RentExpire = r.RentDate.AddHours(8); r.RenterId = mid; ye.SaveChanges(); } Member m = ye.Member.FirstOrDefault((rr) => rr.Id == ir.Member.Id); if (m == null) return "没有该会员"; if (m.IsTemp && m.TempTimes > 0) { m.TempTimes -= 1; cc.JoneCount += 1; ye.SaveChanges(); return "进场成功"; } if (m.IsTemp && m.TempTimes <= 0) { return "次数不足"; } cc.JoneCount += 1; ye.SaveChanges(); return "进场成功"; }
public int AddMember(Member m,byte[] picData) { YogaEntities ye = new YogaEntities(); var mmm = ye.Member.FirstOrDefault((mm) =>mm.CardNo == m.CardNo); if (mmm != null) return -2;//已经存在卡号 ye.AddToMember(m); int id = ye.SaveChanges()==1 ? m.Id : -1; if (id > 0&& picData!=null) { FileStream fs = null; try { fs = new FileStream(Server.MapPath(string.Format("Images/{0}.jpg", m.Id)), FileMode.Create, FileAccess.Write); fs.Write(picData, 0, picData.Length); } finally { if (fs != null) fs.Close(); } } return id; }
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 ? "成功" : "失败"; }
public string Update(Rack c, DateTime start, DateTime end) { YogaEntities ey = new YogaEntities(); Rack cc = ey.Rack.FirstOrDefault((ccc) => ccc.Id == c.Id); if (cc == null) return string.Format("编号为{0}的柜子不存在", c.Id); cc.RackNo = c.RackNo; cc.RentDate = start; cc.RentExpire = end; cc.RenterId = c.RenterId>0?c.RenterId:null; cc.Remarks = c.Remarks; return ey.SaveChanges() == 1 ? "成功" : "失败"; }
public int Add(User a) { YogaEntities ey = new YogaEntities(); ey.AddToUser(a); return ey.SaveChanges() == 1 ? a.Id : -1; }
public string Update(User c) { YogaEntities ey = new YogaEntities(); User cc = ey.User.FirstOrDefault((ccc) => ccc.Id == c.Id); if (cc == null) return string.Format("{0}不存在", c.Id); cc.Password = c.Password; cc.UserType = c.UserType; cc.Name = c.Name; return ey.SaveChanges() == 1 ? "成功" : "失败"; }
public int Add(Rack a) { YogaEntities ey = new YogaEntities(); ey.AddToRack(a); return ey.SaveChanges() == 1 ? a.Id : -1; }
public string CoachAllot(Member c) { YogaEntities ey = new YogaEntities(); Member cc = ey.Member.FirstOrDefault((ccc) => ccc.Id == c.Id); if (cc == null) return string.Format("编号为{0}的会员不存在", c.Id); cc.CoachId = c.CoachId; return ey.SaveChanges() == 1 ? string.Format("编号为{0}的用户已经成功分配给编号为{1}的教练", c.Id, c.CoachId) : "分配失败"; }
public int Add(Collect a) { YogaEntities ey = new YogaEntities(); ey.AddToCollect(a); return ey.SaveChanges() == 1 ? a.Id : -1; }
public string Add(Coach c) { YogaEntities ey = new YogaEntities(); ey.AddToCoach(c); return ey.SaveChanges()==1?"成功":"失败"; }
public string Clear() { YogaEntities ye = new YogaEntities(); ye.ExecuteStoreCommand("delete ImportRecord"); return ye.SaveChanges() == 0 ? "清场成功" : "清场失败"; }
public string Add(Adviser a) { YogaEntities ey = new YogaEntities(); ey.AddToAdviser(a); return ey.SaveChanges() == 1 ? "成功" : "失败"; }
public string Prepaid(int id, double money,int uid) { YogaEntities ye = new YogaEntities(); Member cc = ye.Member.FirstOrDefault((ccc) => ccc.Id == id); if (cc == null) return string.Format("编号为{0}的会员不存在", id); User u = ye.User.FirstOrDefault((uu) => uu.Id == uid); if (u == null) return string.Format("编号为{0}的操作员不存在", uid); cc.CardRestMoney += money; ye.AddToPrepaidRecord(new PrepaidRecord() { Date = DateTime.Now, MemberId = id, Money = money, UserId = uid, MemberName = cc.Name, Operater = u.Name, }); return ye.SaveChanges() == 2 ? "充值成功" : "充值失败"; }
public int Add(Goods a) { YogaEntities ey = new YogaEntities(); ey.AddToGoods(a); return ey.SaveChanges() == 1 ? a.Id:-1; }
public int Add(Payment a) { YogaEntities ey = new YogaEntities(); ey.AddToPayment(a); return ey.SaveChanges() == 1 ? a.Id : -1; }
public string Track(int pid) { YogaEntities ey = new YogaEntities(); PotentialMember cc = ey.PotentialMember.FirstOrDefault((ccc) => ccc.Id == pid); if (cc == null) return string.Format("编号为{0}的潜在客户不存在", pid); cc.LastContact = DateTime.Now; return ey.SaveChanges() == 1 ? "成功" : "失败"; }
public int PotentialToMember(Member m, byte[] picData, int pid) { YogaEntities ey = new YogaEntities(); PotentialMember cc = ey.PotentialMember.FirstOrDefault((ccc) => ccc.Id == pid); if (cc == null) return -1; m.AdviserId = cc.AdviserId; int id = AddMember(m,picData); if (id>0 ) { ey.DeleteObject(cc); ey.SaveChanges(); } return id; }