public ListOfPlacesInHalls ReadAllPlacesOfAllHalls()
        {
            List <PlaceInHall> placesList        = new List <PlaceInHall>();
            SqlConnection      connectToDateBase = new SqlConnection(pathOfDataBase);

            using (connectToDateBase)
            {
                SqlCommand command = new SqlCommand(
                    "SELECT PLACE_ID, HALL_ID, ROW_PLACES, PLACE FROM [PLACESINHALLS];",
                    connectToDateBase);
                connectToDateBase.Open();
                SqlDataReader reader = command.ExecuteReader();
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        PlaceInHall place = new PlaceInHall(reader.GetInt32(0), reader.GetInt32(1), reader.GetInt32(2), reader.GetInt32(3));
                        placesList.Add(place);
                    }
                }
                reader.Close();
            }
            ListOfPlacesInHalls places = new ListOfPlacesInHalls(placesList);

            return(places);
        }
示例#2
0
 public fHalls(AuthorisedUser user)
 {
     InitializeComponent();
     if (user.GetType() == typeof(AdminUser))
     {
         this.user = user;
         ReadingFromDateBase reading = new ReadingFromDateBase();
         hallsList                               = reading.ReadHalls();
         placesList                              = reading.ReadAllPlacesOfAllHalls();
         sourceData.DataSource                   = hallsList.Halls;
         dataGridViewHalls.DataSource            = sourceData;
         dataGridViewHalls.Columns[0].Visible    = false;
         dataGridViewHalls.Columns[1].HeaderText = "Название";
         dataGridViewHalls.Columns[2].HeaderText = "Кол-во мест";
         dataGridViewHalls.Columns[3].HeaderText = "Кол-во мест в ряду";
     }
     else
     {
         this.user = user;
         ReadingFromDateBase reading = new ReadingFromDateBase();
         hallsList                               = reading.ReadHalls();
         placesList                              = reading.ReadAllPlacesOfAllHalls();
         sourceData.DataSource                   = hallsList.Halls;
         dataGridViewHalls.DataSource            = sourceData;
         dataGridViewHalls.Columns[0].Visible    = false;
         dataGridViewHalls.Columns[1].HeaderText = "Название";
         dataGridViewHalls.Columns[2].HeaderText = "Кол-во мест";
         dataGridViewHalls.Columns[3].HeaderText = "Кол-во мест в ряду";
         AddButton.Visible                       = false;
         UpdateButton.Visible                    = false;
         DeleteButton.Visible                    = false;
     }
 }
示例#3
0
 private void DeleteButton_Click(object sender, EventArgs e)
 {
     ClearAllTextBoxesAndGroupBox();
     if (indexRow != -1)
     {
         DeletingFromDateBase deleting = new DeletingFromDateBase();
         deleting.DeleteFromDatabase(hallsList.Halls[indexRow]);
         deleting.DeleteFromDatabase(hallsList.Halls[indexRow].Places);
         hallsList.Halls.RemoveAt(indexRow);
         ReadingFromDateBase reading = new ReadingFromDateBase();
         placesList = reading.ReadAllPlacesOfAllHalls();
         sourceData.ResetBindings(false);
     }
 }
示例#4
0
 private void UpdateButton_Click(object sender, EventArgs e)
 {
     if (indexRow != -1)
     {
         hallsList.Halls[indexRow].HallName        = NameHallInput.Text;
         hallsList.Halls[indexRow].PlacesInRow     = Convert.ToInt32(PlacesInRowInput.Text);
         hallsList.Halls[indexRow].SeatingCapacity = Convert.ToInt32(SeatingCapacityInput.Text);
         UpdatingDataBase updating = new UpdatingDataBase();
         updating.UpdateInDatabase(hallsList.Halls[indexRow]);
         sourceData.ResetBindings(false); //подтверждает изменения
         HallPlaces.Controls.Clear();
         DeletingFromDateBase deleting = new DeletingFromDateBase();
         deleting.DeleteFromDatabase(hallsList.Halls[indexRow].Places);
         hallsList.Halls[indexRow].Places.Clear();
         ReadingFromDateBase reading = new ReadingFromDateBase();
         placesList = reading.ReadAllPlacesOfAllHalls();
         FillingPlaces(hallsList.Halls[indexRow]);
         LoadSchemeOfHall(hallsList.Halls[indexRow].SeatingCapacity, hallsList.Halls[indexRow].PlacesInRow);
     }
 }