Exemple #1
0
 public void TestSetup()
 {
     accessor        = new MockRoomTypeAccessor();
     roomTypeManager = new RoomTypeManager(accessor);
     roomTypes       = new List <RoomType>();
     roomTypes       = roomTypeManager.RetrieveAllRoomTypes("all");
 }
Exemple #2
0
        /// <summary>
        /// Loads the datagrid with the guest type table
        /// </summary>
        public RoomTypes()
        {
            InitializeComponent();

            roomManager = new RoomTypeManager();
            try
            {
                _room = roomManager.RetrieveAllRoomTypes("All");
                if (_currentRoom == null)
                {
                    _currentRoom = _room;
                }
                dgRooms.ItemsSource = _currentRoom;
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemple #3
0
        /// <summary>
        /// Loads the combo box of room types to choose from
        /// </summary>
        public DeleteRoom()
        {
            InitializeComponent();

            roomManager = new RoomTypeManager();
            try
            {
                if (cboRoom.Items.Count == 0)
                {
                    var guestId = roomManager.RetrieveAllRoomTypes();
                    foreach (var item in guestId)
                    {
                        cboRoom.Items.Add(item);
                    }
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemple #4
0
        /// <summary>
        /// Loads the page
        /// </summary>
        public AddRoom()
        {
            InitializeComponent();

            roomManager = new RoomTypeManager();
        }
        public bool deleteRoomType(IRoomType aRoomType)
        {
            try
            {
                ds = new DataSet();
                string sql = "SELECT * From rooms";
                da = new SqlDataAdapter(sql, con);
                da.MissingSchemaAction = MissingSchemaAction.AddWithKey;
                cb = new SqlCommandBuilder(da);  //Generates
                da.Fill(ds, "RoomData");
                DataRow findRow = ds.Tables["RoomData"].Rows.Find(aRoomType.Name);
                if (findRow == null)
                {
                    return true;
                    //ds = new DataSet();
                    //sql = "SELECT * From roomTypes WHERE name = " + aRoomType.RoomTypeId;
                    //da = new SqlDataAdapter(sql, con);
                    //cb = new SqlCommandBuilder(da); //Generates
                    //da.Fill(ds, "RoomTypeData");
                    //DataRow findRow2 = ds.Tables["RoomTypeData"].Rows.Find(aRoomType.RoomTypeId);
                    //if (findRow2 != null)
                    //{
                    //    findRow.Delete(); //mark row as deleted
                    //}
                    //da.Update(ds, "RoomTypeData"); //remove row from database table

                }
            }
            catch (System.Exception excep)
            {
                MessageBox.Show(excep.Message);
                if (getConnection().ToString() == "Open")
                    closeConnection();
                Application.Exit();
            }
            return true;
        }
 public void addNewRoomTypeToDB(IRoomType theRoomType)
 {
     try
     {
         DataSet ds = new DataSet();
         string sql = "SELECT * From roomTypes";
         SqlDataAdapter da = new SqlDataAdapter(sql, con);
         SqlCommandBuilder cb = new SqlCommandBuilder(da);  //Generates
         da.Fill(ds, "UsersData");
         totUsers = ds.Tables["UsersData"].Rows.Count;
         DataRow dRow = ds.Tables["UsersData"].NewRow();
         dRow[0] = theRoomType.RoomTypeId;
         dRow[1] = theRoomType.Name;
         dRow[2] = theRoomType.Description;
         dRow[3] = theRoomType.Capacity;
         dRow[4] = theRoomType.PricePerNight;
         ds.Tables["UsersData"].Rows.Add(dRow);
         da.Update(ds, "UsersData");
     }
     catch (System.Exception excep)
     {
         if (con.State.ToString() == "Open")
             con.Close();
         Application.Exit();
         //Environment.Exit(0); //Force the application to close
     }
 }
 public bool updateRoomTypeInDB(IRoomType aRoomType)
 {
     try
     {
         ds = new DataSet();
         string sql = "SELECT * From roomtypes";
         da = new SqlDataAdapter(sql, con);
         da.MissingSchemaAction = MissingSchemaAction.AddWithKey;
         cb = new SqlCommandBuilder(da);  //Generates
         da.Fill(ds, "RoomTypeData");
         DataRow findRow = ds.Tables["RoomTypeData"].Rows.Find(aRoomType.RoomTypeId);
         if (findRow != null)
         {
             findRow[1] = aRoomType.Name;
             findRow[2] = aRoomType.Capacity;
             findRow[3] = aRoomType.PricePerNight;
         }
         da.Update(ds, "RoomTypeData"); //remove row from database table
     }
     catch (System.Exception excep)
     {
         MessageBox.Show(excep.Message);
         if (getConnection().ToString() == "Open")
             closeConnection();
         Application.Exit();
     }
     return true;
 }
 public bool updateRoomType(IRoomType aRoomType, string name)
 {
     IRoomType duplicateUser = this.RoomTypeList.FirstOrDefault(rm => rm.Name == name);
     if (duplicateUser != null)
     {
         MessageBox.Show("Error, Cannot rename a roomtype to be the same as another existing roomtype");
         return false;
     }
     else
     {
         aRoomType.Name = name;
         DataLayer.updateRoomTypeInDB(aRoomType);
         _roomTypeList = DataLayer.getAllRoomTypes();
         MessageBox.Show("Room Type Updated");
         return true;
        }
 }
 public bool deleteRoomType(IRoomType aRoomType)
 {
     DataLayer.deleteRoomType(aRoomType);
     RoomTypeList.Remove(aRoomType); //remove object from collection
     return true;
 }
 public static void SetNewRoomType(IRoomType aRoomType)
 {
     newRoomType = aRoomType;
 }