// //////////////////////////////////////////////////////////////////////// // 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"]; } }
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(); } } }
/// <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); } } } }