private void btnBuscarCliente_Click(object sender, EventArgs e) { try { E_cliente c = null; String num_doc = txtNumDoc.Text; c = CN_Cliente.Intancia.BuscarCliente(0, num_doc); txtNombreCliente.Text = c.Nombre_Cliente; txtDireccionCliente.Text = c.Direccion_Cliente; cboTipDoc.SelectedValue = c.tipodocumento.Id_TipDoc; txtNumDoc.Text = c.NumeroDoc_Cliente.Trim(); int i = LOCAL.Instancia.ReturnIdCliente(1, c.Id_Cliente); } catch (ApplicationException) { DialogResult r = MessageBox.Show("No se encontro registro, ¿Desea realiza búsqueda avanzada?", "Mensaje", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (r == DialogResult.Yes) { /* escribe en el metodo el formulario q invoco a buscar cliente para saber en que lista * detalle agregar <este aplica en caso que se encuentre mas de 1 comprobante ejecutandose en paralelo>*/ LOCAL.Instancia.Invocar(1, 1); //----------------------------------------------------------------------------------------------------- Frm_ClienteVenta SearchCli = new Frm_ClienteVenta(id_user); SearchCli.ShowDialog(); btnBuscarCliente.Enabled = false; btnBuscarXid.Enabled = true; } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public E_cliente BuscarCliente(int id_cli, String nro_Doc) { try { E_cliente c = null; c = CD_Cliente.Intancia.BuscarCliente(id_cli, nro_Doc); if (c == null) { throw new ApplicationException("No se encontro registro en la BD"); } return(c); } catch (Exception) { throw; } }
private void btnBuscarXid_Click(object sender, EventArgs e) { try { E_cliente c = null; int id_cli = LOCAL.Instancia.ReturnIdCliente(0, 0); c = CN_Cliente.Intancia.BuscarCliente(id_cli, 0.ToString()); btnBuscarXid.Enabled = false; btnBuscarCliente.Enabled = true; txtNombreCliente.Text = c.Nombre_Cliente; txtDireccionCliente.Text = c.Direccion_Cliente; cboTipDoc.SelectedValue = c.tipodocumento.Id_TipDoc; txtNumDoc.Text = c.NumeroDoc_Cliente.Trim(); } catch (ApplicationException) { btnBuscarXid.Enabled = false; btnBuscarCliente.Enabled = true; } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public E_cliente BuscarCliente(int id_Cli, String nro_Doc) { SqlCommand cmd = null; SqlDataReader dr = null; E_cliente c = null; try { SqlConnection cn = ConexionBD.Instancia.Conectar(); cmd = new SqlCommand("spBuscarCliente", cn); cmd.Parameters.AddWithValue("@prmidCliente", id_Cli); cmd.Parameters.AddWithValue("@prmNroDoc", nro_Doc); cmd.CommandType = CommandType.StoredProcedure; cn.Open(); dr = cmd.ExecuteReader(); if (dr.Read()) { c = new E_cliente(); c.Id_Cliente = Convert.ToInt32(dr["Id_Cliente"]); E_TipoDoc td = new E_TipoDoc(); td.Id_TipDoc = Convert.ToInt32(dr["Id_TipDoc"].ToString()); td.Nombre_TipDoc = dr["Nombre_TipDoc"].ToString(); c.tipodocumento = td; c.NumeroDoc_Cliente = dr["NumeroDoc_Cliente"].ToString(); c.Nombre_Cliente = dr["Nombre_Cliente"].ToString(); c.Telefono_Cliente = dr["Telefono_Cliente"].ToString(); c.Celular_Cliente = dr["Celular_Cliente"].ToString(); c.Correo_Cliente = dr["Correo_Cliente"].ToString(); c.Direccion_Cliente = dr["Direccion_Cliente"].ToString(); c.FechaNac_Cliente = dr["FechaNac_Cliente"].ToString(); c.Sexo_Cliente = dr["Sexo_Cliente"].ToString(); } } catch (Exception) { throw; } finally { cmd.Connection.Close(); } return(c); }
private void btnBuscar_Click(object sender, EventArgs e) { try { E_cliente c = new E_cliente(); String Nro_doc = txtNroDoc.Text; c = CN_Cliente.Intancia.BuscarCliente(0, Nro_doc); dgvCliente.Rows.Clear(); String[] fila = new String[] { c.Id_Cliente.ToString(), 1.ToString(), c.Nombre_Cliente, c.tipodocumento.Nombre_TipDoc, c.NumeroDoc_Cliente, c.Telefono_Cliente, c.Celular_Cliente, c.Correo_Cliente, c.Direccion_Cliente }; dgvCliente.Rows.Add(fila); } catch (ApplicationException ae) { MessageBox.Show(ae.Message, "Información", MessageBoxButtons.OK, MessageBoxIcon.Information); dgvCliente.Rows.Clear(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public List <E_cliente> ListarCliente() { SqlCommand cmd = null; SqlDataReader dr = null; List <E_cliente> Lista = null; try { SqlConnection cn = ConexionBD.Instancia.Conectar(); cmd = new SqlCommand("spListarCliente", cn); cmd.CommandType = CommandType.StoredProcedure; cn.Open(); dr = cmd.ExecuteReader(); Lista = new List <E_cliente>(); while (dr.Read()) { E_cliente c = new E_cliente(); c.Id_Cliente = Convert.ToInt32(dr["Id_Cliente"]); E_TipoDoc td = new E_TipoDoc(); td.Nombre_TipDoc = dr["Nombre_TipDoc"].ToString(); c.tipodocumento = td; c.NumeroDoc_Cliente = dr["NumeroDoc_Cliente"].ToString(); c.Nombre_Cliente = dr["Nombre_Cliente"].ToString(); c.Telefono_Cliente = dr["Telefono_Cliente"].ToString(); c.Celular_Cliente = dr["Celular_Cliente"].ToString(); c.Correo_Cliente = dr["Correo_Cliente"].ToString(); c.Direccion_Cliente = dr["Direccion_Cliente"].ToString(); Lista.Add(c); } } catch (Exception) { throw; } finally { cmd.Connection.Close(); } return(Lista); }
private void btnGuardar_Click(object sender, EventArgs e) { try { DialogResult r = MessageBox.Show("¿Desea guardar Boleta?", "Confirmar", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (r == DialogResult.Yes) { SoloNumCeldaGrid(); EscribirNuevoMonto(); ActualizarMontosDgv(); E_Venta v = new E_Venta(); E_cliente c = new E_cliente(); c.Id_Cliente = LOCAL.Instancia.ReturnIdCliente(0, 0); v.cliente = c; E_usuario u = new E_usuario(); u = us; v.usuario = u; E_Sucursal s = new E_Sucursal(); s.Id_Suc = LOCAL.Instancia.Id_Suc; v.sucursal = s; E_Comprobante tc = new E_Comprobante(); tc.Id_TipCom = 1; v.tipocomprobante = tc; E_Moneda m = new E_Moneda(); m.Id_Moneda = Convert.ToInt32(CboMoneda.SelectedValue); v.moneda = m; E_TipoPago tp = new E_TipoPago(); tp.Id_TipPago = Convert.ToInt32(cboTipoPago.SelectedValue); v.tipopago = tp; v.Igv_Venta = 0; v.Descuento_Venta = 0.0; List <E_DetalleVenta> Detalle = new List <E_DetalleVenta>(); foreach (DataGridViewRow row in dgvDetalleBoleta.Rows) { E_DetalleVenta dt = new E_DetalleVenta(); dt.Id_Prod_Det = Convert.ToInt32(row.Cells[0].Value); dt.PrecProd_Det = Convert.ToDouble(row.Cells[3].Value); dt.Cantidad_Det = Convert.ToInt32(row.Cells[2].Value); Detalle.Add(dt); } v.detalleventa = Detalle; v.Desc_Venta = ""; CargarSerie_correlativo(); int result = CN_Venta.Intancia.GuardarVenta(v, 1, serie.Numero_Serie); MessageBox.Show("Se guardo de manera correcta!", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information); dgvDetalleBoleta.Enabled = false; ControlBotones(true, false, false, false); btnAgregarItem.Enabled = false; btnAnular.Enabled = true; ac.BloquearText(this.gbCliente, false); ac.BloquearText(this.panel1, false); lblMontoEnletras.Text = "Son: " + ac.enletras(txtTotal.Text).ToLower() + CboMoneda.Text; } } catch (ApplicationException ae) { MessageBox.Show(ae.Message, "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning); } catch (Exception ex) { MessageBox.Show(ex.Message, "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public E_Venta LstVentaDetalle(int id_venta) { SqlCommand cmd = null; IDataReader idr = null; E_Venta v = null; List <E_DetalleVenta> det = null; try { SqlConnection cn = ConexionBD.Instancia.Conectar(); cmd = new SqlCommand("spMostrarCabeceraVenta", cn); cmd.Parameters.AddWithValue("@prmid_venta", id_venta); cmd.CommandType = CommandType.StoredProcedure; cn.Open(); idr = cmd.ExecuteReader(); if (idr.Read()) { v = new E_Venta(); v.Codigo_Venta = idr["Codigo_Venta"].ToString(); v.Serie_Venta = Convert.ToInt32(idr["Serie_Venta"].ToString()); v.Correlativo_Venta = idr["Correlativo_Venta"].ToString(); v.Igv_Venta = Convert.ToInt32(idr["Igv_Venta"]); v.FechaVenta = Convert.ToDateTime(idr["FechaVenta"]); v.Estado_Venta = idr["Estado_Venta"].ToString(); v.Descuento_Venta = Convert.ToDouble(idr["Descuento_Venta"]); v.Desc_Venta = idr["Desc_Venta"].ToString(); E_cliente c = new E_cliente(); c.Nombre_Cliente = idr["Nombre_Cliente"].ToString(); c.NumeroDoc_Cliente = idr["NumeroDoc_Cliente"].ToString(); E_TipoDoc td = new E_TipoDoc(); td.Nombre_TipDoc = idr["Nombre_TipDoc"].ToString(); c.tipodocumento = td; v.cliente = c; E_Sucursal s = new E_Sucursal(); s.Direccion_Suc = idr["Direccion_Suc"].ToString(); v.sucursal = s; E_usuario u = new E_usuario(); u.Nombre_Usuario = idr["Nombre_Usuario"].ToString(); v.usuario = u; E_Comprobante tc = new E_Comprobante(); tc.Nombre_TipCom = idr["Nombre_TipCom"].ToString(); v.tipocomprobante = tc; E_Moneda m = new E_Moneda(); m.Descripcion_Moneda = idr["Descripcion_Moneda"].ToString(); v.moneda = m; E_TipoPago tp = new E_TipoPago(); tp.Descripcion_TipPago = idr["Descripcion_TipPago"].ToString(); v.tipopago = tp; if (idr.NextResult()) { det = new List <E_DetalleVenta>(); while (idr.Read()) { E_DetalleVenta d = new E_DetalleVenta(); d.PrecProd_Det = Convert.ToDouble(idr["PrecProd_Det"]); d.Cantidad_Det = Convert.ToInt32(idr["Cantidad_Det"]); E_Producto p = new E_Producto(); p.Codigo_Prod = idr["Codigo_Prod"].ToString(); p.Nombre_Prod = idr["Nombre_Prod"].ToString(); p.Precio_Prod = Convert.ToDouble(idr["Precio_Prod"]); d.producto = p; det.Add(d); } v.detalleventa = det; } } } catch (Exception) { throw; } finally { cmd.Connection.Close(); } return(v); }