public ActionResult DeleteChatLieu(ChatLieu cl, int id) { cl = db.chatLieus.Where(m => m.ID == id).FirstOrDefault(); db.chatLieus.Remove(cl); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult AddProduct() { List <_Category> listcate = new List <_Category>(); foreach (var item in db.categories.ToList()) { _Category c = new _Category(); c.IDCategory = item.IDCategory; c.Name = item.Name; listcate.Add(c); } ViewBag.IDCategory = new SelectList(listcate, "IDCategory", "Name", null); List <ThuongHieu> listth = new List <ThuongHieu>(); foreach (var item in db.thuongHieus.ToList()) { ThuongHieu th = new ThuongHieu(); th.ID = item.ID; th.Name = item.Name; listth.Add(th); } ViewBag.IDThuongHieu = new SelectList(listth, "ID", "Name", null); List <ChatLieu> listcl = new List <ChatLieu>(); foreach (var item in db.chatLieus.ToList()) { ChatLieu cl = new ChatLieu(); cl.ID = item.ID; cl.Ten = item.Ten; listcl.Add(cl); } ViewBag.IDChatLieu = new SelectList(listcl, "ID", "Ten", null); return(View()); }
public void CapNhatChatLieu(string ma, string ten) { ChatLieu cl = db.ChatLieus.Where(m => m.MaChatLieu == ma).SingleOrDefault(); cl.TenChatLieu = ten; db.SubmitChanges(); }
public ActionResult DeleteConfirmed(string id) { ChatLieu chatLieu = db.ChatLieux.Find(id); db.ChatLieux.Remove(chatLieu); db.SaveChanges(); return RedirectToAction("Index"); }
protected void btnDelete_Click(object sender, EventArgs e) { int id = Convert.ToInt32((sender as LinkButton).CommandArgument); bool res = false; try { ChatLieu.ChatLieu_Delete(id); res = true; Clear(); } catch (SqlException ex) { Console.WriteLine(ex.Message); res = false; } if (res == true) { lbSuccess.Text = "Deleted successfully!!"; } else { lbError.Text = "There's something wrong. We cannot save your work"; } }
public void XoaChatLieu(string ma) { ChatLieu cl = db.ChatLieus.Where(m => m.MaChatLieu == ma).SingleOrDefault(); db.ChatLieus.DeleteOnSubmit(cl); db.SubmitChanges(); }
public ActionResult ThemChatLieu(ChatLieu cl) { if (ModelState.IsValid) { db.chatLieus.Add(cl); db.SaveChanges(); } return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "MaChatLieu,TenChatLieu")] ChatLieu chatLieu) { if (ModelState.IsValid) { db.Entry(chatLieu).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } return View(chatLieu); }
public ActionResult Create([Bind(Include = "MaChatLieu,TenChatLieu")] ChatLieu chatLieu) { if (ModelState.IsValid) { db.ChatLieux.Add(chatLieu); db.SaveChanges(); return RedirectToAction("Index"); } return View(chatLieu); }
public void LuuTruChatLieu(string ma, string ten) { var chatLieuData = new ChatLieu() { MaChatLieu = ma, TenChatLieu = ten }; db.ChatLieus.InsertOnSubmit(chatLieuData); db.SubmitChanges(); }
public ActionResult Create([Bind(Include = "ChatLieuID,TenChatLieu,KieuDang")] ChatLieu chatLieu) { if (ModelState.IsValid) { db.ChatLieus.Add(chatLieu); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(chatLieu)); }
public ActionResult SuaCL(int id) { ChatLieu chatlieu = db.ChatLieus.SingleOrDefault(n => n.MaCL == id); ViewBag.MaCL = chatlieu.MaCL; if (chatlieu == null) { Response.StatusCode = 404; return(null); } return(View(chatlieu)); }
public ActionResult SuaCL(ChatLieu chatlieu) { if (ModelState.IsValid) { ChatLieu cl = db.ChatLieus.SingleOrDefault(n => n.MaCL == chatlieu.MaCL); cl.TenCL = chatlieu.TenCL; UpdateModel(cl); db.SubmitChanges(); return(RedirectToAction("ChatLieu")); } return(View(chatlieu)); }
public bool Chatlieu(ChatLieu chatLieu) { try { db.ChatLieux.Add(chatLieu); db.SaveChanges(); return(true); } catch { return(false); } }
// GET: Admin/ChatLieu/Delete/5 public ActionResult Delete(string id) { if (id == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } ChatLieu chatLieu = db.ChatLieux.Find(id); if (chatLieu == null) { return HttpNotFound(); } return View(chatLieu); }
// GET: Administrator/ChatLieu/Edit/5 public ActionResult Edit(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ChatLieu chatLieu = db.ChatLieux.Find(id); if (chatLieu == null) { return(HttpNotFound()); } return(View(chatLieu)); }
public ActionResult XacnhanxoaCL(int id) { ChatLieu chatlieu = db.ChatLieus.SingleOrDefault(n => n.MaCL == id); ViewBag.MaCL = chatlieu.MaCL; if (chatlieu == null) { Response.StatusCode = 404; return(null); } db.ChatLieus.DeleteOnSubmit(chatlieu); db.SubmitChanges(); return(RedirectToAction("ChatLieu")); }
public JsonResult UpdateChatlieu(int id, string ten, string malsp, int stt) { var bonho = new ChatLieu(); bonho.ID_CL = id; bonho.Ten = ten; bonho.STT = stt; bonho.MaLSP = Convert.ToInt32(malsp); var result = new UpdateData().Chatlieu(bonho); return(Json(new { status = result })); }
public bool Chatlieu(ChatLieu chatLieu) { try { var data = db.ChatLieux.Find(chatLieu.ID_CL); data.Ten = chatLieu.Ten; data.MaLSP = chatLieu.MaLSP; data.STT = chatLieu.STT; db.SaveChanges(); return(true); } catch { return(false); } }
public ActionResult Chatlieu(ChatLieu chatLieu) { if (ModelState.IsValid) { bool check = new DataDao().Chatlieu(chatLieu); if (check) { SetAlert("thêm thành công", "success"); return(RedirectToAction("Chatlieu", "Data")); } else { ModelState.AddModelError("", "Thêm không thành công"); } } return(View("Chatlieu")); }
protected void btnSave_Click(object sender, EventArgs e) { bool res = false; try { if (btnSave.Text == "Save") { ChatLieu.ChatLieu_Insert(tbTenChatLieu.Text, 0); } else { ChatLieu.ChatLieu_Update(Convert.ToInt32(hfChatLieuID.Value), tbTenChatLieu.Text); } res = true; Clear(); } catch (Exception ex) { Console.WriteLine(ex.Message); res = false; } if (res == true) { if (btnSave.Text == "Save") { lbSuccess.Text = "Saved successfully!!"; } else if (btnSave.Text == "Update") { lbSuccess.Text = "Updated successfully!!"; } } else { lbError.Text = "There's something wrong. We cannot save your work"; } }
public ActionResult Createcl(FormCollection collection, ChatLieu cl) { var CB_MaChatLieu = collection["MaChatLieu"]; var CB_TenChatLieu = collection["TenChatLieu"]; if (string.IsNullOrEmpty(CB_MaChatLieu)) { ViewData["Loi"] = "Mã chất liệu không được để trống"; } else if (string.IsNullOrEmpty(CB_TenChatLieu)) { ViewData["Loi1"] = " Tên chất liệu không được để trống "; } else { cl.MaChatLieu = CB_MaChatLieu; cl.TenChatLieu = CB_TenChatLieu; data.ChatLieus.InsertOnSubmit(cl); data.SubmitChanges(); return(RedirectToAction("Index")); } return(this.Createcl()); }
public ActionResult EditProduct(int id) { var sp1 = db.products.Where(m => m.IDProduct == id).FirstOrDefault(); Session["sp1"] = sp1; List <_Category> listcate = new List <_Category>(); foreach (var item in db.categories.ToList()) { _Category c = new _Category(); c.IDCategory = item.IDCategory; c.Name = item.Name; listcate.Add(c); } ViewBag.IDCategory = new SelectList(listcate, "IDCategory", "Name", null); List <ThuongHieu> listth = new List <ThuongHieu>(); foreach (var item in db.thuongHieus.ToList()) { ThuongHieu th = new ThuongHieu(); th.ID = item.ID; th.Name = item.Name; listth.Add(th); } ViewBag.IDThuongHieu = new SelectList(listth, "ID", "Name", null); List <ChatLieu> listcl = new List <ChatLieu>(); foreach (var item in db.chatLieus.ToList()) { ChatLieu cl = new ChatLieu(); cl.ID = item.ID; cl.Ten = item.Ten; listcl.Add(cl); } ViewBag.IDChatLieu = new SelectList(listcl, "ID", "Ten", null); return(View(db.products.Where(m => m.IDProduct == id).FirstOrDefault())); }
public ActionResult UploadFile(HttpPostedFileBase file) { //dat ten cho file string _FileName = "Chatlieu.xls"; //duong dan luu file string _path = Path.Combine(Server.MapPath("~/Uploads/Excels"), _FileName); //luu file len server file.SaveAs(_path); // đọc dữ liệu từ file Excel DataTable dt = ReadDataFromExcelFile(_path); //CopyDataByBulk(dt); for (int i = 0; i < dt.Rows.Count; i++) { ChatLieu cl = new ChatLieu(); cl.ChatLieuID = dt.Rows[i][0].ToString(); cl.TenChatLieu = dt.Rows[i][1].ToString(); cl.KieuDang = dt.Rows[i][2].ToString(); db.ChatLieus.Add(cl); db.SaveChanges(); } return(RedirectToAction("Index")); }
/// <summary> /// To the entity. /// </summary> /// <param name="model">The model.</param> /// <param name="destination">The destination.</param> /// <returns>ChatLieu.</returns> public static ChatLieu ToEntity(this ChatLieuModel model, ChatLieu destination) { return(model.MapTo(destination)); }
/// <summary> /// To the model. /// </summary> /// <param name="entity">The entity.</param> /// <returns>ChatLieuModel.</returns> public static ChatLieuModel ToModel(this ChatLieu entity) { return(entity.MapTo <ChatLieu, ChatLieuModel>()); }
public void Insert(ChatLieu entity) { chatlieu.Insert(entity); }
public void Delete(ChatLieu entity) { chatlieu.Delete(entity); }
public void Update(ChatLieu entity) { chatlieu.Update(entity); }
protected virtual ChatLieu ModelToEntity(ChatLieuModel model) { ChatLieu a = chatLieuService.GetById(model.ID); return(a == null ? null : model.ToEntity(a)); }