public ActionResult Edit(int id) { GetSelectList(); MusicInfo info = MusicBLL.GetList(p => p.ID == id).FirstOrDefault(); return(View(info)); }
public ActionResult Create(MusicInfo info) { if (string.IsNullOrEmpty(info.Name)) { return(Json(new APIJson("请填写名称"))); } if (info.CategoryID <= 0) { return(Json(new APIJson("请选择分类"))); } HttpPostedFileBase FileMain = Request.Files["FileMain"]; if (null == FileMain) { return(Json(new APIJson(-1, "请选择音频文件"))); } info.SRC = "/Content/File/Music/" + Guid.NewGuid().ToString() + FileMain.FileName.Substring(FileMain.FileName.LastIndexOf(".")); FileMain.SaveAs(Server.MapPath(info.SRC)); info.MD5 = Md5Helper.GetMD5HashFromFile(Server.MapPath(info.SRC)); if (MusicBLL.Create(info).ID > 0) { return(Json(new APIJson(0, "提交成功", new { info.ID }))); } return(Json(new APIJson(-1, "提交失败,请重试"))); }
/// <summary> /// 删除id /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { var selectIndex = e.RowIndex; var id = (GridView1.DataKeys[selectIndex].Value as int?).Value; MusicBLL ubll = new MusicBLL(); bool rs = ubll.DeleteByID(id); if (rs == true) { Response.Redirect("index.aspx"); } }
private IQueryable <MusicInfo> GetListData() { var list = MusicBLL.GetList(p => true); string Name = Function.GetRequestString("Name"); if (!string.IsNullOrEmpty(Name)) { list = list.Where(a => a.Name.Contains(Name)); ViewBag.TxtName = Name; } list = list.OrderBy(p => p.CategoryID).ThenBy(a => a.SortID).ThenBy(a => a.ID); return(list); }
public ActionResult Delete(int id) { var info = MusicBLL.GetList(p => p.ID == id).FirstOrDefault(); if (null == info) { return(Json(new APIJson(-1, "删除失败,参数有误"))); } if (MusicBLL.Delete(info)) { return(Json(new APIJson(0, "删除成功"))); } return(Json(new APIJson(-1, "删除失败,请重试"))); }
protected void btn_AddUser_Click(object sender, EventArgs e) { //添加歌曲 MusicInfo music = new MusicInfo(); music.Title = this.Title.Text; music.Duration = Convert.ToInt32(this.Duration.Text); music.Singer = this.Singer.Text; MusicBLL mus = new MusicBLL(); bool result = mus.AddMusic(music); if (result == true) { Response.Write("<script language='javascript'>alert('增加成功')</script>"); } }
public ActionResult UpdateMD5() { var sresult = string.Empty; var list = MusicBLL.GetList(a => true).ToList(); foreach (var item in list) { var FileFullName = Server.MapPath(item.SRC); if (System.IO.File.Exists(FileFullName)) { item.MD5 = Md5Helper.GetMD5HashFromFile(FileFullName); bool result = MusicBLL.Edit(item); sresult += FileFullName + "|MD5=" + item.MD5 + "|Result=" + result; } } return(Content(sresult)); }
public ActionResult Edit(MusicInfo info) { MusicInfo infoExist = MusicBLL.GetList(p => p.ID == info.ID).FirstOrDefault(); if (string.IsNullOrEmpty(info.Name)) { return(Json(new APIJson("请填写名称"))); } if (info.CategoryID <= 0) { return(Json(new APIJson("请选择分类"))); } HttpPostedFileBase FileMain = Request.Files["FileMain"]; if (null != FileMain) { info.SRC = "/Content/File/Music/" + Guid.NewGuid().ToString() + FileMain.FileName.Substring(FileMain.FileName.LastIndexOf(".")); FileMain.SaveAs(Server.MapPath(info.SRC)); infoExist.SRC = info.SRC; infoExist.MD5 = Md5Helper.GetMD5HashFromFile(Server.MapPath(info.SRC)); } if (info.PlayTime <= 0) { info.PlayTime = 1; } infoExist.CategoryID = info.CategoryID; infoExist.Name = info.Name; infoExist.SortID = info.SortID; infoExist.Enable = info.Enable; infoExist.PlayTime = info.PlayTime; if (MusicBLL.Edit(infoExist)) { return(Json(new APIJson(0, "提交成功"))); } return(Json(new APIJson(-1, "提交失败,请重试"))); }