public ActionResult Create(NewPatient patient) { string name = patient.Name; string address = patient.Address; string contact = patient.Contactno; DateTime dob = patient.Dob; string city = patient.City; new Dataaccess().ExecuteProcess(name,address,contact,dob,city); ViewBag.message = "INSERTED SUCCESSFULLY"; return View("New"); }
public ActionResult PatientDelete(NewPatient patient) { int k1 = new Dataaccess().Delete(patient.Id); if (k1 == 1) { TempData["ErrorMessage"] = "Patient Deleted"; return RedirectToAction("Show", patient); } else { return View(); } }
public ActionResult EditPatient(NewPatient patient1) { if (ModelState.IsValid) { int k = new Dataaccess().Edit(patient1); if (k == 1) { TempData["ErrorMessage"] = "Edit Successfully"; return RedirectToAction("Show",patient1); } else return View(patient1); } return View(); }
public int Edit(NewPatient patient) { SqlConnection connection = new SqlConnection( @"Data Source=.\SQLExpress;Initial Catalog=PatientManagmentSystem;Integrated Security=True;"); connection.Open(); string strQuery = "spx_EditPatient"; SqlCommand command = new SqlCommand(strQuery, connection); command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@Id", patient.Id); command.Parameters.AddWithValue("@Name", patient.Name); command.Parameters.AddWithValue("@Address", patient.Address); command.Parameters.AddWithValue("@Contact", patient.Contactno); command.Parameters.AddWithValue("@Dob", patient.Dob); command.Parameters.AddWithValue("@City", patient.City); command.CommandText = strQuery; command.Connection = connection; int i = command.ExecuteNonQuery(); connection.Close(); return i; }
public List<NewPatient> Fetch(int id) { SqlConnection connection = new SqlConnection( @"Data Source=.\SQLExpress;Initial Catalog=PatientManagmentSystem;Integrated Security=True;"); connection.Open(); string strQuery = "spx_Fetch_Patient"; SqlCommand command = new SqlCommand(strQuery, connection); command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@P_Id", id); command.CommandText = strQuery; command.Connection = connection; SqlDataReader sdr = command.ExecuteReader(); List<NewPatient> patient = new List<NewPatient>(); if (sdr.HasRows) { while (sdr.Read()) { var pat = new NewPatient(); pat.Id = (int) sdr[0]; pat.Name = (string) sdr[1]; pat.Address = (string) sdr[2]; pat.Contactno = (string) sdr[3]; pat.Dob = (DateTime) sdr[4]; pat.City = (string) sdr[5]; patient.Add(pat); } } connection.Close(); return patient; }