protected void btnDelete_Click(object sender, EventArgs e) { int companyId = Int32.Parse(hdfCompanyId.Value.Trim()); PostPageChanges(); int unitId = GetUnitId(); UnitsGateway unitsGateway = new UnitsGateway(); unitsGateway.LoadByUnitId(unitId, companyId); string unitType = unitsGateway.GetType(unitId); string unitState = unitsGateway.GetState(unitId); if (unitId > 0) { switch (Delete(unitId, companyId)) { case 0: // Store active tab for postback Session["activeTabUnits"] = "0"; Session["dialogOpenedUnits"] = "0"; // Redirect string url = "./units_delete.aspx?source_page=units_navigator2.aspx&unit_id=" + unitId + "&unit_type=" + unitType + "&unit_state=" + unitState + GetNavigatorState() + "&update=yes&active_tab=0"; Response.Redirect(url); break; case 1: cvSelection.ErrorMessage = "The unit has been registered in a Timesheet, you cannot delete it."; cvSelection.IsValid = false; break; case 2: cvSelection.ErrorMessage = "The unit has been registered in the Add Team Project Time wizard, you cannot delete him."; cvSelection.IsValid = false; break; case 3: cvSelection.ErrorMessage = "The unit has been registered in the Add Team Project Time wizard, you cannot delete him."; cvSelection.IsValid = false; break; case 4: cvSelection.ErrorMessage = "The unit has services active, you cannot delete him."; cvSelection.IsValid = false; break; } } else { RestoreNavigatorState(); cvSelection.IsValid = false; } }
public string GetUrl(object str) { int unitId = Int32.Parse(str.ToString()); int companyId = Int32.Parse(hdfCompanyId.Value); string url = ""; UnitsGateway unitsGateway = new UnitsGateway(); unitsGateway.LoadByUnitId(unitId, companyId); if (unitsGateway.Table.Rows.Count > 0) { string unitType = unitsGateway.GetType(unitId); string unitState = unitsGateway.GetState(unitId); url = "./../../Units/units_summary.aspx?source_page=wucAlarms.ascx&dashboard=True&dashboard=True&unit_id=" + unitId + "&unit_type=" + unitType + "&unit_state=" + unitState + "&active_tab=0" + GetNavigatorState(); } return url; }
// //////////////////////////////////////////////////////////////////////// // NAVIGATION EVENTS // protected void tkrmTop_ItemClick(object sender, RadMenuEventArgs e) { // Store active tab for postback Session["activeTabUnits"] = "0"; Session["dialogOpenedUnits"] = "0"; string activeTab = hdfActiveTab.Value; string url = ""; switch (e.Item.Value) { case "mSave": this.Save(); break; case "mApply": this.Apply(); break; case "mCancel": Session.Remove("libraryTDSForUnits"); if (Request.QueryString["source_page"] == "units_navigator2.aspx" || Request.QueryString["source_page"] == "units_add.aspx") { url = "./units_navigator2.aspx?source_page=units_edit.aspx" + GetNavigatorState() + "&update=" + (string)ViewState["update"]; } if (Request.QueryString["source_page"] == "units_summary.aspx") { url = "./units_summary.aspx?source_page=units_edit.aspx&unit_id=" + hdfUnitId.Value + "&unit_type=" + hdfUnitType.Value + "&unit_state=" + hdfUnitState.Value + "&active_tab=" + hdfActiveTab.Value + GetNavigatorState() + "&update=" + (string)ViewState["update"]; } break; case "mPrevious": Session.Remove("libraryTDSForUnits"); // Get previous record int previousId = UnitsNavigator.GetPreviousId((UnitsNavigatorTDS)Session["unitsNavigatorTDS"], Int32.Parse(hdfUnitId.Value)); if (previousId != Int32.Parse(hdfUnitId.Value)) { this.Apply(); // ... Redirect int companyId = Int32.Parse(hdfCompanyId.Value); int unitId = Int32.Parse(hdfUnitId.Value); UnitsGateway unitsGateway = new UnitsGateway(); unitsGateway.LoadByUnitId(unitId, companyId); string unitType = unitsGateway.GetType(unitId); string unitState = unitsGateway.GetState(unitId); url = "./units_edit.aspx?source_page=" + Request.QueryString["source_page"] + "&unit_id=" + previousId + "&unit_type=" + unitType + "&unit_state=" + unitState + "&active_tab=" + activeTab + GetNavigatorState() + "&update=yes"; } break; case "mNext": Session.Remove("libraryTDSForUnits"); // Get next record int nextId = UnitsNavigator.GetNextId((UnitsNavigatorTDS)Session["unitsNavigatorTDS"], Int32.Parse(hdfUnitId.Value)); if (nextId != Int32.Parse(hdfUnitId.Value)) { this.Apply(); // ... Redirect int companyId = Int32.Parse(hdfCompanyId.Value); int unitId = Int32.Parse(hdfUnitId.Value); UnitsGateway unitsGateway = new UnitsGateway(); unitsGateway.LoadByUnitId(unitId, companyId); string unitType = unitsGateway.GetType(unitId); string unitState = unitsGateway.GetState(unitId); url = "./units_edit.aspx?source_page=" + Request.QueryString["source_page"] + "&unit_id=" + nextId + "&unit_type=" + unitType + "&unit_state=" + unitState + "&active_tab=" + activeTab + GetNavigatorState() + "&update=yes"; } break; } if (url != "") Response.Redirect(url); }
// ///////////////////////////////////////////////////////////////////////////////////////////////////// // STEP6 - FINISH OPTIONS // // //////////////////////////////////////////////////////////////////////// // STEP6 - FINISH OPTIONS - METHODS // private void StepFinalStepIn() { // Set instruction mWizard2 master2 = (mWizard2)this.Master; master2.WizardInstruction = "What would you like to do?"; string url = ""; UnitsGateway unitsGateway = new UnitsGateway(null); int unitId = unitsGateway.GetLastUnitId(); UnitsGateway unitsGatewayForLoad = new UnitsGateway(); unitsGatewayForLoad.LoadByUnitId(unitId, int.Parse(hdfCompanyId.Value)); string unitType = unitsGatewayForLoad.GetType(unitId); string unitState = unitsGatewayForLoad.GetState(unitId); hdfUpdate.Value = "yes"; // Store active tab for postback Session["activeTabUnits"] = "0"; Session["dialogOpenedUnits"] = "0"; url = "./units_summary.aspx?source_page=units_add.aspx&unit_id=" + unitId.ToString() + "&unit_type=" + unitType + "&unit_state=" + unitState + "&active_tab=0" + GetNavigatorState(); lkbtnOpenUnit.Attributes.Add("onclick", string.Format("return lkbtnOpenServiceClick('{0}');", url)); url = "./units_edit.aspx?source_page=units_add.aspx&unit_id=" + unitId.ToString() + "&unit_type=" + unitType + "&unit_state=" + unitState + "&active_tab=0" + GetNavigatorState(); lkbtnEditUnit.Attributes.Add("onclick", string.Format("return lkbtnEditServiceClick('{0}');", url)); lkbtnClose.Attributes.Add("onclick", "return lkbtnCloseClick();"); }
// ///////////////////////////////////////////////////////////////////////////////////////////////////// // // STEP1 - BEGIN // // //////////////////////////////////////////////////////////////////////// // STEP1 - BEGIN - METHODS // private void StepBeginIn() { // Set instruction Label instruction = (Label)this.Master.FindControl("lblInstruction"); instruction.Text = "Please select a unit"; // Set initial unit id if (hdfInitialUnitId.Value != "none") { int unitId = Int32.Parse(hdfInitialUnitId.Value); int companyId = Int32.Parse(hdfCompanyId.Value); UnitsGateway unitsGateway = new UnitsGateway(); unitsGateway.LoadByUnitId(unitId, companyId); string state = unitsGateway.GetState(unitId) ; if (state != "Disposed") { try { ddlUnits.SelectedValue = hdfInitialUnitId.Value; } catch { } } if (hdfDashboard.Value == "True") { try { ddlUnits.Enabled = false; } catch { } } } }
protected void btnEdit_Click(object sender, EventArgs e) { int companyId = Int32.Parse(hdfCompanyId.Value.Trim()); PostPageChanges(); int unitId = GetUnitId(); if (unitId > 0) { UnitsGateway unitsGateway = new UnitsGateway(); unitsGateway.LoadByUnitId(unitId, companyId); string unitType = unitsGateway.GetType(unitId); string unitState = unitsGateway.GetState(unitId); // Store active tab for postback Session["activeTabUnits"] = "0"; Session["dialogOpenedUnits"] = "0"; // Redirect string url = "./units_edit.aspx?source_page=units_navigator2.aspx&unit_id=" + unitId + "&unit_type=" + unitType + "&unit_state=" + unitState + "&active_tab=0" + GetNavigatorState(); Response.Redirect(url); } else { RestoreNavigatorState(); cvSelection.IsValid = false; } }