コード例 #1
0
        //Removes an existing Extra form the DB
        public void deleteExtra(ExtrasEN e)
        {
            string        s = ConfigurationManager.ConnectionStrings["DefaultConnection"].ToString(); //String where it's stored the instructions for the connecton for the DB
            SqlConnection c = new SqlConnection(s);                                                   //The connection is effectuated

            try
            {
                c.Open();                  //The select in SQL language that is processed in the DB which will return all the rows from the table "extra"
                SqlCommand com = new SqlCommand("Delete From Extras Where Id = " + e.Id, c);
                com.ExecuteNonQuery();     //Executes the SQL command
            }
            catch (Exception exc)
            {
                exc.ToString();      //In case of an error it is printed here
                Console.WriteLine("ERROR: Delete extra");
            }
            finally
            {
                c.Close();      //Closes the connection to the DB
            }
        }
コード例 #2
0
ファイル: ExtrasCAD.cs プロジェクト: SamuelHdez/at-ta-project
        public void deleteExtra(ExtrasEN e)
        {
            string        s = ConfigurationManager.ConnectionStrings["DatabaseConnection"].ToString();
            SqlConnection c = new SqlConnection(s);

            try
            {
                c.Open();
                SqlCommand com = new SqlCommand("Delete From Extras Where Id = " + e.Id, c);
                com.ExecuteNonQuery();
            }
            catch (Exception exc)
            {
                exc.ToString();
                Console.WriteLine("ERROR: Delete extra");
            }
            finally
            {
                c.Close();
            }
        }
コード例 #3
0
ファイル: ExtrasCAD.cs プロジェクト: SamuelHdez/at-ta-project
        public void updateExtra(ExtrasEN e)
        {
            string        s = ConfigurationManager.ConnectionStrings["DatabaseConnection"].ToString();
            SqlConnection c = new SqlConnection(s);

            try
            {
                c.Open();
                SqlCommand com = new SqlCommand("Update Extras Set WiFi = '" + e.WiFi + "', Food = '" + e.Food + "', Discount ='" +
                                                e.Discount + "' Where Id = " + e.Id, c);
                com.ExecuteNonQuery();
            }
            catch (Exception exc)
            {
                exc.ToString();
                Console.WriteLine("ERROR: Update extra");
            }
            finally
            {
                c.Close();
            }
        }
コード例 #4
0
        //Adds a new Extra to the DB
        public void addExtra(ExtrasEN e)
        {
            string        s = ConfigurationManager.ConnectionStrings["DefaultConnection"].ToString(); //String where it's stored the instructions for the connecton for the DB
            SqlConnection c = new SqlConnection(s);                                                   //The connection is effectuated

            try
            {
                c.Open();                   //The select in SQL language that is processed in the DB which will return all the rows from the table "extra"
                SqlCommand com = new SqlCommand("Insert Into Extras (Id,WiFi,Food,Discount) VALUES ('" + e.Id + "','" + e.WiFi + "','" + e.Food + "','" +
                                                e.Discount + "')", c);

                com.ExecuteNonQuery();     //Executes the SQL command
            }
            catch (Exception exc)
            {
                exc.ToString();      //In case of an error it is printed here
                Console.WriteLine("ERROR: Add extra");
            }
            finally
            {
                c.Close();      //Closes the connection to the DB
            }
        }
コード例 #5
0
ファイル: ExtrasCAD.cs プロジェクト: SamuelHdez/at-ta-project
        public void addExtra(ExtrasEN e)
        {
            string        s = ConfigurationManager.ConnectionStrings["DatabaseConnection"].ToString();
            SqlConnection c = new SqlConnection(s);

            try
            {
                c.Open();
                SqlCommand com = new SqlCommand("Insert Into Extras (Id,WiFi,Food,Discount) VALUES ('" + e.Id + "','" + e.WiFi + "','" + e.Food + "','" +
                                                e.Discount + "')", c);

                com.ExecuteNonQuery();
            }
            catch (Exception exc)
            {
                exc.ToString();
                Console.WriteLine("ERROR: Add extra");
            }
            finally
            {
                c.Close();
            }
        }