// //////////////////////////////////////////////////////////////////////// // EVENTS // protected void Page_Load(object sender, EventArgs e) { // Register client scripts this.RegisterClientScripts(); if (!IsPostBack) { // Security check if (!(Convert.ToBoolean(Session["sgLFS_FLEETMANAGEMENT_SERVICES_VIEW"]) && Convert.ToBoolean(Session["sgLFS_FLEETMANAGEMENT_SERVICES_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["service_id"] == null) || ((string)Request.QueryString["active_tab"] == null) || ((string)Request.QueryString["dashboard"] == null)) { Response.Redirect("./../../error_page.aspx?error=" + "Invalid query string in services_edit.aspx"); } // Tag Page hdfCompanyId.Value = Session["companyID"].ToString(); hdfFmType.Value = "Services"; hdfServiceId.Value = Request.QueryString["service_id"].ToString(); hdfActiveTab.Value = Request.QueryString["active_tab"].ToString(); hdfLoginId.Value = Convert.ToInt32(Session["loginID"]).ToString(); hdfDashboard.Value = Request.QueryString["dashboard"].ToString(); // Prepare initial data Session.Remove("serviceCostsDummy"); Session.Remove("serviceNotesDummy"); // If coming from int companyId = Int32.Parse(hdfCompanyId.Value.Trim()); int serviceId = Int32.Parse(hdfServiceId.Value.Trim()); string fmType = hdfFmType.Value; // ... services_navigator2.aspx, services_add_request.aspx, services_manager_tool.aspx if ((Request.QueryString["source_page"] == "services_navigator2.aspx") || (Request.QueryString["source_page"] == "services_add_request.aspx") || (Request.QueryString["source_page"] == "services_manager_tool.aspx")) { StoreNavigatorState(); ViewState["update"] = "no"; // ... Set initial tab if ((string)Session["dialogOpenedServices"] != "1") { hdfActiveTab.Value = Request.QueryString["active_tab"]; serviceInformationTDS = new ServiceInformationTDS(); ServiceInformationBasicInformation serviceInformationBasicInformation = new ServiceInformationBasicInformation(serviceInformationTDS); serviceInformationBasicInformation.LoadByServiceId(serviceId, companyId); ServiceInformationServiceCost serviceInformationServiceCostForEdit = new ServiceInformationServiceCost(serviceInformationTDS); serviceInformationServiceCostForEdit.LoadByServiceId(serviceId, companyId); ServiceInformationServiceNote serviceInformationServiceNoteForEdit = new ServiceInformationServiceNote(serviceInformationTDS); serviceInformationServiceNoteForEdit.LoadByServiceId(serviceId, companyId); } else { hdfActiveTab.Value = (string)Session["activeTabServices"]; // Restore datasets serviceInformationTDS = (ServiceInformationTDS)Session["serviceInformationTDS"]; } // ... Store dataset Session["serviceInformationTDS"] = serviceInformationTDS; } // ... services_summary.aspx or services_edit if ((Request.QueryString["source_page"] == "services_summary.aspx") || (Request.QueryString["source_page"] == "services_edit.aspx")) { StoreNavigatorState(); ViewState["update"] = Request.QueryString["update"]; // ... Restore dataset serviceInformationTDS = (ServiceInformationTDS)Session["serviceInformationTDS"]; // ... Set initial tab if ((string)Session["dialogOpenedServices"] != "1") { hdfActiveTab.Value = Request.QueryString["active_tab"]; if (ViewState["update"].ToString().Trim() == "yes") { ServiceInformationBasicInformation serviceInformationBasicInformation = new ServiceInformationBasicInformation(serviceInformationTDS); serviceInformationBasicInformation.LoadByServiceId(serviceId, companyId); ServiceInformationServiceCost serviceInformationServiceCostForEdit = new ServiceInformationServiceCost(serviceInformationTDS); serviceInformationServiceCostForEdit.LoadByServiceId(serviceId, companyId); ServiceInformationServiceNote serviceInformationServiceNoteForEdit = new ServiceInformationServiceNote(serviceInformationTDS); serviceInformationServiceNoteForEdit.LoadByServiceId(serviceId, companyId); // ... Store dataset Session["serviceInformationTDS"] = serviceInformationTDS; } } else { hdfActiveTab.Value = (string)Session["activeTabServices"]; } } // Prepare initial data lblMissingData.Visible = false; // ... Set initial tab int activeTab = Int32.Parse(hdfActiveTab.Value); tcDetailedInformation.ActiveTabIndex = activeTab; // ... For total cost ServiceInformationServiceCost serviceInformationServiceCostForTotalCost = new ServiceInformationServiceCost(serviceInformationTDS); tbxTotalCost.Text = Decimal.Round(serviceInformationServiceCostForTotalCost.GetTotalCost(serviceId, companyId), 2).ToString(); // ... Data for current servicew LoadServiceData(companyId); // Databind Page.DataBind(); ServiceInformationBasicInformationGateway serviceInformationBasicInformationGateway = new ServiceInformationBasicInformationGateway(serviceInformationTDS); if (serviceInformationBasicInformationGateway.GetAssignTeamMemberId(serviceId).HasValue) { try { ddlAssignmentDataAssignToTeamMember.SelectedValue = ((int)serviceInformationBasicInformationGateway.GetAssignTeamMemberId(serviceId)).ToString(); } catch { ddlAssignmentDataAssignToTeamMember.SelectedIndex = 0; } int teamMemberId = (int)serviceInformationBasicInformationGateway.GetAssignTeamMemberId(serviceId); EmployeeGateway employeeGateway = new EmployeeGateway(); employeeGateway.LoadByEmployeeId(teamMemberId); tbxAssignmentDataAssignToTeamMemberReadOnly.Text = employeeGateway.GetLastName(teamMemberId) + " " + employeeGateway.GetFirstName(teamMemberId); } // For thirds party vendor autocomplete aceThirdPartyVendor.ContextKey = serviceId.ToString() + "," + hdfCompanyId.Value; // ... For Library if (Session["libraryTDSForServices"] != null) { libraryTDSForServices = (LibraryTDS)Session["libraryTDSForServices"]; } else { libraryTDSForServices = new LibraryTDS(); } } else { // Restore datasets serviceInformationTDS = (ServiceInformationTDS)Session["serviceInformationTDS"]; // Set initial tab int activeTab = Int32.Parse(hdfActiveTab.Value); tcDetailedInformation.ActiveTabIndex = activeTab; if (Session["libraryTDSForServices"] != null) { libraryTDSForServices = (LibraryTDS)Session["libraryTDSForServices"]; } else { libraryTDSForServices = new LibraryTDS(); } LoadNotes(); } }
protected void grdCosts_RowUpdating(object sender, GridViewUpdateEventArgs e) { Page.Validate("costsDataEdit"); if (Page.IsValid) { int serviceId = (int)e.Keys["ServiceID"]; int refId = (int)e.Keys["RefID"]; int companyId = Int32.Parse(hdfCompanyId.Value); string partNumber = ((TextBox)grdCosts.Rows[e.RowIndex].FindControl("tbxPartNumber")).Text.Trim(); string partName = ((TextBox)grdCosts.Rows[e.RowIndex].FindControl("tbxPartName")).Text.Trim(); string vendor = ((TextBox)grdCosts.Rows[e.RowIndex].FindControl("tbxVendor")).Text.Trim(); decimal cost = decimal.Parse(((TextBox)grdCosts.Rows[e.RowIndex].FindControl("tbxCost")).Text.Trim()); int? noteId = null; if (((Label)grdCosts.Rows[e.RowIndex].FindControl("lblNoteIDEdit")).Text != "") noteId = Int32.Parse(((Label)grdCosts.Rows[e.RowIndex].FindControl("lblNoteIDEdit")).Text); // Update data ServiceInformationServiceCost model = new ServiceInformationServiceCost(serviceInformationTDS); model.Update(serviceId, refId, partNumber, partName, vendor, cost, noteId); // Store dataset Session["serviceInformationTDS"] = serviceInformationTDS; // Calc TotalCost tbxTotalCost.Text = Decimal.Round(model.GetTotalCost(serviceId, companyId), 2).ToString(); } else { e.Cancel = true; } }
private void GrdCostsAdd() { if (ValidateCostsFooter()) { Page.Validate("costsDataAdd"); if (Page.IsValid) { int serviceId = Int32.Parse(hdfServiceId.Value); int companyId = Int32.Parse(hdfCompanyId.Value); string newPartNumber = ((TextBox)grdCosts.FooterRow.FindControl("tbxPartNumberNew")).Text.Trim(); string newPartName = ((TextBox)grdCosts.FooterRow.FindControl("tbxPartNameNew")).Text.Trim(); string newVendor = ((TextBox)grdCosts.FooterRow.FindControl("tbxVendorNew")).Text.Trim(); decimal newCost = Decimal.Round(Decimal.Parse(((TextBox)grdCosts.FooterRow.FindControl("tbxCostNew")).Text.Trim()),2); bool inServiceCostDatabase = false; ServiceInformationServiceCost model = new ServiceInformationServiceCost(serviceInformationTDS); model.Insert(serviceId, newPartNumber, newPartName, newVendor, newCost, false, companyId, inServiceCostDatabase, null);//TODO Session.Remove("serviceCostsDummy"); Session["serviceInformationTDS"] = serviceInformationTDS; // Calc TotalCost tbxTotalCost.Text = Decimal.Round(model.GetTotalCost(serviceId, companyId), 2).ToString(); grdCosts.DataBind(); grdCosts.PageIndex = grdCosts.PageCount - 1; } } }
protected void grdCosts_RowDeleting(object sender, GridViewDeleteEventArgs e) { // Costs Gridview, if the gridview is edition mode if (grdCosts.EditIndex >= 0) { grdCosts.UpdateRow(grdCosts.EditIndex, true); } // Delete costs int serviceId = (int)e.Keys["ServiceID"]; int refId = (int)e.Keys["RefID"]; int companyId = Int32.Parse(hdfCompanyId.Value); ServiceInformationServiceCost model = new ServiceInformationServiceCost(serviceInformationTDS); model.Delete(serviceId, refId); // Store dataset Session["serviceInformationTDS"] = serviceInformationTDS; // Calc TotalCost tbxTotalCost.Text = Decimal.Round(model.GetTotalCost(serviceId, companyId), 2).ToString(); }
// //////////////////////////////////////////////////////////////////////// // EVENTS // protected void Page_Load(object sender, EventArgs e) { // Register client scripts this.RegisterClientScripts(); if (!IsPostBack) { // Security check if (!(Convert.ToBoolean(Session["sgLFS_FLEETMANAGEMENT_SERVICES_VIEW"]) && Convert.ToBoolean(Session["sgLFS_FLEETMANAGEMENT_SERVICES_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["service_id"] == null) || ((string)Request.QueryString["active_tab"] == null) || ((string)Request.QueryString["dashboard"] == null)) { Response.Redirect("./../../error_page.aspx?error=" + "Invalid query string in services_summary.aspx"); } // Tag Page hdfCompanyId.Value = Session["companyID"].ToString(); hdfFmType.Value = "Services"; hdfServiceId.Value = Request.QueryString["service_id"].ToString(); hdfActiveTab.Value = Request.QueryString["active_tab"].ToString(); hdfLoginId.Value = Convert.ToInt32(Session["loginID"]).ToString(); hdfDashboard.Value = Request.QueryString["dashboard"].ToString(); // Prepare initial data Session.Remove("serviceCostsDummy"); Session.Remove("serviceNotesDummy"); // If comming from int companyId = Int32.Parse(hdfCompanyId.Value.Trim()); int serviceId = Int32.Parse(hdfServiceId.Value.Trim()); string fmType = hdfFmType.Value; // ... services_navigator2.aspx, add_service_request.aspx, wucSRUnassigned.ascx, wucSRMyServiceRequest.ascx, wucItemsAboutToExpire.ascx, wucExpiredItems.ascx, wucAlarms.ascx, wucSRInProgress.ascx, services_manager_tool.aspx if ((Request.QueryString["source_page"] == "services_navigator2.aspx") || (Request.QueryString["source_page"] == "services_add_request.aspx") || (Request.QueryString["source_page"] == "wucSRUnassigned.ascx") || (Request.QueryString["source_page"] == "wucSRMyServiceRequest.ascx") || (Request.QueryString["source_page"] == "wucItemsAboutToExpire.ascx") || (Request.QueryString["source_page"] == "wucExpiredItems.ascx") || (Request.QueryString["source_page"] == "wucAlarms.ascx") || (Request.QueryString["source_page"] == "wucSRInProgress.ascx") || (Request.QueryString["source_page"] == "services_manager_tool.aspx")) { StoreNavigatorState(); ViewState["update"] = "yes"; // ... ... Set initial tab if ((string)Session["dialogOpenedServices"] != "1") { hdfActiveTab.Value = Request.QueryString["active_tab"]; serviceInformationTDS = new ServiceInformationTDS(); ServiceInformationBasicInformation serviceInformationBasicInformation = new ServiceInformationBasicInformation(serviceInformationTDS); serviceInformationBasicInformation.LoadByServiceId(serviceId, companyId); ServiceInformationServiceCost serviceInformationServiceCostForEdit = new ServiceInformationServiceCost(serviceInformationTDS); serviceInformationServiceCostForEdit.LoadByServiceId(serviceId, companyId); tbxTotalCost.Text = Decimal.Round(serviceInformationServiceCostForEdit.GetTotalCost(serviceId, companyId), 2).ToString(); ServiceInformationServiceNote serviceInformationServiceNoteForEdit = new ServiceInformationServiceNote(serviceInformationTDS); serviceInformationServiceNoteForEdit.LoadByServiceId(serviceId, companyId); } else { hdfActiveTab.Value = (string)Session["activeTabServices"]; // Restore datasets serviceInformationTDS = (ServiceInformationTDS)Session["serviceInformationTDS"]; } tcDetailedInformation.ActiveTabIndex = Int32.Parse(hdfActiveTab.Value); // Store dataset Session["serviceInformationTDS"] = serviceInformationTDS; } // ... services_delete.aspx or services_edit.aspx if ((Request.QueryString["source_page"] == "services_delete.aspx") || (Request.QueryString["source_page"] == "services_edit.aspx") || (Request.QueryString["source_page"] == "services_state.aspx")) { StoreNavigatorState(); ViewState["update"] = Request.QueryString["update"]; // Restore dataset serviceInformationTDS = (ServiceInformationTDS)Session["serviceInformationTDS"]; ServiceInformationBasicInformation serviceInformationBasicInformation = new ServiceInformationBasicInformation(serviceInformationTDS); serviceInformationBasicInformation.LoadByServiceId(serviceId, companyId); ServiceInformationServiceCost serviceInformationServiceCostForEdit = new ServiceInformationServiceCost(serviceInformationTDS); serviceInformationServiceCostForEdit.LoadByServiceId(serviceId, companyId); tbxTotalCost.Text = Decimal.Round(serviceInformationServiceCostForEdit.GetTotalCost(serviceId, companyId), 2).ToString(); ServiceInformationServiceNote serviceInformationServiceNoteForEdit = new ServiceInformationServiceNote(serviceInformationTDS); serviceInformationServiceNoteForEdit.LoadByServiceId(serviceId, companyId); // ... Set initial tab if ((string)Session["dialogOpenedServices"] != "1") { hdfActiveTab.Value = Request.QueryString["active_tab"]; } else { hdfActiveTab.Value = (string)Session["activeTabServices"]; } tcDetailedInformation.ActiveTabIndex = Int32.Parse(hdfActiveTab.Value); // Store dataset Session["serviceInformationTDS"] = serviceInformationTDS; } // Prepare initial data // ... Data for current service LoadServiceData(companyId); // ... For total cost ServiceInformationServiceCost serviceInformationServiceCostForTotalCost = new ServiceInformationServiceCost(serviceInformationTDS); tbxTotalCost.Text = Decimal.Round(serviceInformationServiceCostForTotalCost.GetTotalCost(serviceId, companyId), 2).ToString(); // Databind Page.DataBind(); } else { // Restore datasets serviceInformationTDS = (ServiceInformationTDS)Session["serviceInformationTDS"]; // Set initial tab int activeTab = Int32.Parse(hdfActiveTab.Value); tcDetailedInformation.ActiveTabIndex = activeTab; } }