protected void btnSave_Click(object sender, EventArgs e) { try { Doctor d = new Doctor(); d.DoctorID = Int32.Parse(txtDId.Text); d.dName = txtDName.Text; d.dEmail = txtEmail.Text; d.dScheduleDay = calSDay.SelectedDate.ToShortDateString(); d.DepartmentId = Int32.Parse(dlistDepartment.SelectedValue); d.RoomId = Int32.Parse(dListRoomNo.SelectedValue); //Existing Record Checking Validation bool recordtExists = db.Doctors.Any(dn => dn.DoctorID.Equals(d.DoctorID)); //Existing Record Checking Validation if (recordtExists) { refreshAll(); Literal1.Text = "Data Existed Before!!!"; btnDelete.Visible = false; btnEdit.Visible = false; btnCancel.Visible = false; btnSave.Visible = true; btnSearch.Visible = true; Clear(); } else { db.Doctors.Add(d); db.SaveChanges(); Clear(); refreshAll(); Literal1.Text = "Data Inserted Successfully!!!"; btnDelete.Visible = false; btnEdit.Visible = false; btnCancel.Visible = false; btnSave.Visible = true; btnSearch.Visible = true; } } catch (Exception ex) { Literal1.Text = ex.Message; } }
public void AddMatchByTagName(string stadiumName, string hostID, string guestID, string mainReffereID, string technicalReffereID, string linearReffereID, string observerReffereID, int hostGoals, int guestGoals) { try { using (dbEntities1 context = new dbEntities1()) { Stadium stadium = context.Stadium.FirstOrDefault(x => x.name == stadiumName); Club hostClub = context.Club.FirstOrDefault(x => x.name == hostID); Club guestClub = context.Club.FirstOrDefault(x => x.name == guestID); Referee mainReffere = context.Referee.FirstOrDefault(x => x.lastName == mainReffereID); Referee technicalReffere = context.Referee.FirstOrDefault(x => x.lastName == technicalReffereID); Referee linearReffere = context.Referee.FirstOrDefault(x => x.lastName == linearReffereID); Referee observerReffere = context.Referee.FirstOrDefault(x => x.lastName == observerReffereID); Match match = new Match { Stadium = stadium, Club = hostClub, Club1 = guestClub, Referee = mainReffere, Referee1 = technicalReffere, Referee2 = linearReffere, Referee3 = observerReffere, hostGoals = hostGoals, guestGoals = guestGoals }; context.Match.Add(match); context.SaveChanges(); } } catch (Exception e) { throw e; } }
internal bool AddWinners(int clubID, string year, int wonMatches, int lostMatches, int goalsScored, int goalsLost) { try { using (dbEntities1 context = new dbEntities1()) { Winners winners = new Winners { clubID = clubID, year = year, wonMatches = wonMatches, lostMatches = lostMatches, goalsScored = goalsScored, goalsLost = goalsLost }; context.Winners.Add(winners); context.SaveChanges(); return(true); } } catch (Exception e) { throw e; } }
internal bool EditMatch(int stadiumID, int hostID, int guestID, int mainRefereeID, int technicalRefereeID, int linearRefereeID, int observerRefereeID, int hostGoals, int guestGoals, int currentMatchID) { try { using (dbEntities1 context = new dbEntities1()) { Match match = context.Match.FirstOrDefault(x => x.id == currentMatchID); match.stadiumID = stadiumID; match.hostID = hostID; match.guestID = guestID; match.mainRefereeID = mainRefereeID; match.technicalRefereeID = technicalRefereeID; match.linesRefereeID = linearRefereeID; match.observerRefereeID = observerRefereeID; match.hostGoals = hostGoals; match.guestGoals = guestGoals; context.Entry(match).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); return(true); } } catch (Exception e) { throw e; } }
public bool AddRecord(Record record) { try { using (dbEntities1 context = new dbEntities1()) { context.Record.Add(record); context.SaveChanges(); return(true); } } catch (Exception e) { throw e; } }
internal bool EditRecord(string newType, string newName, long currentRecordID) { try { using (dbEntities1 context = new dbEntities1()) { Record record = context.Record.FirstOrDefault(x => x.id == currentRecordID); record.type = newType; record.name = newName; context.Entry(record).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); return(true); } } catch (Exception e) { throw e; } }
internal bool EditTimetable(int matchID, int refereeID, long currentTimetableID) { try { using (dbEntities1 context = new dbEntities1()) { Timetable timetable = context.Timetable.FirstOrDefault(x => x.id == currentTimetableID); timetable.matchID = matchID; timetable.refereeID = refereeID; context.Entry(timetable).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); return(true); } } catch (Exception e) { throw e; } }
internal bool EditTicket(int matchID, string pESEL, long currentTicketID) { try { using (dbEntities1 context = new dbEntities1()) { Ticket ticket = context.Ticket.FirstOrDefault(x => x.id == currentTicketID); ticket.matchID = matchID; ticket.PESEL = pESEL; context.Entry(ticket).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); return(true); } } catch (Exception e) { throw e; } }
public bool RemoveTicketByMatchID(long matchID) { try { using (dbEntities1 context = new dbEntities1()) { List <Ticket> ticketList = context.Ticket.Where(x => x.matchID == matchID).ToList(); foreach (Ticket item in ticketList) { context.Ticket.Remove(item); } context.SaveChanges(); return(true); } } catch (Exception e) { throw e; } }
internal bool RemovePlayer(int iD) { try { using (dbEntities1 context = new dbEntities1()) { Player player = context.Player.FirstOrDefault(x => x.id == iD); if (!CanRemovePlayer(player)) { return(false); } context.Player.Remove(player); context.SaveChanges(); return(true); } } catch (Exception e) { throw e; } }
public bool RemoveReffere(long reffereID) { try { using (dbEntities1 context = new dbEntities1()) { Referee referee = context.Referee.FirstOrDefault(x => x.id == reffereID); if (!CanRemoveReffere(referee)) { return(false); } context.Referee.Remove(referee); context.SaveChanges(); return(true); } } catch (Exception e) { throw e; } }
internal bool EditReferee(string firstName, string lastName, double salary, int recordID, int iD) { try { using (dbEntities1 context = new dbEntities1()) { Referee referee = context.Referee.FirstOrDefault(x => x.id == iD); referee.firstName = firstName; referee.lastName = lastName; referee.salary = salary; referee.recordID = recordID; context.Entry(referee).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); return(true); } } catch (Exception e) { throw e; } }
public bool RemoveTicket(long ticketID) { try { using (dbEntities1 context = new dbEntities1()) { Ticket ticket = context.Ticket.FirstOrDefault(x => x.id == ticketID); if (!CanRemoveTicket(ticket)) { return(false); } context.Ticket.Remove(ticket); context.SaveChanges(); return(true); } } catch (Exception e) { throw e; } }
internal bool EditPlayer(string firstName, string lastName, int clubID, int recordID, int playerID) { try { using (dbEntities1 context = new dbEntities1()) { Player player = context.Player.FirstOrDefault(x => x.id == playerID); player.firstName = firstName; player.lastName = lastName; player.clubID = clubID; player.recordID = recordID; context.Entry(player).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); return(true); } } catch (Exception e) { throw e; } }
internal bool RemoveWinners(int iD) { try { using (dbEntities1 context = new dbEntities1()) { Winners winners = context.Winners.FirstOrDefault(x => x.id == iD); if (!CanRemoveWinners(winners)) { return(false); } context.Winners.Remove(winners); context.SaveChanges(); return(true); } } catch (Exception e) { throw e; } }
internal bool RemoveStaff(int iD) { try { using (dbEntities1 context = new dbEntities1()) { TrainingStaff staff = context.TrainingStaff.FirstOrDefault(x => x.id == iD); if (!CanRemoveStaff(staff)) { return(false); } context.TrainingStaff.Remove(staff); context.SaveChanges(); return(true); } } catch (Exception e) { throw e; } }
public bool RemoveTimetable(long ID) { try { using (dbEntities1 context = new dbEntities1()) { Timetable timetable = context.Timetable.FirstOrDefault(x => x.id == ID); if (!CanRemoveTimetable(timetable)) { return(false); } context.Timetable.Remove(timetable); context.SaveChanges(); return(true); } } catch (Exception e) { throw e; } }
public void AddTicket(string PESEL, int matchID, string date) { try { using (dbEntities1 context = new dbEntities1()) { DateTime myDate = DateTime.Parse(date); Match match = context.Match.FirstOrDefault(x => x.id == matchID); Ticket ticket = new Ticket { Match = match, PESEL = PESEL, }; context.Ticket.Add(ticket); context.SaveChanges(); } } catch (Exception e) { throw e; } }
public void AddReffere(string firstName, string lastName, double salary, int recordID) { try { using (dbEntities1 context = new dbEntities1()) { Referee referee = new Referee { firstName = firstName, lastName = lastName, salary = salary, recordID = recordID }; context.Referee.Add(referee); context.SaveChanges(); } } catch (Exception e) { throw e; } }
public void AddTimetable(long matchID, long refereeID) { try { using (dbEntities1 context = new dbEntities1()) { Match match = context.Match.FirstOrDefault(x => x.id == matchID); Referee referee = context.Referee.FirstOrDefault(x => x.id == refereeID); Timetable timetable = new Timetable { Match = match, Referee = referee }; context.Timetable.Add(timetable); context.SaveChanges(); } } catch (Exception e) { throw e; } }
internal bool EditStaff(string firstName, string lastName, int clubID, int staffID, int age, string duty) { try { using (dbEntities1 context = new dbEntities1()) { TrainingStaff staff = context.TrainingStaff.FirstOrDefault(x => x.id == staffID); staff.firstName = firstName; staff.lastName = lastName; staff.clubID = clubID; staff.age = age; staff.duty = duty; context.Entry(staff).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); return(true); } } catch (Exception e) { throw e; } }
public bool RemoveMatch(long matchID) { try { using (dbEntities1 context = new dbEntities1()) { Match match = context.Match.FirstOrDefault(x => x.id == matchID); if (!CanRemoveMatch(match))//nie posiada graczy ani członków sztabu { return(false); } ticketService.RemoveTicketByMatchID(match.id); context.Match.Remove(match); context.SaveChanges(); return(true); } } catch (Exception e) { throw e; } }
internal bool AddPlayer(string firstName, string lastName, int clubID, int recordID) { try { using (dbEntities1 context = new dbEntities1()) { Player player = new Player { firstName = firstName, lastName = lastName, clubID = clubID, recordID = recordID }; context.Player.Add(player); context.SaveChanges(); return(true); } } catch (Exception e) { throw e; } }
internal bool EditWinners(int clubID, string year, int wonMatches, int lostMatches, int goalsScored, int goalsLost, int winnersID) { try { using (dbEntities1 context = new dbEntities1()) { Winners winners = context.Winners.FirstOrDefault(x => x.id == winnersID); winners.goalsScored = goalsScored; winners.goalsLost = goalsLost; winners.lostMatches = lostMatches; winners.clubID = clubID; winners.wonMatches = wonMatches; winners.lostMatches = lostMatches; winners.year = year; context.Entry(winners).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); return(true); } } catch (Exception e) { throw e; } }
internal bool AddStaff(string firstName, string lastName, int clubID, int age, string duty) { try { using (dbEntities1 context = new dbEntities1()) { TrainingStaff staff = new TrainingStaff { firstName = firstName, lastName = lastName, clubID = clubID, age = age, duty = duty, }; context.TrainingStaff.Add(staff); context.SaveChanges(); return(true); } } catch (Exception e) { throw e; } }