public static DietRequestE getDietRequestByID(int id) { DietRequestE temp = null; SqlCommand com = new SqlCommand("getDietRequestByID", Connection.Con); // Prodecure com.CommandType = CommandType.StoredProcedure; com.Parameters.Add(new SqlParameter("@id", id)); if (com.Connection.State == ConnectionState.Closed) { com.Connection.Open(); } SqlDataReader rd = com.ExecuteReader(); if (rd.HasRows) { if (rd.Read()) { temp = new DietRequestE { RequestID = Convert.ToInt32(rd["RequestID"]), RequestContent = rd["RequestContent"].ToString(), Health = Convert.ToBoolean(rd["Health"]), Fitness = Convert.ToBoolean(rd["Fitness"]), WeightLoss = Convert.ToBoolean(rd["WeightLoss"]), WeightGain = Convert.ToBoolean(rd["WeightGain"]) }; } } com.Dispose(); com.Connection.Close(); return(temp); }
public static int InsertDietRequest(DietRequestE dietRequest) { int requestID = 0; SqlCommand com = new SqlCommand("InsertDietRequest", Connection.Con); // Prodecure com.CommandType = CommandType.StoredProcedure; com.Parameters.Add(new SqlParameter("@requestContent", dietRequest.RequestContent)); com.Parameters.Add(new SqlParameter("@health", dietRequest.Health)); com.Parameters.Add(new SqlParameter("@fitness", dietRequest.Fitness)); com.Parameters.Add(new SqlParameter("@weightGain", dietRequest.WeightGain)); com.Parameters.Add(new SqlParameter("@weightLoss", dietRequest.WeightLoss)); if (com.Connection.State == ConnectionState.Closed) { com.Connection.Open(); } SqlDataReader rd = com.ExecuteReader(); if (rd.HasRows) { rd.Read(); requestID = Convert.ToInt32(rd[0]); } com.Dispose(); com.Connection.Close(); return(requestID); }
protected void saveRequest_Click(object sender, EventArgs e) { DietRequestE dietRequest = new DietRequestE(); dietRequest.RequestContent = content_textbox.Text; dietRequest.Health = false; dietRequest.Fitness = false; dietRequest.WeightGain = false; dietRequest.WeightLoss = false; switch (ddlGender.Text) { case "1": dietRequest.Health = true; break; case "2": dietRequest.Fitness = true; break; case "3": dietRequest.WeightGain = true; break; case "4": dietRequest.WeightLoss = true; break; } int requestID = BusinessLayers.Business.insertDietRequest(dietRequest); DietE diet = new DietE(); diet.DietitianID = Convert.ToInt32(Session["selectedDietitianID"]); diet.DietRequestID = requestID; diet.UserID = (Session["user"] as Entity.UserE).UserID; int dietID = BusinessLayers.Business.insertDiet(diet); Logging.logDiet(diet.UserID.ToString(), dietID.ToString()); Session["dietID"] = dietID; Response.Redirect("~/User/MedicalReport"); }
public static void UpdateDietRequest(DietRequestE obj) { SqlCommand com = new SqlCommand("UpdateDietRequest", Connection.Con); // Prodecure com.CommandType = CommandType.StoredProcedure; com.Parameters.Add(new SqlParameter("@fitness", obj.Fitness)); com.Parameters.Add(new SqlParameter("@health", obj.Health)); com.Parameters.Add(new SqlParameter("@requestContent", obj.RequestContent)); com.Parameters.Add(new SqlParameter("@weightGain", obj.WeightGain)); com.Parameters.Add(new SqlParameter("@weightLoss", obj.WeightLoss)); if (com.Connection.State == ConnectionState.Closed) { com.Connection.Open(); } SqlDataReader rd = com.ExecuteReader(); com.Dispose(); com.Connection.Close(); }
public static void updateDietRequest(DietRequestE obj) { DietRequestC.UpdateDietRequest(obj); }
public static int insertDietRequest(DietRequestE obj) { return(DietRequestC.InsertDietRequest(obj)); }