Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Data;
- using System.Data.SqlClient;
- using System.Configuration;
- /// <summary>
- /// Summary description for Form
- /// </summary>
- public class Form
- {
- string _connStr = ConfigurationManager.ConnectionStrings["formContext"].ConnectionString;
- private string _Iden_Form_ID;
- private string _Age;
- private string _CurrentHeight;
- private string _CurrentWeight;
- private string _WorkoutGoals;
- public Form()
- {
- this.Iden_Form_ID = null;
- this.Age = null;
- this.Current_Height = null;
- this.Current_Weight = null;
- this.Workout_Goals = null;
- }
- public Form(string p_Age, string p_CurrentHeight, string p_CurrentWeight, string p_WorkoutGoals)
- {
- this.Age = p_Age;
- this.Current_Height = p_CurrentHeight;
- this.Current_Weight = p_CurrentWeight;
- this.Workout_Goals = p_WorkoutGoals;
- }
- public string Iden_Form_ID
- {
- get { return _Iden_Form_ID; }
- set { _Iden_Form_ID = value; }
- }
- public string Age
- {
- get { return _Age; }
- set { _Age = value; }
- }
- public string Current_Height
- {
- get { return _CurrentHeight; }
- set { _CurrentHeight = value; }
- }
- public string Current_Weight
- {
- get { return _CurrentWeight; }
- set { _CurrentWeight = value; }
- }
- public string Workout_Goals
- {
- get { return _WorkoutGoals; }
- set { _WorkoutGoals = value; }
- }
- public List<Form> getallData()
- {
- List<Form> formlist = new List<Form>();
- string age, currentHeight, currentWeight, workoutGoals;
- string queryStr = "Select * FROM [Forms] Order By Iden_Form_ID";
- SqlConnection conn = new SqlConnection(_connStr);
- SqlCommand cmd = new SqlCommand(queryStr, conn);
- conn.Open();
- SqlDataReader dr = cmd.ExecuteReader();
- while (dr.Read())
- {
- age = dr["Age"].ToString();
- currentHeight = dr["Current_Height"].ToString();
- currentWeight = dr["Current_Weight"].ToString();
- workoutGoals = dr["Workout_Goals"].ToString();
- Form form = new Form(age, currentHeight, currentWeight, workoutGoals);
- formlist.Add(form);
- }
- conn.Close();
- dr.Close();
- dr.Dispose();
- return formlist;
- }
- public int FormInsert()
- {
- int result = 0;
- string formStr = "INSERT INTO [Forms](Age, Current_Height, Current_Weight, Workout_Goals)" +
- "values(@Age, @Current_Height, @Current_Weight, @Workout_Goals)";
- SqlConnection conn = new SqlConnection(_connStr);
- SqlCommand cmd = new SqlCommand(formStr, conn);
- cmd.Parameters.AddWithValue("@Age", this.Age);
- cmd.Parameters.AddWithValue("@Current_Height", this.Current_Height);
- cmd.Parameters.AddWithValue("@Current_Weight", this.Current_Weight);
- cmd.Parameters.AddWithValue("@Workout_Goals", this.Workout_Goals);
- conn.Open();
- result += cmd.ExecuteNonQuery();
- conn.Close();
- //result += 1;
- return result;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement