protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { int assignedToNum = 0; if (e.NewValues["AssignedToEm.EmployeeNumber"] != null) { assignedToNum = Convert.ToInt32(e.NewValues["AssignedToEm.EmployeeNumber"].ToString()); } int tickNum = Convert.ToInt32(e.Keys["TicketNumber"].ToString()); if (assignedToNum != 0) //if ticket is re-assigned, reasign ticket. { TicketUtilities atn = new TicketUtilities(); atn.UpdateAssign(assignedToNum, tickNum, "Assigned"); } else //else (ticket unassigned will make it here, but wont go in the last if, so won't do anything. { string stat = (e.NewValues["Status"].ToString()); if (stat == "Cancelled" || stat == "Completed" || stat == "Submitted") { TicketUtilities tu = new TicketUtilities(); tu.UpdateStat(Convert.ToInt32(DropDownList1.SelectedValue), tickNum, stat); } } GridView1.EditIndex = -1; GridView1.DataBind(); }
//Submit button protected void btn1_Click(object sender, EventArgs e) { TicketUtilities tl = new TicketUtilities(); //updates display box lblOutput.Text = "Thank you for your submission"; //visible is changed depending on if employee exists //client can now enter new emp if (lblMessage.Visible) { Employee em = new Employee(Convert.ToInt32(txtEmpNum.Text), Convert.ToString(txtFN.Text), Convert.ToString(txtLN.Text), Convert.ToInt32(txtOfficeNum.Text), Convert.ToString(txtPhoneNum.Text), Convert.ToString(txtEmail.Text), Convert.ToString(DropDownList2.SelectedValue)); tl.InsertEmp(em); } Ticket t = new Ticket(Convert.ToInt32(txtEmpNum.Text), Convert.ToDateTime(txtDate.Text), Convert.ToString(DropDownList1.SelectedValue), Convert.ToString(txtIssueDesc.Text), "Submitted", 0); int tickNum = tl.InsertTicketNum(t); //clear all fields txtEmpNum.Text = ""; txtFN.Text = ""; txtLN.Text = ""; txtOfficeNum.Text = ""; txtPhoneNum.Text = ""; txtEmail.Text = ""; txtIssueDesc.Text = ""; //displays pin (ticketNumber) lblPinNum.Text = "Your Pin is:" + tickNum; }
//checks status from ticket pin protected void btuView_Click(object sender, EventArgs e) { TicketUtilities pinNum = new TicketUtilities(); Ticket ticket = pinNum.GetTicketByPin(Convert.ToInt32(txtPin.Text)); GridView1.Visible = true; GridView1.DataBind(); }
protected void DropDownList3_SelectedIndexChanged(object sender, EventArgs e) { //updates GridView1 with the new selected index TicketUtilities tu = new TicketUtilities(); List <Ticket> ti = tu.GetFilterByAssignedLN(Convert.ToInt32(DropDownList3.SelectedValue)); GridView1.DataSource = ti; GridView1.DataBind(); }
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { //updates GridView1 with the new selected index TicketUtilities tu = new TicketUtilities(); List <Ticket> ti = tu.GetFilterByStatus(DropDownList1.Text); GridView1.DataSource = ti; GridView1.DataBind(); }
protected void btuViewAll_Click(object sender, EventArgs e) { //updates GridView1 to select * (all) TicketUtilities tu = new TicketUtilities(); List <Ticket> ticks = TicketUtilities.GetAllTickets(); GridView1.DataSource = ticks; GridView1.DataBind(); }
private void CancelTrip_Click(object sender, RoutedEventArgs e) { if (cancelTrip.Flyout is Flyout f) { f.Hide(); } // Can only see this button if a trip is selected, so don't need // to check var db = new AirContext(); var user = db.Users.Include(dbuser => dbuser.CustInfo).Single(dbuser => dbuser.UserId == UserSession.userId); var SelectedTrip = TripList.SelectedItem as Trip; // If a flight has taken off already or will do so in less than an hour // we need to stop the cancellation DateTime inOneHour = DateTime.Now.AddHours(1); bool takenOff = false; foreach (Ticket ticket in SelectedTrip.Tickets) { var sf = ticket.Flight; DateTime departureTime = sf.DepartureTime; if (departureTime < inOneHour) { // This flight has already taken off or will in the next hour takenOff = true; } } if (takenOff || SelectedTrip.IsCanceled) { // Not allowed to cancel, so display an error OutputInfo.Title = "No cancellation possible"; OutputInfo.Message = "One or more of your flights has already taken off, or will in less than an hour, so you cannot cancel this trip"; OutputInfo.Severity = InfoBarSeverity.Error; OutputInfo.IsOpen = true; // and return return; } // cancel the trip TicketUtilities.CancelTrip(SelectedTrip, user); // and display a message saying we did to the user OutputInfo.Title = "Flight Cancelled!"; OutputInfo.Message = "Your trip was successfully cancelled!"; OutputInfo.Severity = InfoBarSeverity.Success; OutputInfo.IsOpen = true; }
//retrieves pin by email protected void btnEnter_Click(object sender, EventArgs e) { TicketUtilities tu = new TicketUtilities(); string em = Convert.ToString(txtRetrieve.Text); List <Ticket> email = tu.GetPinByEmail(em); if (email.Count != 0) { GridView2.Visible = true; GridView2.DataBind(); } else { lblPin.Text = "Email address doesn't exist. Please try again!"; } }
//Continue button protected void btnAutoFill_Click(object sender, EventArgs e) { //populates text boxes based on Employee Number. Doesn't check if box is empty. txtFN.Enabled = true; txtLN.Enabled = true; txtOfficeNum.Enabled = true; txtPhoneNum.Enabled = true; txtEmail.Enabled = true; TicketUtilities tu = new TicketUtilities(); int num = 0; //This was catching error, might be cause converting empty string to num. Going to catch. try{ num = Convert.ToInt32(txtEmpNum.Text); } catch (FormatException fe) { if (fe.Source != null) { lblOutput.Text = ("IOException: " + fe.Message); } throw; } Employee emp = tu.GetEmpNum(num); if (emp != null)//if the record in database Employees table exists { txtFN.Text = emp.FirstName; txtLN.Text = emp.LastName; txtOfficeNum.Text = (emp.OfficeNumber).ToString(); txtPhoneNum.Text = emp.PhoneNumber; txtEmail.Text = emp.EMail; DropDownList2.SelectedValue = emp.JobDescription; lblMessage.Visible = false; //lblmessage is for createing new employee } else { lblMessage.Text = "The Employee Number does not exist. Enter info to create new Employee"; lblMessage.Visible = true; } }
//editing currently doesn't work. protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e) { //When client changes status of ticket GridView1.EditIndex = e.NewEditIndex; TicketUtilities tu = new TicketUtilities(); //populates new temporary dropdownlist with 5 options DropDownList ddl1 = ((DropDownList)GridView1.Rows[e.NewEditIndex].FindControl("DropDownList4")); ddl1.Items.Add("Unassigned"); ddl1.Items.Add("Assigned"); ddl1.Items.Add("Completed"); ddl1.Items.Add("Submitted"); ddl1.Items.Add("Canceled"); //creates another drop down list of clients to re-assign ticket DropDownList ddl = ((DropDownList)GridView1.Rows[e.NewEditIndex].FindControl("DropDownList5")); ddl.DataTextField = "LastName"; ddl.DataValueField = "EmployeeNumber"; ddl.DataSource = tu.GetAllAssignedLastName(); ddl.DataBind(); }
//Page_PreRender protected void Page_PreRender(object sender, EventArgs e) { if (!IsPostBack) { TicketUtilities tu = new TicketUtilities(); //Populates and databinds dropdown boxes... //DropDownList1 = Status DropDownList1.DataSource = tu.GetAllStatus(); DropDownList1.DataBind(); DropDownList1.Items.Insert(0, "Filter by Status"); //DropDownList1 = Submitted Last Name DropDownList2.DataTextField = "LastName"; DropDownList2.DataValueField = "EmployeeNumber"; DropDownList2.DataSource = tu.GetAllLastName(); DropDownList2.DataBind(); DropDownList2.Items.Insert(0, new ListItem("Filter Submitted by Last Name", "-1")); //DropDownList1 = AssignedTo by LastName DropDownList3.DataTextField = "LastName"; DropDownList3.DataValueField = "EmployeeNumber"; DropDownList3.DataSource = tu.GetAllAssignedLastName(); DropDownList3.DataBind(); DropDownList3.Items.Insert(0, new ListItem("Filter AssignedTo by Last Name", "-1")); } }