public int Update(VolunteersShowEdit item) { try { s26webDataContext db = new s26webDataContext(); var data = db.Volunteers.FirstOrDefault(f => f.Id == item.Id); if (data != null) { data.Mobile = item.Mobile; if (item.Password != "" && item.Password != null) { data.Password = Get_HashPassword(item.Password); } data.Name = item.Name; data.BabyBirthday = item.BabyBirthday; data.NowBrand = item.NowBrand; data.BrandName = item.BrandName; data.Email = item.Email; data.CityId = item.CityId; data.AreaId = item.AreaId; data.Address = item.Address; data.GiftMobile = item.GiftMobile; data.CityId2 = item.CityId2; data.AreaId2 = item.AreaId2; data.Address2 = item.Address2; data.Status = item.Status; //data.SendCount = v.SendCount; data.SerialNo = item.SerialNo; //data.Photo = v.Photos; data.MemberNumber = item.NowBrand; data.FBConnect = item.FBConnect; data.FBFriend = item.FBFriend; data.Memo = item.Memo; //data.UpdateTime = DateTime.UtcNow; //使用者更新時間 data.AdminUpdateTime = DateTime.UtcNow; //管理者更新 data.LastMemberId = item.LastMemberId; if (item.Status == 2 && data.EnableTime == null) { data.EnableTime = DateTime.UtcNow; } else data.EnableTime = data.EnableTime; db.SubmitChanges(); db.Connection.Close(); return data.Id; } db.Connection.Close(); return -1; } catch { return -1; } }
public int MemberUpdate(VolunteersShowEdit item, HttpPostedFileBase file, string vid, HttpServerUtilityBase Server) { try { s26webDataContext db = new s26webDataContext(); var data = db.Volunteers.FirstOrDefault(f => f.Id == item.Id); if (file != null) if (file.ContentLength > 0 && file.ContentType.ToLower() == "image/jpeg" || file.ContentType == "image/png") data.Photos = Method.Upload_File(file, vid, Server); data.Name = item.Name; data.BabyBirthday = item.BabyBirthday; data.Email = item.Email; data.NowBrand = item.NowBrand; data.MemberNumber = item.NowBrand; data.BrandName = item.BrandName; data.SerialNo = item.SerialNo; data.UpdateTime = DateTime.UtcNow; db.SubmitChanges(); db.Connection.Close(); return data.Id; } catch { return -1; } }
public VolunteersShowEdit Get_One(int id) { s26webDataContext db = new s26webDataContext(); VolunteersShowEdit data = new VolunteersShowEdit(); var item = db.Volunteers.FirstOrDefault(f => f.Id == id); var eCRM = db.eCRM.FirstOrDefault(f => f.Id == item.MemberNumber); var user = db.UserProfile.FirstOrDefault(f => f.Id == item.LastMemberId); //var u = db.UserProfile.Where(w => w.Id == i.LastUserId).Select(s => s.Name).FirstOrDefault(); data.Mobile = item.Mobile; data.Password = item.Password; data.Name = item.Name; data.BabyBirthday = item.BabyBirthday; data.NowBrand = item.NowBrand; data.BrandName = item.BrandName; data.Email = item.Email; data.CityId = item.CityId.HasValue?item.CityId.Value:0; data.AreaId = item.AreaId.HasValue ? item.AreaId.Value : 0; data.Address = item.Address; //data.GiftMobile = item.GiftMobile; //data.CityId2 = item.CityId2; //data.AreaId2 = item.AreaId2; //data.Address2 = item.Address2; data.Status = item.Status; //data.SendCount = v.SendCount; data.SerialNo = item.SerialNo; data.Photos = item.Photos; data.MemberNumber = item.MemberNumber; if (eCRM != null) data.MemberNumberName = eCRM.UserName; data.FBConnect = item.FBConnect; data.FBFriend = item.FBFriend; data.Memo = item.Memo; data.CreateTime = item.CreateTime.AddHours(8); data.UpdateTime = item.UpdateTime.AddHours(8); data.LastMemberId = item.LastMemberId; if (item.LastMemberId == null) data.LastMember = ""; else data.LastMember = user.Name; if (item.AdminUpdateTime == null) { data.AdminUpdateTime = null; } else { data.AdminUpdateTime = item.AdminUpdateTime.Value.AddHours(8); } data.Point = item.Point; data.Point_List = db.Point_List.Where(w => w.Vid == id).OrderByDescending(o => o.SendTime).Select(s => new Point_List { SendTime = s.SendTime.AddHours(8), Category_Name = s.Category_Name, Point = s.Point }).ToList(); data.Orders_List = db.Orders_List.Where(w => w.VolunteersId == id).OrderByDescending(o => o.Id).Select(s => new Orders_List { Id = s.Id, Osid = s.Osid, OrdersTime = s.OrdersTime.AddHours(8), ProductName = s.ProductName, Order_Quantity = s.Order_Quantity, TotalPrice = s.TotalPrice, OrdersStates = s.OrdersStates, OrderstateName = s.OrderstateName, PerProductPrice = s.PerProductPrice }).ToList(); db.Connection.Close(); return data; }