public DataTable Legs_Select(Exercise_Report_Info_Class d) { SqlConnection conn = new SqlConnection(myconnstrng); DataTable dt = new DataTable(); try { Console.WriteLine(d.Last_Report_Date); Console.WriteLine(d.Today_Date); // string sql = "INSERT INTO Exercise_Info(Customer_Name,Address,Phone_No,Email_Id,Gender,Age,Biceps_Size,Calf_Size,Chest_Size,Hip_Size,Weight,Height,Fat_Percent,Package,Personal_Trainer,Time_Preference,BMI) VALUES(@Customer_Name, @Address, @Phone_No, @Email_Id, @Gender, @Age, @Biceps_Size, @Calf_Size, @Chest_Size, @Hip_Size,@Weight,@Height,@Fat_Percent,@Package,@Personal_Trainer,@Time_Preference,@BMI)"; string sql = " select SUM(Free_Squats), SUM(Weighted_Squats), SUM(Free_Lunges), SUM(Weighted_Lunges) , SUM(Leg_Press), SUM(Leg_Curls_Front) , SUM(Leg_Curls_Back) , SUM(Free_Calf_Raise) , SUM(Weighted_Calf_Raise) from Cardio_Legs_Info where Customer_Name=@Customer_Name and Date Between @Last_Report_Date and @Today_Date";// Customer_Name='+ @Customer_Name + ' and Date Between ' +@Last_Report_Date + ' and '+ @Today_Date )"; SqlCommand cmd = new SqlCommand(sql, conn); cmd.Parameters.AddWithValue("@Customer_Name", d.Customer_Name); cmd.Parameters.AddWithValue("@Last_Report_Date", d.Last_Report_Date); cmd.Parameters.AddWithValue("@Today_Date", d.Today_Date); Console.WriteLine(cmd); Console.WriteLine(sql); SqlDataAdapter adapter = new SqlDataAdapter(cmd); Console.WriteLine(adapter); conn.Open(); adapter.Fill(dt); int rows = cmd.ExecuteNonQuery(); } catch (System.Data.SqlClient.SqlException sqlException) { System.Windows.Forms.MessageBox.Show(sqlException.Message); } finally { conn.Close(); } return(dt); }
public DataTable Back_Select(Exercise_Report_Info_Class d) { SqlConnection conn = new SqlConnection(myconnstrng); DataTable dt = new DataTable(); try { Console.WriteLine(d.Last_Report_Date); Console.WriteLine(d.Today_Date); // string sql = "INSERT INTO Exercise_Info(Customer_Name,Address,Phone_No,Email_Id,Gender,Age,Biceps_Size,Calf_Size,Chest_Size,Hip_Size,Weight,Height,Fat_Percent,Package,Personal_Trainer,Time_Preference,BMI) VALUES(@Customer_Name, @Address, @Phone_No, @Email_Id, @Gender, @Age, @Biceps_Size, @Calf_Size, @Chest_Size, @Hip_Size,@Weight,@Height,@Fat_Percent,@Package,@Personal_Trainer,@Time_Preference,@BMI)"; string sql = " select SUM(Deadlift), SUM(Pullups), SUM(Bentrows), SUM(Chinup) , SUM(Tbar_Standing),SUM(Seated_Row), SUM(Reverse_Grip_Machine_Row), SUM(Pulldown), SUM(Deline_Dumbell_Pullover) , SUM(Single_Arm_Dumbell_Row) from Back_Info where Customer_Name=@Customer_Name and Date Between @Last_Report_Date and @Today_Date";// Customer_Name='+ @Customer_Name + ' and Date Between ' +@Last_Report_Date + ' and '+ @Today_Date )"; SqlCommand cmd = new SqlCommand(sql, conn); cmd.Parameters.AddWithValue("@Customer_Name", d.Customer_Name); cmd.Parameters.AddWithValue("@Last_Report_Date", d.Last_Report_Date); cmd.Parameters.AddWithValue("@Today_Date", d.Today_Date); Console.WriteLine(cmd); Console.WriteLine(sql); SqlDataAdapter adapter = new SqlDataAdapter(cmd); Console.WriteLine(adapter); conn.Open(); adapter.Fill(dt); int rows = cmd.ExecuteNonQuery(); } catch (System.Data.SqlClient.SqlException sqlException) { System.Windows.Forms.MessageBox.Show(sqlException.Message); } finally { conn.Close(); } return(dt); }