public ActionResult deleteHealthData(FormCollection collection) { string connectString = System.Configuration.ConfigurationManager.ConnectionStrings["HealthDBConnectionString"].ToString(); Linq2SQLDataContext db = new Linq2SQLDataContext(connectString); health Hospital = db.healths.FirstOrDefault(e => e.ID == Int32.Parse(collection.Get("del_subj_id"))); db.healths.DeleteOnSubmit(Hospital); db.SubmitChanges(); return(RedirectToAction("Data", "Home")); }
public ActionResult getHealthData(String id) { string connectString = System.Configuration.ConfigurationManager.ConnectionStrings["HealthDBConnectionString"].ToString(); Linq2SQLDataContext db = new Linq2SQLDataContext(connectString); var Hospital = (from m in db.healths where m.ID == Int32.Parse(id) select m); return(Json(Hospital.Single())); }
public List <health> viewHealthData() { string connectString = System.Configuration.ConfigurationManager.ConnectionStrings["HealthDBConnectionString"].ToString(); Linq2SQLDataContext db = new Linq2SQLDataContext(connectString); var Hospital = (from m in db.healths orderby m.ID ascending select m).ToList(); return(Hospital); }
public ActionResult updateHealthData(FormCollection collection) { string connectString = System.Configuration.ConfigurationManager.ConnectionStrings["HealthDBConnectionString"].ToString(); Linq2SQLDataContext db = new Linq2SQLDataContext(connectString); int id; bool isUpdate = int.TryParse(collection.Get("subj_id"), out id); health healthPopulate; if (isUpdate) { healthPopulate = db.healths.FirstOrDefault(e => e.ID == id); } else { healthPopulate = new health(); } try { healthPopulate.DRG_Definition = collection.Get("DRG_Definition"); healthPopulate.Provider_Id = (Double.Parse(collection.Get("Provider_Id"))); healthPopulate.Provider_Name = collection.Get("Provider_Name"); healthPopulate.Provider_Street_Address = collection.Get("Provider_Street_Address"); healthPopulate.Provider_City = collection.Get("Provider_City"); healthPopulate.Provider_State = collection.Get("Provider_State"); healthPopulate.Provider_Zip_Code = (Double.Parse(collection.Get("Provider_Zip_Code"))); healthPopulate.Hospital_Referral_Region_Description = collection.Get("Hospital_Referral_Region_Description"); healthPopulate._Total_Discharges_ = (Double.Parse(collection.Get("_Total_Discharges_"))); healthPopulate._Average_Covered_Charges_ = (Decimal.Parse(collection.Get("_Average_Covered_Charges_"))); healthPopulate._Average_Total_Payments_ = (Decimal.Parse(collection.Get("_Average_Total_Payments_"))); if (!isUpdate) { db.healths.InsertOnSubmit(healthPopulate); } db.SubmitChanges(); return(RedirectToAction("Data", "Home")); } catch (Exception e) { return(RedirectToAction("Data", "Home")); } }