public List <SubProductoEntidad> FiltrarxProducto(string codigo) { SqlConnection cn = new SqlConnection(Conexion.CnBanca); try { Conexion.abrirConexion(cn); SqlCommand cmd = new SqlCommand("usp_SubProducto_FiltrarxProducto", cn); cmd.Parameters.Add(new SqlParameter("@Cod_Producto", SqlDbType.VarChar, 15)).Value = codigo; cmd.CommandType = CommandType.StoredProcedure; List <SubProductoEntidad> ListaSubProductos = new List <SubProductoEntidad>(); using (var reader = cmd.ExecuteReader()) { while (reader.Read()) { SubProductoEntidad oSubProductoEntidad = new SubProductoEntidad(); oSubProductoEntidad.Cod_SubProducto = Reader.GetStringValue(reader, "Cod_SubProducto"); oSubProductoEntidad.SubProducto = Reader.GetStringValue(reader, "SubProducto"); ListaSubProductos.Add(oSubProductoEntidad); } } return(ListaSubProductos); } catch (Exception ex) { return(null); } finally { Conexion.cerrarConexion(cn); } }
public CanalEntidad obtenerDatosXCodigo(string codigo) { SqlConnection cn = new SqlConnection(Conexion.CnBanca); try { Conexion.abrirConexion(cn); SqlCommand cmd = new SqlCommand("usp_Canal_FiltrarxCodigo", cn); cmd.Parameters.Add(new SqlParameter("@Cod_Canal", SqlDbType.VarChar, 15)).Value = codigo; cmd.CommandType = CommandType.StoredProcedure; CanalEntidad oCanalEntidad = null; using (var reader = cmd.ExecuteReader()) { while (reader.Read()) { oCanalEntidad = new CanalEntidad(); oCanalEntidad.Cod_Canal = Reader.GetStringValue(reader, "Cod_Canal").Trim(); oCanalEntidad.Canal = Reader.GetStringValue(reader, "Canal"); oCanalEntidad.RUC = Reader.GetStringValue(reader, "RUC"); oCanalEntidad.Razon_Social = Reader.GetStringValue(reader, "Razon_Social"); oCanalEntidad.Direccion = Reader.GetStringValue(reader, "Dirección"); oCanalEntidad.Region = new RegionEntidad { Cod_Region = Reader.GetStringValue(reader, "Cod_Region"), }; oCanalEntidad.Provincia = new ProvinciaEntidad { Cod_Provincia = Reader.GetStringValue(reader, "Cod_Provincia"), }; oCanalEntidad.Distrito = new DistritoEntidad { Cod_Distrito = Reader.GetStringValue(reader, "Cod_Distrito"), }; oCanalEntidad.Telefono1 = Reader.GetStringValue(reader, "Teléfono1"); oCanalEntidad.Telefono2 = Reader.GetStringValue(reader, "Teléfono2"); oCanalEntidad.Celular = Reader.GetStringValue(reader, "Celular"); oCanalEntidad.Email = Reader.GetStringValue(reader, "Email"); oCanalEntidad.Representante_Legal = Reader.GetStringValue(reader, "Representante_Legal"); oCanalEntidad.Fecha_Inicio = Reader.GetDateTimeValue(reader, "Fecha_Inicio").ToString("dd/MM/yyyy"); oCanalEntidad.Fecha_Cese = Reader.GetDateTimeValue(reader, "Fecha_Cese").ToString("dd/MM/yyyy"); oCanalEntidad.Estado = Reader.GetStringValue(reader, "Estado"); oCanalEntidad.Fecha_Ult_Camb = Reader.GetDateTimeValue(reader, "Fecha_Ult_Camb").ToString("dd/MM/yyyy"); oCanalEntidad.Usuario = new UsuarioEntidad { Cod_Usuario = Reader.GetTinyIntValue(reader, "Cod_Usuario"), }; } } return(oCanalEntidad); } catch (Exception ex) { return(null); } finally { Conexion.cerrarConexion(cn); } }
public TarifarioEntidad obtenerDatosXCodigo(string codigo) { SqlConnection cn = new SqlConnection(Conexion.CnBanca); try { Conexion.abrirConexion(cn); SqlCommand cmd = new SqlCommand("usp_Tarifario_FiltraxCodigo", cn); cmd.Parameters.Add(new SqlParameter("@Cod_Tarifa", SqlDbType.Int)).Value = Int32.Parse(codigo); cmd.CommandType = CommandType.StoredProcedure; TarifarioEntidad oTarifarioEntidad = null; using (var reader = cmd.ExecuteReader()) { while (reader.Read()) { oTarifarioEntidad = new TarifarioEntidad(); oTarifarioEntidad.Cod_Tarifa = Reader.GetIntValue(reader, "Cod_Tarifa"); oTarifarioEntidad.Canal = new CanalEntidad { Cod_Canal = Reader.GetStringValue(reader, "Cod_Canal"), }; oTarifarioEntidad.SubCanal = new SubCanalEntidad { Cod_SubCanal = Reader.GetStringValue(reader, "Cod_SubCanal"), }; oTarifarioEntidad.Producto = new ProductoEntidad { Cod_Producto = Reader.GetStringValue(reader, "Cod_Producto"), }; oTarifarioEntidad.SubProducto = new SubProductoEntidad { Cod_SubProducto = Reader.GetStringValue(reader, "Cod_SubProducto"), }; oTarifarioEntidad.Tarifa_Inicio = Reader.GetDecimalValue(reader, "Tarifa_Inicio"); oTarifarioEntidad.Tarifa_Fin = Reader.GetDecimalValue(reader, "Tarifa_Fin"); oTarifarioEntidad.Tipo = Reader.GetTinyIntValue(reader, "Tipo"); oTarifarioEntidad.Tarifario = decimal.Parse((Reader.GetDecimalValue(reader, "Tarifario") * 100).ToString("#.#0")); oTarifarioEntidad.Fecha_Ultimo = Reader.GetDateTimeValue(reader, "Fecha_Ultimo").ToString("dd/MM/yyyy"); oTarifarioEntidad.Fecha_Registro = Reader.GetDateTimeValue(reader, "Fecha_Registro").ToString("dd/MM/yyyy"); oTarifarioEntidad.TipoComision = Reader.GetTinyIntValue(reader, "Tipo_Comision"); oTarifarioEntidad.Estado = Reader.GetStringValue(reader, "Estado"); oTarifarioEntidad.Usuario = new UsuarioEntidad { Nom_Usuario = Reader.GetStringValue(reader, "Nom_Usuario"), }; } } return(oTarifarioEntidad); } catch (Exception ex) { return(null); } finally { Conexion.cerrarConexion(cn); } }
public bool grabarDatos(SubCanalEntidad entidad, ref string codigo) { SqlConnection cn = new SqlConnection(Conexion.CnBanca); SqlTransaction trans = null; try { bool estado = false; Conexion.abrirConexion(cn); trans = cn.BeginTransaction(); SqlCommand cmd = new SqlCommand("usp_SubCanal_Grabar", cn); cmd.Parameters.Add(new SqlParameter("@SubCanal", SqlDbType.VarChar, 150)).Value = entidad.SubCanal.ToUpper(); cmd.Parameters.Add(new SqlParameter("@Cod_Canal", SqlDbType.VarChar, 15)).Value = entidad.Canal.Cod_Canal; cmd.Parameters.Add(new SqlParameter("@Dirección", SqlDbType.VarChar, 250)).Value = entidad.Direccion.ToUpper(); cmd.Parameters.Add(new SqlParameter("@Cod_Region", SqlDbType.VarChar, 6)).Value = entidad.Region.Cod_Region; cmd.Parameters.Add(new SqlParameter("@Cod_Provincia", SqlDbType.VarChar, 6)).Value = entidad.Provincia.Cod_Provincia; cmd.Parameters.Add(new SqlParameter("@Cod_Distrito", SqlDbType.VarChar, 6)).Value = entidad.Distrito.Cod_Distrito; cmd.Parameters.Add(new SqlParameter("@Fecha_Inicio", SqlDbType.SmallDateTime)).Value = DateTime.Parse(entidad.Fecha_Inicio); cmd.Parameters.Add(new SqlParameter("@Fecha_Cese", SqlDbType.SmallDateTime)).Value = DateTime.Parse(entidad.Fecha_Cese); cmd.Parameters.Add(new SqlParameter("@Estado", SqlDbType.Char, 1)).Value = entidad.Estado; cmd.Parameters.Add(new SqlParameter("@Cod_Usuario", SqlDbType.TinyInt)).Value = entidad.Usuario.Cod_Usuario; cmd.Parameters.Add(new SqlParameter("@Cod_SubCanal", SqlDbType.VarChar, 15)).Direction = ParameterDirection.Output; cmd.CommandType = CommandType.StoredProcedure; cmd.Transaction = trans; if (cmd.ExecuteNonQuery() > 0) { estado = true; } if (estado) { codigo = cmd.Parameters["@Cod_SubCanal"].Value.ToString(); trans.Commit(); } else { trans.Rollback(); } return(estado); } catch (Exception ex) { if (trans != null) { trans.Rollback(); } return(false); } finally { Conexion.cerrarConexion(cn); } }
public bool modificarDatos(TarifarioEntidad entidad) { SqlConnection cn = new SqlConnection(Conexion.CnBanca); SqlTransaction trans = null; try { bool estado = false; Conexion.abrirConexion(cn); trans = cn.BeginTransaction(); SqlCommand cmd = new SqlCommand("usp_Tarifario_Modificar", cn); cmd.Parameters.Add(new SqlParameter("@Cod_Tarifa", SqlDbType.Int)).Value = entidad.Cod_Tarifa; cmd.Parameters.Add(new SqlParameter("@Cod_Canal", SqlDbType.VarChar, 15)).Value = (entidad.Canal.Cod_Canal != null ? entidad.Canal.Cod_Canal : ""); cmd.Parameters.Add(new SqlParameter("@Cod_SubCanal", SqlDbType.VarChar, 15)).Value = (entidad.SubCanal.Cod_SubCanal != null ? entidad.SubCanal.Cod_SubCanal : ""); cmd.Parameters.Add(new SqlParameter("@Cod_Producto", SqlDbType.VarChar, 15)).Value = (entidad.Producto.Cod_Producto != null ? entidad.Producto.Cod_Producto : ""); cmd.Parameters.Add(new SqlParameter("@Cod_SubProducto", SqlDbType.VarChar, 15)).Value = (entidad.SubProducto.Cod_SubProducto != null ? entidad.SubProducto.Cod_SubProducto : ""); cmd.Parameters.Add(new SqlParameter("@Tarifa_Inicio", SqlDbType.Real)).Value = entidad.Tarifa_Inicio; cmd.Parameters.Add(new SqlParameter("@Tarifa_Fin", SqlDbType.Real)).Value = entidad.Tarifa_Fin; cmd.Parameters.Add(new SqlParameter("@Tipo", SqlDbType.TinyInt)).Value = entidad.Tipo; cmd.Parameters.Add(new SqlParameter("@Tarifario", SqlDbType.Real)).Value = entidad.Tarifario; cmd.Parameters.Add(new SqlParameter("@Estado", SqlDbType.Char, 1)).Value = entidad.Estado; cmd.Parameters.Add(new SqlParameter("@Cod_Usuario", SqlDbType.TinyInt)).Value = entidad.Usuario.Cod_Usuario; cmd.CommandType = CommandType.StoredProcedure; cmd.Transaction = trans; if (cmd.ExecuteNonQuery() > 0) { estado = true; } if (estado) { trans.Commit(); } else { trans.Rollback(); } return(estado); } catch (Exception ex) { if (trans != null) { trans.Rollback(); } return(false); } finally { Conexion.cerrarConexion(cn); } }
public List <CanalEntidad> obtenerDatosXFiltro(CanalEntidad entidad) { SqlConnection cn = new SqlConnection(Conexion.CnBanca); try { Conexion.abrirConexion(cn); SqlCommand cmd = new SqlCommand("usp_Canal_Filtrar", cn); cmd.Parameters.Add(new SqlParameter("@Cod_Canal", SqlDbType.VarChar, 15)).Value = (entidad.Cod_Canal != null ? entidad.Cod_Canal : ""); cmd.Parameters.Add(new SqlParameter("@Cod_SubCanal", SqlDbType.VarChar, 15)).Value = (entidad.Cod_SubCanal != null ? entidad.Cod_SubCanal : ""); cmd.Parameters.Add(new SqlParameter("@Ruc", SqlDbType.VarChar, 11)).Value = (entidad.RUC != null ? entidad.RUC : ""); cmd.Parameters.Add(new SqlParameter("@FechaInicio", SqlDbType.SmallDateTime)).Value = DateTime.Parse(entidad.FechaInicio); cmd.Parameters.Add(new SqlParameter("@FechaFin", SqlDbType.SmallDateTime)).Value = DateTime.Parse(entidad.FechaFin); cmd.CommandType = CommandType.StoredProcedure; List <CanalEntidad> ListaCanal = new List <CanalEntidad>(); using (var reader = cmd.ExecuteReader()) { while (reader.Read()) { CanalEntidad oCanalEntidad = new CanalEntidad(); oCanalEntidad.Cod_Canal = Reader.GetStringValue(reader, "Cod_Canal"); oCanalEntidad.Canal = Reader.GetStringValue(reader, "Canal"); oCanalEntidad.Fecha_Inicio = Reader.GetDateTimeValue(reader, "Fecha_Inicio").ToString("dd/MM/yyyy"); oCanalEntidad.Fecha_Cese = Reader.GetDateTimeValue(reader, "Fecha_Cese").ToString("dd/MM/yyyy"); oCanalEntidad.Estado = Reader.GetStringValue(reader, "Estado"); oCanalEntidad.Direccion = Reader.GetStringValue(reader, "Dirección"); oCanalEntidad.Telefono1 = Reader.GetStringValue(reader, "Teléfono1"); oCanalEntidad.Telefono2 = Reader.GetStringValue(reader, "Teléfono2"); oCanalEntidad.Celular = Reader.GetStringValue(reader, "Celular"); oCanalEntidad.Distrito = new DistritoEntidad { Descripcion = Reader.GetStringValue(reader, "Descripcion"), }; oCanalEntidad.Representante_Legal = Reader.GetStringValue(reader, "Representante_Legal"); oCanalEntidad.Fecha_Ult_Camb = Reader.GetDateTimeValue(reader, "Fecha_Ult_Camb").ToString("dd/MM/yyyy"); oCanalEntidad.Usuario = new UsuarioEntidad { Nom_Usuario = Reader.GetStringValue(reader, "Nom_Usuario"), }; ListaCanal.Add(oCanalEntidad); } } return(ListaCanal); } catch (Exception ex) { return(null); } finally { Conexion.cerrarConexion(cn); } }
public bool grabarDatos(ReclamoEntidad entidad, ref string codigo) { SqlConnection cn = new SqlConnection(Conexion.CnBanca); SqlTransaction trans = null; try { bool estado = false; Conexion.abrirConexion(cn); trans = cn.BeginTransaction(); SqlCommand cmd = new SqlCommand("usp_Reclamo_Grabar", cn); cmd.Parameters.Add(new SqlParameter("@N_Solicitud", SqlDbType.VarChar, 15)).Value = entidad.Solicitud.N_Solicitud; cmd.Parameters.Add(new SqlParameter("@Tipo_Reclamo", SqlDbType.TinyInt)).Value = entidad.TipoReclamo.Cod_TipoReclamo; cmd.Parameters.Add(new SqlParameter("@Cod_MotivoRechazoSolicitud", SqlDbType.VarChar, 15)).Value = entidad.MotivoRechazoSolicitud.Cod_MotivoRechazoSolicitud; cmd.Parameters.Add(new SqlParameter("@Observaciones", SqlDbType.VarChar, 500)).Value = entidad.Observaciones; cmd.Parameters.Add(new SqlParameter("@Cod_Usuario", SqlDbType.TinyInt)).Value = entidad.Usuario.Cod_Usuario; cmd.Parameters.Add(new SqlParameter("@FechaInicio", SqlDbType.SmallDateTime)).Value = entidad.FechaInicio; cmd.Parameters.Add(new SqlParameter("@Estado", SqlDbType.Char, 1)).Value = entidad.Estado; cmd.Parameters.Add(new SqlParameter("@Cod_Reclamo", SqlDbType.VarChar, 15)).Direction = ParameterDirection.Output; cmd.CommandType = CommandType.StoredProcedure; cmd.Transaction = trans; if (cmd.ExecuteNonQuery() > 0) { estado = true; } if (estado) { codigo = cmd.Parameters["@Cod_Reclamo"].Value.ToString(); trans.Commit(); } else { trans.Rollback(); } return(estado); } catch (Exception ex) { if (trans != null) { trans.Rollback(); } return(false); } finally { Conexion.cerrarConexion(cn); } }
public bool grabarRespuesta(ReclamoEntidad entidad) { SqlConnection cn = new SqlConnection(Conexion.CnBanca); SqlTransaction trans = null; try { bool estado = false; Conexion.abrirConexion(cn); trans = cn.BeginTransaction(); SqlCommand cmd = new SqlCommand("usp_Reclamo_GrabarRespuesta", cn); cmd.Parameters.Add(new SqlParameter("@Cod_Reclamo", SqlDbType.VarChar, 15)).Value = entidad.Cod_Reclamo; cmd.Parameters.Add(new SqlParameter("@Cod_RespuestaReclamo", SqlDbType.VarChar, 15)).Value = entidad.RespuestaReclamo.Cod_RespuestaReclamo; cmd.CommandType = CommandType.StoredProcedure; cmd.Transaction = trans; if (cmd.ExecuteNonQuery() > 0) { estado = true; } if (estado) { trans.Commit(); } else { trans.Rollback(); } return(estado); } catch (Exception ex) { if (trans != null) { trans.Rollback(); } return(false); } finally { Conexion.cerrarConexion(cn); } }
public bool Activar(SolicitudEntidad entidad) { SqlConnection cn = new SqlConnection(Conexion.CnBanca); SqlTransaction trans = null; try { bool estado = false; Conexion.abrirConexion(cn); trans = cn.BeginTransaction(); SqlCommand cmd = new SqlCommand("usp_Solicitud_Activar", cn); cmd.Parameters.Add(new SqlParameter("@N_Solicitud", SqlDbType.VarChar, 15)).Value = entidad.N_Solicitud; cmd.Parameters.Add(new SqlParameter("@Estado", SqlDbType.VarChar, 2)).Value = entidad.Estado; cmd.CommandType = CommandType.StoredProcedure; cmd.Transaction = trans; if (cmd.ExecuteNonQuery() > 0) { estado = true; } if (estado) { trans.Commit(); } else { trans.Rollback(); } return(estado); } catch (Exception ex) { if (trans != null) { trans.Rollback(); } return(false); } finally { Conexion.cerrarConexion(cn); } }
public List <DistritoEntidad> listar(string Cod_Provincia) { SqlConnection cn = new SqlConnection(Conexion.CnBanca); try { Conexion.abrirConexion(cn); SqlCommand cmd = new SqlCommand("usp_Distrito_Listar", cn); cmd.Parameters.Add(new SqlParameter("@Cod_Provincia", SqlDbType.VarChar, 6)).Value = Cod_Provincia; cmd.CommandType = CommandType.StoredProcedure; List <DistritoEntidad> ListaDistritos = new List <DistritoEntidad>(); using (var reader = cmd.ExecuteReader()) { while (reader.Read()) { DistritoEntidad oDistritoEntidad = new DistritoEntidad(); oDistritoEntidad.Cod_Distrito = Reader.GetStringValue(reader, "Cod_Distrito"); oDistritoEntidad.Descripcion = Reader.GetStringValue(reader, "Descripcion"); oDistritoEntidad.Provincia = new ProvinciaEntidad { Cod_Provincia = Reader.GetStringValue(reader, "Cod_Provincia"), }; ListaDistritos.Add(oDistritoEntidad); } } return(ListaDistritos); } catch (Exception ex) { return(null); } finally { Conexion.cerrarConexion(cn); } }
public List <SolicitudEntidad> FiltrarActivas(SolicitudEntidad entidad) { SqlConnection cn = new SqlConnection(Conexion.CnBanca); try { Conexion.abrirConexion(cn); SqlCommand cmd = new SqlCommand("usp_Solicitud_Filtrar_Activos", cn); cmd.Parameters.Add(new SqlParameter("@FechaInicio", SqlDbType.SmallDateTime)).Value = DateTime.Parse(entidad.FechaInicio); cmd.Parameters.Add(new SqlParameter("@FechaFin", SqlDbType.SmallDateTime)).Value = DateTime.Parse(entidad.FechaFin); cmd.Parameters.Add(new SqlParameter("@Cod_Canal", SqlDbType.VarChar, 15)).Value = (entidad.Canal.Cod_Canal != null ? entidad.Canal.Cod_Canal : ""); cmd.Parameters.Add(new SqlParameter("@Cod_Producto", SqlDbType.VarChar, 15)).Value = (entidad.Producto.Cod_Producto != null ? entidad.Producto.Cod_Producto : ""); cmd.Parameters.Add(new SqlParameter("@TipoComision", SqlDbType.TinyInt)).Value = entidad.TipoComision; cmd.CommandType = CommandType.StoredProcedure; List <SolicitudEntidad> ListaSolicitudes = new List <SolicitudEntidad>(); using (var reader = cmd.ExecuteReader()) { while (reader.Read()) { SolicitudEntidad oSolicitudEntidad = new SolicitudEntidad(); oSolicitudEntidad.Fecha_Aprob_Rech = Reader.GetDateTimeValue(reader, "Fecha_Aprob_Rech").ToString("dd/MM/yyyy"); oSolicitudEntidad.BT_Cliente = Reader.GetStringValue(reader, "BT_Cliente"); oSolicitudEntidad.N_Operación = Reader.GetStringValue(reader, "N_Operación"); oSolicitudEntidad.Producto = new ProductoEntidad { Producto = Reader.GetStringValue(reader, "Producto"), }; oSolicitudEntidad.SubProducto = new SubProductoEntidad { SubProducto = Reader.GetStringValue(reader, "SubProducto"), }; oSolicitudEntidad.Moneda = Reader.GetStringValue(reader, "Moneda"); oSolicitudEntidad.Línea_Desembolsos = Reader.GetDecimalValue(reader, "Línea_Desembolsos"); oSolicitudEntidad.Plazo = Reader.GetSmallIntValue(reader, "Plazo"); oSolicitudEntidad.Saldo_Ant = Reader.GetDecimalValue(reader, "Saldo_Ant"); oSolicitudEntidad.Saldo_Act = Reader.GetDecimalValue(reader, "Saldo_Act"); oSolicitudEntidad.Canal = new CanalEntidad { Canal = Reader.GetStringValue(reader, "Canal"), }; oSolicitudEntidad.Vendedor = new VendedorEntidad { Nombre = Reader.GetStringValue(reader, "Nombre"), Apellido = Reader.GetStringValue(reader, "Apellido"), Apellido2 = Reader.GetStringValue(reader, "Apellido2"), }; oSolicitudEntidad.Estado = Reader.GetStringValue(reader, "Estado"); oSolicitudEntidad.TipoComision = Reader.GetTinyIntValue(reader, "TipoComision"); oSolicitudEntidad.Reclamo = Reader.GetStringValue(reader, "Reclamo"); ListaSolicitudes.Add(oSolicitudEntidad); } } return(ListaSolicitudes.OrderBy(x => x.Fecha_Aprob_Rech).ToList()); } catch (Exception ex) { return(null); } finally { Conexion.cerrarConexion(cn); } }
public bool modificarDatos(VendedorEntidad entidad) { SqlConnection cn = new SqlConnection(Conexion.CnBanca); SqlTransaction trans = null; try { bool estado = false; Conexion.abrirConexion(cn); trans = cn.BeginTransaction(); SqlCommand cmd = new SqlCommand("usp_Vendedor_Modificar", cn); cmd.Parameters.Add(new SqlParameter("@Cod_Vendedor", SqlDbType.VarChar, 15)).Value = entidad.Cod_Vendedor.Trim(); cmd.Parameters.Add(new SqlParameter("@Cod_Canal", SqlDbType.VarChar, 15)).Value = entidad.Cod_Canal.Trim(); cmd.Parameters.Add(new SqlParameter("@Cod_SubCanal", SqlDbType.VarChar, 15)).Value = entidad.Cod_SubCanal.Trim(); cmd.Parameters.Add(new SqlParameter("@Cod_Region", SqlDbType.VarChar, 6)).Value = entidad.Region.Cod_Region; cmd.Parameters.Add(new SqlParameter("@Cod_Provincia", SqlDbType.VarChar, 6)).Value = entidad.Provincia.Cod_Provincia; cmd.Parameters.Add(new SqlParameter("@Cod_Distrito", SqlDbType.VarChar, 6)).Value = entidad.Distrito.Cod_Distrito; cmd.Parameters.Add(new SqlParameter("@Tipo_Doc", SqlDbType.TinyInt)).Value = entidad.Tipo_Doc.Tipo_Doc; cmd.Parameters.Add(new SqlParameter("@Num_Doc", SqlDbType.VarChar, 15)).Value = entidad.Num_Doc.Trim(); cmd.Parameters.Add(new SqlParameter("@Nombre", SqlDbType.VarChar, 150)).Value = entidad.Nombre.Trim(); cmd.Parameters.Add(new SqlParameter("@Apellido", SqlDbType.VarChar, 150)).Value = entidad.Apellido.Trim(); cmd.Parameters.Add(new SqlParameter("@Apellido2", SqlDbType.VarChar, 150)).Value = entidad.Apellido2.Trim(); cmd.Parameters.Add(new SqlParameter("@Direccion", SqlDbType.VarChar, 250)).Value = entidad.Direccion.Trim(); cmd.Parameters.Add(new SqlParameter("@Telefono1", SqlDbType.VarChar, 15)).Value = entidad.Telefono1.Trim(); cmd.Parameters.Add(new SqlParameter("@Telefono2", SqlDbType.VarChar, 15)).Value = entidad.Telefono2.Trim(); cmd.Parameters.Add(new SqlParameter("@Celular", SqlDbType.VarChar, 15)).Value = entidad.Celular.Trim(); cmd.Parameters.Add(new SqlParameter("@Fecha_Inicio", SqlDbType.SmallDateTime)).Value = DateTime.Parse(entidad.Fecha_Inicio.Trim()); cmd.Parameters.Add(new SqlParameter("@Fecha_Cese", SqlDbType.SmallDateTime)).Value = DateTime.Parse(entidad.Fecha_Cese.Trim()); cmd.Parameters.Add(new SqlParameter("@Estado", SqlDbType.Char, 1)).Value = entidad.Estado.Trim(); cmd.Parameters.Add(new SqlParameter("@Cod_Usuario", SqlDbType.TinyInt)).Value = entidad.Usuario.Cod_Usuario; cmd.CommandType = CommandType.StoredProcedure; cmd.Transaction = trans; if (cmd.ExecuteNonQuery() > 0) { estado = true; } if (estado) { trans.Commit(); } else { trans.Rollback(); } return(estado); } catch (Exception ex) { if (trans != null) { trans.Rollback(); } return(false); } finally { Conexion.cerrarConexion(cn); } }
public List <VendedorEntidad> obtenerDatosXFiltro(VendedorEntidad entidad) { SqlConnection cn = new SqlConnection(Conexion.CnBanca); try { Conexion.abrirConexion(cn); SqlCommand cmd = new SqlCommand("usp_Vendedor_Filtrar", cn); cmd.Parameters.Add(new SqlParameter("@Cod_Canal", SqlDbType.VarChar, 15)).Value = (entidad.Canal.Cod_Canal != null ? entidad.Canal.Cod_Canal : ""); cmd.Parameters.Add(new SqlParameter("@Cod_SubCanal", SqlDbType.VarChar, 15)).Value = (entidad.SubCanal.Cod_SubCanal != null ? entidad.SubCanal.Cod_SubCanal : ""); cmd.Parameters.Add(new SqlParameter("@Tipo_Doc", SqlDbType.TinyInt)).Value = (entidad.Tipo_Doc.Tipo_Doc != null ? entidad.Tipo_Doc.Tipo_Doc : 0); cmd.Parameters.Add(new SqlParameter("@Num_Doc", SqlDbType.VarChar, 15)).Value = (entidad.Num_Doc != null ? entidad.Num_Doc : ""); cmd.Parameters.Add(new SqlParameter("@Nombre", SqlDbType.VarChar, 150)).Value = (entidad.Nombre != null ? entidad.Nombre : ""); cmd.Parameters.Add(new SqlParameter("@Apellido", SqlDbType.VarChar, 150)).Value = (entidad.Apellido != null ? entidad.Apellido : ""); cmd.Parameters.Add(new SqlParameter("@FechaInicio", SqlDbType.SmallDateTime)).Value = DateTime.Parse(entidad.FechaInicio); cmd.Parameters.Add(new SqlParameter("@FechaFin", SqlDbType.SmallDateTime)).Value = DateTime.Parse(entidad.FechaFin); cmd.CommandType = CommandType.StoredProcedure; List <VendedorEntidad> ListaVendedor = new List <VendedorEntidad>(); using (var reader = cmd.ExecuteReader()) { while (reader.Read()) { VendedorEntidad oVendedorEntidad = new VendedorEntidad(); oVendedorEntidad.Cod_Vendedor = Reader.GetStringValue(reader, "Cod_Vendedor"); oVendedorEntidad.Canal = new CanalEntidad { Canal = Reader.GetStringValue(reader, "Canal"), }; oVendedorEntidad.SubCanal = new SubCanalEntidad { SubCanal = Reader.GetStringValue(reader, "SubCanal"), }; oVendedorEntidad.Distrito = new DistritoEntidad { Descripcion = Reader.GetStringValue(reader, "Descripcion"), }; oVendedorEntidad.Tipo_Doc = new TipoDocumentoEntidad { Nomb_Doc = Reader.GetStringValue(reader, "Nomb_Doc"), }; oVendedorEntidad.Num_Doc = Reader.GetStringValue(reader, "Num_Doc"); oVendedorEntidad.Nombre = Reader.GetStringValue(reader, "Nombre"); oVendedorEntidad.Apellido = Reader.GetStringValue(reader, "Apellido"); oVendedorEntidad.Apellido2 = Reader.GetStringValue(reader, "Apellido2"); oVendedorEntidad.Direccion = Reader.GetStringValue(reader, "Dirección"); oVendedorEntidad.Telefono1 = Reader.GetStringValue(reader, "Telefono1"); oVendedorEntidad.Telefono2 = Reader.GetStringValue(reader, "Telefono2"); oVendedorEntidad.Celular = Reader.GetStringValue(reader, "Celular"); oVendedorEntidad.Fecha_Inicio = Reader.GetDateTimeValue(reader, "Fecha_Inicio").ToString("dd/MM/yyyy"); oVendedorEntidad.Fecha_Cese = Reader.GetDateTimeValue(reader, "Fecha_Cese").ToString("dd/MM/yyyy"); oVendedorEntidad.Estado = Reader.GetStringValue(reader, "Estado"); oVendedorEntidad.Fecha_Ult_Camb = Reader.GetDateTimeValue(reader, "Fecha_Ult_Camb").ToString("dd/MM/yyyy"); oVendedorEntidad.Usuario = new UsuarioEntidad { Nom_Usuario = Reader.GetStringValue(reader, "Nom_Usuario"), }; ListaVendedor.Add(oVendedorEntidad); } } return(ListaVendedor); } catch (Exception ex) { return(null); } finally { Conexion.cerrarConexion(cn); } }
public bool grabarDiferido(List <PagoComisionEntidad> lista, ref string Cod_Diferido) { SqlConnection cn = new SqlConnection(Conexion.CnBanca); SqlTransaction trans = null; try { bool estado = true; Cod_Diferido = ""; Conexion.abrirConexion(cn); trans = cn.BeginTransaction(); SqlCommand cmd_01 = new SqlCommand("usp_Correlativo_CrearCorrelativo", cn); cmd_01.CommandType = CommandType.StoredProcedure; cmd_01.Transaction = trans; cmd_01.Parameters.Add(new SqlParameter("@Flag", SqlDbType.VarChar, 2)).Value = "CD"; cmd_01.Parameters.Add(new SqlParameter("@Codigo", SqlDbType.VarChar, 15)).Direction = ParameterDirection.Output; if (cmd_01.ExecuteNonQuery() > 0) { Cod_Diferido = cmd_01.Parameters["@Codigo"].Value.ToString(); } else { estado = false; } if (string.IsNullOrWhiteSpace(Cod_Diferido) == false) { foreach (var entidad in lista) { SqlCommand cmd_02 = new SqlCommand("usp_PagoComision_GrabarDiferido", cn); cmd_02.CommandType = CommandType.StoredProcedure; cmd_02.Transaction = trans; cmd_02.Parameters.Add(new SqlParameter("@IdPagoComision", SqlDbType.Int)).Value = entidad.IdPagoComision; cmd_02.Parameters.Add(new SqlParameter("@MontoDiferido", SqlDbType.Real)).Value = entidad.MontoDiferido; cmd_02.Parameters.Add(new SqlParameter("@FechaDiferido", SqlDbType.SmallDateTime)).Value = DateTime.Parse(entidad.FechaDiferido); cmd_02.Parameters.Add(new SqlParameter("@SaldoPendiente", SqlDbType.Real)).Value = entidad.SaldoPendiente; cmd_02.Parameters.Add(new SqlParameter("@Cod_Diferido", SqlDbType.VarChar, 15)).Value = Cod_Diferido; cmd_02.Parameters.Add(new SqlParameter("@CuentaContable2", SqlDbType.VarChar, 20)).Value = entidad.CuentaContable2; if (cmd_02.ExecuteNonQuery() < 1) { estado = false; break; } } } if (estado) { trans.Commit(); } else { estado = false; Cod_Diferido = ""; trans.Rollback(); } return(estado); } catch (Exception ex) { if (trans != null) { trans.Rollback(); } return(false); } finally { Conexion.cerrarConexion(cn); } }
public VendedorEntidad obtenerDatosXCodigo(string codigo) { SqlConnection cn = new SqlConnection(Conexion.CnBanca); try { Conexion.abrirConexion(cn); SqlCommand cmd = new SqlCommand("usp_Vendedor_FiltrarxCodigo", cn); cmd.Parameters.Add(new SqlParameter("@Cod_Vendedor", SqlDbType.VarChar, 15)).Value = codigo; cmd.CommandType = CommandType.StoredProcedure; VendedorEntidad oVendedorEntidad = null; using (var reader = cmd.ExecuteReader()) { while (reader.Read()) { oVendedorEntidad = new VendedorEntidad(); oVendedorEntidad.Cod_Vendedor = Reader.GetStringValue(reader, "Cod_Vendedor"); oVendedorEntidad.Canal = new CanalEntidad { Cod_Canal = Reader.GetStringValue(reader, "Cod_Canal"), }; oVendedorEntidad.SubCanal = new SubCanalEntidad { Cod_SubCanal = Reader.GetStringValue(reader, "Cod_SubCanal"), }; oVendedorEntidad.Region = new RegionEntidad { Cod_Region = Reader.GetStringValue(reader, "Cod_Region"), }; oVendedorEntidad.Provincia = new ProvinciaEntidad { Cod_Provincia = Reader.GetStringValue(reader, "Cod_Provincia"), }; oVendedorEntidad.Distrito = new DistritoEntidad { Cod_Distrito = Reader.GetStringValue(reader, "Cod_Distrito"), }; oVendedorEntidad.Tipo_Doc = new TipoDocumentoEntidad { Tipo_Doc = Reader.GetTinyIntValue(reader, "Tipo_Doc"), }; oVendedorEntidad.Num_Doc = Reader.GetStringValue(reader, "Num_Doc"); oVendedorEntidad.Nombre = Reader.GetStringValue(reader, "Nombre"); oVendedorEntidad.Apellido = Reader.GetStringValue(reader, "Apellido"); oVendedorEntidad.Apellido2 = Reader.GetStringValue(reader, "Apellido2"); oVendedorEntidad.Direccion = Reader.GetStringValue(reader, "Dirección"); oVendedorEntidad.Telefono1 = Reader.GetStringValue(reader, "Telefono1"); oVendedorEntidad.Telefono2 = Reader.GetStringValue(reader, "Telefono2"); oVendedorEntidad.Celular = Reader.GetStringValue(reader, "Celular"); oVendedorEntidad.Fecha_Inicio = Reader.GetDateTimeValue(reader, "Fecha_Inicio").ToString("dd/MM/yyyy"); oVendedorEntidad.Fecha_Cese = Reader.GetDateTimeValue(reader, "Fecha_Cese").ToString("dd/MM/yyyy"); oVendedorEntidad.Estado = Reader.GetStringValue(reader, "Estado"); oVendedorEntidad.Fecha_Ult_Camb = Reader.GetDateTimeValue(reader, "Fecha_Ult_Camb").ToString("dd/MM/yyyy"); oVendedorEntidad.Usuario = new UsuarioEntidad { Cod_Usuario = Reader.GetTinyIntValue(reader, "Cod_Usuario"), }; } } return(oVendedorEntidad); } catch (Exception ex) { return(null); } finally { Conexion.cerrarConexion(cn); } }
public List <PagoComisionEntidad> FiltrarDiferidos(PagoComisionEntidad entidad) { SqlConnection cn = new SqlConnection(Conexion.CnBanca); try { Conexion.abrirConexion(cn); SqlCommand cmd = new SqlCommand("usp_PagoComision_FiltrarDiferido", cn); cmd.Parameters.Add(new SqlParameter("@FechaInicio", SqlDbType.SmallDateTime)).Value = DateTime.Parse(entidad.FechaInicio); cmd.Parameters.Add(new SqlParameter("@FechaFin", SqlDbType.SmallDateTime)).Value = DateTime.Parse(entidad.FechaFin); cmd.Parameters.Add(new SqlParameter("@Cod_Canal", SqlDbType.VarChar, 15)).Value = (entidad.Canal.Cod_Canal != null ? entidad.Canal.Cod_Canal : ""); cmd.Parameters.Add(new SqlParameter("@TipoComision", SqlDbType.TinyInt)).Value = entidad.TipoComision; cmd.Parameters.Add(new SqlParameter("@Cod_Producto", SqlDbType.VarChar, 15)).Value = (entidad.Producto.Cod_Producto != null ? entidad.Producto.Cod_Producto : ""); cmd.CommandType = CommandType.StoredProcedure; List <PagoComisionEntidad> ListaPagoComisiones = new List <PagoComisionEntidad>(); using (var reader = cmd.ExecuteReader()) { while (reader.Read()) { PagoComisionEntidad oPagoComisionEntidad = new PagoComisionEntidad(); oPagoComisionEntidad.Fecha_Aprob_Rech = Reader.GetDateTimeValue(reader, "Fecha_Aprob_Rech").ToString("dd/MM/yyyy"); oPagoComisionEntidad.BT_Cliente = Reader.GetStringValue(reader, "BT_Cliente"); oPagoComisionEntidad.N_Operación = Reader.GetStringValue(reader, "N_Operación"); oPagoComisionEntidad.Producto = new ProductoEntidad { Producto = Reader.GetStringValue(reader, "Producto"), }; oPagoComisionEntidad.SubProducto = new SubProductoEntidad { SubProducto = Reader.GetStringValue(reader, "SubProducto"), }; oPagoComisionEntidad.Moneda = Reader.GetStringValue(reader, "Moneda"); oPagoComisionEntidad.Línea_Desembolsos = Reader.GetDecimalValue(reader, "Línea_Desembolsos"); oPagoComisionEntidad.Plazo = Reader.GetSmallIntValue(reader, "Plazo"); oPagoComisionEntidad.Canal = new CanalEntidad { Canal = Reader.GetStringValue(reader, "Canal"), }; oPagoComisionEntidad.Subcanal = new SubCanalEntidad { SubCanal = Reader.GetStringValue(reader, "SubCanal"), }; oPagoComisionEntidad.Vendedor = new VendedorEntidad { Nombre = Reader.GetStringValue(reader, "Nombre"), Apellido = Reader.GetStringValue(reader, "Apellido"), Apellido2 = Reader.GetStringValue(reader, "Apellido2"), }; oPagoComisionEntidad.Estado = Reader.GetStringValue(reader, "Estado"); oPagoComisionEntidad.FechaComision = Reader.GetDateTimeValue(reader, "FechaComision").ToString("dd/MM/yyyy"); oPagoComisionEntidad.MontoComision = Reader.GetDecimalValue(reader, "MontoComision"); oPagoComisionEntidad.Tarifario = Reader.GetDecimalValue(reader, "Tarifario"); oPagoComisionEntidad.TipoTarifa = Reader.GetTinyIntValue(reader, "TipoTarifa"); oPagoComisionEntidad.Cod_Comision = Reader.GetStringValue(reader, "Cod_Comision"); oPagoComisionEntidad.CuentaContable1 = Reader.GetStringValue(reader, "CuentaContable1"); oPagoComisionEntidad.FechaDiferido = Reader.GetDateTimeValue(reader, "FechaDiferido").ToString("dd/MM/yyyy"); oPagoComisionEntidad.Solicitud = new SolicitudEntidad { Estado = Reader.GetStringValue(reader, "Estado_Solicitud") }; oPagoComisionEntidad.MontoDiferido = Reader.GetDecimalValue(reader, "MontoDiferido"); oPagoComisionEntidad.SaldoPendiente = Reader.GetDecimalValue(reader, "SaldoPendiente"); oPagoComisionEntidad.SaldoPagado = Reader.GetDecimalValue(reader, "SaldoPagado"); oPagoComisionEntidad.CuentaContable2 = Reader.GetStringValue(reader, "CuentaContable2"); oPagoComisionEntidad.Cod_Diferido = Reader.GetStringValue(reader, "Cod_Diferido"); ListaPagoComisiones.Add(oPagoComisionEntidad); } } return(ListaPagoComisiones); } catch (Exception ex) { return(null); } finally { Conexion.cerrarConexion(cn); } }
public List <TarifarioEntidad> obtenerDatosXFiltro(TarifarioEntidad entidad) { SqlConnection cn = new SqlConnection(Conexion.CnBanca); try { Conexion.abrirConexion(cn); SqlCommand cmd = new SqlCommand("usp_Tarifario_Filtrar", cn); cmd.Parameters.Add(new SqlParameter("@Cod_Canal", SqlDbType.VarChar, 15)).Value = (entidad.Canal.Cod_Canal != null ? entidad.Canal.Cod_Canal : ""); cmd.Parameters.Add(new SqlParameter("@Cod_SubCanal", SqlDbType.VarChar, 15)).Value = (entidad.SubCanal.Cod_SubCanal != null ? entidad.SubCanal.Cod_SubCanal : ""); cmd.Parameters.Add(new SqlParameter("@Ruc", SqlDbType.VarChar, 11)).Value = (entidad.Canal.RUC != null ? entidad.Canal.RUC : ""); cmd.Parameters.Add(new SqlParameter("@FechaInicio", SqlDbType.SmallDateTime)).Value = DateTime.Parse(entidad.FechaInicio); cmd.Parameters.Add(new SqlParameter("@FechaFin", SqlDbType.SmallDateTime)).Value = DateTime.Parse(entidad.FechaFin); cmd.CommandType = CommandType.StoredProcedure; List <TarifarioEntidad> ListaTarifario = new List <TarifarioEntidad>(); using (var reader = cmd.ExecuteReader()) { while (reader.Read()) { TarifarioEntidad oTarifarioEntidad = new TarifarioEntidad(); oTarifarioEntidad.Cod_Tarifa = Reader.GetIntValue(reader, "Cod_Tarifa"); oTarifarioEntidad.Canal = new CanalEntidad { Canal = Reader.GetStringValue(reader, "Canal"), }; oTarifarioEntidad.SubCanal = new SubCanalEntidad { SubCanal = Reader.GetStringValue(reader, "SubCanal"), }; oTarifarioEntidad.Producto = new ProductoEntidad { Cod_Producto = Reader.GetStringValue(reader, "Cod_Producto"), Producto = Reader.GetStringValue(reader, "Producto"), }; oTarifarioEntidad.SubProducto = new SubProductoEntidad { Cod_SubProducto = Reader.GetStringValue(reader, "Cod_SubProducto"), SubProducto = Reader.GetStringValue(reader, "SubProducto"), }; oTarifarioEntidad.Tarifa_Inicio = Reader.GetDecimalValue(reader, "Tarifa_Inicio"); oTarifarioEntidad.Tarifa_Fin = Reader.GetDecimalValue(reader, "Tarifa_Fin"); oTarifarioEntidad.Tipo = Reader.GetTinyIntValue(reader, "Tipo"); oTarifarioEntidad.Tarifario = Reader.GetDecimalValue(reader, "Tarifario"); oTarifarioEntidad.Estado = Reader.GetStringValue(reader, "Estado"); oTarifarioEntidad.Fecha_Registro = Reader.GetDateTimeValue(reader, "Fecha_Registro").ToString("dd/MM/yyyy"); oTarifarioEntidad.Usuario = new UsuarioEntidad { Empleado = new EmpleadoEntidad { Nombre = Reader.GetStringValue(reader, "Nombre"), Apellido = Reader.GetStringValue(reader, "Apellido"), Apellido2 = Reader.GetStringValue(reader, "Apellido2"), } }; ListaTarifario.Add(oTarifarioEntidad); } } return(ListaTarifario); } catch (Exception ex) { return(null); } finally { Conexion.cerrarConexion(cn); } }
public bool grabarDatos(List <SolicitudEntidad> lista, ref string Cod_Comision) { SqlConnection cn = new SqlConnection(Conexion.CnBanca); SqlTransaction trans = null; try { bool estado = true; Cod_Comision = ""; Conexion.abrirConexion(cn); trans = cn.BeginTransaction(); SqlCommand cmd_01 = new SqlCommand("usp_Correlativo_CrearCorrelativo", cn); cmd_01.CommandType = CommandType.StoredProcedure; cmd_01.Transaction = trans; cmd_01.Parameters.Add(new SqlParameter("@Flag", SqlDbType.VarChar, 2)).Value = "CC"; cmd_01.Parameters.Add(new SqlParameter("@Codigo", SqlDbType.VarChar, 15)).Direction = ParameterDirection.Output; if (cmd_01.ExecuteNonQuery() > 0) { Cod_Comision = cmd_01.Parameters["@Codigo"].Value.ToString(); } else { estado = false; } if (string.IsNullOrWhiteSpace(Cod_Comision) == false) { foreach (var entidad in lista) { SqlCommand cmd_02 = new SqlCommand("usp_PagoComision_Grabar", cn); cmd_02.CommandType = CommandType.StoredProcedure; cmd_02.Transaction = trans; cmd_02.Parameters.Add(new SqlParameter("@Cod_Comision", SqlDbType.VarChar, 15)).Value = Cod_Comision; cmd_02.Parameters.Add(new SqlParameter("@N_Solicitud", SqlDbType.VarChar, 15)).Value = entidad.N_Solicitud; cmd_02.Parameters.Add(new SqlParameter("@Cod_Canal", SqlDbType.VarChar, 15)).Value = entidad.Canal.Cod_Canal; cmd_02.Parameters.Add(new SqlParameter("@Cod_SubCanal", SqlDbType.VarChar, 15)).Value = entidad.Subcanal.Cod_SubCanal; cmd_02.Parameters.Add(new SqlParameter("@Cod_Region", SqlDbType.VarChar, 6)).Value = entidad.Region.Cod_Region; cmd_02.Parameters.Add(new SqlParameter("@Cod_Provincia", SqlDbType.VarChar, 6)).Value = entidad.Provincia.Cod_Provincia; cmd_02.Parameters.Add(new SqlParameter("@Cod_Distrito", SqlDbType.VarChar, 6)).Value = entidad.Distrito.Cod_Distrito; cmd_02.Parameters.Add(new SqlParameter("@Cod_Vendedor", SqlDbType.VarChar, 15)).Value = entidad.Vendedor.Cod_Vendedor; cmd_02.Parameters.Add(new SqlParameter("@Fecha_Ingreso", SqlDbType.SmallDateTime)).Value = DateTime.Parse(entidad.Fecha_Ingreso); cmd_02.Parameters.Add(new SqlParameter("@Fecha_Aprob_Rech", SqlDbType.SmallDateTime)).Value = DateTime.Parse(entidad.Fecha_Aprob_Rech); //cmd_02.Parameters.Add(new SqlParameter("@Estado", SqlDbType.VarChar, 2)).Value = entidad.Estado; cmd_02.Parameters.Add(new SqlParameter("@Línea_Desembolsos", SqlDbType.Real)).Value = entidad.Línea_Desembolsos; cmd_02.Parameters.Add(new SqlParameter("@Cod_Producto", SqlDbType.VarChar, 15)).Value = entidad.Producto.Cod_Producto; cmd_02.Parameters.Add(new SqlParameter("@Cod_SubProducto", SqlDbType.VarChar, 15)).Value = entidad.SubProducto.Cod_SubProducto; cmd_02.Parameters.Add(new SqlParameter("@Plazo", SqlDbType.SmallInt)).Value = entidad.Plazo; cmd_02.Parameters.Add(new SqlParameter("@Saldo_Act", SqlDbType.Real)).Value = entidad.Saldo_Act; cmd_02.Parameters.Add(new SqlParameter("@BT_Cliente", SqlDbType.VarChar, 15)).Value = entidad.BT_Cliente; cmd_02.Parameters.Add(new SqlParameter("@N_Operación", SqlDbType.VarChar, 15)).Value = entidad.N_Operación; cmd_02.Parameters.Add(new SqlParameter("@FechaComision", SqlDbType.SmallDateTime)).Value = entidad.FechaComision; cmd_02.Parameters.Add(new SqlParameter("@MontoComision", SqlDbType.Real)).Value = entidad.ComisionTarifario; cmd_02.Parameters.Add(new SqlParameter("@Tarifario", SqlDbType.Real)).Value = entidad.Tarifario; cmd_02.Parameters.Add(new SqlParameter("@TipoTarifa", SqlDbType.TinyInt)).Value = entidad.Tipo; cmd_02.Parameters.Add(new SqlParameter("@TipoComision", SqlDbType.TinyInt)).Value = entidad.TipoComision; if (cmd_02.ExecuteNonQuery() < 1) { estado = false; break; } } } if (estado) { trans.Commit(); } else { estado = false; Cod_Comision = ""; trans.Rollback(); } return(estado); } catch (Exception ex) { if (trans != null) { trans.Rollback(); } return(false); } finally { Conexion.cerrarConexion(cn); } }
public ReclamoEntidad FiltrarxCodigo(string codigo) { SqlConnection cn = new SqlConnection(Conexion.CnBanca); try { Conexion.abrirConexion(cn); SqlCommand cmd = new SqlCommand("usp_Reclamo_FiltrarxCodigo", cn); cmd.Parameters.Add(new SqlParameter("@Cod_Reclamo", SqlDbType.VarChar, 15)).Value = codigo; cmd.CommandType = CommandType.StoredProcedure; ReclamoEntidad oReclamoEntidad = null; using (var reader = cmd.ExecuteReader()) { while (reader.Read()) { oReclamoEntidad = new ReclamoEntidad(); oReclamoEntidad.Cod_Reclamo = Reader.GetStringValue(reader, "Cod_Reclamo"); oReclamoEntidad.Solicitud = new SolicitudEntidad { N_Solicitud = Reader.GetStringValue(reader, "N_Solicitud"), Vendedor = new VendedorEntidad { Cod_Vendedor = Reader.GetStringValue(reader, "Cod_Vendedor"), Nombre = Reader.GetStringValue(reader, "Nombre_Vendedor"), Apellido = Reader.GetStringValue(reader, "ApellidoPaterno_Vendedor"), Apellido2 = Reader.GetStringValue(reader, "ApellidoMaterno_Vendedor"), }, Canal = new CanalEntidad { Canal = Reader.GetStringValue(reader, "Canal"), }, Subcanal = new SubCanalEntidad { SubCanal = Reader.GetStringValue(reader, "Subcanal"), }, Region = new RegionEntidad { Descripcion = Reader.GetStringValue(reader, "Region"), }, Provincia = new ProvinciaEntidad { Descripcion = Reader.GetStringValue(reader, "Provincia"), }, Distrito = new DistritoEntidad { Descripcion = Reader.GetStringValue(reader, "Distrito"), }, BT_Cliente = Reader.GetStringValue(reader, "BT_Cliente"), Tipo_Doc = new TipoDocumentoEntidad { Nomb_Doc = Reader.GetStringValue(reader, "NomTipoDocumento_Cliente"), }, Num_Doc = Reader.GetStringValue(reader, "NumeroDocumento_Cliente"), Nombre_Cliente = Reader.GetStringValue(reader, "Nombre_Cliente"), Apellido1_Cliente = Reader.GetStringValue(reader, "Apellido1_Cliente"), Apellido2_Cliente = Reader.GetStringValue(reader, "Apellido2_Cliente"), N_Operación = Reader.GetStringValue(reader, "N_Operación"), Fecha_Aprob_Rech = Reader.GetDateTimeValue(reader, "Fecha_Aprob_Rech").ToString("dd/MM/yyyy"), Producto = new ProductoEntidad { Producto = Reader.GetStringValue(reader, "Producto"), }, SubProducto = new SubProductoEntidad { SubProducto = Reader.GetStringValue(reader, "SubProducto"), }, }; oReclamoEntidad.TipoReclamo = new TipoReclamoEntidad { Cod_TipoReclamo = Reader.GetTinyIntValue(reader, "Tipo_Reclamo"), //Nom_TipoReclamo = Reader.GetStringValue(reader, "Nom_TipoReclamo"), }; oReclamoEntidad.MotivoRechazoSolicitud = new MotivoRechazoSolicitudEntidad { Cod_MotivoRechazoSolicitud = Reader.GetStringValue(reader, "Cod_MotivoRechazoSolicitud"), }; oReclamoEntidad.RespuestaReclamo = new RespuestaReclamoEntidad { Cod_RespuestaReclamo = Reader.GetStringValue(reader, "Cod_RespuestaReclamo"), }; oReclamoEntidad.Observaciones = Reader.GetStringValue(reader, "Observaciones"); oReclamoEntidad.Usuario = new UsuarioEntidad { Nom_Usuario = Reader.GetStringValue(reader, "Nom_Usuario"), }; oReclamoEntidad.FechaInicio = Reader.GetDateTimeValue(reader, "FechaInicio").ToString("dd/MM/yyyy"); oReclamoEntidad.FechaFin = Reader.GetDateTimeValue(reader, "FechaFin").ToString("dd/MM/yyyy"); oReclamoEntidad.Estado = Reader.GetStringValue(reader, "Estado"); } } return(oReclamoEntidad); } catch (Exception ex) { return(null); } finally { Conexion.cerrarConexion(cn); } }
public List <ReclamoEntidad> obtenerDatosXFiltro(ReclamoEntidad entidad) { SqlConnection cn = new SqlConnection(Conexion.CnBanca); try { Conexion.abrirConexion(cn); SqlCommand cmd = new SqlCommand("usp_Reclamo_Filtrar", cn); cmd.Parameters.Add(new SqlParameter("@FechaInicio", SqlDbType.SmallDateTime)).Value = entidad.FechaInicio; cmd.Parameters.Add(new SqlParameter("@FechaFin", SqlDbType.SmallDateTime)).Value = entidad.FechaFin; cmd.Parameters.Add(new SqlParameter("@Ruc", SqlDbType.VarChar, 11)).Value = (entidad.Ruc != null ? entidad.Ruc : ""); cmd.Parameters.Add(new SqlParameter("@Cod_Canal", SqlDbType.VarChar, 15)).Value = (entidad.Solicitud.Canal.Cod_Canal != null ? entidad.Solicitud.Canal.Cod_Canal : ""); cmd.Parameters.Add(new SqlParameter("@Cod_Subcanal", SqlDbType.VarChar, 15)).Value = (entidad.Solicitud.Subcanal.Cod_SubCanal != null ? entidad.Solicitud.Subcanal.Cod_SubCanal : ""); cmd.Parameters.Add(new SqlParameter("@Cod_Vendedor", SqlDbType.VarChar, 15)).Value = (entidad.Solicitud.Vendedor.Cod_Vendedor != null ? entidad.Solicitud.Vendedor.Cod_Vendedor : ""); cmd.Parameters.Add(new SqlParameter("@NombresVendedor", SqlDbType.VarChar, 150)).Value = (entidad.Solicitud.Vendedor.Nombre != null ? entidad.Solicitud.Vendedor.Nombre : ""); cmd.Parameters.Add(new SqlParameter("@ApellidosVendedor", SqlDbType.VarChar, 150)).Value = (entidad.Solicitud.Vendedor.Apellido != null ? entidad.Solicitud.Vendedor.Apellido : ""); cmd.Parameters.Add(new SqlParameter("@Tipo_Doc", SqlDbType.TinyInt)).Value = (entidad.Solicitud.Vendedor.Tipo_Doc.Tipo_Doc != null ? entidad.Solicitud.Vendedor.Tipo_Doc.Tipo_Doc : 0); cmd.Parameters.Add(new SqlParameter("@Num_Doc", SqlDbType.VarChar, 15)).Value = (entidad.Solicitud.Vendedor.Num_Doc != null ? entidad.Solicitud.Vendedor.Num_Doc : ""); cmd.CommandType = CommandType.StoredProcedure; List <ReclamoEntidad> ListaReclamo = new List <ReclamoEntidad>(); using (var reader = cmd.ExecuteReader()) { while (reader.Read()) { ReclamoEntidad oReclamoEntidad = new ReclamoEntidad(); oReclamoEntidad.Cod_Reclamo = Reader.GetStringValue(reader, "Cod_Reclamo"); oReclamoEntidad.Solicitud = new SolicitudEntidad { Canal = new CanalEntidad { Cod_Canal = Reader.GetStringValue(reader, "Cod_Canal"), Canal = Reader.GetStringValue(reader, "Canal"), }, Vendedor = new VendedorEntidad { Cod_Vendedor = Reader.GetStringValue(reader, "Cod_Vendedor"), Nombre = Reader.GetStringValue(reader, "Nombre_Vendedor"), Apellido = Reader.GetStringValue(reader, "ApellidoPaterno_Vendedor"), Apellido2 = Reader.GetStringValue(reader, "ApellidoMaterno_Vendedor"), }, BT_Cliente = Reader.GetStringValue(reader, "BT_Cliente"), Producto = new ProductoEntidad { Cod_Producto = Reader.GetStringValue(reader, "Cod_Producto"), Producto = Reader.GetStringValue(reader, "Producto"), }, Fecha_Aprob_Rech = Reader.GetDateTimeValue(reader, "Fecha_Aprob_Rech").ToString("dd/MM/yyyy"), }; oReclamoEntidad.TipoReclamo = new TipoReclamoEntidad { Cod_TipoReclamo = Reader.GetTinyIntValue(reader, "Tipo_Reclamo"), Nom_TipoReclamo = Reader.GetStringValue(reader, "Nom_TipoReclamo"), }; oReclamoEntidad.MotivoRechazoSolicitud = new MotivoRechazoSolicitudEntidad { Cod_MotivoRechazoSolicitud = Reader.GetStringValue(reader, "Cod_MotivoRechazoSolicitud"), Nom_MotivoRechazoSolicitud = Reader.GetStringValue(reader, "Nom_MotivoRechazoSolicitud"), }; oReclamoEntidad.FechaInicio = Reader.GetDateTimeValue(reader, "FechaInicio").ToString("dd/MM/yyyy"); oReclamoEntidad.FechaFin = Reader.GetDateTimeValue(reader, "FechaFin").ToString("dd/MM/yyyy"); oReclamoEntidad.Estado = Reader.GetStringValue(reader, "Estado"); ListaReclamo.Add(oReclamoEntidad); } } return(ListaReclamo); } catch (Exception ex) { return(null); } finally { Conexion.cerrarConexion(cn); } }