public void DeleteDimension <TResult>(TResult obj) where TResult : class { var resultType = typeof(TResult); if (resultType == typeof(Customer)) { var command = new DeleteCustomerCommand { Customer = obj as Customer }; _processXml.Process(command.ToXml()); } if (resultType == typeof(Supplier)) { var command = new DeleteSupplierCommand { Supplier = obj as Supplier }; _processXml.Process(command.ToXml()); } if (resultType == typeof(BalanceSheet)) { var command = new DeleteGeneralLedgerCommand { GeneralLedger = obj as BalanceSheet }; _processXml.Process(command.ToXml()); } if (resultType == typeof(ProfitLoss)) { var command = new DeleteGeneralLedgerCommand { GeneralLedger = obj as ProfitLoss }; _processXml.Process(command.ToXml()); } if (resultType == typeof(CostCenter)) { var command = new DeleteCostCenterCommand { CostCenter = obj as CostCenter }; _processXml.Process(command.ToXml()); } if (resultType == typeof(Article)) { var command = new DeleteArticleCommand { Article = obj as Article }; _processXml.Process(command.ToXml()); } if (resultType == typeof(Vat)) { var command = new DeleteVatCommand { Vat = obj as Vat }; _processXml.Process(command.ToXml()); } if (resultType == typeof(Currency)) { var command = new DeleteCurrencyCommand { Currency = obj as Currency }; _processXml.Process(command.ToXml()); } }
protected void acceptBtn_Click(object sender, EventArgs e) { string acpId = id.Value; string acpName = name.Value; string acpType = type.SelectedValue; String init = dateinit.Text; String end = dateend.Text; string administrator = admin.Value; List <string> selectedUnits = organizationalUnitsCkl.Items.Cast <ListItem>() .Where(li => li.Selected) .Select(li => li.Value) .ToList(); if ((!acpId.Equals("")) && (!acpName.Equals("")) && (!init.Equals("")) && (!administrator.Equals("")) && (selectedUnits.Count != 0)) { if (end.Equals("")) { end = "9999-12-31"; } double admin = 0; bool isNumber = double.TryParse(administrator, out admin); if (isNumber) { int adminInt = Convert.ToInt32(admin); try { GetEmployeesCommand cmd = new GetEmployeesCommand(); cmd.Execute(); employees = cmd.GetResult(); bool adminExist = false; foreach (Employee employee in employees) { if (employee.id == adminInt) { adminExist = true; } } if (adminExist) { try { Employee employee = new Employee(adminInt); AccountCoursePermit acpToUpdate = new AccountCoursePermit(acpId, acpName, Int32.Parse(acpType), Convert.ToDateTime(init), Convert.ToDateTime(end), employee); DeleteCostCenterCommand command = new DeleteCostCenterCommand(acpToUpdate); command.Execute(); int response = command.GetResult(); if (response == 200) { UpdateAccountCoursePermitCommand _cmd = new UpdateAccountCoursePermitCommand(acpToUpdate); _cmd.Execute(); int result = _cmd.GetResult(); if (result == 200) { foreach (string unit in selectedUnits) { int unitId = Int32.Parse(unit); CostCenter costCenter = new CostCenter(unitId, acpToUpdate.id); CreateNewCostCenterCommand cmdCostCenter = new CreateNewCostCenterCommand(costCenter); cmdCostCenter.Execute(); } ScriptManager.RegisterStartupScript(this, this.GetType(), "randomText", "sweetAlert('Se ha modificado exitosamente', 'success', '/site/employees/acp/acpdata.aspx')", true); } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "randomText", "errorSweetAlert('Se ha generado un error procesando su solicitud', 'error')", true); } } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "randomText", "errorSweetAlert('El código ingresado ya se encuentra registrado en el sistema', 'error')", true); } } catch (Exception ex) { ScriptManager.RegisterStartupScript(this, this.GetType(), "randomText", "errorSweetAlert('Se ha generado un error procesando su solicitud', 'error')", true); } } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "randomText", "errorSweetAlert('El empleado seleccionado no se encuentra registrado en el sistema', 'error')", true); } } catch (Exception ex) { ScriptManager.RegisterStartupScript(this, this.GetType(), "randomText", "errorSweetAlert('Se ha generado un error procesando su solicitud, 'error'')", true); } } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "randomText", "errorSweetAlert('El campo de administrador no tiene formato númerico', 'error')", true); } } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "randomText", "errorSweetAlert('Existen campos vacíos en el formulario', 'error')", true); } }