Ejemplo n.º 1
0
        protected void loginButton_Click(object sender, EventArgs e)
        {
            UserTypeDao userTypeDao = new UserTypeDao();
            userTypeDao.userName = userNameTextBox.Text;
            userTypeDao.password = passwordTextBox.Text;
            userTypeDao.userType = userTypeDDList.SelectedItem.Text;

            if(userTypeDDList.SelectedItem.Text!= "---User Type---")
            {
                UserLoginDal userLoginDal = new UserLoginDal();
                DataTable dt = userLoginDal.GetLoginInDB(userTypeDao);
                if(dt.Rows.Count>0)
                {
                    Session["user"] = userNameTextBox.Text;
                    if(dt.Rows[0]["User_Type"].ToString() == "Assistance")
                        Response.Redirect("PatientInfoInsertPage.aspx");
                    if (dt.Rows[0]["User_Type"].ToString() == "Doctor")
                      Response.Redirect("DoctorPageUI.aspx");
                }
                else
                {
                    Response.Write("User name or Passowrd does not match!");
                }
            }
            else
            {
                Response.Write("Select the user type...");
            }
        }
        // GET: Admin/UserType
        public ActionResult Index()
        {
            UserTypeDao          db   = new UserTypeDao();
            List <loaikhachhang> list = db.List();
            loaikhachhang        type = new loaikhachhang();

            ViewData["list"] = list;
            ViewData["type"] = type;
            return(View());
        }
 public ActionResult Destroy(int code)
 {
     try
     {
         var type = new UserTypeDao().Destroy(code);
         if (TempData["ModelSuccess"] == null)
         {
             TempData.Add("ModelSuccess", "Xóa thành công.");
         }
         return(RedirectToAction("Index", "UserType"));
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
     }
     if (TempData["ModelErrors"] == null)
     {
         TempData.Add("ModelErrors", "Có lỗi xảy ra! Không thể xóa.");
     }
     return(RedirectToAction("Index", "UserType"));
 }
 public ActionResult Update(loaikhachhang model)
 {
     try
     {
         var type = new UserTypeDao().Update(model);
         if (TempData["ModelSuccess"] == null)
         {
             TempData.Add("ModelSuccess", "Cập nhật thành công.");
         }
         return(RedirectToAction("Index", "UserType"));
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
     }
     if (TempData["ModelErrors"] == null)
     {
         TempData.Add("ModelErrors", "Có lỗi xảy ra! Không thể cập nhật.");
     }
     return(RedirectToAction("Index", "UserType"));
 }
        public DataTable GetLoginInDB(UserTypeDao userTypeDao)
        {
            DataTable       dt         = new DataTable();
            ConnectionClass connection = new ConnectionClass();
            string          query      = "select* from Registration_Form_T where User_Name ='" + userTypeDao.userName + "' and Password='******' and User_Type='" + userTypeDao.userType + "'";

            try
            {
                SqlDataAdapter da = new SqlDataAdapter(query, connection.GetOpen());
                da.Fill(dt);
            }
            catch (Exception r)
            {
                dt = null;
            }
            finally
            {
                connection.GetClose();
            }
            return(dt);
        }
 public ActionResult Store(loaikhachhang model)
 {
     try
     {
         UserTypeDao db = new UserTypeDao();
         db.Insert(model);
         if (TempData["ModelSuccess"] == null)
         {
             TempData.Add("ModelSuccess", "Thêm thành công.");
         }
         return(RedirectToAction("Index", "UserType"));
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
     }
     if (TempData["ModelErrors"] == null)
     {
         TempData.Add("ModelErrors", "Có lỗi xảy ra! Không thể thêm.");
     }
     return(RedirectToAction("Index", "UserType"));
 }
        public ActionResult Edit(int code)
        {
            var type = new UserTypeDao().GetByID(code);

            return(View(type));
        }