public ActionResult ChangePass(string oldPass, string newPass1, string newPass2) { int r = new DoctorModels().changePass(Session[Constants.SESSION_ID] as string, oldPass, newPass1, newPass2); if (r == -1) { ViewBag.Err1 = "Hãy nhập mật khẩu mới"; return(View()); } if (r == -2) { ViewBag.Err2 = "Nhập lại không đúng"; return(View()); } if (r == -3) { ViewBag.Err3 = "Sai mật khẩu"; return(View()); } if (r == 0) { ViewBag.Err4 = "Hệ thống đang cập nhập, vui lòng quay lại sau"; return(View()); } ViewBag.Success = "Cập nhật mật khẩu thành công"; return(View()); }
public bool Create(DoctorModels DoctorModel) { bool result = true; string connectionString = @"Data Source=(LocalDb)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\aspnet-WebApplication1-20201104082923.mdf;Initial Catalog=aspnet-WebApplication1-20201104082923;Integrated Security=True"; string sqlExpression = "INSERT INTO Doctors ([Idr], [DocFIO], [Cabinet], [Qualification], [Work_experience], [EmailD]) VALUES (@Idr, @DocFIO, @Cabinet, @Qualification, @Work_experience, @EmailD)"; using (SqlConnection connection = new SqlConnection(connectionString)) { SqlCommand sql = new SqlCommand(sqlExpression, connection); sql.Parameters.Add("@Idr", SqlDbType.NVarChar); sql.Parameters["@Idr"].Value = DoctorModel.Idr; sql.Parameters.Add("@DocFIO", SqlDbType.NVarChar); sql.Parameters["@DocFIO"].Value = DoctorModel.DocFIO; sql.Parameters.Add("@Cabinet", SqlDbType.NVarChar); sql.Parameters["@Cabinet"].Value = DoctorModel.Cabinet; sql.Parameters.Add("@Qualification", SqlDbType.NVarChar); sql.Parameters["@Qualification"].Value = DoctorModel.Qualification; sql.Parameters.Add("@Work_experience", SqlDbType.NVarChar); sql.Parameters["@Work_experience"].Value = DoctorModel.Work_experience; sql.Parameters.Add("@EmailD", SqlDbType.NVarChar); sql.Parameters["@EmailD"].Value = DoctorModel.EmailD; try { connection.Open(); Int32 rowsAffected = sql.ExecuteNonQuery(); Console.WriteLine("RowsAffected: {0}", rowsAffected); } catch (Exception) { result = false; } return(result); } }
public bool Edit(DoctorModels DoctorModel) { bool result = true; string connectionString = @"Data Source=(LocalDb)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\aspnet-WebApplication1-20201104082923.mdf;Initial Catalog=aspnet-WebApplication1-20201104082923;Integrated Security=True"; string sqlExpression = "UPDATE Doctors SET DocFIO=@DocFIO, Cabinet=@Cabinet, Qualification=@Qualification, Work_experience=@Work_experience WHERE Idr=@Idr"; using (SqlConnection connection = new SqlConnection(connectionString)) { SqlCommand sql = new SqlCommand(sqlExpression, connection); sql.Parameters.Add("@Idr", SqlDbType.NVarChar); sql.Parameters["@Idr"].Value = DoctorModel.Idr; sql.Parameters.Add("@DocFIO", SqlDbType.NVarChar); sql.Parameters["@DocFIO"].Value = DoctorModel.DocFIO; sql.Parameters.Add("@Cabinet", SqlDbType.NVarChar); sql.Parameters["@Cabinet"].Value = DoctorModel.Cabinet; sql.Parameters.Add("@Qualification", SqlDbType.NVarChar); sql.Parameters["@Qualification"].Value = DoctorModel.Qualification; sql.Parameters.Add("@Work_experience", SqlDbType.NVarChar); sql.Parameters["@Work_experience"].Value = DoctorModel.Work_experience; try { connection.Open(); Int32 rowsAffected = sql.ExecuteNonQuery(); Console.WriteLine("RowsAffected: {0}", rowsAffected); } catch (Exception) { result = false; } return(result); } }
public ActionResult Details(string id = "0") { var model = new DoctorModels().detail(id); if (model == null) { return(RedirectToAction(actionName: "NotAuthorize", controllerName: "Login")); } return(View(model)); }
public ActionResult Delete(int Idr, DoctorModels DoctorModel) { int records1 = DoctorModel.Delete(Idr); if (records1 > 0) { return(RedirectToAction("Index")); } else { ModelState.AddModelError("", "Can Not Delete"); return(View("Index")); } }
public ActionResult Edit([Bind(Exclude = "")] DoctorModels DoctorModel) { try { if (Doctor.Edit(DoctorModel)) { return(RedirectToAction("Index")); } else { return(View("Edit")); } } catch { return(View("Edit")); } }
public ActionResult Create([Bind(Exclude = "")] DoctorModels DoctorModel) { try { if (Doctor.Create(DoctorModel)) { return(RedirectToAction("Index")); } else { return(View("Create")); } } catch { return(View("Create")); } }
public ActionResult Edit(string id) { ViewBag.getListHospitals = new HospitalModels().getListHospitals(); ViewBag.getListTinhs = new TinhModels().getListTinhs(); ViewBag.getListXas = new XaModels().getListXas(); ViewBag.getListHuyens = new HuyenModels().getListHuyens(); var model = new DoctorModels().detail(id); // neu la manager, k cung benh vien vs doctor if ((Session[Constants.SESSION_GROUPID] as string) == Constants.G_MANAGER && model.idbv.Trim() != (Session[Constants.SESSION_HOSPITAL_ID] as string).Trim()) { return(RedirectToAction(actionName: "NotAuthorize", controllerName: "Login")); } if ((Session[Constants.SESSION_GROUPID] as string) == Constants.G_DOCTOR && model.idbsy.Trim() != (Session[Constants.SESSION_ID] as string).Trim()) { return(RedirectToAction(actionName: "NotAuthorize", controllerName: "Login")); } return(View(model)); }
public ActionResult Alls() { var model = new DoctorModels().getAll(); return(View(model)); }