static void Main() { admin = new Admin(); AllAuditories = new List <Auditorium>(); AllTeachers = new List <Teacher>(); AllAuditories = AppSerializer.DeserializeAud("AudSave.bin"); AllTeachers = AppSerializer.DeserializeTeach("TeachSave.bin"); //AllAuditories[0][0, 0] = ""; CheckAudToMatchWithTeachers(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); while (LogOff == true) { LogOff = false; Application.Run(new AuthWindow()); if (ActiveUser.GetType() == typeof(Admin)) { Application.Run(new AdminWindow()); } else if (ActiveUser.GetType() == typeof(Teacher)) { Application.Run(new TeacherWindow()); } } }
public void UpdateAudBox() { this.AuditoriumBox.Items.Clear(); for (int i = 0; i < Program.AllAuditories.Count; ++i) { this.AuditoriumBox.Items.Add(Program.AllAuditories[i].AudID); } AuditoriumBox.Text = ""; AppSerializer.SerializeAud(Program.AllAuditories, "AudSave.bin"); }
public void UpdateTeacherBox() { this.TeachersBox.Items.Clear(); for (int i = 0; i < Program.AllTeachers.Count; ++i) { this.TeachersBox.Items.Add(Program.AllTeachers[i].FullName); } TeachersBox.Text = ""; AppSerializer.SerializeTeach(Program.AllTeachers, "TeachSave.bin"); }
private void BookingButton_Click(object sender, EventArgs e) { if (AuditoriumBox.SelectedIndex >= 0) { int ColumnWidth = 60; int RowHeight = 30; Form Bookingform = new Form(); Bookingform.Size = new Size(650, 650); Bookingform.MaximumSize = Bookingform.Size; Bookingform.MinimumSize = Bookingform.Size; Bookingform.Show(); Label CellHolder = new Label(); DataGridView AudGrid = new DataGridView(); foreach (string day in AppEnums.Days) { AudGrid.Columns.Add(day, day); } string[] row; foreach (string time in AppEnums.LessonsTime) { row = new string[AppEnums.Days.Length]; for (int i = 0; i < row.Length; ++i) { row[i] = time; } AudGrid.Rows.Add(row); } AudGrid.Location = new Point(150, 100); AudGrid.Size = new Size(ColumnWidth * AppEnums.Days.Length + 2, RowHeight * AppEnums.LessonsTime.Length + 2 + AudGrid.ColumnHeadersHeight); AudGrid.ScrollBars = ScrollBars.None; AudGrid.AllowDrop = false; AudGrid.AllowUserToResizeColumns = false; AudGrid.AllowUserToResizeRows = false; AudGrid.AllowUserToAddRows = false; AudGrid.RowHeadersVisible = false; AudGrid.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing; DataGridViewCellStyle ScheduleCellStyle = new DataGridViewCellStyle(); DataGridViewCellStyle TeacherCellStyle = new DataGridViewCellStyle(); DataGridViewCellStyle DefaultCellStyle = new DataGridViewCellStyle(); ScheduleCellStyle.BackColor = Color.Red; TeacherCellStyle.BackColor = Color.Brown; DefaultCellStyle.BackColor = Color.White; for (int i = 0; i < AppEnums.LessonsTime.Length; i++) { AudGrid.Rows[i].ReadOnly = true; AudGrid.Rows[i].Height = RowHeight; } for (int i = 0; i < AppEnums.Days.Length; i++) { AudGrid.Columns[i].Width = ColumnWidth; AudGrid.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable; } for (int i = 0; i < AppEnums.LessonsTime.Length; i++) { for (int j = 0; j < AppEnums.Days.Length; j++) { if (Program.AllAuditories[AuditoriumBox.SelectedIndex][i, j] == "schedule") { AudGrid.Rows[i].Cells[j].Style = ScheduleCellStyle; } else if (Program.AllAuditories[AuditoriumBox.SelectedIndex][i, j] != "") { AudGrid.Rows[i].Cells[j].Style = TeacherCellStyle; } } } Bookingform.Text = "Бронирование"; CellHolder.Location = new Point(50, 400); Font font = new Font(CellHolder.Font.FontFamily, 10); CellHolder.Font = font; CellHolder.Text = ""; CellHolder.Size = new Size(500, 30); Button BookButton = new Button(); BookButton.Text = "Забронировать"; BookButton.Size = new Size(200, 40); BookButton.Location = new Point(50, 500); Button UnBookButton = new Button(); UnBookButton.Text = "Cнять бронирование"; UnBookButton.Size = new Size(200, 40); UnBookButton.Location = new Point(300, 500); Label AudLabel = new Label(); AudLabel.Font = font; AudLabel.Text = "Аудитория:"; AudLabel.Text += Program.AllAuditories[AuditoriumBox.SelectedIndex].AudID; AudLabel.Location = new Point(30, 50); AudLabel.Size = new Size(300, 30); Bookingform.Controls.Add(BookButton); Bookingform.Controls.Add(UnBookButton); Bookingform.Controls.Add(AudLabel); Bookingform.Controls.Add(AudGrid); Bookingform.Controls.Add(CellHolder); AudGrid.ClearSelection(); AudGrid.SelectionChanged += (Sender, args) => { if (AudGrid.SelectedCells.Count == 1) { if (Program.AllAuditories[AuditoriumBox.SelectedIndex] [AudGrid.SelectedCells[0].RowIndex, AudGrid.SelectedCells[0].ColumnIndex] == Program.ActiveUser.GUID) { CellHolder.Text = "Забронировано вами"; } else { if (Program.AllAuditories[AuditoriumBox.SelectedIndex] [AudGrid.SelectedCells[0].RowIndex, AudGrid.SelectedCells[0].ColumnIndex] == "schedule") { CellHolder.Text = "Забронировано по расписанию"; } else if (Program.AllAuditories[AuditoriumBox.SelectedIndex] [AudGrid.SelectedCells[0].RowIndex, AudGrid.SelectedCells[0].ColumnIndex] != "") { CellHolder.Text = "Забронировано преподавателем: "; CellHolder.Text += Program.AllTeachers.Find(x => x.GUID == Program.AllAuditories[AuditoriumBox.SelectedIndex] [AudGrid.SelectedCells[0].RowIndex, AudGrid.SelectedCells[0].ColumnIndex]).FullName; } else { CellHolder.Text = "Свободно"; } } } else { CellHolder.Text = ""; } }; AudGrid.CellStyleChanged += (Sender, args) => { if (AudGrid.SelectedCells.Count == 1) { if (Program.AllAuditories[AuditoriumBox.SelectedIndex] [AudGrid.SelectedCells[0].RowIndex, AudGrid.SelectedCells[0].ColumnIndex] == Program.ActiveUser.GUID) { CellHolder.Text = "Забронировано вами"; } else { if (Program.AllAuditories[AuditoriumBox.SelectedIndex] [AudGrid.SelectedCells[0].RowIndex, AudGrid.SelectedCells[0].ColumnIndex] == "schedule") { CellHolder.Text = "Забронировано по расписанию"; } else if (Program.AllAuditories[AuditoriumBox.SelectedIndex] [AudGrid.SelectedCells[0].RowIndex, AudGrid.SelectedCells[0].ColumnIndex] != "") { CellHolder.Text = "Забронировано преподавателем: "; CellHolder.Text += Program.AllTeachers.Find(x => x.GUID == Program.AllAuditories[AuditoriumBox.SelectedIndex] [AudGrid.SelectedCells[0].RowIndex, AudGrid.SelectedCells[0].ColumnIndex]).FullName; } else { CellHolder.Text = "Свободно"; } } } else { CellHolder.Text = ""; } }; BookButton.Click += (Sender, args) => { if (AudGrid.SelectedCells.Count > 0) { foreach (DataGridViewCell cell in AudGrid.SelectedCells) { if (Program.AllAuditories[AuditoriumBox.SelectedIndex][cell.RowIndex, cell.ColumnIndex] == "") { Program.AllAuditories[AuditoriumBox.SelectedIndex][cell.RowIndex, cell.ColumnIndex] = Program.ActiveUser.GUID; cell.Style = TeacherCellStyle; } } } AudGrid.ClearSelection(); AppSerializer.SerializeAud(Program.AllAuditories, "AudSave.bin"); }; UnBookButton.Click += (Sender, args) => { if (AudGrid.SelectedCells.Count > 0) { foreach (DataGridViewCell cell in AudGrid.SelectedCells) { if (Program.AllAuditories[AuditoriumBox.SelectedIndex][cell.RowIndex, cell.ColumnIndex] == Program.ActiveUser.GUID) { Program.AllAuditories[AuditoriumBox.SelectedIndex][cell.RowIndex, cell.ColumnIndex] = ""; cell.Style = DefaultCellStyle; } } } AppSerializer.SerializeAud(Program.AllAuditories, "AudSave.bin"); AudGrid.ClearSelection(); }; } }