public HallForm(Hall hall, int newHall) { InitializeComponent(); Hall = hall; errorTB.Text = string.Empty; if (newHall == 0) { nameTB.Text = Hall.Name; priceTB.Text = Convert.ToString(Hall.Price); capacityNUM.Value = Convert.ToDecimal(Hall.Capacity); vipRB.Checked = Hall.OnlyVip; } }
private void GetInfoHall(Hall hall) { dataLB1.Text = hall.Name; dataLB2.Text = Convert.ToString(hall.Capacity); dataLB3.Text = Convert.ToString(hall.Price) + " р./час"; if (hall.OnlyVip) { dataLB4.Text = "только для VIP"; } else { dataLB4.Text = "для всех"; } }
private void objectsCB_SelectedIndexChanged(object sender, EventArgs e) { if (currentModel == Employee) { Employee employee = repository.Employees.FirstOrDefault(em => em.FullName == (string)objectsCB.SelectedItem); if (employee == null) { return; } currentId = employee.ID; GetInfoEmployee(employee); return; } if (currentModel == Customer) { Customer customer = repository.Customers.FirstOrDefault(c => c.FullName == (string)objectsCB.SelectedItem); if (customer == null) { return; } currentId = customer.ID; GetInfoCustomer(customer); return; } if (currentModel == Hall) { Hall hall = repository.Halls.FirstOrDefault(h => h.Name == (string)objectsCB.SelectedItem); if (hall == null) { return; } currentId = hall.ID; GetInfoHall(hall); return; } if (currentModel == Rent) { Rent rent = repository.Rents.FirstOrDefault(r => r.TimeStart.ToString() == (string)objectsCB.SelectedItem); if (rent == null) { return; } currentId = rent.ID; GetInfoRent(rent); return; } }
private void removeBTN_Click(object sender, EventArgs e) { if (user.Position != Admin) { MessageBox.Show("Вы можете только просматривать!"); return; } if (currentModel == Employee && currentId != -1) { Employee employee = repository.Employees.FirstOrDefault(em => em.ID == currentId); if (employee == null) { return; } objectsCB.Items.Remove(employee.FullName); repository.Employees.Remove(employee); repository.Save(); objectsCB.SelectedItem = null; objectsCB.Text = string.Empty; currentId = -1; ClearInfo(); return; } if (currentModel == Customer && currentId != -1) { Customer customer = repository.Customers.FirstOrDefault(c => c.ID == currentId); if (customer == null) { return; } objectsCB.Items.Remove(customer.FullName); repository.Customers.Remove(customer); repository.Save(); objectsCB.SelectedItem = null; objectsCB.Text = string.Empty; currentId = -1; ClearInfo(); return; } if (currentModel == Hall && currentId != -1) { Hall hall = repository.Halls.FirstOrDefault(h => h.ID == currentId); if (hall == null) { return; } objectsCB.Items.Remove(hall.Name); repository.Halls.Remove(hall); repository.Save(); objectsCB.SelectedItem = null; objectsCB.Text = string.Empty; currentId = -1; ClearInfo(); return; } if (currentModel == Rent && currentId != -1) { Rent rent = repository.Rents.FirstOrDefault(r => r.ID == currentId); if (rent == null) { return; } objectsCB.Items.Remove(rent.TimeStart.ToString()); repository.Rents.Remove(rent); repository.Save(); objectsCB.SelectedItem = null; objectsCB.Text = string.Empty; currentId = -1; ClearInfo(); return; } MessageBox.Show("Выберите модель!"); }
private void editBTN_Click(object sender, EventArgs e) { if (user.Position != Admin) { MessageBox.Show("Вы можете только просматривать!"); return; } if (currentModel == Employee && currentId != -1) { Employee employee = repository.Employees.FirstOrDefault(em => em.ID == currentId); if (employee == null) { return; } EmpForm emp = new EmpForm(employee, 0); if (emp.ShowDialog() == DialogResult.Yes) { objectsCB.SelectedItem = employee.FullName; repository.Save(); } return; } if (currentModel == Customer && currentId != -1) { Customer customer = repository.Customers.FirstOrDefault(c => c.ID == currentId); if (customer == null) { return; } CustForm cust = new CustForm(customer, 0); if (cust.ShowDialog() == DialogResult.Yes) { objectsCB.SelectedItem = customer.FullName; repository.Save(); } return; } if (currentModel == Hall && currentId != -1) { Hall hall = repository.Halls.FirstOrDefault(h => h.ID == currentId); if (hall == null) { return; } HallForm hal = new HallForm(hall, 0); if (hal.ShowDialog() == DialogResult.Yes) { objectsCB.SelectedItem = hall.Name; repository.Save(); } return; } if (currentModel == Rent && currentId != -1) { Rent rent = repository.Rents.FirstOrDefault(r => r.ID == currentId); if (rent == null) { return; } RentForm ren = new RentForm(rent, 0, repository.Customers, repository.Halls, repository.Rents); if (ren.ShowDialog() == DialogResult.Yes) { objectsCB.SelectedItem = rent.TimeStart.ToString(); repository.Save(); } return; } MessageBox.Show("Выберите модель!"); }
private void hallCB_SelectedIndexChanged(object sender, EventArgs e) { Hall hall = Halls.FirstOrDefault(h => h.Name == (string)hallCB.SelectedItem); peopleNUM.Maximum = hall.Capacity; }