Esempio n. 1
0
 public int ThemLoai(Loai l)
 {
     if (loai.kiemTraTrungMa(l.maLoai))
     {
         return(-1);
     }
     else
     {
         if (loai.ThemLoai(l))
         {
             return(1);
         }
         return(0);
     }
 }
Esempio n. 2
0
        public ActionResult Index(string tenloai)
        {
            if (Session["TaiKhoan"] != null)
            {
                var tk = Session["TaiKhoan"] as KhachHang;


                if (tk.LoaiTK == "Khách Hàng")
                {
                    return(View("../Home/Index"));
                }
                else
                {
                    LoaiDAO dao = new LoaiDAO();
                    if (Session["UpdateLoai"] == null)
                    {
                        if (dao.ThemLoai(tk.MaKH, tenloai) == false)
                        {
                            ViewBag.Err = "Tên loại đã tồn tại";
                        }
                        else
                        {
                            Session["ListLoai"] = dao.GetList();
                        }
                    }
                    else
                    {
                        var nsx = Session["UpdateLoai"] as Loai;
                        if (dao.UpdateLoai(tk.MaKH, nsx.MaLoai, tenloai) == false)
                        {
                            ViewBag.Err = "Tên loại đã tồn tại";
                        }
                        else
                        {
                            Session["UpdateLoai"] = null;
                            Session["ListLoai"]   = dao.GetList();
                        }
                    }
                    return(View("Index"));
                }
            }
            else
            {
                return(View("../DangNhap/Index"));
            }
        }