public TipoComprobanteBe Obtener(int tipoComprobanteId, SqlConnection cn) { TipoComprobanteBe respuesta = null; try { using (SqlCommand cmd = new SqlCommand("dbo.usp_tipocomprobante_obtener", cn)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@tipoComprobanteId", tipoComprobanteId.GetNullable()); using (SqlDataReader dr = cmd.ExecuteReader()) { if (dr.HasRows) { if (dr.Read()) { respuesta = new TipoComprobanteBe(); respuesta.TipoComprobanteId = dr.GetData <int>("TipoComprobanteId"); respuesta.Codigo = dr.GetData <string>("Codigo"); respuesta.Nombre = dr.GetData <string>("Nombre"); } } } } } catch (Exception ex) { respuesta = null; } return(respuesta); }
public List <TipoComprobanteBe> ListarComboTipoComprobante(SqlConnection cn) { List <TipoComprobanteBe> lista = null; try { using (SqlCommand cmd = new SqlCommand("dbo.usp_tipocomprobante_listar_combo", cn)) { cmd.CommandType = CommandType.StoredProcedure; using (SqlDataReader dr = cmd.ExecuteReader()) { if (dr.HasRows) { lista = new List <TipoComprobanteBe>(); while (dr.Read()) { TipoComprobanteBe item = new TipoComprobanteBe(); item.CodigoTipoComprobante = dr.GetData <int>("CodigoTipoComprobante"); item.Nombre = dr.GetData <string>("Nombre"); item.CodigoSunat = dr.GetData <string>("CodigoSunat"); lista.Add(item); } } } } } catch (Exception ex) { log.Error(ex.Message); } return(lista); }
public List <TipoComprobanteBe> Listar(SqlConnection cn) { List <TipoComprobanteBe> lista = null; try { using (SqlCommand cmd = new SqlCommand("dbo.usp_tipocomprobante_listar", cn)) { cmd.CommandType = CommandType.StoredProcedure; using (SqlDataReader dr = cmd.ExecuteReader()) { if (dr.HasRows) { lista = new List <TipoComprobanteBe>(); while (dr.Read()) { TipoComprobanteBe item = new TipoComprobanteBe(); item.TipoComprobanteId = dr.GetData <int>("TipoComprobanteId"); item.Codigo = dr.GetData <string>("Codigo"); item.Nombre = dr.GetData <string>("Nombre"); item.IdentificadorSerie = dr.GetData <string>("IdentificadorSerie"); lista.Add(item); } } } } } catch (Exception ex) { lista = null; } return(lista); }
bool ValidarFormulario() { bool estaValidado = true; LimpiarErrores(); if (cbbCodigoTipoComprobante.SelectedIndex == 0) { estaValidado = false; lblErrorCodigoTipoComprobante.Text = "Debe seleccionar un tipo de comprobante"; SetToolTipError(lblErrorCodigoTipoComprobante); } if (txtSerial.Text.Trim() == "") { estaValidado = false; lblErrorSerial.Text = "Debe ingresar serial"; SetToolTipError(lblErrorSerial); } else { TipoComprobanteBe tipoComprobante = (TipoComprobanteBe)cbbCodigoTipoComprobante.SelectedItem; if (tipoComprobante.CodigoTipoComprobante != -1) { if (txtSerial.Text.Trim().Length != 4) { estaValidado = false; lblErrorSerial.Text = $"Debe tener {4} caracteres"; SetToolTipError(lblErrorSerial); } } bool existeSerie = serieBl.ExisteSerie(txtSerial.Text.Trim(), (int)cbbCodigoTipoComprobante.SelectedValue, codigoSerie); if (existeSerie) { estaValidado = false; lblErrorSerial.Text = $"El serial ya existe"; SetToolTipError(lblErrorSerial); } } if (txtValorInicial.Text.Trim() == "") { estaValidado = false; lblErrorValorInicial.Text = "Debe ingresar valor inicial"; SetToolTipError(lblErrorValorInicial); } else { decimal valorInicial = 0; if (!decimal.TryParse(txtValorInicial.Text.Trim(), out valorInicial)) { estaValidado = false; lblErrorValorInicial.Text = "Debe ingresar un valor numérico"; SetToolTipError(lblErrorValorInicial); } } if (txtValorFinal.Text.Trim() == "") { estaValidado = false; lblErrorValorFinal.Text = "Debe ingresar valor final"; SetToolTipError(lblErrorValorFinal); } else { decimal valorFinal = 0; if (!decimal.TryParse(txtValorFinal.Text.Trim(), out valorFinal)) { estaValidado = false; lblErrorValorFinal.Text = "Debe ingresar un valor numérico"; SetToolTipError(lblErrorValorFinal); } } if (txtValorActual.Text.Trim() == "") { estaValidado = false; lblErrorValorActual.Text = "Debe ingresar valor actual"; SetToolTipError(lblErrorValorActual); } else { decimal valorActual = 0; if (!decimal.TryParse(txtValorActual.Text.Trim(), out valorActual)) { estaValidado = false; lblErrorValorActual.Text = "Debe ingresar un valor numérico"; SetToolTipError(lblErrorValorActual); } } return(estaValidado); }