public void ConsultaCatSolucion(Sesion sesion, int area, ref List <CrmCatSolucion> List) { try { SqlDataReader dr = null; CapaDatos.CD_Datos CapaDatos = new CapaDatos.CD_Datos(sesion.Emp_Cnx); string[] Parametros = { "@Id_Emp", "@Id_Area" }; object[] Valores = { sesion.Id_Emp, area }; SqlCommand sqlcmd = CapaDatos.GenerarSqlCommand("spCRMCatSoluciones", ref dr, Parametros, Valores); CrmCatSolucion catSolucion; while (dr.Read()) { catSolucion = new CrmCatSolucion(); catSolucion.Clave = (int)dr.GetValue(dr.GetOrdinal("Id_Sol")); catSolucion.Solucion = (string)dr.GetValue(dr.GetOrdinal("Sol_Descripcion")); catSolucion.Porcentaje = (double)dr.GetValue(dr.GetOrdinal("Sol_Potencial")); List.Add(catSolucion); } CapaDatos.LimpiarSqlcommand(ref sqlcmd); } catch (Exception ex) { throw ex; } }
public void ComboArea(Sesion sesion, int segmento, ref List <CrmCatSolucion> list) { try { SqlDataReader dr = null; CapaDatos.CD_Datos CapaDatos = new CapaDatos.CD_Datos(sesion.Emp_Cnx); string[] Parametros = { "@Id1", "@Id2", "@Id3" }; object[] Valores = { 1, sesion.Id_Emp, segmento }; SqlCommand sqlcmd = CapaDatos.GenerarSqlCommand("spCatCRMAreaSegmento_Combo", ref dr, Parametros, Valores); CrmCatSolucion catSoluciones; while (dr.Read()) { catSoluciones = new CrmCatSolucion(); catSoluciones.Id = (int)dr.GetValue(dr.GetOrdinal("Id")); catSoluciones.Descripcion = (string)dr.GetValue(dr.GetOrdinal("Descripcion")); list.Add(catSoluciones); } CapaDatos.LimpiarSqlcommand(ref sqlcmd); } catch (Exception ex) { throw ex; } }
public void ModificarSolucion(CrmCatSolucion soluciones, string Conexion, int Id_Emp, ref int valido) { try { CapaDatos.CD_Datos CapaDatos = new CapaDatos.CD_Datos(Conexion); string[] Parametros = { "@Id_Emp", "@Id_Sol", "@Sol_Descripcion", "@Sol_Potencial" }; object[] Valores = { Id_Emp, soluciones.Clave, soluciones.Descripcion, soluciones.Porcentaje }; SqlCommand sqlcmd = CapaDatos.GenerarSqlCommand("spCRMCatSoluciones_Modificar", ref valido, Parametros, Valores); CapaDatos.LimpiarSqlcommand(ref sqlcmd); } catch (Exception ex) { throw ex; } }
public void EliminarCatSolucion(Sesion sesion, CrmCatSolucion solucion, ref int valido) { try { CapaDatos.CD_Datos CapaDatos = new CapaDatos.CD_Datos(sesion.Emp_Cnx); string[] Parametros = { "@Id_Emp", "@Id_Sol", "@Sol_Descripcion", "@Id_Area", "@Sol_Potencial" }; object[] Valores = { sesion.Id_Emp, solucion.Clave, solucion.Descripcion, solucion.Area, solucion.Porcentaje }; SqlCommand sqlcmd = CapaDatos.GenerarSqlCommand("spCRMCatSoluciones_Eliminar", ref valido, Parametros, Valores); CapaDatos.LimpiarSqlcommand(ref sqlcmd); } catch (Exception ex) { throw ex; } }
public void ModificarSolucion(CrmCatSolucion soluciones, string Conexion, int Id_Emp, ref int valido) { try { CD_CrmCatSoluciones claseCapaDatos = new CD_CrmCatSoluciones(); claseCapaDatos.ModificarSolucion(soluciones, Conexion, Id_Emp, ref valido); } catch (Exception ex) { throw ex; } }
public void EliminarCatSolucion(Sesion sesion, CrmCatSolucion solucion, ref int valido) { try { CD_CrmCatSoluciones claseCapaDatos = new CD_CrmCatSoluciones(); claseCapaDatos.EliminarCatSolucion(sesion, solucion, ref valido); } catch (Exception ex) { throw ex; } }
protected void rgAreas_ItemCommand(object source, GridCommandEventArgs e) {//botones del grid try { ErrorManager(); Int32 item = default(Int32); item = e.Item.ItemIndex; if (e.CommandName == "Modificar") { if (!_PermisoModificar) { Alerta("No tiene permisos para modificar"); return; } txtPosicion.Text = rgAreas.Items[item]["Solucion"].Text; txtPotencial.Text = rgAreas.Items[item]["Porcentaje"].Text; ibtnCrear_Click(null, null); HF_Modificar.Value = rgAreas.Items[item]["Clave"].Text; } else if (e.CommandName.ToString() == "Delete") { if (item >= 0) { CN__Comun.RemoverValidadores(Validators); CrmCatSolucion solucion = new CrmCatSolucion(); solucion.Area = Convert.ToInt32(ddlAreas.SelectedValue); solucion.Clave = Convert.ToInt32(rgAreas.Items[item]["Clave"].Text); solucion.Descripcion = rgAreas.Items[item]["Solucion"].Text; solucion.Porcentaje = Convert.ToDouble(rgAreas.Items[item]["Porcentaje"].Text); Eliminar(solucion); } } } catch (Exception ex) { if (ex.Message.Contains("conflicted with the REFERENCE constraint")) { Alerta("El registro está siendo utilizado por otro componente"); } else { ErrorManager(ex, new System.Diagnostics.StackTrace().GetFrame(0).GetMethod().Name); } } }
private void Eliminar(CrmCatSolucion solucion) { try { if (!_PermisoEliminar) { Alerta("No tiene permisos para eliminar"); return; } else { HF_Modificar.Value = ""; int valido = 0; Sesion session = new Sesion(); session = (Sesion)Session["Sesion" + Session.SessionID]; CN_CrmCatSoluciones cls = new CN_CrmCatSoluciones(); cls.EliminarCatSolucion(session, solucion, ref valido); if (valido == 1) { Alerta("La Solución #" + solucion.Clave + " fue eliminada satisfactoriamente"); } else if (valido == -2) { Alerta("No se puede eliminar la solución, ya fue asignada a un proyecto"); } else { Alerta("No se pudo eliminar la solución #" + solucion.Clave); } rgAreas.Rebind(); } } catch (Exception ex) { throw ex; } }
protected void Guardar() { try { CrmCatSolucion soluciones = new CrmCatSolucion(); soluciones.Area = !string.IsNullOrEmpty(ddlAreas.SelectedValue) ? Convert.ToInt32(ddlAreas.SelectedValue) : 0; soluciones.Descripcion = txtPosicion.Text; //Request.Form["txtPosicion"].ToString();//txtPosicion.Text; soluciones.Porcentaje = txtPotencial.Value.Value; // == null) ? Convert.ToDouble(txtPotencial.Value.Value) : 0; if (soluciones.Area == 0) { Alerta("Seleccione una área valida"); return; } if (string.IsNullOrEmpty(soluciones.Descripcion)) { Alerta("Ingrese una descripción de la solución"); return; } if (soluciones.Porcentaje == 0) { Alerta("Ingrese un valor de porcentaje"); return; } soluciones.Id = Convert.ToInt32(MaximoId()); int valido = 0; CN_CrmCatSoluciones cls = new CN_CrmCatSoluciones(); Sesion session2 = new Sesion(); session2 = (Sesion)Session["Sesion" + Session.SessionID]; if (HF_Modificar.Value == "") { if (!_PermisoGuardar) { Alerta("No tiene permisos para grabar"); return; } cls.InsertCatSolucion(session2, soluciones, ref valido); } else { if (!_PermisoModificar) { Alerta("No tiene permisos para modificar"); return; } soluciones.Clave = Convert.ToInt32(HF_Modificar.Value); cls.ModificarSolucion(soluciones, session.Emp_Cnx, session.Id_Emp, ref valido); } if (valido == 1) { FinGuardar(); //Alerta("Registro agregado satisfactoriamente"); } else { Alerta("Ocurrio un error al intentar guardar"); } rgAreas.Rebind(); txtPosicion.Focus(); } catch (Exception ex) { throw ex; } }