Example #1
0
        public static int delete_Course(Word word)
        {
            SqlConnection con = new SqlConnection(GetConnectionString());
            string del = "DELETE FROM Words "
                + "WHERE ID = @ID ";
            SqlCommand cmd = new SqlCommand(del, con);
            cmd.Parameters.AddWithValue("ID", word.Id);
            //cmd.Parameters.AddWithValue("value", word.Value);

            con.Open();
            int i = cmd.ExecuteNonQuery();
            con.Close();
            return i;
        }
Example #2
0
        public static int insert_word(Word word)
        {
            SqlConnection con = new SqlConnection(GetConnectionString());
            string ins = "INSERT INTO Words "
                + " (ID,  Value) "
                + " VALUES( @OID, @value)";
            SqlCommand cmd = new SqlCommand(ins, con);
            cmd.Parameters.AddWithValue("ID", word.Id);
            cmd.Parameters.AddWithValue("value", word.Value);

            con.Open();
            int i = cmd.ExecuteNonQuery();
            con.Close();
            return word.Id;
        }
Example #3
0
        public static int insert_Course(Word word)
        {
            // Set Identity_Insert Orders ON;
            SqlConnection con = new SqlConnection(GetConnectionString());
            string ins = "INSERT INTO Words "
                + " (  Value) "
                + " VALUES(  @value)";
            SqlCommand cmd = new SqlCommand(ins, con);

            //cmd.Parameters.AddWithValue("ID", word.ID);
            cmd.Parameters.AddWithValue("value", word.Value);

            con.Open();
            int i = cmd.ExecuteNonQuery();
            con.Close();

            return word.Id;
        }
Example #4
0
        public static List<Word> GetWords()
        {
            List<Word> courseList = new List<Word>();
            SqlConnection con = new SqlConnection(GetConnectionString());
            string sel = "SELECT Id, Value "
                + "FROM Words ORDER BY ID desc";
            SqlCommand cmd = new SqlCommand(sel, con);
            con.Open();
            SqlDataReader dr =
                cmd.ExecuteReader(CommandBehavior.CloseConnection);
            Word word;
            while (dr.Read())
            {
                word = new Word();
                word.Id = Convert.ToInt16(dr["ID"].ToString());
                word.Value = dr["value"].ToString();

                courseList.Add(word);
            }
            dr.Close();
            return courseList;
        }
Example #5
0
 public static string return_CourseID(Word word)
 {
     SqlConnection con = new SqlConnection(GetConnectionString());
     string sel = "SELECT top(1) ID "
         + "FROM Words Order by ID desc";
     SqlCommand cmd = new SqlCommand(sel, con);
     con.Open();
     SqlDataReader dr =
         cmd.ExecuteReader(CommandBehavior.CloseConnection);
     // Order order;
     String retOrder_id = "";
     while (dr.Read())
     {
         retOrder_id = dr["ID"].ToString(); // RETURNING NULL HERE
     }
     dr.Close();
     return retOrder_id;
 }
Example #6
0
        public static int update_Course(Word original_word, Word word)
        {
            SqlConnection con = new SqlConnection(GetConnectionString());
            string up = "UPDATE Words "
                + "SET ID = @ID, "
                + "SET Value = @value, "
                + "Where ID = @origional_ID "
                + "AND Value = @original_value ";
            SqlCommand cmd = new SqlCommand(up, con);

            // cmd.Parameters.AddWithValue("Order_ID", order.Order_ID);
            cmd.Parameters.AddWithValue("ID", word.Id);
            cmd.Parameters.AddWithValue("value", word.Value);
            ///////ORIGINAL PARAMS///////////////////////////////////
            cmd.Parameters.AddWithValue("original_ID", original_word.Id);
            cmd.Parameters.AddWithValue("original_value", original_word.Value);

            int updateCount = cmd.ExecuteNonQuery();
            con.Close();
            return updateCount;
        }