// ///////////////////////////////////////////////////////////////////////////////////////////////////// // STEP4 - WARNING // // //////////////////////////////////////////////////////////////////////// // STEP4 - WARNING - METHODS // private void StepWarningIn() { // Set instruction Label instruction = (Label)this.Master.FindControl("lblInstruction"); instruction.Text = "Warning: The category you are about to delete contains the following units and checklist rules associated"; foreach (int categoryId in arrayCategoriesSelected) { CategoriesAddNew categoriesAddNew = new CategoriesAddNew(null); tbxWarning.Text = categoriesAddNew.GetRulesAndUnitsByCategoryId(categoryId, Int32.Parse(hdfCompanyId.Value)); } }
private void Save() { // save to database DB.Open(); DB.BeginTransaction(); try { CategoriesAddNew categoriesAddNew = new CategoriesAddNew(categoriesAddTDS); categoriesAddNew.Save(); // Store datasets categoriesAddTDS.AcceptChanges(); Session["categoriesAddTDS"] = categoriesAddTDS; DB.CommitTransaction(); } catch (Exception ex) { DB.RollbackTransaction(); string url = string.Format("./../../error_page.aspx?error={0}", ex.Message.Replace('\n', ' ')); Response.Redirect(url); } }
private bool StepSummaryFinish() { if (Page.IsValid) { int companyId = Convert.ToInt32(Session["companyID"]); string unitType = ""; if (rbtnEquipment.Checked) unitType = "Equipment"; else unitType = "Vehicle"; int? categoryId = null; foreach (int categoryIdInArray in arrayCategoriesSelected) { categoryId = categoryIdInArray; } if (rbtnAddCategory.Checked) { CategoriesAddNew categoriesAddnew = new CategoriesAddNew(categoriesAddTDS); categoriesAddnew.Insert(null, null, unitType, tbxName.Text.Trim(), categoryId, false, companyId, false); } if (rbtnEditCategory.Checked) { CategoriesAddNew categoriesAddnew = new CategoriesAddNew(categoriesAddTDS); categoriesAddnew.Insert(categoryId, null, unitType, tbxName.Text.Trim(), null, false, companyId, true); } if (rbtnDeleteCategory.Checked) { int? newCategoryId = null; if (arrayCategoriesSelected2.Count > 0) { foreach (int categoryId2 in arrayCategoriesSelected2) { newCategoryId = categoryId2; } } CategoriesAddNew categoriesAddnew = new CategoriesAddNew(categoriesAddTDS); categoriesAddnew.Insert(categoryId, newCategoryId, unitType, tbxName.Text.Trim(), null, true, companyId, true); } // Store database Session["categoriesAddTDS"] = categoriesAddTDS; Save(); hdfUpdate.Value = "yes"; return true; } else { return false; } }
protected void Wizard_NextButtonClick(object sender, WizardNavigationEventArgs e) { switch (wzCategoriesAdd.ActiveStep.Name) { case "Type": e.Cancel = !StepTypeNext(); if (!e.Cancel) { ViewState["StepFrom"] = "Type"; } break; case "Operation": e.Cancel = !StepOperationNext(); if (!e.Cancel) { ViewState["StepFrom"] = "Operation"; } break; case "Categories": e.Cancel = !StepCategoriesNext(); if (!e.Cancel) { ViewState["StepFrom"] = "Categories"; if (rbtnDeleteCategory.Checked) { bool inUse = false; foreach (int categoryId in arrayCategoriesSelected) { CategoriesAddNew categoriesAddNew = new CategoriesAddNew(null); inUse = categoriesAddNew.CategoryIsUsed(categoryId, Int32.Parse(hdfCompanyId.Value)); } if (inUse) { wzCategoriesAdd.ActiveStepIndex = wzCategoriesAdd.WizardSteps.IndexOf(StepWarning); } else { wzCategoriesAdd.ActiveStepIndex = wzCategoriesAdd.WizardSteps.IndexOf(StepSummary); } } else { wzCategoriesAdd.ActiveStepIndex = wzCategoriesAdd.WizardSteps.IndexOf(StepSummary); } } break; case "Warning": e.Cancel = !StepWarningNext(); if (!e.Cancel) { ViewState["StepFrom"] = "Warning"; } break; case "Category to replace": e.Cancel = !StepCategories2Next(); if (!e.Cancel) { ViewState["StepFrom"] = "Categories2"; } break; default: throw new Exception("Not exists the option for " + wzCategoriesAdd.ActiveStep.Name + " step in categories_edit.Wizard_NextButtonClick function"); } }