private void buttonProvide_Click(object sender, EventArgs e) { ClearLayoutPanel(); using (KochkaDBEntities1 ct = new KochkaDBEntities1()) { foreach (Provide p in ct.Provides) { UserControlProvide item = new UserControlProvide() { ClubNumber = p.NumberOfClub.ToString(), Provide = p.NameService }; if (p.NameService == "Gym") { item.ProvidePic = _Resize(Resources.Gym); } else if (p.NameService == "Sauna") { item.ProvidePic = _Resize(Resources.Sauna); } else { item.ProvidePic = _Resize(Resources.Swimming_Pool); } flowLayoutPanelMain.Controls.Add(item); } } }
private void buttonTeam_Click(object sender, EventArgs e) { ClearLayoutPanel(); using (KochkaDBEntities1 ct = new KochkaDBEntities1()) { UserControlAdd add = new UserControlAdd(); flowLayoutPanelMain.Controls.Add(add); foreach (Employee empl in ct.Employees) { UserControlEmployee item = new UserControlEmployee() { FIO = empl.EmplyeeSecondName + " " + empl.EmplyeeName + " " + empl.EmplyeeMiddleName, Exp = empl.Experience.ToString(), NumbClub = empl.NumberOfClub.ToString(), Pos = empl.Name }; if (Program.CurrentUser.Group == 3) { item.Tabel = empl.ServiceNumber.ToString(); item.VisibleButtons = true; } flowLayoutPanelMain.Controls.Add(item); } } }
private void buttonDelete_Click(object sender, EventArgs e) { using (KochkaDBEntities1 ct = new KochkaDBEntities1()) { var item = ct.Employees.FirstOrDefault(x => x.ServiceNumber.ToString() == labelTabel.Text); ct.Employees.Remove(item); ct.SaveChanges(); buttonDelete.Text = "Удалено!"; buttonDelete.Enabled = false; } }
private void buttonGuestVisit_Click(object sender, EventArgs e) { using (KochkaDBEntities1 context = new KochkaDBEntities1()) { ClearLayoutPanel(); UserControlGuestVisit item = new UserControlGuestVisit(); UserControlGuestVisit2 item2 = new UserControlGuestVisit2(); flowLayoutPanelMain.Height = 550; flowLayoutPanelMain.Controls.Add(item); flowLayoutPanelMain.Controls.Add(item2); } }
private void buttonEdit_Click(object sender, EventArgs e) { if (buttonEdit.Text == "Изменить") { foreach (Control c in Controls) { if (c is TextBox t) { t.Visible = true; t.ReadOnly = false; } } buttonEdit.Text = "Сохранить"; } else { foreach (Control c in Controls) { if (c is TextBox t) { t.Visible = false; t.ReadOnly = true; } } if (textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == "" || textBox4.Text == "") { return; } labelFIO.Text = textBox1.Text; labelClubNumber.Text = textBox2.Text; labelExp.Text = textBox3.Text; labelPosition.Text = textBox4.Text; using (KochkaDBEntities1 ct = new KochkaDBEntities1()) { Employee empl = ct.Employees.FirstOrDefault(x => x.ServiceNumber.ToString() == labelTabel.Text); if (empl != null) { empl.EmplyeeSecondName = labelFIO.Text.Split(' ')[0]; empl.EmplyeeName = labelFIO.Text.Split(' ')[1]; if (labelFIO.Text.Split(' ').Length > 2) { empl.EmplyeeMiddleName = labelFIO.Text.Split(' ')[2]; } empl.Name = labelPosition.Text; ct.SaveChanges(); } } buttonEdit.Text = "Изменить"; } }
private void buttonClubCard_Click(object sender, EventArgs e) { ClearLayoutPanel(); using (KochkaDBEntities1 ct = new KochkaDBEntities1()) { foreach (ClubCard c in ct.ClubCards) { UserClubCards cc = new UserClubCards() { Grafik = c.ChartOfVisits, Cost = c.CoastMonth + "/" + c.CoastHalfYear + "/" + c.CoastYear, Quantity = c.QuantityOfVisitsPerMonth.ToString(), NameClubCard = c.CardName }; flowLayoutPanelMain.Controls.Add(cc); } } }
private void buttonAdd_Click(object sender, EventArgs e) { using (KochkaDBEntities1 ct = new KochkaDBEntities1()) { Employee em = new Employee() { EmplyeeSecondName = textBox1.Text.Split(' ')[0], EmplyeeName = textBox1.Text.Split(' ')[1], EmplyeeMiddleName = (textBox1.Text.Split(' ').Length > 2) ? textBox1.Text.Split(' ')[2] : null, Experience = Convert.ToInt32(textBox3.Text), NumberOfClub = Convert.ToInt32(textBox2.Text), Name = textBox4.Text }; em.ServiceNumber = ct.Employees.Where(x => x.NumberOfClub == em.NumberOfClub).Count(); var item = ct.Clubs.FirstOrDefault(x => x.NumberOfClub == em.NumberOfClub);//типа триггер if (item == null) { return; } var item2 = ct.Positions.FirstOrDefault(x => x.Name == em.Name); if (item2 == null) { return; } ct.Employees.Add(em); ct.SaveChanges(); } buttonAdd.Text = "Добавлено!"; foreach (Control c in Controls) { if (c is TextBox t) { t.Text = ""; } } buttonAdd.Enabled = false; }
private void button_Click(object sender, EventArgs e) { using (KochkaDBEntities1 ct = new KochkaDBEntities1()) { if (Program.CurrentUser.Group == 1) { if (ButtonText == "Мой абонемент") { SeasonTicket t = ct.SeasonTickets .ToList() .FirstOrDefault(x => x.CardNumber == Program.CurrentUser.Login); Employee em = ct.Employees .ToList() .FirstOrDefault(x => x.ServiceNumber == t.ServiceNumber); UserControlSeasonTicket item = new UserControlSeasonTicket() { ClubNumber = t.NumberOfClub.ToString(), DateEnd = t.DateOfEnd.ToString(), DateBegin = t.DateOfRegistration.ToString(), StillHave = t.VisitsStillHave.ToString(), Employee = em.Name, ContactId = t.ContractId.ToString(), NameCard = t.CardName, ClubCard = t.CardNumber }; f2.ClearLayoutPanel(); panel.Controls.Add(item); } if (ButtonText == "Мой тренер") { CoachContract contract = ct.CoachContracts .ToList() .FirstOrDefault(x => x.CardNumber == Program.CurrentUser.Login); Employee employee = ct.Employees .ToList() .FirstOrDefault(x => x.ServiceNumber == contract.ServiceNumber); UserControlTrainerCoach item = new UserControlTrainerCoach() { ContractId = contract.CoachContractId.ToString(), CoachName = employee.EmplyeeSecondName + ' ' + employee.Name + ' ' + employee.EmplyeeMiddleName, Quanity = contract.QuantityTraining.ToString(), StillHave = contract.StillHaveTraining.ToString(), DateBegin = contract.DateOfConclusion.ToString(), DateEnd = contract.ExpiryDate.ToString(), ClientName = ct.Visitors.ToList().FirstOrDefault(x => x.CardNumber == contract.CardNumber).VisitorSecondName }; f2.ClearLayoutPanel(); panel.Controls.Add(item); } if (ButtonText == "Посещения") { f2.ClearLayoutPanel(); bool Empty = true; foreach (Visit visit in ct.Visits.ToList()) { if (visit.CardNumber == Program.CurrentUser.Login) { UserControlVisits item = new UserControlVisits() { Date = visit.DateOfVisit.ToString(), NumberOfClub = visit.NumberOfClub.ToString(), CardName = visit.CardName.ToString(), ContarctId = visit.ContractId.ToString(), CName = ct.Visitors .ToList() .FirstOrDefault(x => x.CardNumber == Program.CurrentUser.Login).VisitorSecondName }; Empty = false; panel.Controls.Add(item); } } if (Empty) { panel.Controls .Add ( new UserControlGuestVisit() { TextMessage = "Посещений нет", ClearSecondLabel = "" } ); } } } else if (Program.CurrentUser.Group == 2) { if (ButtonText == "Мои контракты") { f2.ClearLayoutPanel(); bool Empty = true; Employee employee = ct.Employees .ToList() .FirstOrDefault(x => x.ServiceNumber.ToString() == Program.CurrentUser.Login); foreach (CoachContract contract in ct.CoachContracts.ToList()) { if (contract.ServiceNumber.ToString() == Program.CurrentUser.Login) { UserControlTrainerCoach item = new UserControlTrainerCoach() { ContractId = contract.CoachContractId.ToString(), CoachName = employee.EmplyeeSecondName + ' ' + employee.Name + ' ' + employee.EmplyeeMiddleName, Quanity = contract.QuantityTraining.ToString(), StillHave = contract.StillHaveTraining.ToString(), DateBegin = contract.DateOfConclusion.ToString(), DateEnd = contract.ExpiryDate.ToString(), ClientName = ct.Visitors.ToList().FirstOrDefault(x => x.CardNumber == contract.CardNumber).VisitorSecondName }; Empty = false; panel.Controls.Add(item); } } if (Empty) { panel.Controls .Add ( new UserControlGuestVisit() { TextMessage = "Контрактов нет", ClearSecondLabel = "" } ); } } } else if (Program.CurrentUser.Group == 3) { if (ButtonText == "Абонементы") { f2.ClearLayoutPanel(); UserControlSeasonTicket it = new UserControlSeasonTicket(); var tick = from seasonTicket in ct.SeasonTickets join employee in ct.Employees on seasonTicket.ServiceNumber equals employee.ServiceNumber join visitor in ct.Visitors on seasonTicket.CardNumber equals visitor.CardNumber select new { NumberOfClub = seasonTicket.NumberOfClub, NameCard = seasonTicket.CardName, CardNumber = seasonTicket.CardNumber, DateBegin = seasonTicket.DateOfRegistration, DateEnd = seasonTicket.DateOfEnd, StillHave = seasonTicket.VisitsStillHave, ContractId = seasonTicket.ContractId, EmployeeName = employee.EmplyeeSecondName, ClientName = visitor.VisitorSecondName }; foreach (var i in tick.ToList()) { UserControlSeasonTicket item = new UserControlSeasonTicket() { ClubNumber = i.NumberOfClub.ToString(), NameCard = i.NameCard, ClubCard = i.CardNumber, DateBegin = i.DateBegin.ToString(), DateEnd = i.DateEnd.ToString(), ContactId = i.ContractId.ToString(), StillHave = i.StillHave.ToString(), Employee = i.EmployeeName, Client = i.ClientName }; panel.Controls.Add(item); } } if (ButtonText == "Клиенты") { f2.ClearLayoutPanel(); foreach (Visitor v in ct.Visitors) { UserControlVisitor item = new UserControlVisitor() { Client = v.VisitorSecondName + ' ' + v.VisitorName, Birth = v.VisitorBDate.ToString(), ClubCard = v.CardNumber, Passport = v.VisitorPassport }; panel.Controls.Add(item); } } if (ButtonText == "Контракты") { f2.ClearLayoutPanel(); bool Empty = true; foreach (CoachContract contract in ct.CoachContracts.ToList()) { UserControlTrainerCoach item = new UserControlTrainerCoach() { ContractId = contract.CoachContractId.ToString(), CoachName = "Табельный номер тренера: " + contract.ServiceNumber.ToString(), Quanity = contract.QuantityTraining.ToString(), StillHave = contract.StillHaveTraining.ToString(), DateBegin = contract.DateOfConclusion.ToString(), DateEnd = contract.ExpiryDate.ToString(), ClientName = ct.Visitors.ToList().FirstOrDefault(x => x.CardNumber == contract.CardNumber).VisitorSecondName }; Empty = false; panel.Controls.Add(item); } if (Empty) { panel.Controls .Add ( new UserControlGuestVisit() { TextMessage = "Контрактов нет", ClearSecondLabel = "" } ); } } if (ButtonText == "Посещения") { f2.ClearLayoutPanel(); bool Empty = true; foreach (Visit visit in ct.Visits.ToList()) { try { UserControlVisits item = new UserControlVisits() { Date = visit.DateOfVisit.ToString(), NumberOfClub = visit.NumberOfClub.ToString(), CardName = visit.CardName.ToString(), ContarctId = visit.ContractId.ToString(), CName = ct.Visitors .ToList() .FirstOrDefault(x => x.CardNumber == visit.CardNumber).VisitorSecondName }; Empty = false; panel.Controls.Add(item); } catch (Exception ex) { throw new NullReferenceException(ex.Message); } } if (Empty) { panel.Controls .Add ( new UserControlGuestVisit() { TextMessage = "Посещений нет", ClearSecondLabel = "" } ); } } if (ButtonText == "Заявки на гостевой визит") { string line; f2.ClearLayoutPanel(); System.IO.StreamReader file = new System.IO.StreamReader("Applications.txt"); while ((line = file.ReadLine()) != null) { UserControlApp app = new UserControlApp() { Date = line.Split(' ')[0] + ' ' + line.Split(' ')[1], Number = line.Split(' ')[2], NameClient = line.Split(' ')[3] + ' ' + line.Split(' ')[4] }; panel.Controls.Add(app); } file.Close(); } } } }