void LoadData() { int idKhachHang = Convert.ToInt32(Session["idKhachHang"]); List <ListFavourite> listFavourite = db.ListFavourites.Where(x => x.idAccount == idKhachHang).ToList(); List <Comic> lsComic = new List <Comic>(); foreach (ListFavourite ls in listFavourite) { Comic comic = db.Comics.FirstOrDefault(x => x.idComic == ls.idComic); lsComic.Add(comic); } dgvFavouriteComic.DataSource = lsComic; dgvFavouriteComic.DataBind(); }
protected void btnUpload_Click(object sender, EventArgs e) { string sTenFile; int idComic = Convert.ToInt32(Request.Params["idComic"].ToString()); sTenFile = FileUpload1.FileName; FileUpload1.SaveAs(MapPath("~/img/Comic/" + sTenFile)); lblNotice.Text = "Đã upload thành công"; Managerment_PageEntities db = new Managerment_PageEntities(); Comic obj = db.Comics.FirstOrDefault(x => x.idComic == idComic); obj.imgComic = sTenFile; db.SaveChanges(); LoadData(); getNameTypeComic(); }
protected void btnUpdateComicDetail_Command(object sender, CommandEventArgs e) { int idComic = Convert.ToInt32(Request.Params["idComic"]); string nameComic = txtnameComic.Text; int typeComic = Convert.ToInt32(cmbNameType.SelectedValue); string decription = txtDecription.Text; string author = txtAuthor.Text; Managerment_PageEntities db = new Managerment_PageEntities(); Comic obj = db.Comics.FirstOrDefault(x => x.idComic == idComic); obj.nameComic = nameComic; obj.idTypeComic = typeComic; obj.decription = decription; obj.author = author; db.SaveChanges(); LoadData(); }
protected void btnUpdateStatus_Command(object sender, CommandEventArgs e) { int idComic = int.Parse(e.CommandArgument.ToString()); Managerment_PageEntities db = new Managerment_PageEntities(); Comic comic = db.Comics.FirstOrDefault(x => x.idComic == idComic); Boolean status = Convert.ToBoolean(comic.status.ToString()); Boolean statusafterupdate = true; if (status == true) { statusafterupdate = false; } else { statusafterupdate = true; } comic.status = statusafterupdate; db.SaveChanges(); LoadData(); }
public string getStatus(object idComic) { try { Managerment_PageEntities db = new Managerment_PageEntities(); Comic obj = db.Comics.FirstOrDefault(x => x.idComic.ToString() == idComic.ToString()); if (obj.status == true) { return("Đang kích hoạt!"); } else { return("Vô hiệu hóa!"); } } catch { return("Không có!"); } }
public string getStatus(object idComic) { try { Managerment_PageEntities db = new Managerment_PageEntities(); Comic obj = db.Comics.FirstOrDefault(x => x.idComic.ToString() == idComic.ToString()); if (obj.status == true) { return("Kích Hoạt"); } else { return("Vô Hiệu Hóa"); } } catch { return(""); } }
void LoadData() { int idComic = Convert.ToInt32(Request.Params["idComic"]); Managerment_PageEntities db = new Managerment_PageEntities(); Comic obj = db.Comics.FirstOrDefault(x => x.idComic == idComic); txtIdComic.Text = obj.idComic.ToString(); txtnameComic.Text = obj.nameComic.ToString(); cmbNameType.SelectedValue = obj.idTypeComic.ToString(); txtDecription.Text = obj.decription.ToString(); txtAuthor.Text = obj.author.ToString(); int idAccount = Convert.ToInt32(obj.idAccount.ToString()); Account_Detail obj2 = db.Account_Detail.FirstOrDefault(x => x.idAccount == idAccount); txtPoster.Text = obj2.fullname.ToString(); List <Chuong> data = db.Chuongs.Where(x => x.idComic == idComic).ToList(); dgvChuong.DataSource = data; dgvChuong.DataBind(); Comic obj3 = db.Comics.FirstOrDefault(x => x.idComic == idComic); img.ImageUrl = "img/Comic/" + obj3.imgComic.ToString(); }
protected void CreateAccount_Click(object sender, EventArgs e) { string nameComic = txtNameComic.Text; string typeofComic = cmbNameType.SelectedValue; string decription = txtDecription.Text; string author = txtAuthor.Text; string username = Session["username"].ToString(); Managerment_PageEntities db = new Managerment_PageEntities(); Account obj = db.Accounts.FirstOrDefault(x => x.username == username); int idAccount = obj.idAccount; Comic newComic = new Comic(); newComic.nameComic = nameComic; newComic.idTypeComic = Convert.ToInt32(typeofComic); newComic.imgComic = "avatar.jpg"; newComic.decription = decription; newComic.author = author; newComic.idAccount = idAccount; newComic.status = false; db.Comics.Add(newComic); db.SaveChanges(); LoadData(); }