//lay ma chuyen muc lon nhat public string GetMaNXBMax() { SQLDataContext.CreateDataContext(); string chuyenmuc = ""; try { //string masach = ""; int maso; SQLDataContext.SQLData.sp_getMaCMMax(ref chuyenmuc); maso = int.Parse(chuyenmuc.Substring(2)) + 1; if (maso.ToString().Length == 1) { chuyenmuc = "CM00" + maso.ToString(); } else if (maso.ToString().Length == 2) { chuyenmuc = "CM0" + maso.ToString(); } else { chuyenmuc = "CM" + maso.ToString(); } CHUYENMUC cm = new CHUYENMUC(); cm.MACHUYENMUC = chuyenmuc; SQLDataContext.SQLData.CHUYENMUCs.InsertOnSubmit(cm); SQLDataContext.SQLData.SubmitChanges(); return(chuyenmuc); } catch { return("demo"); } }
protected void btnCapNhat_Click(object sender, EventArgs e) { try { //lay thong tin tu textbox CHUYENMUC lpDTO = new CHUYENMUC(); lpDTO.MaChuyenMuc = int.Parse(this.txtmachuyenmuc.Text); lpDTO.TenChuyenMuc = this.txttenchuyenmuc.Text; //Goi ham cap nhat BUSChuyenMuc BUSChuyenMuc = new BUSChuyenMuc(); if (BUSChuyenMuc.CapNhat(lpDTO) == 0) { //Thong bao lbThongBao.Text = "Cập Nhật Thành Công"; lbThongBao.Visible = true; //Response.Redirect("LoaiMatHang.aspx"); } else { lbThongBao.Text = "Cập Nhật Không Thành Công"; lbThongBao.Visible = true; } } catch { lbThongBao.Text = "Cập nhật Không Thành Công"; lbThongBao.Visible = true; } }
public ActionResult DeleteConfirmed(int id) { CHUYENMUC cHUYENMUC = db.CHUYENMUCs.Find(id); db.CHUYENMUCs.Remove(cHUYENMUC); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "MACM,TENCM,URLCM")] CHUYENMUC cHUYENMUC) { if (ModelState.IsValid) { db.Entry(cHUYENMUC).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(cHUYENMUC)); }
public ActionResult Create([Bind(Include = "MACM,TENCM,URLCM")] CHUYENMUC cHUYENMUC) { if (ModelState.IsValid) { db.CHUYENMUCs.Add(cHUYENMUC); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(cHUYENMUC)); }
public bool XoaCM(CHUYENMUC cm) { try { SQLDataContext.SQLData.SP_XOACHUYENMUC(cm.MACHUYENMUC); return(true); } catch { return(false); } }
public bool SuaCM(CHUYENMUC cm) { try { SQLDataContext.SQLData.SP_SUACHUYENMUC(cm.MACHUYENMUC, cm.TENCHUYENMUC); return(true); } catch { return(false); } }
public bool ThemCM(CHUYENMUC cm) { try { SuaCM(cm); return(true); } catch { return(false); } }
//delete ma sach rong public void DeleteMaCMMax() { try { CHUYENMUC chuyenmuc = SQLDataContext.SQLData.CHUYENMUCs.Single(cm => cm.TENCHUYENMUC == null); SQLDataContext.SQLData.CHUYENMUCs.DeleteOnSubmit(chuyenmuc); SQLDataContext.SQLData.SubmitChanges(); } catch { } }
// GET: Admin/CHUYENMUC/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CHUYENMUC cHUYENMUC = db.CHUYENMUCs.Find(id); if (cHUYENMUC == null) { return(HttpNotFound()); } return(View(cHUYENMUC)); }
public ActionResult AddCate(CHUYENMUC cm) { if (ModelState.IsValid) { var DAO = new CateDao(); long id = DAO.addCate(cm); if (id > 0) { return(RedirectToAction("Index", "CateManager")); } else { ModelState.AddModelError("", "Thêm thể loại thất bại"); } } return(View("Index")); }
public int Them(CHUYENMUC lpDTO) { DAOChuyenMuc CHUYENMUC = new DAOChuyenMuc(); return CHUYENMUC.Them(lpDTO); }
public int CapNhat(CHUYENMUC lpDTO) { DAOChuyenMuc CHUYENMUC = new DAOChuyenMuc(); return CHUYENMUC.CapNhat(lpDTO); }
public long addCate(CHUYENMUC tk) { db.CHUYENMUCs.Add(tk); db.SaveChanges(); return(tk.IDCM); }