public ActionResult AddPatient() { var model = new DiseaseDetailModel() { Areas = GetAreas(), Disease = GetDisease() }; return View(model); }
public ActionResult AddPatient(DiseaseDetailModel diseaseDetail) { try { if (ModelState.IsValid) { diseaseDetail.DocId = Convert.ToInt32(Session["DocId"]); diseaseDetail.PatientAddDate = DateTime.Now; diseaseDetail.Save(); TempData["Success"] = "Patient added Successfully."; ModelState.Clear(); // making form, emty after submission of form } else { //empData["Error"] = "Please provide Required data."; } var model1 = new DiseaseDetailModel() { Areas = GetAreas(), Disease = GetDisease() }; return View(model1); } catch (Exception ex) { throw ex; } }
/// <summary> /// Showing the complete record from the diseasedetails database /// </summary> /// <returns></returns> public List<DiseaseDetailModel> GetDiseaseDetailAll() { try { string Q_ShowAllDiseaseDetailAll = "select * from diseasedetails"; Logger.Debug("DiseaseDetailModel", "GetDiseaseDetailAll", "Assigning value to the variable"); string cmdText = string.Format(Q_ShowAllDiseaseDetailAll); Logger.Debug("DiseaseMasterModel", "GetDiseaseMasterAll", "Creating database"); Database db = new Database(); Logger.Debug("DiseaseMasterModel", "GetDiseaseMasterAll", "Database created"); Logger.Debug("DiseaseMasterModel", "GetDiseaseMasterAll", "reading data from database"); DbDataReader reader = db.Select(cmdText); if (reader.HasRows) { List<DiseaseDetailModel> diseaseDetailList = new List<DiseaseDetailModel>(); while (reader.Read()) { DiseaseDetailModel diseaseDetail = new DiseaseDetailModel(); diseaseDetail.Id = Convert.ToInt32(reader["Id"]); Logger.Debug("DiseaseDetailModel", "GetDiseaseDetailById", "Id read from database"); diseaseDetail.DocId = Convert.ToInt32(reader["DocId"]); Logger.Debug("DiseaseDetailModel", "GetDiseaseDetailById", "DocId read from database"); diseaseDetail.Age = Convert.ToInt32(reader["Age"]); Logger.Debug("DiseaseDetailModel", "GetDiseaseDetailById", "Age read from database"); diseaseDetail.Gender = ParameterFormater.UnescapeXML(reader["Gender"].ToString()); Logger.Debug("DiseaseDetailModel", "GetDiseaseDetailById", "Gender read from database"); diseaseDetail.AreaId = Convert.ToInt32(reader["AreaId"]); Logger.Debug("DiseaseDetailModel", "GetDiseaseDetailById", "AreaId read from database"); diseaseDetail.PatientAddDate = Convert.ToDateTime(reader["PatientAddDate"].ToString()); Logger.Debug("DiseaseDetailModel", "GetDiseaseDetailById", "Patient admit date read from database"); diseaseDetail.DiseaseId = Convert.ToInt32(reader["DiseaseId"]); Logger.Debug("DiseaseDetailModel", "GetDiseaseDetailById", "DiseaseId read from database"); diseaseDetailList.Add(diseaseDetail); } Logger.Debug("DiseaseDetailModel", "GetDiseaseDetailById", "Checking reader has closed the connection."); if (!reader.IsClosed) { Logger.Debug("DiseaseDetailModel", "GetDiseaseDetailById", "closing database connection"); reader.Close(); } Logger.Debug("DiseaseDetailModel", "GetDiseaseDetailById", "Object returning value"); return diseaseDetailList; } return null; } catch (Exception ex) { Logger.Error("DiseaseDetailModel", "GetDiseaseDetailById", "Error occured while Selecting data from disease detail for all", ex); throw ex; } finally { Logger.Debug("DiseaseDetailModel", "GetDiseaseDetailById", "Closed sleeping connection"); Database.KillConnections(); } }
/// <summary> /// Showing record by ID from database DiseaseDetails /// </summary> /// <param name="diseaseDetailId"></param> /// <returns></returns> public DiseaseDetailModel GetDiseaseDetailById(int diseaseDetailId) { try { string Q_ShowDiseaseDetailById = "select * from diseasedetails where Id = {0}"; Logger.Debug("DiseaseDetailModel", "GetDiseaseDetailById", "storing values in variable."); string cmdText = string.Format(Q_ShowDiseaseDetailById, diseaseDetailId); Logger.Debug("DiseaseDetailModel", "GetDiseaseDetailById", "storing values in variable after id check."); Logger.Debug("DiseaseDetailModel", "GetDiseaseDetailById", " creating Database"); Database db = new Database(); Logger.Debug("DiseaseDetailModel", "GetDiseaseDetailById", "Database created"); Logger.Debug("DiseaseDetailModel", "GetDiseaseDetailById", "Reading value from Database by Id"); DbDataReader reader = db.Select(cmdText); Logger.Debug("DiseaseDetailModel", "GetDiseaseDetailById", "Reading value done"); Logger.Debug("DiseaseDetailModel", "GetDiseaseDetailById", "checking database has rows!"); if (reader.HasRows) { DiseaseDetailModel diseaseDetail = new DiseaseDetailModel(); Logger.Debug("DiseaseDetailModel", "GetDiseaseDetailById", "Diseasemaster object created"); Logger.Debug("DiseaseDetailModel", "GetDiseaseDetailById", "Reading database values"); while (reader.Read()) { diseaseDetail.Id = Convert.ToInt32(reader["Id"]); Logger.Debug("DiseaseDetailModel", "GetDiseaseDetailById", "Id read from database"); diseaseDetail.DocId = Convert.ToInt32(reader["DocId"]); Logger.Debug("DiseaseDetailModel", "GetDiseaseDetailById", "DocId read from database"); diseaseDetail.Age = Convert.ToInt32(reader["Age"]); Logger.Debug("DiseaseDetailModel", "GetDiseaseDetailById", "Age read from database"); diseaseDetail.Gender = ParameterFormater.UnescapeXML(reader["Gender"].ToString()); Logger.Debug("DiseaseDetailModel", "GetDiseaseDetailById", "Gender read from database"); diseaseDetail.AreaId = Convert.ToInt32(reader["AreaId"]); Logger.Debug("DiseaseDetailModel", "GetDiseaseDetailById", "AreaId read from database"); diseaseDetail.DiseaseId = Convert.ToInt32(reader["DiseaseId"]); Logger.Debug("DiseaseDetailModel", "GetDiseaseDetailById", "DiseaseId read from database"); diseaseDetail.PatientAddDate = Convert.ToDateTime(reader["PatientAddDate"].ToString()); Logger.Debug("DiseaseDetailModel", "GetDiseaseDetailById", "Patient admit date read from database"); /* diseaseDetail.PatientAddDate = ParameterFormater.UnescapeXML(reader["PatientAddDate"].ToString()); Logger.Debug("DiseaseDetailModel", "GetDiseaseDetailById", "ShortAreaName read from database.");diseaseDetail.DocId = Convert.ToInt32(reader["DocId"]); Logger.Debug("DiseaseDetailModel", "GetDiseaseDetailById", "DocId read from database"); */ } Logger.Debug("DiseaseDetailModel", "GetDiseaseDetailById", "Checking reader has closed the connection."); if (!reader.IsClosed) { Logger.Debug("DiseaseDetailModel", "GetDiseaseDetailById", "closing database connection"); reader.Close(); Logger.Debug("DiseaseDetailModel", "GetDiseaseDetailById", "Connection closed"); } Logger.Debug("DiseaseDetailModel", "GetDiseaseDetailById", "Object returning value"); return diseaseDetail; } return null; } catch (Exception ex) { Logger.Error("DiseaseDetailModel", "GetDiseaseDetailById", "Erro occured while Selecting data from disease master detail by id", ex); throw ex; } finally { Logger.Debug("DiseaseDetailModel", "GetDiseaseDetailById", "Closed sleeping connection"); Database.KillConnections(); } }
/// <summary> /// Showing the complete record from the diseasedetails database /// </summary> /// <returns></returns> public List <DiseaseDetailModel> GetDiseaseDetailAll() { try { string Q_ShowAllDiseaseDetailAll = "select * from diseasedetails"; Logger.Debug("DiseaseDetailModel", "GetDiseaseDetailAll", "Assigning value to the variable"); string cmdText = string.Format(Q_ShowAllDiseaseDetailAll); Logger.Debug("DiseaseMasterModel", "GetDiseaseMasterAll", "Creating database"); Database db = new Database(); Logger.Debug("DiseaseMasterModel", "GetDiseaseMasterAll", "Database created"); Logger.Debug("DiseaseMasterModel", "GetDiseaseMasterAll", "reading data from database"); DbDataReader reader = db.Select(cmdText); if (reader.HasRows) { List <DiseaseDetailModel> diseaseDetailList = new List <DiseaseDetailModel>(); while (reader.Read()) { DiseaseDetailModel diseaseDetail = new DiseaseDetailModel(); diseaseDetail.Id = Convert.ToInt32(reader["Id"]); Logger.Debug("DiseaseDetailModel", "GetDiseaseDetailById", "Id read from database"); diseaseDetail.DocId = Convert.ToInt32(reader["DocId"]); Logger.Debug("DiseaseDetailModel", "GetDiseaseDetailById", "DocId read from database"); diseaseDetail.Age = Convert.ToInt32(reader["Age"]); Logger.Debug("DiseaseDetailModel", "GetDiseaseDetailById", "Age read from database"); diseaseDetail.Gender = ParameterFormater.UnescapeXML(reader["Gender"].ToString()); Logger.Debug("DiseaseDetailModel", "GetDiseaseDetailById", "Gender read from database"); diseaseDetail.AreaId = Convert.ToInt32(reader["AreaId"]); Logger.Debug("DiseaseDetailModel", "GetDiseaseDetailById", "AreaId read from database"); diseaseDetail.PatientAddDate = Convert.ToDateTime(reader["PatientAddDate"].ToString()); Logger.Debug("DiseaseDetailModel", "GetDiseaseDetailById", "Patient admit date read from database"); diseaseDetail.DiseaseId = Convert.ToInt32(reader["DiseaseId"]); Logger.Debug("DiseaseDetailModel", "GetDiseaseDetailById", "DiseaseId read from database"); diseaseDetailList.Add(diseaseDetail); } Logger.Debug("DiseaseDetailModel", "GetDiseaseDetailById", "Checking reader has closed the connection."); if (!reader.IsClosed) { Logger.Debug("DiseaseDetailModel", "GetDiseaseDetailById", "closing database connection"); reader.Close(); } Logger.Debug("DiseaseDetailModel", "GetDiseaseDetailById", "Object returning value"); return(diseaseDetailList); } return(null); } catch (Exception ex) { Logger.Error("DiseaseDetailModel", "GetDiseaseDetailById", "Error occured while Selecting data from disease detail for all", ex); throw ex; } finally { Logger.Debug("DiseaseDetailModel", "GetDiseaseDetailById", "Closed sleeping connection"); Database.KillConnections(); } }
/// <summary> /// Showing record by ID from database DiseaseDetails /// </summary> /// <param name="diseaseDetailId"></param> /// <returns></returns> public DiseaseDetailModel GetDiseaseDetailById(int diseaseDetailId) { try { string Q_ShowDiseaseDetailById = "select * from diseasedetails where Id = {0}"; Logger.Debug("DiseaseDetailModel", "GetDiseaseDetailById", "storing values in variable."); string cmdText = string.Format(Q_ShowDiseaseDetailById, diseaseDetailId); Logger.Debug("DiseaseDetailModel", "GetDiseaseDetailById", "storing values in variable after id check."); Logger.Debug("DiseaseDetailModel", "GetDiseaseDetailById", " creating Database"); Database db = new Database(); Logger.Debug("DiseaseDetailModel", "GetDiseaseDetailById", "Database created"); Logger.Debug("DiseaseDetailModel", "GetDiseaseDetailById", "Reading value from Database by Id"); DbDataReader reader = db.Select(cmdText); Logger.Debug("DiseaseDetailModel", "GetDiseaseDetailById", "Reading value done"); Logger.Debug("DiseaseDetailModel", "GetDiseaseDetailById", "checking database has rows!"); if (reader.HasRows) { DiseaseDetailModel diseaseDetail = new DiseaseDetailModel(); Logger.Debug("DiseaseDetailModel", "GetDiseaseDetailById", "Diseasemaster object created"); Logger.Debug("DiseaseDetailModel", "GetDiseaseDetailById", "Reading database values"); while (reader.Read()) { diseaseDetail.Id = Convert.ToInt32(reader["Id"]); Logger.Debug("DiseaseDetailModel", "GetDiseaseDetailById", "Id read from database"); diseaseDetail.DocId = Convert.ToInt32(reader["DocId"]); Logger.Debug("DiseaseDetailModel", "GetDiseaseDetailById", "DocId read from database"); diseaseDetail.Age = Convert.ToInt32(reader["Age"]); Logger.Debug("DiseaseDetailModel", "GetDiseaseDetailById", "Age read from database"); diseaseDetail.Gender = ParameterFormater.UnescapeXML(reader["Gender"].ToString()); Logger.Debug("DiseaseDetailModel", "GetDiseaseDetailById", "Gender read from database"); diseaseDetail.AreaId = Convert.ToInt32(reader["AreaId"]); Logger.Debug("DiseaseDetailModel", "GetDiseaseDetailById", "AreaId read from database"); diseaseDetail.DiseaseId = Convert.ToInt32(reader["DiseaseId"]); Logger.Debug("DiseaseDetailModel", "GetDiseaseDetailById", "DiseaseId read from database"); diseaseDetail.PatientAddDate = Convert.ToDateTime(reader["PatientAddDate"].ToString()); Logger.Debug("DiseaseDetailModel", "GetDiseaseDetailById", "Patient admit date read from database"); /* * diseaseDetail.PatientAddDate = ParameterFormater.UnescapeXML(reader["PatientAddDate"].ToString()); * Logger.Debug("DiseaseDetailModel", "GetDiseaseDetailById", "ShortAreaName read from database.");diseaseDetail.DocId = Convert.ToInt32(reader["DocId"]); * Logger.Debug("DiseaseDetailModel", "GetDiseaseDetailById", "DocId read from database"); */ } Logger.Debug("DiseaseDetailModel", "GetDiseaseDetailById", "Checking reader has closed the connection."); if (!reader.IsClosed) { Logger.Debug("DiseaseDetailModel", "GetDiseaseDetailById", "closing database connection"); reader.Close(); Logger.Debug("DiseaseDetailModel", "GetDiseaseDetailById", "Connection closed"); } Logger.Debug("DiseaseDetailModel", "GetDiseaseDetailById", "Object returning value"); return(diseaseDetail); } return(null); } catch (Exception ex) { Logger.Error("DiseaseDetailModel", "GetDiseaseDetailById", "Erro occured while Selecting data from disease master detail by id", ex); throw ex; } finally { Logger.Debug("DiseaseDetailModel", "GetDiseaseDetailById", "Closed sleeping connection"); Database.KillConnections(); } }