Title: web services code2                                 If you need copy same format use firefox or chrome or safari but iexplorer not work


Preview of Code
using System;
using System.Data;
using System.Data.SqlClient;
using System.Web;
using System.Collections.Generic;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;
 
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class DMService : System.Web.Services.WebService
{
    public DMService()
    {
 
    }
 
    public static SqlConnection SQLConn = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|\\Database1.mdf;Integrated Security=SSPI;User Instance=True");    
    public static SqlDataAdapter SQLAdp = new SqlDataAdapter("select * from users", SQLConn);  
    public static DataSet DataS = new DataSet();
 
 
    [WebMethod(Description = "Check User Name (Patient or Doctor) and if Registered return True else False the table parameter takes `users` if Patient or `doctors` if Doctor ")]
    public bool Check_Login_Or_Exist_Name(string UserName, string Password,string table)
    {
 
        if (SQLConn.State == ConnectionState.Closed)
            SQLConn.Open();
 
        if (Password.Equals(string.Empty))
            SQLAdp.SelectCommand.CommandText = "select * from [" + table + "] where User_Name like (`" + UserName + "`)";
        else
            SQLAdp.SelectCommand.CommandText = "select * from [" + table + "] where User_Name like (`" + UserName + "`) and password like (`" + Password + "`)";
 
        int Found = SQLAdp.Fill(DataS);
 
        SQLConn.Close();
 
        if (Found > 0)
            return true;
        else return false;
 
    }
 
    [WebMethod(Description = "Registration For Patient in `users` Table and Return with Registration`s Process , parameter takes record like (User_Name, Password, Name, Age, Sex, Email, Mobile, Last_Enter, BMI, Health_Condition, Hight, Weight, Active, High_Risk, High_Risk_DATE, [Option]) ")]
    public string Registration_For_Patient(string[] Record)
    {
 
        try
        {
            
            if (SQLConn.State == ConnectionState.Closed)
                SQLConn.Open();
 
            SqlCommand insert = new SqlCommand();
 
            insert.Connection = SQLConn;
 
            insert.CommandText = "INSERT INTO users  (User_Name, Password, Name, Age, Sex, Email, Mobile, Last_Enter, BMI, Health_Condition, Hight, Weight, Active, High_Risk, High_Risk_DATE, [Option]) VALUES(@User_Name, @Password, @Name, @Age, @Sex, @Email, @Mobile, @Last_Enter, @BMI, @Health_Condition, @Hight, @Weight, @Active, @High_Risk, @High_Risk_DATE, @Option)";
 
            insert.Parameters.Add(new SqlParameter("@User_Name", System.Data.SqlDbType.VarChar, 0, "User_Name"));
            insert.Parameters.Add(new SqlParameter("@Password", System.Data.SqlDbType.VarChar, 0, "Password"));
            insert.Parameters.Add(new SqlParameter("@Name", System.Data.SqlDbType.VarChar, 0, "Name"));
            insert.Parameters.Add(new SqlParameter("@Age", System.Data.SqlDbType.Int, 0, "Age"));
            insert.Parameters.Add(new SqlParameter("@Sex", System.Data.SqlDbType.VarChar, 0, "Sex"));
            insert.Parameters.Add(new SqlParameter("@Email", System.Data.SqlDbType.VarChar, 0, "Email"));
            insert.Parameters.Add(new SqlParameter("@Mobile", System.Data.SqlDbType.VarChar, 0, "Mobile"));
            insert.Parameters.Add(new SqlParameter("@Last_Enter", System.Data.SqlDbType.DateTime, 0, "Last_Enter"));
            insert.Parameters.Add(new SqlParameter("@BMI", System.Data.SqlDbType.Float, 0, "BMI"));
            insert.Parameters.Add(new SqlParameter("@Health_Condition", System.Data.SqlDbType.VarChar, 0, "Health_Condition"));
            insert.Parameters.Add(new SqlParameter("@Hight", System.Data.SqlDbType.Float, 0, "Hight"));
            insert.Parameters.Add(new SqlParameter("@Weight", System.Data.SqlDbType.Float, 0, "Weight"));
            insert.Parameters.Add(new SqlParameter("@Active", System.Data.SqlDbType.Float, 0, "Active"));
            insert.Parameters.Add(new SqlParameter("@High_Risk", System.Data.SqlDbType.Int, 0, "High_Risk"));
            insert.Parameters.Add(new SqlParameter("@High_Risk_DATE", System.Data.SqlDbType.DateTime, 0, "High_Risk_DATE"));
            insert.Parameters.Add(new SqlParameter("@Option", System.Data.SqlDbType.Int, 0, "[Option]"));
 
            insert.Parameters[0].Value = Record[0];
            insert.Parameters[1].Value = Record[1];
            insert.Parameters[2].Value = Record[2];
            insert.Parameters[3].Value = Convert.ToInt32(Record[3]);
            insert.Parameters[4].Value = Record[4];
            insert.Parameters[5].Value = Record[5];
            insert.Parameters[6].Value = Record[6];
            insert.Parameters[7].Value = DateTime.Now.ToShortDateString();
            insert.Parameters[8].Value = Convert.ToDouble(Record[8]);
            insert.Parameters[9].Value = Record[9];
            insert.Parameters[10].Value = Convert.ToDouble(Record[10]);
            insert.Parameters[11].Value = Convert.ToDouble(Record[11]);
            insert.Parameters[12].Value = Convert.ToDouble(Record[12]);
            insert.Parameters[13].Value = Convert.ToInt32(Record[13]);
            insert.Parameters[14].Value = DateTime.Now.ToShortDateString();
            insert.Parameters[15].Value = Convert.ToInt32(Record[15]);
 
 
            if (insert.ExecuteNonQuery() == 1)
            {
                SQLConn.Close();
                return "Sucessfull Insert";
            }
 
            SQLConn.Close();
            return "Failed";
 
        }
        catch (Exception s)
        {
            SQLConn.Close();
            return s.Message;
        }
 
    
 
    }
 
    [WebMethod(Description = "Registration For Doctor in `users` Table and Return with Registration`s Process , parameter takes record like (Name, User_Name, Password, Mobile , Email ,Specialization) ")]
    public string Registration_For_Doctor(string[] Record)
    {
        try
        {
            if (SQLConn.State == ConnectionState.Closed)
                SQLConn.Open();
 
            SqlCommand insert = new SqlCommand();
 
            insert.Connection = SQLConn;
 
            insert.CommandText = "INSERT INTO doctors  (Name, User_Name, Password, Mobile , Email ) VALUES(@Name,@User_Name, @Password, @Mobile , @Email)";
 
            insert.Parameters.Add(new SqlParameter("@Name", System.Data.SqlDbType.VarChar, 0, "Name"));
            insert.Parameters.Add(new SqlParameter("@User_Name", System.Data.SqlDbType.VarChar, 0, "User_Name"));
            insert.Parameters.Add(new SqlParameter("@Password", System.Data.SqlDbType.VarChar, 0, "Password"));
            insert.Parameters.Add(new SqlParameter("@Mobile", System.Data.SqlDbType.VarChar, 0, "Mobile"));
            insert.Parameters.Add(new SqlParameter("@Email", System.Data.SqlDbType.VarChar, 0, "Email"));
 
 
            insert.Parameters[0].Value = Record[0];
            insert.Parameters[1].Value = Record[1];
            insert.Parameters[2].Value = Record[2];
            insert.Parameters[3].Value = Convert.ToInt32(Record[3]);
            insert.Parameters[4].Value = Record[4];
 
 
 
            if (insert.ExecuteNonQuery() == 1)
            {
                SQLConn.Close();
                return "Sucessfull Insert";
            }
 
            SQLConn.Close();
            return "faild";
 
        }
        catch (Exception s)
        {
            SQLConn.Close();
            return s.Message;
        }
 
    }
 
    [WebMethod(Description = "Add New Meal in `Colorie` Table , takes one parameter Meal object")]
    public int Add_New_Meal(Meal meal)
    {
 
        if (SQLConn.State == ConnectionState.Closed)
            SQLConn.Open();
 
        SqlCommand insert = new SqlCommand("INSERT INTO Colorie  (Name, Type, Calories) VALUES (@Name, @Type, @Calories)", SQLConn);
 
        insert.Parameters.AddRange(new System.Data.SqlClient.SqlParameter[] {
                new SqlParameter("@Name", System.Data.SqlDbType.VarChar, 0, "Name"),
                new SqlParameter("@Type", System.Data.SqlDbType.VarChar, 0, "Type"),
                new SqlParameter("@Calories", System.Data.SqlDbType.VarChar, 0, "Calories")});
 
        insert.Parameters[0].Value = meal.name;
        insert.Parameters[1].Value = meal.type;
        insert.Parameters[2].Value = meal.calories;
 
        int x =insert.ExecuteNonQuery();
        SQLConn.Close();
 
        return x;
    }
 
    [WebMethod(Description = "Save Diet Table of specific Patient in `Diet` Table in First Time , takes Patient`s Name and 2D Matrix of Diet Table to be Save .")]
    public string Save_Diet_Table(string User_Name, string[][] Table)
    {
 
        try
        {
            if (SQLConn.State == ConnectionState.Closed)
                SQLConn.Open();
 
 
            SqlCommand insert = new SqlCommand();
            insert.CommandText = "INSERT INTO [Diet] ([User_Name], [Day], [Breakfast], [Lunch], [Dinner], [Exercises], [Date]) VALUES (@User_Name, @Day, @Breakfast, @Lunch, @Dinner, @Exercises, @Date)";
            insert.Connection = SQLConn;
            insert.Parameters.AddRange(new System.Data.SqlClient.SqlParameter[] {
                new SqlParameter("@User_Name", System.Data.SqlDbType.VarChar, 0, "User_Name"),
                new SqlParameter("@Day", System.Data.SqlDbType.VarChar, 0, "Day"),
                new SqlParameter("@Breakfast", System.Data.SqlDbType.VarChar, 0, "Breakfast"),
                new SqlParameter("@Lunch", System.Data.SqlDbType.VarChar, 0, "Lunch"),
                new SqlParameter("@Dinner", System.Data.SqlDbType.VarChar, 0, "Dinner"),
                new SqlParameter("@Exercises", System.Data.SqlDbType.VarChar, 0, "Exercises"),
                new SqlParameter("@Date", System.Data.SqlDbType.DateTime, 0, "Date")});
 
            for (int i = 0; i < 7; i++)
            {
 
                insert.Parameters[0].Value = User_Name;
                insert.Parameters[1].Value = Table[i][0];
                insert.Parameters[2].Value = Table[i][1];
                insert.Parameters[3].Value = Table[i][2];
                insert.Parameters[4].Value = Table[i][3];
                insert.Parameters[5].Value = Table[i][4];
                insert.Parameters[6].Value = DateTime.Now.ToString();
                insert.ExecuteNonQuery();
 
            }
            SQLConn.Close();
            return "Sucessfull Save";
        }
        catch (Exception d)
        {
            SQLConn.Close();
            return d.Message;
        }
 
    }
 
    [WebMethod(Description = "Load Diet Table of specific Patient from `Diet` Table , takes Patient`s Name to be Load .")]
    public DataSet Load_Diet_Table(string User_Name)
    {
        if (SQLConn.State == ConnectionState.Closed)
            SQLConn.Open();
 
        SQLAdp.SelectCommand.CommandText = "SELECT top 7 User_Name, Day, Breakfast, Lunch, Dinner, Exercises, Date FROM Diet Where (User_Name=`" + User_Name + "`) ORDER BY Date DESC";
        DataS.Clear();
        SQLAdp.Fill(DataS, "Diet");
 
        SQLConn.Close();
 
        return DataS;
 
    }
 
    [WebMethod(Description = "Update Diet Table of specific Patient of `Diet` Table , takes Patient`s Name and 2D Matrix of Diet Table to be Update .")]
    public string Update_Diet_Table(string User_Name, string[][] Table)
    {
        try
        {
            if (SQLConn.State == ConnectionState.Closed)
                SQLConn.Open();
 
            SqlCommand update = new SqlCommand();
            update.CommandText = "UPDATE Diet SET Breakfast = @Breakfast, Lunch = @Lunch, Dinner = @Dinner, Exercises = @Exercises, Date = @Date WHERE (User_Name = @User_Name) And (Day = @Day)";
            update.Connection = SQLConn;
            update.Parameters.AddRange(new System.Data.SqlClient.SqlParameter[] {
                new SqlParameter("@User_Name", System.Data.SqlDbType.VarChar, 0, "User_Name"),
                new SqlParameter("@Day", System.Data.SqlDbType.VarChar, 0, "Day"),
                new SqlParameter("@Breakfast", System.Data.SqlDbType.VarChar, 0, "Breakfast"),
                new SqlParameter("@Lunch", System.Data.SqlDbType.VarChar, 0, "Lunch"),
                new SqlParameter("@Dinner", System.Data.SqlDbType.VarChar, 0, "Dinner"),
                new SqlParameter("@Exercises", System.Data.SqlDbType.VarChar, 0, "Exercises"),
                new SqlParameter("@Date", System.Data.SqlDbType.DateTime, 0, "Date")});
            int ExecuteNonQuery = 0;
            for (int i = 0; i < 7; i++)
            {
                update.Parameters[0].Value = User_Name;
                update.Parameters[1].Value = Table[i][0];
                update.Parameters[2].Value = Table[i][1];
                update.Parameters[3].Value = Table[i][2];
                update.Parameters[4].Value = Table[i][3];
                update.Parameters[5].Value = Table[i][4];
                update.Parameters[6].Value = DateTime.Now.ToString();
                ExecuteNonQuery += update.ExecuteNonQuery();
 
            }
            SQLConn.Close();
 
            return "Secessfull Update";
        }
        catch (Exception d)
        {
            SQLConn.Close();
            return d.Message;
        }
    }
 
    [WebMethod(Description = "take parameter string Type of Food and return DataSet ")]
    public DataSet Get_Name_Of_FoodType(string FoodType)
    {
        if (SQLConn.State == ConnectionState.Closed)
            SQLConn.Open();
 
        SQLAdp.SelectCommand.CommandText = "SELECT Name From Colorie Where (Type =`" + FoodType + "`)";
 
        DataS.Clear();
 
        SQLAdp.Fill(DataS, "Colorie");
        SQLConn.Close();
 
        return DataS;
    }
 
    [WebMethod(Description = "Return Ten Records of the Highest Patients` High Risk From Database ")]
    public DataSet Query_Top_10_Patiants_By_High_Risk()
    {
        if (SQLConn.State == ConnectionState.Closed)
            SQLConn.Open();
 
        SQLAdp.SelectCommand.CommandText = "SELECT TOP (10)  Name, Age, Last_Enter, BMI, Hight, Weight, Active, High_Risk ,Email,User_Name FROM  users ORDER BY High_Risk DESC";
        DataS.Clear();
        SQLAdp.Fill(DataS, "users");
        SQLConn.Close();
 
        return DataS;
    }
 
    [WebMethod (Description = "Get High Risk values of Patiant for number of Given Days ")]
    public DataSet Get_High_Risk_of_Patiant(string name, int days)
    {
        DateTime dt = DateTime.Now.AddDays(-days);
 
        if (SQLConn.State == ConnectionState.Closed)
            SQLConn.Open();
 
        SQLAdp.SelectCommand.Parameters.Clear();
        SQLAdp.SelectCommand.CommandText = "SELECT User_Name, Age, BMI, Health_Condition, Weight, Hight, Last_Enter, Active, High_Risk, High_Risk_Date FROM  personl WHERE (User_Name = `" + name + "`) AND (High_Risk_Date > @High_Risk_Date)";
        SQLAdp.SelectCommand.Parameters.Add(new SqlParameter("@High_Risk_Date", System.Data.SqlDbType.DateTime, 0, "High_Risk_Date"));
        SQLAdp.SelectCommand.Parameters[0].Value = dt.ToShortDateString();
 
        DataS.Clear();
        SQLAdp.Fill(DataS, "personl");
 
        SQLConn.Close();
 
        return DataS;
    }
 
    [WebMethod(Description = "Update Pateint Status by inserting in `personl` table , record parameter takes like this matrix (User_Name, Age , BMI , Health_Condition , Weight , Hight , Last_Enter , Active , High_Risk , High_Risk_Date) ")]
    public string Add_In_Personl_Table(string[] Record)
    {
        try
        {
            if (SQLConn.State == ConnectionState.Closed)
                SQLConn.Open();
 
            SqlCommand insert = new SqlCommand();
 
            insert.Connection = SQLConn;
 
            insert.CommandText = "INSERT INTO personl  (User_Name, Age , BMI , Health_Condition , Weight , Hight , Last_Enter , Active , High_Risk , High_Risk_Date) VALUES(@User_Name, @Age, @BMI, @Health_Condition, @Weight,@Hight, @Last_Enter, @Active, @High_Risk, @High_Risk_DATE)";
 
            insert.Parameters.Add(new SqlParameter("@User_Name", System.Data.SqlDbType.VarChar, 0, "User_Name"));
            insert.Parameters.Add(new SqlParameter("@Age", System.Data.SqlDbType.Int, 0, "Age"));
            insert.Parameters.Add(new SqlParameter("@BMI", System.Data.SqlDbType.Float, 0, "BMI"));
            insert.Parameters.Add(new SqlParameter("@Health_Condition", System.Data.SqlDbType.VarChar, 0, "Health_Condition"));
            insert.Parameters.Add(new SqlParameter("@Weight", System.Data.SqlDbType.Float, 0, "Weight"));
            insert.Parameters.Add(new SqlParameter("@Hight", System.Data.SqlDbType.Float, 0, "Hight"));            
            insert.Parameters.Add(new SqlParameter("@Last_Enter", System.Data.SqlDbType.DateTime, 0, "Last_Enter"));
            insert.Parameters.Add(new SqlParameter("@Active", System.Data.SqlDbType.Float, 0, "Active"));
            insert.Parameters.Add(new SqlParameter("@High_Risk", System.Data.SqlDbType.Int, 0, "High_Risk"));
            insert.Parameters.Add(new SqlParameter("@High_Risk_DATE", System.Data.SqlDbType.DateTime, 0, "High_Risk_DATE"));
 
            insert.Parameters[0].Value = Record[0];
            insert.Parameters[1].Value = Record[1];
            insert.Parameters[2].Value = Record[2];
            insert.Parameters[3].Value = Record[3];
            insert.Parameters[4].Value = Record[4];
            insert.Parameters[5].Value = Record[5];
            insert.Parameters[6].Value = DateTime.Now.ToShortDateString();
            insert.Parameters[7].Value =Record[6];
            insert.Parameters[8].Value = Record[7];
            insert.Parameters[9].Value = DateTime.Now.ToShortDateString(); 
 
 
 
            if (insert.ExecuteNonQuery() == 1)
            {
                SQLConn.Close();
                return "Sucessfull Insert";
            }
 
            SQLConn.Close();
            return "faild";
 
        }
        catch (Exception s)
        {
            SQLConn.Close();
            return s.Message;
        }
    }
 
    [WebMethod(Description = "Update Pateint Record of `users` Table ")]
    public string Update_User_Record(string user_name ,string age,string bmi,string hight,string weight,string active,string hr)
    {
 
        try
        {
 
            if (SQLConn.State == ConnectionState.Closed)
                SQLConn.Open();
 
            SqlCommand insert = new SqlCommand();
 
            insert.Connection = SQLConn;
 
            insert.CommandText = "UPDATE  users SET Age =@Age, Hight =@Hight, Weight =@Weight, Active =@Active, High_Risk =@High_Risk, High_Risk_DATE =@High_Risk_DATE,Last_Enter=@Last_Enter WHERE (User_Name = @User_Name)";
 
            insert.Parameters.Add(new SqlParameter("@User_Name", System.Data.SqlDbType.VarChar, 0, "User_Name"));
            insert.Parameters.Add(new SqlParameter("@Age", System.Data.SqlDbType.Int, 0, "Age"));
            insert.Parameters.Add(new SqlParameter("@Last_Enter", System.Data.SqlDbType.DateTime, 0, "Last_Enter"));
            insert.Parameters.Add(new SqlParameter("@BMI", System.Data.SqlDbType.Float, 0, "BMI"));
            insert.Parameters.Add(new SqlParameter("@Hight", System.Data.SqlDbType.Float, 0, "Hight"));
            insert.Parameters.Add(new SqlParameter("@Weight", System.Data.SqlDbType.Float, 0, "Weight"));
            insert.Parameters.Add(new SqlParameter("@Active", System.Data.SqlDbType.Float, 0, "Active"));
            insert.Parameters.Add(new SqlParameter("@High_Risk", System.Data.SqlDbType.Int, 0, "High_Risk"));
            insert.Parameters.Add(new SqlParameter("@High_Risk_DATE", System.Data.SqlDbType.DateTime, 0, "High_Risk_DATE"));
 
 
 
 
            insert.Parameters[0].Value = user_name;
            insert.Parameters[1].Value = age;
            insert.Parameters[2].Value = DateTime.Now.ToShortDateString();
            insert.Parameters[3].Value = bmi;
            insert.Parameters[4].Value = hight;
            insert.Parameters[5].Value = weight;
            insert.Parameters[6].Value = active;
            insert.Parameters[7].Value = hr;
            insert.Parameters[8].Value = DateTime.Now.ToShortDateString();
 
 
            if (insert.ExecuteNonQuery() == 1)
            {
                SQLConn.Close();
                return "Sucessfull Update";
            }
 
            SQLConn.Close();
            return "faild";
 
        }
        catch (Exception s)
        {
 
            SQLConn.Close();
            return s.Message;
        }
 
    }
 
    [WebMethod(Description = "Check if the Pateint update his Record Today or Not ")]
    public bool IsTodayUpdated(string User_Name)
    {
        if (SQLConn.State == ConnectionState.Closed)
            SQLConn.Open();
 
        SQLAdp.SelectCommand.CommandText = "SELECT User_Name,Last_Enter FROM personl WHERE User_Name  = @User_Name and Last_Enter = @Last_Enter";
        SQLAdp.SelectCommand.Parameters.Clear();
        SQLAdp.SelectCommand.Parameters.Add(new SqlParameter("@User_Name", System.Data.SqlDbType.VarChar, 0, "User_Name"));
        SQLAdp.SelectCommand.Parameters.Add(new SqlParameter("@Last_Enter", System.Data.SqlDbType.DateTime, 0, "Last_Enter"));
 
        SQLAdp.SelectCommand.Parameters[0].Value = User_Name;
        SQLAdp.SelectCommand.Parameters[1].Value = DateTime.Now.ToShortDateString();
 
        DataS.Clear();
 
        if (SQLAdp.Fill(DataS, "users") > 0)
        {
            SQLConn.Close();
            return true;
        }
        else
        {
            SQLConn.Close();
            return false;
        }
 
    }
 
    [WebMethod(Description = "Update Pateint Record of `personl` Table ")]
    public string Update_Personl_Table(string[] Record)
    {
 
        try
        {
            if (SQLConn.State == ConnectionState.Closed)
                SQLConn.Open();
 
            SqlCommand update = new SqlCommand();
 
            update.Connection = SQLConn;
 
            update.CommandText = "UPDATE personl SET Age = @Age, BMI = @BMI, Weight = @Weight, Hight = @Hight, Last_Enter = @Last_Enter, Active = @Active,  High_Risk = @High_Risk, High_Risk_Date = @High_Risk_Date WHERE (User_Name = @User_Name))";
 
            update.Parameters.Add(new SqlParameter("@User_Name", System.Data.SqlDbType.VarChar, 0, "User_Name"));
            update.Parameters.Add(new SqlParameter("@Age", System.Data.SqlDbType.Int, 0, "Age"));
            update.Parameters.Add(new SqlParameter("@BMI", System.Data.SqlDbType.Float, 0, "BMI"));
            update.Parameters.Add(new SqlParameter("@Weight", System.Data.SqlDbType.Float, 0, "Weight"));
            update.Parameters.Add(new SqlParameter("@Hight", System.Data.SqlDbType.Float, 0, "Hight"));
            update.Parameters.Add(new SqlParameter("@Last_Enter", System.Data.SqlDbType.DateTime, 0, "Last_Enter"));
            update.Parameters.Add(new SqlParameter("@Active", System.Data.SqlDbType.Float, 0, "Active"));
            update.Parameters.Add(new SqlParameter("@High_Risk", System.Data.SqlDbType.Int, 0, "High_Risk"));
            update.Parameters.Add(new SqlParameter("@High_Risk_DATE", System.Data.SqlDbType.DateTime, 0, "High_Risk_DATE"));
 
            update.Parameters[0].Value = Record[0];//User_Name
            update.Parameters[1].Value = Record[1];//Age
            update.Parameters[2].Value = Record[2];//BMI
            update.Parameters[3].Value = Record[3];//Weight
            update.Parameters[4].Value = Record[4];//Hight
            update.Parameters[5].Value = DateTime.Now.ToShortDateString();//Last_Enter
            update.Parameters[6].Value = Record[5];//Active
            update.Parameters[7].Value = Record[6];//High_Risk
            update.Parameters[8].Value = DateTime.Now.ToShortDateString();
 
            if (update.ExecuteNonQuery() == 1)
            {
                SQLConn.Close();
                return "Sucessfull Updated";
            }
 
            SQLConn.Close();
            return "faild";
 
        }
        catch (Exception s)
        {
            SQLConn.Close();
            return s.Message;
        }
    }
 
    [WebMethod(Description = "Get Last Record of Patient from `personl` Table")]
    public DataSet Get_Last_Record_in_Personal_Table(string user_name)
    {
            if (SQLConn.State == ConnectionState.Closed)
                SQLConn.Open();
 
            SQLAdp.SelectCommand.CommandText = "SELECT TOP (1) *FROM  personl WHERE (User_Name = `"+user_name+"`) ORDER BY Last_Enter DESC";
            DataS.Clear();
            SQLAdp.Fill(DataS, "personl");
 
            SQLConn.Close();
 
            return DataS;
    }
 
    [WebMethod(Description = "Get Complete List of Patient`s High Risk from `personl` Table")]
    public DataSet GetHighRiskList(string user_name)
    {
        if (SQLConn.State == ConnectionState.Closed)
            SQLConn.Open();
 
        SQLAdp.SelectCommand.CommandText = "SELECT * FROM  personl WHERE (User_Name = `" + user_name + "`) ";
        DataS.Clear();
        SQLAdp.Fill(DataS, "personl");
 
        SQLConn.Close();
 
        return DataS;
    }
 
    [WebMethod(Description = "Get The Record of the Given Food Name ")]
    public DataSet Get_Colorie_Of_FoodName(string FoodName)
    {
        if (SQLConn.State == ConnectionState.Closed)
            SQLConn.Open();
 
        SQLAdp.SelectCommand.CommandText = "SELECT  *From Colorie Where (Name =`" + FoodName + "`)";
 
        DataS.Clear();
 
        SQLAdp.Fill(DataS, "Colorie");
        SQLConn.Close();
 
        return DataS;
    }
 
    [WebMethod(Description = "Determine whether Given User Name from the specific Table is Found or Not")]
    public bool Is_User_Name_Found_in_Table(string User_Name, string TableName)
    {
        if (SQLConn.State == ConnectionState.Closed)
            SQLConn.Open();
 
        SQLAdp.SelectCommand.CommandText = "SELECT * FROM " + TableName + " Where (User_Name=`" + User_Name + "`)";
        DataS.Clear();
 
        return (SQLAdp.Fill(DataS, TableName) > 0) ? true : false;
 
    }
 
    [WebMethod(Description = "Get Complete Record of User from Given User Name and Given Table ")]
    public DataSet Query_By_Name_and_Table(string User_Name, string TableName)
    {
        if (SQLConn.State == ConnectionState.Closed)
            SQLConn.Open();
        SQLAdp.SelectCommand.CommandText = "SELECT  User_Name, Password, Name, Age, Sex, Email, Mobile, Last_Enter, BMI, Health_Condition, Hight, Weight, Active, High_Risk, High_Risk_DATE, [Option] FROM " + TableName + " Where (User_Name=`" + User_Name + "`)";
        DataS.Clear();
        SQLAdp.Fill(DataS, TableName);
        SQLConn.Close();
 
        return DataS;
 
    }
 
    [WebMethod(Description = "Get Complete Record of User from Given User Name and Given Table ")]
    public DataSet Get_List_Weight(string User_Name, string TableName,int days)
    {
        DateTime dt = DateTime.Now.AddDays(-days);
 
        if (SQLConn.State == ConnectionState.Closed)
            SQLConn.Open();
 
        SQLAdp.SelectCommand.Parameters.Clear();
        SQLAdp.SelectCommand.CommandText = "SELECT  * FROM " + TableName + " Where (User_Name=`" + User_Name + "`)AND (Last_Enter > @Last_Enter)";
        SQLAdp.SelectCommand.Parameters.Add(new SqlParameter("@Last_Enter", System.Data.SqlDbType.DateTime, 0, "Last_Enter"));
        SQLAdp.SelectCommand.Parameters[0].Value = dt.ToShortDateString();
        DataS.Clear();
        SQLAdp.Fill(DataS, TableName);
        SQLConn.Close();
 
        return DataS;
 
    }
 
 
}
 
public class Meal
{
    public string name, type;
    public float calories;
    public Meal()
    {
    }
    public Meal(string Name, string Type, float Calories)
    {
        name = Name;
        type = Type;
        calories = Calories;
    }
}