Ejemplo n.º 1
0
        public DataSet deleteHotel(HotelEN h, int i) // It will delete the index passed in the view
        {
            string        s      = ConfigurationManager.ConnectionStrings["DatabaseConnection"].ToString();
            SqlConnection c      = new SqlConnection(s);
            DataSet       virtdb = new DataSet();

            try
            {
                SqlDataAdapter da = new SqlDataAdapter();
                da.Fill(virtdb, "hotel");
                DataTable t = new DataTable();
                t = virtdb.Tables["hotel"];

                t.Rows[i].Delete();

                SqlCommandBuilder cbuilder = new SqlCommandBuilder(da);
                da.Update(virtdb, "hotel");
            }
            catch (Exception ex)
            {
                ex.ToString();
                Console.WriteLine("ERROR: Delete hotel");
            }
            finally
            {
                c.Close();
            }
            return(virtdb);
        }
Ejemplo n.º 2
0
        public DataSet updateHotel(HotelEN h, int i)
        {
            string        s      = ConfigurationManager.ConnectionStrings["DatabaseConnection"].ToString();
            SqlConnection c      = new SqlConnection(s);
            DataSet       virtdb = new DataSet();

            try
            {
                SqlDataAdapter da = new SqlDataAdapter();
                da.Fill(virtdb, "hotel");
                DataTable t = new DataTable();
                t = virtdb.Tables["hotel"];

                t.Rows[i]["Id"] = h.Id;

                t.Rows[i]["Id"]       = h.Id;
                t.Rows[i]["Name"]     = h.Name;
                t.Rows[i]["City"]     = h.City;
                t.Rows[i]["Days"]     = h.Days;
                t.Rows[i]["Phone"]    = h.Phone;
                t.Rows[i]["Adress"]   = h.Address;
                t.Rows[i]["Email"]    = h.Email;
                t.Rows[i]["Stars"]    = h.Stars;
                t.Rows[i]["Bedrooms"] = h.Bedrooms;
                t.Rows[i]["Date"]     = h.Date;

                SqlCommandBuilder cbuilder = new SqlCommandBuilder(da);
                da.Update(virtdb, "hotel");
            }
            catch (Exception ex)
            {
                ex.ToString();
                Console.WriteLine("ERROR: Delete hotel");
            }
            finally
            {
                c.Close();
            }
            return(virtdb);
        }
Ejemplo n.º 3
0
        public void addHotel(HotelEN h)
        {
            string        s      = ConfigurationManager.ConnectionStrings["DatabaseConnection"].ToString();
            SqlConnection c      = new SqlConnection(s);
            DataSet       virtdb = new DataSet();

            try
            {
                SqlDataAdapter da = new SqlDataAdapter();
                da.Fill(virtdb, "hotel");
                DataTable t = new DataTable();
                t = virtdb.Tables["hotel"];
                DataRow newRow = t.NewRow();
                newRow[0] = h.Id;
                newRow[1] = h.Name;
                newRow[2] = h.City;
                newRow[3] = h.Days;
                newRow[4] = h.Phone;
                newRow[5] = h.Address;
                newRow[6] = h.Email;
                newRow[7] = h.Stars;
                newRow[8] = h.Bedrooms;
                newRow[9] = h.Date;
                t.Rows.Add(newRow);
                SqlCommandBuilder cbuilder = new SqlCommandBuilder(da);
                da.Update(virtdb, "hotel");
            }
            catch (Exception ex)
            {
                ex.ToString();
                Console.WriteLine("ERROR: Add hotel");
            }
            finally
            {
                c.Close();
            }
        }
Ejemplo n.º 4
0
        public DataSet showHotels(HotelEN h)
        {
            string s;

            s = ConfigurationManager.ConnectionStrings["DefaultConnection"].ToString();
            DataSet       virtdb = new DataSet();
            SqlConnection c      = new SqlConnection(s);

            try
            {
                SqlDataAdapter da = new SqlDataAdapter("select * from Hotel", c);
                da.Fill(virtdb, "hotel");
            }
            catch (Exception ex)
            {
                ex.ToString();
                Console.WriteLine("ERROR: show hotel");
            }
            finally
            {
                c.Close();
            }
            return(virtdb);
        }