public static void DeleteListAll(string uid) { TianLaiDBDataContext db = new TianLaiDBDataContext(); var item = db.PlayList.Where(p => p.Uid == uid); db.PlayList.DeleteAllOnSubmit(item); db.SubmitChanges(); }
public static void DeleteByMid(int mid) { TianLaiDBDataContext db = new TianLaiDBDataContext(); var item = db.Music.FirstOrDefault(p => p.Mid == mid); db.Music.DeleteOnSubmit(item); db.SubmitChanges(); }
public static void DeleteByAid(int aid) { TianLaiDBDataContext db = new TianLaiDBDataContext(); var item = db.Album.FirstOrDefault(p => p.Aid == aid); db.Album.DeleteOnSubmit(item); db.SubmitChanges(); }
public static void DeleteBySid(int sid) { TianLaiDBDataContext db = new TianLaiDBDataContext(); var item = db.Singer.FirstOrDefault(p => p.Sid == sid); db.Singer.DeleteOnSubmit(item); db.SubmitChanges(); }
public static void DeletePlayListAll() { TianLaiDBDataContext db = new TianLaiDBDataContext(); db.PlayList.DeleteAllOnSubmit(db.PlayList); db.SubmitChanges(); }
public ActionResult AddMusic([Bind(Exclude="Mid")] Music music) { foreach (string upload in Request.Files) { string path = AppDomain.CurrentDomain.BaseDirectory + "uploads/"; string filename = Path.GetFileName(Request.Files[upload].FileName); if (filename.ToLower().IndexOf(".mp3") == -1) { Response.Write("<div style='color:Red;'>请上传mp3格式文件!</div>"); return View(); } Request.Files[upload].SaveAs(Path.Combine(path, filename)); music.Url = "../../uploads/" + filename; } if (ModelState.IsValid) { try { TianLaiDBDataContext db = new TianLaiDBDataContext(); db.Music.InsertOnSubmit(music); db.SubmitChanges(); return Content("<label style='color:#35006A'>操作成功!</label>"); } catch (Exception ex) { ex.ToString(); return Content("<label style='color:Red'>操作失败!</label>"); } } else return View(music); }
public static void DeleteList(int mid,string uid) { TianLaiDBDataContext db = new TianLaiDBDataContext(); var item = db.PlayList.FirstOrDefault(p => p.Mid == mid&&p.Uid==uid); db.PlayList.DeleteOnSubmit(item); db.SubmitChanges(); }
public static void DeleteList(int mid, string uid) { TianLaiDBDataContext db = new TianLaiDBDataContext(); var item = db.PlayList.FirstOrDefault(p => p.Mid == mid && p.Uid == uid); db.PlayList.DeleteOnSubmit(item); db.SubmitChanges(); }
public void AddToPlayList(string mids, string uid) { string sql = "select * from Music where Mid in (" + mids + ")"; var result = db.ExecuteQuery <Music>(sql); foreach (var item in result) { PlayList pl = new PlayList(); pl.Mid = item.Mid; pl.Uid = uid; db.PlayList.InsertOnSubmit(pl); db.SubmitChanges(); } }
public ActionResult AddAlbum([Bind(Exclude="Aid")] Album album) { if (ModelState.IsValid) { try { TianLaiDBDataContext db = new TianLaiDBDataContext(); db.Album.InsertOnSubmit(album); db.SubmitChanges(); return Content("<label style='color:#35006A'>操作成功!</label>"); } catch (Exception ex) { ex.ToString(); return Content("<label style='color:Red'>操作失败!</label>"); } } else return View(album); }
public ActionResult ModAlbum(int aid,Album album) { try { TianLaiDBDataContext db = new TianLaiDBDataContext(); album = db.Album.SingleOrDefault(p => p.Aid == aid); UpdateModel(album); db.SubmitChanges(); return Content("<label style='color:#35006A'>操作成功!</label>"); } catch (Exception ex) { ex.ToString(); return Content("<label style='color:Red'>操作失败!</label>"); } }
public ActionResult Register([Bind(Exclude = "ID,IsAdmin,AuthCode,CreateTime")] FormCollection formcollection) { UserInfo userinfo=new UserInfo(); userinfo.Uid = formcollection["username"]; userinfo.Password = formcollection["password"]; userinfo.Uname = formcollection["nickname"]; userinfo.Email = formcollection["email"]; userinfo.Photo = formcollection["selectbox"]; try { using (TianLaiDBDataContext db = new TianLaiDBDataContext()) { //检查账户是否重复 if (db.UserInfo.Where(p => p.Uid == userinfo.Uid).FirstOrDefault() != null) { ViewData["unameconfirm"] = "<label style='color:Red'>用户名重复,请重新输入</label>"; return View(userinfo); } using (System.Transactions.TransactionScope transaction = new System.Transactions.TransactionScope()) { //指定已排除的默认值 userinfo.IsAdmin = false; userinfo.AuthCode = Guid.NewGuid().ToString(); userinfo.Password = HashPassword(userinfo.Password); userinfo.Createdata = DateTime.Now; //将数据保存至数据库 db.UserInfo.InsertOnSubmit(userinfo); db.SubmitChanges(); System.Net.Mail.SmtpClient sc = new System.Net.Mail.SmtpClient("smtp.qq.com", 25); sc.Credentials = new System.Net.NetworkCredential("342354548", "0oO0oO"); sc.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network; string verify_url = new Uri(Request.Url, System.Web.Routing.RouteTable.Routes.GetVirtualPath (Request.RequestContext, new System.Web.Routing.RouteValueDictionary (new { action = "Verify", authCode = userinfo.AuthCode })).VirtualPath).AbsoluteUri; sc.Send("*****@*****.**", userinfo.Email, "会员注册确认信", verify_url); transaction.Complete(); } } } catch (System.Net.Mail.SmtpException) { ModelState.AddModelError("Email", "很抱歉!系统发生异常,目前无法寄送确认信,请稍候再试!"); return View(userinfo); } return Content("注册信息已发出,请登录邮箱验证!"); }
public ActionResult Verify(string authCode) { using (TianLaiDBDataContext db = new TianLaiDBDataContext()) { var member = db.UserInfo.Where(p => p.AuthCode == authCode).FirstOrDefault(); if (member != null) { ViewData["Result"] = "会员验证成功!"; member.AuthCode = null; db.SubmitChanges(); Session["CurrentUser"] = db.UserInfo.ToList().Find(u => u.Uid == member.Uid); } else { ViewData["Result"] = "找不到此验证码,您是否已经验证过了呢?"; } } return View(); }
public ActionResult ModPermission(string uid) { try { TianLaiDBDataContext db = new TianLaiDBDataContext(); UserInfo userinfo = db.UserInfo.SingleOrDefault(p => p.Uid == uid); if (userinfo.IsAdmin == true) userinfo.IsAdmin = false; else userinfo.IsAdmin = true; UpdateModel(userinfo); db.SubmitChanges(); return View("Permission",db.UserInfo); } catch (Exception ex) { ex.ToString(); return Content("<label style='color:Red'>操作失败!</label>"); } }
public ActionResult ModSinger(int sid,Singer singer) { if (ModelState.IsValid) { try { TianLaiDBDataContext db = new TianLaiDBDataContext(); singer = db.Singer.SingleOrDefault(d => d.Sid == sid); UpdateModel(singer); db.SubmitChanges(); return Content("<label style='color:#35006A'>操作成功!</label>"); } catch (Exception ex) { ex.ToString(); return Content("<label style='color:Red'>操作失败!</label>"); } } else { return View(singer); } }
public ActionResult ModMusic(int mid,Music music) { try { TianLaiDBDataContext db = new TianLaiDBDataContext(); music = db.Music.SingleOrDefault(p => p.Mid == mid); UpdateModel(music); db.SubmitChanges(); return Content("<label style='color:#35006A'>操作成功!</label>"); } catch (Exception ex) { ex.ToString(); return Content("<label style='color:Red'>操作失败!</label>"); } }