//for filter by Training status private static void LoadObjectForStatus(TrainingType Type, ref List<Listing> output, string SelectedValue, BookedEvent bk, PrebookedEvent pk) { Listing newList = new Listing(); Staff staff = new Staff(); Staff supervisor = new Staff(); string TrainingName = ""; switch (Type) { case TrainingType.Book: staff = Staff.getStaffInfo(bk.StaffUsername); if (staff != null) { newList.StaffID = staff.StaffID; newList.StaffName = staff.Name.ToUpper(); } supervisor = Staff.GetSupervisorByUsername(staff.Username); if (supervisor != null) { newList.SupervisorName = supervisor.Name.ToUpper(); } else { newList.SupervisorName = "NOT DEFINED"; } newList.ApplicationType = "BOOK"; TrainingName = EventGroup.getTitle(bk.EventId); if (TrainingName != null || TrainingName != "") newList.Title = TrainingName.ToUpper(); newList.DateRequest = bk.RequestDate; newList.Status = SelectedValue.ToUpper(); if (bk.SAPStatus == 0) newList.PostedSAPStatus = "PENDING"; if (bk.SAPStatus == 2) newList.PostedSAPStatus = "POSTED"; output.Add(newList); break; case TrainingType.Prebook: staff = Staff.getStaffInfo(pk.StaffUsername); if (staff != null) { newList.StaffID = staff.StaffID; newList.StaffName = staff.Name.ToUpper(); } supervisor = Staff.GetSupervisorByUsername(staff.Username); if (supervisor != null) { newList.SupervisorName = supervisor.Name.ToUpper(); } else { newList.SupervisorName = "NOT DEFINED"; } newList.ApplicationType = "PREBOOK"; TrainingName = EventGroup.getTitle(pk.EventId); if (TrainingName != null || TrainingName != "") newList.Title = TrainingName.ToUpper(); newList.DateRequest = pk.RequestDate; newList.Status = SelectedValue.ToUpper(); if (pk.SAPStatus == 0) newList.PostedSAPStatus = "PENDING"; if (pk.SAPStatus == 2) newList.PostedSAPStatus = "POSTED"; output.Add(newList); break; } }
public void LoadAll(TrainingType Type, string TrainingName, BookedEvent booked, PrebookedEvent prebooked) { Staff staff = new Staff(); Staff supervisor = new Staff(); switch (Type) { case TrainingType.Prebook: DateRequest = prebooked.RequestDate; staff = Staff.getStaffInfo(prebooked.StaffUsername); if (staff != null) { StaffID = staff.StaffID; StaffName = staff.Name; } supervisor = Staff.GetSupervisorByUsername(prebooked.StaffUsername); if (supervisor != null) { SupervisorName = supervisor.Name.ToUpper(); } else { SupervisorName = "NOT DEFINED"; } ApplicationType = "PREBOOK"; Title = TrainingName.ToUpper(); Status = getTrainingStatus(prebooked.Stage, prebooked.SAPStatus, TrainingType.Prebook); if (prebooked.SAPStatus == 1) PostedSAPStatus = "PENDING"; if (prebooked.SAPStatus == 2) PostedSAPStatus = "POSTED"; break; case TrainingType.Book: DateRequest = booked.RequestDate; staff = Staff.getStaffInfo(booked.StaffUsername); if (staff != null) { StaffID = staff.StaffID; StaffName = staff.Name; } supervisor = Staff.GetSupervisorByUsername(booked.StaffUsername); if (supervisor != null) { SupervisorName = supervisor.Name.ToUpper(); } else { SupervisorName = "NOT DEFINED"; } ApplicationType = "BOOK"; Title = TrainingName.ToUpper(); Status = getTrainingStatus(booked.Stage, booked.SAPStatus, TrainingType.Book); if (booked.SAPStatus == 0) PostedSAPStatus = "PENDING"; if (booked.SAPStatus == 2) PostedSAPStatus = "POSTED"; break; } }
protected void btnConfirm_Click(object sender, EventArgs e) { // validate that dates have been selected if (HasUnselectedDates()) { ShowMessage("Please select a date for all the events you are confirming."); return; } using(UtilityDb db = new UtilityDb()) { db.OpenConnectionESS(); db.PrepareInsert("REQ_BookedEvents"); foreach (GridViewRow row in gvEvents.Rows) { CheckBox cb = (CheckBox)row.Cells[0].FindControl("chkSelect"); if (cb.Checked) { RadioButtonList rbEventDates = (RadioButtonList)row.Cells[ColumnEventDates].FindControl("rbEventDates"); int eventDateId = Convert.ToInt32(rbEventDates.SelectedValue); string staffUsername = gvEvents.DataKeys[row.RowIndex].Values["StaffUsername"].ToString(); int eventId = Convert.ToInt32(gvEvents.DataKeys[row.RowIndex].Values["EventId"].ToString()); Staff staff = Staff.GetFromUsername(staffUsername); Staff supervisor = staff.GetSupervisor(); // check whether a booking already exists for this event date List<BookedEvent> existing = BookedEvent.GetAll(staffUsername, null); bool exists = false; foreach (BookedEvent be in existing) { if (be.EventDateId == eventDateId) { exists = true; break; } } // not found? convert to booked event if (!exists) { BookedEvent be = new BookedEvent(); be.RequestDate = DateTime.Now; be.StaffUsername = staffUsername; be.RequesterUsername = staffUsername; be.Stage = 1; // submit to supervisor be.EventDateId = eventDateId; be.EventId = eventId; DataRow dataRow = db.Insert(null); be.Save(dataRow); db.Insert(dataRow); // send notification to supervisor List<EventDate> lstEd= new List<EventDate>(); EventDate ed = EventDate.GetFromId(eventDateId); lstEd.Add(ed); BookingEventSelector.SendNotificationEmail(lstEd, Server, staffUsername); } // delete from db AttendanceConfirmation.Delete(staffUsername, eventId); } db.EndInsert(); } } ShowEvents(); string sScript0 = "window.alert('Your Prebook(s) Training confirmed and submitted.');"; ScriptManager.RegisterClientScriptBlock(Page, GetType(), "Prebook.aspx", sScript0, true); return; }
public static List<BookedEvent> GetAll(string staffUsername, int? stage) { List<BookedEvent> output = new List<BookedEvent>(); using (SqlConnection conn = UtilityDb.GetConnectionESS()) { string sql = string.Format("SELECT * FROM REQ_BookedEvents WHERE UPPER(StaffUsername)='{0}'", staffUsername.ToUpper()); if (stage.HasValue) sql += " AND stage=" + stage.Value; SqlDataReader dr = UtilityDb.GetDataReader(sql, conn); while (dr.Read()) { BookedEvent obj = new BookedEvent(); obj.LoadFromReader(dr); output.Add(obj); } } return output; }
internal static List<BookedEvent> getByUsername(string Username) { List<BookedEvent> output = new List<BookedEvent>(); using (SqlConnection conn = UtilityDb.GetConnectionESS()) { string sql = string.Format("SELECT * FROM REQ_BookedEvents WHERE UPPER(StaffUsername)='{0}'", Username.ToUpper()); SqlDataReader dr = UtilityDb.GetDataReader(sql, conn); while (dr.Read()) { BookedEvent obj = new BookedEvent(); obj.LoadFromReader(dr); output.Add(obj); } } return output; }
internal static List<BookedEvent> getByEventID(int SelectedID) { List<BookedEvent> output = new List<BookedEvent>(); using (SqlConnection conn = UtilityDb.GetConnectionESS()) { string sql = string.Format("SELECT * FROM REQ_BookedEvents WHERE EventID={0}", SelectedID); SqlDataReader dr = UtilityDb.GetDataReader(sql, conn); while (dr.Read()) { BookedEvent be = new BookedEvent(); be.LoadFromReader(dr); output.Add(be); } } return output; }
internal static List<BookedEvent> GetAll() { List<BookedEvent> output = new List<BookedEvent>(); using (SqlConnection conn = UtilityDb.GetConnectionESS()) { string sql = string.Format("SELECT * FROM REQ_BookedEvents"); SqlDataReader dr = UtilityDb.GetDataReader(sql, conn); while (dr.Read()) { BookedEvent obj = new BookedEvent(); obj.LoadFromReader(dr); output.Add(obj); } } return output; }
public static BookedEvent GetByEventDateId(string staffUsername, int eventDateId) { using (SqlConnection conn = UtilityDb.GetConnectionESS()) { string sql = "SELECT * FROM REQ_BookedEvents WHERE UPPER(StaffUsername)='" + staffUsername.ToUpper() + "' AND EventDateId=" + eventDateId.ToString(); SqlDataReader dr = UtilityDb.GetDataReader(sql, conn); while (dr.Read()) { BookedEvent output = new BookedEvent(); output.LoadFromReader(dr); return output; } } return null; }