public int ScoreAt(Daytime daytime) { int score = 0; foreach (User user in this.Participants) { bool countedScore = false; foreach (Blocked_timeslot blockedTimeSlot in user.BlockedTimeslots) { if (daytime.Id == blockedTimeSlot.Daytime_id) { if (!blockedTimeSlot.Hardblock) { ++score; countedScore = true; break; } else { return(-1); } } } if (!countedScore) { score += 2; } } return(score); }
public Daytime ProcessRow(Daytime daytime, MySqlDataReader Reader, int offset) { daytime.Id = Reader.GetInt32(0 + offset); daytime.Date = Reader.GetDateTime(1 + offset); daytime.Timeslot = Reader.GetInt32(2 + offset); return daytime; }
public Blocked_timeslot(Daytime dayTimeinput, bool blocktype) { this.Daytime = dayTimeinput; this.Hardblock = blocktype; }
public Daytime ProcessRow(Daytime daytime, MySqlDataReader Reader) { return this.ProcessRow(daytime, Reader, 0); }
public int Save(Daytime daytime) { Boolean insert = true; if (daytime.Id != 0) { insert = false; } this._db.OpenConnection(); MySqlCommand command = this._db.CreateCommand(); if (insert) { command.CommandText = "INSERT INTO daytime (date, timeslot) VALUES " + "(?date, ?timeslot)"; } else { command.CommandText = "UPDATE daytime (date, timeslot) VALUES " + "(?date, ?timeslot) WHERE id = ?id"; } command.Parameters.Add(new MySqlParameter("?id", MySqlDbType.Int32)).Value = daytime.Id; command.Parameters.Add(new MySqlParameter("?date", MySqlDbType.Datetime)).Value = daytime.Date; command.Parameters.Add(new MySqlParameter("?timeslot", MySqlDbType.Int32)).Value = daytime.Timeslot; this._db.ExecuteCommand(command); this._db.CloseConnection(); if (insert) { this._db.OpenConnection(); MySqlCommand command2 = this._db.CreateCommand(); command2.CommandText = "SELECT LAST_INSERT_ID()"; MySqlDataReader Reader = this._db.ExecuteCommand(command2); Reader.Read(); this._db.CloseConnection(); return Reader.GetInt32(0); } return 0; }
public int ScoreAt(Daytime daytime) { int score = 0; foreach (User user in this.Participants) { bool countedScore = false; foreach (Blocked_timeslot blockedTimeSlot in user.BlockedTimeslots) { if (daytime.Id == blockedTimeSlot.Daytime_id) { if (!blockedTimeSlot.Hardblock) { ++score; countedScore = true; break; } else { return -1; } } } if (!countedScore) { score += 2; } } return score; }
void Session_Drop(object sender, DragEventArgs e) { CustomLabel session = sender as CustomLabel; if (session != null && session.Background != Brushes.Red) { // If the DataObject contains string data, extract it. if (e.Data.GetDataPresent(DataFormats.StringFormat)) { string dataString = (string)e.Data.GetData(DataFormats.StringFormat); if (dataString != null) { string[] other = dataString.Split(';'); Session s = _controller.SessionMapper.Find(Convert.ToInt32(other[0])); Daytime d = _controller.DaytimeMapper.Find(GetSessionDate(session), Grid.GetRow(session)); if (d == null) { string[] date = GetSessionDate(session).Split('-'); d = new Daytime(0, new DateTime(Convert.ToInt32(date[2]), Convert.ToInt32(date[1]), Convert.ToInt32(date[0])), Grid.GetRow(session) + 1); d.Id = _controller.DaytimeMapper.Save(d); } s.Daytime = d; s.Classroom = _controller.ClassroomMapper.Find(Grid.GetColumn(session) + 1); addSession(s, false); removeSessionLabel(other[1], Convert.ToInt32(other[2]), Convert.ToInt32(other[3])); } } else { int id = (int)e.Data.GetData("System.Int32"); if (id != 0) { Session s = new Session(); Daytime d = _controller.DaytimeMapper.Find(GetSessionDate(session), Grid.GetRow(session)); if (d == null) { string[] date = GetSessionDate(session).Split('-'); d = new Daytime(0, new DateTime(Convert.ToInt32(date[2]), Convert.ToInt32(date[1]), Convert.ToInt32(date[0])), Grid.GetRow(session) + 1); d.Id = _controller.DaytimeMapper.Save(d); } s.Daytime = d; s.Classroom = _controller.ClassroomMapper.Find(Grid.GetColumn(session) + 1); s.Pair = _controller.PairMapper.Find(Convert.ToInt32(id)); addSession(s, true); } } revertCheckAvailability(); } }