/// <summary> /// Save /// </summary> /// <param name="companyId">companyId</param> public void Save(int companyId) { SupportTicketInformationTDS toDoListInformationChanges = (SupportTicketInformationTDS)Data.GetChanges(); if (toDoListInformationChanges != null) { if (toDoListInformationChanges.BasicInformation.Rows.Count > 0) { SupportTicketInformationBasicInformationGateway toDoListInformationBasicInformationGateway = new SupportTicketInformationBasicInformationGateway(toDoListInformationChanges); // Update to do foreach (SupportTicketInformationTDS.BasicInformationRow row in (SupportTicketInformationTDS.BasicInformationDataTable)toDoListInformationChanges.BasicInformation) { // Unchanged values int supportTicketId = row.SupportTicketID; int categoryId = row.CategoryID; string subject = toDoListInformationBasicInformationGateway.GetSubject(supportTicketId); DateTime creationDate = toDoListInformationBasicInformationGateway.GetCreationDate(supportTicketId); int createdById = toDoListInformationBasicInformationGateway.GetCreatedByID(supportTicketId); // Original values DateTime? originalDueDate = null; if (toDoListInformationBasicInformationGateway.GetDueDateOriginal(supportTicketId).HasValue) originalDueDate = (DateTime)toDoListInformationBasicInformationGateway.GetDueDateOriginal(supportTicketId); string originalState = toDoListInformationBasicInformationGateway.GetStateOriginal(supportTicketId); // New variables DateTime? newDueDate = null; if (toDoListInformationBasicInformationGateway.GetDueDate(supportTicketId).HasValue) newDueDate = (DateTime)toDoListInformationBasicInformationGateway.GetDueDate(supportTicketId); string newState = toDoListInformationBasicInformationGateway.GetState(supportTicketId); SupportTicketSupportTicket toDoListSupportTicket = new SupportTicketSupportTicket(null); toDoListSupportTicket.UpdateDirect(supportTicketId, categoryId, subject, creationDate, createdById, originalState, originalDueDate, row.Deleted, row.COMPANY_ID, supportTicketId, categoryId, subject, creationDate, createdById, newState, newDueDate, row.Deleted, row.COMPANY_ID); } } } }
private void LoadData(int supportTicketId) { SupportTicketInformationBasicInformationGateway supportTicketInformationBasicInformationGateway = new SupportTicketInformationBasicInformationGateway(supportTicketInformationTDS); if (supportTicketInformationBasicInformationGateway.Table.Rows.Count > 0) { // Load to do Details int companyId = Int32.Parse(hdfCompanyId.Value); int createdById = supportTicketInformationBasicInformationGateway.GetCreatedByID(supportTicketId); hdfCreatedById.Value = createdById.ToString(); EmployeeGateway employeeGateway = new EmployeeGateway(); employeeGateway.LoadByEmployeeId(createdById); tbxCreatedBy.Text = employeeGateway.GetFullName(createdById); tbxCreationDate.Text = supportTicketInformationBasicInformationGateway.GetCreationDate(supportTicketId).ToString(); tbxState.Text = supportTicketInformationBasicInformationGateway.GetState(supportTicketId); tbxCategoryName.Text = supportTicketInformationBasicInformationGateway.GetCategoryName(supportTicketId); if (supportTicketInformationBasicInformationGateway.GetDueDate(supportTicketId).HasValue) { DateTime dueDateValue = (DateTime)supportTicketInformationBasicInformationGateway.GetDueDate(supportTicketId); tbxDueDate.Text = dueDateValue.Month.ToString() + "/" + dueDateValue.Day.ToString() + "/" + dueDateValue.Year.ToString(); } } }
// //////////////////////////////////////////////////////////////////////// // EVENTS // protected void Page_Load(object sender, EventArgs e) { // Register client scripts this.RegisterClientScripts(); if (!IsPostBack) { // Security check if (!(Convert.ToBoolean(Session["sgLFS_ITTST_SUPPORTTICKET_ADMIN"]))) { if (!(Convert.ToBoolean(Session["sgLFS_ITTST_SUPPORTTICKET_VIEW"]) && Convert.ToBoolean(Session["sgLFS_ITTST_SUPPORTTICKET_EDIT"]))) { Response.Redirect("./../../error_page.aspx?error=" + "You are not authorized to view this page. Contact your system administrator."); } } // Validate query string if (((string)Request.QueryString["source_page"] == null) || ((string)Request.QueryString["supportTicket_id"] == null) || ((string)Request.QueryString["action"] == null)) { Response.Redirect("./../../error_page.aspx?error=" + "Invalid query string in supportTicket_activity.aspx"); } // Tag Page hdfCompanyId.Value = Session["companyID"].ToString(); hdfSupportTicketId.Value = Request.QueryString["supportTicket_id"].ToString(); hdfAction.Value = Request.QueryString["action"].ToString(); hdfDashboard.Value = Request.QueryString["dashboard"].ToString(); // If coming from int companyId = Int32.Parse(hdfCompanyId.Value.Trim()); int currentSupportTicketId = Int32.Parse(hdfSupportTicketId.Value.ToString()); Session.Remove("activityInformationDummyForST"); // ... supportTicket_navigator2.aspx if (Request.QueryString["source_page"] == "supportTicket_navigator2.aspx") { StoreNavigatorState(); supportTicketInformationTDS = new SupportTicketInformationTDS(); activityInformation = new SupportTicketInformationTDS.ActivityInformationDataTable(); SupportTicketInformationBasicInformation supportTicketInformationBasicInformation = new SupportTicketInformationBasicInformation(supportTicketInformationTDS); supportTicketInformationBasicInformation.LoadAllBySupportTicketId(currentSupportTicketId, companyId); SupportTicketInformationBasicInformationGateway supportTicketInformationBasicInformationGatewayForState = new SupportTicketInformationBasicInformationGateway(supportTicketInformationBasicInformation.Data); string state = supportTicketInformationBasicInformationGatewayForState.GetState(currentSupportTicketId); if (state == "Completed") hdfCompleted.Value = "True"; SupportTicketInformationActivityInformation supportTicketInformationActivityInformation = new SupportTicketInformationActivityInformation(supportTicketInformationTDS); supportTicketInformationActivityInformation.LoadAllBySupportTicketId(currentSupportTicketId, companyId); // Store dataset Session["supportTicketInformationTDS"] = supportTicketInformationTDS; Session["activityInformationForST"] = activityInformation; } // ... supportTicket_summary.aspx or supportTicket_edit.aspx if ((Request.QueryString["source_page"] == "supportTicket_summary.aspx") || (Request.QueryString["source_page"] == "supportTicket_edit.aspx")) { StoreNavigatorState(); ViewState["update"] = Request.QueryString["update"]; // Restore dataset supportTicketInformationTDS = (SupportTicketInformationTDS)Session["supportTicketInformationTDS"]; activityInformation = (SupportTicketInformationTDS.ActivityInformationDataTable)Session["activityInformationForST"]; if (ViewState["update"].ToString().Trim() == "yes") { SupportTicketInformationBasicInformation supportTicketInformationBasicInformation = new SupportTicketInformationBasicInformation(supportTicketInformationTDS); supportTicketInformationBasicInformation.LoadAllBySupportTicketId(currentSupportTicketId, companyId); SupportTicketInformationBasicInformationGateway supportTicketInformationBasicInformationGatewayForState = new SupportTicketInformationBasicInformationGateway(supportTicketInformationBasicInformation.Data); string state = supportTicketInformationBasicInformationGatewayForState.GetState(currentSupportTicketId); if (state == "Completed") hdfCompleted.Value = "True"; SupportTicketInformationActivityInformation supportTicketInformationActivityInformation = new SupportTicketInformationActivityInformation(supportTicketInformationTDS); supportTicketInformationActivityInformation.LoadAllBySupportTicketId(currentSupportTicketId, companyId); // Store dataset Session["supportTicketInformationTDS"] = supportTicketInformationTDS; Session["activityInformationForST"] = activityInformation; } } // Prepare initial data // ... for subject SupportTicketInformationBasicInformationGateway supportTicketInformationBasicInformationGateway = new SupportTicketInformationBasicInformationGateway(); supportTicketInformationBasicInformationGateway.LoadAllBySupportTicketId(currentSupportTicketId, companyId); lblTitleSubjectName.Text = " " + supportTicketInformationBasicInformationGateway.GetSubject(currentSupportTicketId); // ... Data for current to do list LoadSupportTicketData(currentSupportTicketId, companyId); } else { // Restore datasets supportTicketInformationTDS = (SupportTicketInformationTDS)Session["supportTicketInformationTDS"]; activityInformation = (SupportTicketInformationTDS.ActivityInformationDataTable)Session["activityInformationForST"]; } }
protected void grdSupportTicket_RowDataBound(object sender, GridViewRowEventArgs e) { // Control of footer row if (e.Row.RowType == DataControlRowType.Footer) { int loginId = Convert.ToInt32(Session["loginID"]); EmployeeGateway employeeGateway = new EmployeeGateway(); int employeeId = employeeGateway.GetEmployeIdByLoginId(loginId); // Select action DropDownList actions = (DropDownList)e.Row.FindControl("ddlActionsNew"); actions.SelectedValue = hdfAction.Value; // Only the assigned user could close the todo if (hdfAssignedUser.Value != employeeId.ToString()) { actions.Items.Remove("Close"); } // Make fields visible for actions if (hdfAction.Value == "Assign To User") { ((DropDownList)e.Row.FindControl("ddlAssignToTeamMemberNew")).Visible = true; ((CustomValidator)e.Row.FindControl("cvTeamMemberNew")).Visible = true; ((TextBox)e.Row.FindControl("tbxUserNew")).Visible = false; ((Label)e.Row.FindControl("lblClosed")).Visible = false; ((Label)e.Row.FindControl("lblUserNew")).Text = "Assign To"; } // Make fields visible for actions if (hdfAction.Value == "Assign To Owner") { ((DropDownList)e.Row.FindControl("ddlAssignToTeamMemberNew")).Visible = true; ((CustomValidator)e.Row.FindControl("cvTeamMemberNew")).Visible = true; ((TextBox)e.Row.FindControl("tbxUserNew")).Visible = false; ((Label)e.Row.FindControl("lblClosed")).Visible = false; ((Label)e.Row.FindControl("lblUserNew")).Text = "Assign To"; int currentSupportTicketId = Int32.Parse(hdfSupportTicketId.Value.ToString()); SupportTicketInformationBasicInformationGateway supportTicketInformationBasicInformationGatewayForState = new SupportTicketInformationBasicInformationGateway(supportTicketInformationTDS); int ownerId = supportTicketInformationBasicInformationGatewayForState.GetCreatedByID(currentSupportTicketId); ((DropDownList)e.Row.FindControl("ddlAssignToTeamMemberNew")).SelectedValue = ownerId.ToString(); ((DropDownList)e.Row.FindControl("ddlAssignToTeamMemberNew")).Enabled = false; } if (hdfAction.Value == "Add Comment") { ((DropDownList)e.Row.FindControl("ddlAssignToTeamMemberNew")).Visible = false; ((CustomValidator)e.Row.FindControl("cvTeamMemberNew")).Visible = false; ((TextBox)e.Row.FindControl("tbxUserNew")).Visible = true; EmployeeGateway employeeGatewayForUser = new EmployeeGateway(); employeeGatewayForUser.LoadByEmployeeId(employeeId); ((TextBox)e.Row.FindControl("tbxUserNew")).Text = employeeGatewayForUser.GetFullName(employeeId); ((Label)e.Row.FindControl("lblClosed")).Visible = false; ((Label)e.Row.FindControl("lblUserNew")).Text = "Comment Added By"; } if (hdfAction.Value == "Complete") { ((DropDownList)e.Row.FindControl("ddlAssignToTeamMemberNew")).Visible = false; ((CustomValidator)e.Row.FindControl("cvTeamMemberNew")).Visible = false; ((TextBox)e.Row.FindControl("tbxUserNew")).Visible = true; EmployeeGateway employeeGatewayForUser = new EmployeeGateway(); employeeGatewayForUser.LoadByEmployeeId(Int32.Parse(hdfAssignedUser.Value)); ((TextBox)e.Row.FindControl("tbxUserNew")).Text = employeeGatewayForUser.GetFullName(Int32.Parse(hdfAssignedUser.Value)); ((Label)e.Row.FindControl("lblClosed")).Visible = false; ((Label)e.Row.FindControl("lblUserNew")).Text = "Support Ticket Completed By"; } if (hdfCompleted.Value == "True") { ((DropDownList)e.Row.FindControl("ddlActionsNew")).Visible = false; ((TextBox)e.Row.FindControl("tbxDateTimeNew")).Visible = false; ((DropDownList)e.Row.FindControl("ddlAssignToTeamMemberNew")).Visible = false; ((CustomValidator)e.Row.FindControl("cvTeamMemberNew")).Visible = false; ((TextBox)e.Row.FindControl("tbxUserNew")).Visible = false; ((TextBox)e.Row.FindControl("tbxCommentsNew")).Visible = false; ((Label)e.Row.FindControl("lblActionNew")).Visible = false; ((Label)e.Row.FindControl("lblDateTimeNew")).Visible = false; ((Label)e.Row.FindControl("lblUserNew")).Visible = false; ((Label)e.Row.FindControl("lblCommentsNew")).Visible = false; ((ImageButton)e.Row.FindControl("ibtnAdd")).Visible = false; ((Label)e.Row.FindControl("lblClosed")).Visible = true; } if (hdfAction.Value == "Put On Hold") { ((DropDownList)e.Row.FindControl("ddlAssignToTeamMemberNew")).Visible = false; ((CustomValidator)e.Row.FindControl("cvTeamMemberNew")).Visible = false; ((TextBox)e.Row.FindControl("tbxUserNew")).Visible = true; EmployeeGateway employeeGatewayForOnHold = new EmployeeGateway(); employeeGatewayForOnHold.LoadByEmployeeId(employeeId); ((TextBox)e.Row.FindControl("tbxUserNew")).Text = employeeGatewayForOnHold.GetFullName(employeeId); ((Label)e.Row.FindControl("lblClosed")).Visible = false; ((Label)e.Row.FindControl("lblUserNew")).Text = "On Hold By"; } // Date and time DateTime creationDate = DateTime.Now; ((TextBox)e.Row.FindControl("tbxDateTimeNew")).Text = creationDate.ToString(); } // Control of edit rows if ((e.Row.RowType == DataControlRowType.DataRow) && ((e.Row.RowState == DataControlRowState.Edit) || (e.Row.RowState == (DataControlRowState.Edit | DataControlRowState.Alternate)))) { // Date and time DateTime creationDate = DateTime.Now; ((TextBox)e.Row.FindControl("tbxDateTimeEdit")).Text = creationDate.ToString(); string type_ = ((Label)e.Row.FindControl("lblType")).Text; int loginId = Convert.ToInt32(Session["loginID"]); EmployeeGateway employeeGateway = new EmployeeGateway(); int employeeId = employeeGateway.GetEmployeIdByLoginId(loginId); int supportTicketId = Int32.Parse(((Label)e.Row.FindControl("lblSupportTicketID")).Text); int refId = Int32.Parse(((Label)e.Row.FindControl("lblRefID")).Text); SupportTicketInformationActivityInformationGateway supportTicketInformationActivityInformationGateway = new SupportTicketInformationActivityInformationGateway(supportTicketInformationTDS); // Make fields visible for actions if (type_ == "AssignUser") { int employeeIdForAssign = supportTicketInformationActivityInformationGateway.GetEmployeeID(supportTicketId, refId); ((DropDownList)e.Row.FindControl("ddlAssignToTeamMemberEdit")).Visible = true; ((DropDownList)e.Row.FindControl("ddlAssignToTeamMemberEdit")).SelectedValue = employeeIdForAssign.ToString(); ((CustomValidator)e.Row.FindControl("cvTeamMemberEdit")).Visible = true; ((TextBox)e.Row.FindControl("tbxUserEdit")).Visible = false; ((Label)e.Row.FindControl("lblUserEdit")).Text = "Assign To"; } if (type_ == "AddComment") { ((DropDownList)e.Row.FindControl("ddlAssignToTeamMemberEdit")).Visible = false; ((CustomValidator)e.Row.FindControl("cvTeamMemberEdit")).Visible = false; ((TextBox)e.Row.FindControl("tbxUserEdit")).Visible = true; EmployeeGateway employeeGatewayForUser = new EmployeeGateway(); employeeGatewayForUser.LoadByEmployeeId(employeeId); ((TextBox)e.Row.FindControl("tbxUserEdit")).Text = employeeGatewayForUser.GetFullName(employeeId); ((Label)e.Row.FindControl("lblUserEdit")).Text = "Comment Added By"; } if (type_ == "CloseTicket") { ((DropDownList)e.Row.FindControl("ddlAssignToTeamMemberEdit")).Visible = false; ((CustomValidator)e.Row.FindControl("cvTeamMemberEdit")).Visible = false; ((TextBox)e.Row.FindControl("tbxUserEdit")).Visible = true; EmployeeGateway employeeGatewayForUser = new EmployeeGateway(); employeeGatewayForUser.LoadByEmployeeId(Int32.Parse(hdfAssignedUser.Value)); ((TextBox)e.Row.FindControl("tbxUserEdit")).Text = employeeGatewayForUser.GetFullName(Int32.Parse(hdfAssignedUser.Value)); ((Label)e.Row.FindControl("lblUserEdit")).Text = "Support Ticket Completed By"; } if (type_ == "OnHold") { ((DropDownList)e.Row.FindControl("ddlAssignToTeamMemberEdit")).Visible = false; ((CustomValidator)e.Row.FindControl("cvTeamMemberEdit")).Visible = false; ((TextBox)e.Row.FindControl("tbxUserEdit")).Visible = true; EmployeeGateway employeeGatewayForOnHold = new EmployeeGateway(); employeeGatewayForOnHold.LoadByEmployeeId(employeeId); ((TextBox)e.Row.FindControl("tbxUserEdit")).Text = employeeGatewayForOnHold.GetFullName(employeeId); ((Label)e.Row.FindControl("lblUserEdit")).Text = "On Hold By"; } } // Control normal rows if ((e.Row.RowType == DataControlRowType.DataRow) && ((e.Row.RowState == DataControlRowState.Normal) || (e.Row.RowState == (DataControlRowState.Normal | DataControlRowState.Alternate)))) { // Validate admin actions if ((Convert.ToBoolean(Session["sgLFS_ITTST_SUPPORTTICKET_ADMIN"]))) { ((ImageButton)e.Row.FindControl("ibtnEdit")).Visible = true; ((ImageButton)e.Row.FindControl("ibtnDelete")).Visible = true; } else { bool inDataBase = bool.Parse(((Label)e.Row.FindControl("lblInDataBase")).Text); if (inDataBase) { ((ImageButton)e.Row.FindControl("ibtnEdit")).Visible = false; ((ImageButton)e.Row.FindControl("ibtnDelete")).Visible = false; } else { ((ImageButton)e.Row.FindControl("ibtnEdit")).Visible = true; ((ImageButton)e.Row.FindControl("ibtnDelete")).Visible = true; } } // Change label text string type_ = ((Label)e.Row.FindControl("lblType")).Text; if (type_ == "AssignUser") { ((Label)e.Row.FindControl("lblUser")).Text = "Assign To"; } if (type_ == "AddComment") { ((Label)e.Row.FindControl("lblUser")).Text = "Comment Added By"; } if (type_ == "CloseTicket") { ((Label)e.Row.FindControl("lblUser")).Text = "Support Ticket Completed By"; } if (type_ == "OnHold") { ((Label)e.Row.FindControl("lblUser")).Text = "On Hold By"; } } }
protected void ddlActionsNew_SelectedIndexChanged(object sender, EventArgs e) { GridViewRow row = grdSupportTicket.FooterRow; DropDownList action = ((DropDownList)row.FindControl("ddlActionsNew")); switch (action.SelectedValue) { case "Assign To User": ((DropDownList)row.FindControl("ddlAssignToTeamMemberNew")).Visible = true; ((CustomValidator)row.FindControl("cvTeamMemberNew")).Visible = true; ((TextBox)row.FindControl("tbxUserNew")).Visible = false; ((Label)row.FindControl("lblUserNew")).Text = "Assign To"; break; case "Assign To Owner": ((DropDownList)row.FindControl("ddlAssignToTeamMemberNew")).Visible = true; ((CustomValidator)row.FindControl("cvTeamMemberNew")).Visible = true; ((TextBox)row.FindControl("tbxUserNew")).Visible = false; ((Label)row.FindControl("lblUserNew")).Text = "Assign To"; int currentSupportTicketId = Int32.Parse(hdfSupportTicketId.Value.ToString()); SupportTicketInformationBasicInformationGateway supportTicketInformationBasicInformationGatewayForState = new SupportTicketInformationBasicInformationGateway(supportTicketInformationTDS); int ownerId = supportTicketInformationBasicInformationGatewayForState.GetCreatedByID(currentSupportTicketId); ((DropDownList)row.FindControl("ddlAssignToTeamMemberNew")).SelectedValue = ownerId.ToString(); ((DropDownList)row.FindControl("ddlAssignToTeamMemberNew")).Enabled = false; break; case "Add Comment": int loginId = Convert.ToInt32(Session["loginID"]); EmployeeGateway employeeGateway = new EmployeeGateway(); int employeeId = employeeGateway.GetEmployeIdByLoginId(loginId); ((DropDownList)row.FindControl("ddlAssignToTeamMemberNew")).Visible = false; ((CustomValidator)row.FindControl("cvTeamMemberNew")).Visible = false; ((TextBox)row.FindControl("tbxUserNew")).Visible = true; ((Label)row.FindControl("lblUserNew")).Text = "Comment Added By"; EmployeeGateway employeeGatewayForUser = new EmployeeGateway(); employeeGatewayForUser.LoadByEmployeeId(employeeId); ((TextBox)row.FindControl("tbxUserNew")).Text = employeeGatewayForUser.GetFullName(employeeId); break; case "Complete": ((DropDownList)row.FindControl("ddlAssignToTeamMemberNew")).Visible = false; ((CustomValidator)row.FindControl("cvTeamMemberNew")).Visible = false; ((TextBox)row.FindControl("tbxUserNew")).Visible = true; ((Label)row.FindControl("lblUserNew")).Text = "Support Ticket Completed By"; EmployeeGateway employeeGatewayForUserComplete = new EmployeeGateway(); employeeGatewayForUserComplete.LoadByEmployeeId(Int32.Parse(hdfAssignedUser.Value)); ((TextBox)row.FindControl("tbxUserNew")).Text = employeeGatewayForUserComplete.GetFullName(Int32.Parse(hdfAssignedUser.Value)); break; case "Put On Hold": int loginIdOnHold = Convert.ToInt32(Session["loginID"]); EmployeeGateway employeeGatewayOnHold = new EmployeeGateway(); int employeeIdOnHold = employeeGatewayOnHold.GetEmployeIdByLoginId(loginIdOnHold); ((DropDownList)row.FindControl("ddlAssignToTeamMemberNew")).Visible = false; ((CustomValidator)row.FindControl("cvTeamMemberNew")).Visible = false; ((TextBox)row.FindControl("tbxUserNew")).Visible = true; ((Label)row.FindControl("lblUserNew")).Text = "On Hold By"; EmployeeGateway employeeGatewayForOnHold = new EmployeeGateway(); employeeGatewayForOnHold.LoadByEmployeeId(employeeIdOnHold); ((TextBox)row.FindControl("tbxUserNew")).Text = employeeGatewayForOnHold.GetFullName(employeeIdOnHold); break; } }
// //////////////////////////////////////////////////////////////////////// // PUBLIC METHODS // /// <summary> /// LoadAllBySupportTicketId /// </summary> /// <param name="supportTicketId">supportTicketId</param> /// <param name="companyId">companyId</param> public void LoadAllBySupportTicketId(int supportTicketId, int companyId) { SupportTicketInformationBasicInformationGateway toDoListInformationBasicInformationGateway = new SupportTicketInformationBasicInformationGateway(Data); toDoListInformationBasicInformationGateway.LoadAllBySupportTicketId(supportTicketId, companyId); }