private void btn_luu_Click(object sender, EventArgs e) { var kiemtra = from kt in db.Maus where kt.MaMau == txt_mamau.Text select kt; if (kiemtra.Count() > 0) { MessageBox.Show("Trùng khóa. Vui lòng nhập lại!!!"); return; } if (txt_mamau.Text == "" || txt_tenmau.Text == "") { MessageBox.Show("Vui lòng nhập đầy đủ thông tin!!!"); } else { Mau mau = new Mau(); mau.MaMau = txt_mamau.Text; mau.TenMau = txt_tenmau.Text; db.Maus.InsertOnSubmit(mau); db.SubmitChanges(); frm_mau_Load(sender, e); MessageBox.Show("Thêm thành công"); } txt_mamau.Enabled = false; }
protected void btnDelete_Click(object sender, EventArgs e) { int id = Convert.ToInt32((sender as LinkButton).CommandArgument); bool res = false; try { Mau.Mau_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 ActionResult DeleteConfirmed(int id) { Mau mau = db.Maus.Find(id); db.Maus.Remove(mau); db.SaveChanges(); return(RedirectToAction("Index")); }
public int Insert(Mau obj) { SqlParameter[] para = { new SqlParameter("Mau", obj.mauSP) }; return(base.ExcuteSQL("MAU_Insert", para)); }
public ActionResult Edit([Bind(Include = "Mamau,Tenmau")] Mau mau) { if (ModelState.IsValid) { db.Entry(mau).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(mau)); }
public int Update(Mau obj) { SqlParameter[] para = { new SqlParameter("MaMau", obj.maMau), new SqlParameter("Mau", obj.mauSP) }; return(base.ExcuteSQL("MAU_Update", para)); }
public ActionResult Create([Bind(Include = "Mamau,Tenmau")] Mau mau) { if (ModelState.IsValid) { db.Maus.Add(mau); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(mau)); }
public bool insert(Mau mau) { try { mau.Code = "#" + mau.Code; db.Maus.Add(mau); db.SaveChanges(); return(true); } catch (Exception) { return(false); } }
// GET: Mau/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Mau mau = db.Maus.Find(id); if (mau == null) { return(HttpNotFound()); } return(View(mau)); }
public bool update(Mau mau) { try { var mauUpdate = db.Maus.Find(mau.ID); mauUpdate.Name = mau.Name; mauUpdate.Code = "#" + mau.Code; db.SaveChanges(); return(true); } catch (Exception) { return(false); } }
public JsonResult Save(Mau mau) { if (mau.ID > 0) { return(Json(new { //them danh muc status = new MauDAO().update(mau) })); } else { return(Json(new { //cap nhat danh muc status = new MauDAO().insert(mau) })); } }
protected void btnSave_Click(object sender, EventArgs e) { bool res = false; try { if (btnSave.Text == "Save") { Mau.Mau_Insert(tbTenMau.Text, 0); } else { Mau.Mau_Update(Convert.ToInt32(hfMauID.Value), tbTenMau.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"; } }
/// <summary> /// Models to entity. /// </summary> /// <param name="model">The model.</param> /// <returns>Mau.</returns> protected virtual Mau ModelToEntity(MauModel model) { Mau a = MauService.GetById(model.ID); return(a == null ? null : model.ToEntity(a)); }
public int Insert(Mau obj) { return(dal.Insert(obj)); }
public int Update(Mau obj) { return(dal.Update(obj)); }
public override string ToString() { String s = Tu.ToString() + "/" + Mau.ToString(); return(s); }
/// <summary> /// To the model. /// </summary> /// <param name="entity">The entity.</param> /// <returns>MauModel.</returns> public static MauModel ToModel(this Mau entity) { return(entity.MapTo <Mau, MauModel>()); }
public void Insert(Mau entity) { repos.Insert(entity); }
public void Delete(Mau entity) { repos.Delete(entity); }
public void Update(Mau entity) { repos.Update(entity); }
/// <summary> /// To the entity. /// </summary> /// <param name="model">The model.</param> /// <param name="destination">The destination.</param> /// <returns>Mau.</returns> public static Mau ToEntity(this MauModel model, Mau destination) { return(model.MapTo(destination)); }
public bool ThemMau(string Mau) { Mau mau = new Mau(); mau.TenMau = Mau; try { using (DBGiayDepEntities db = new DBGiayDepEntities()) { db.Maus.Add(mau); db.SaveChanges(); return true; } } catch (Exception e) { Debug.WriteLine(e); return false; } }