private void fillAbonos(int id, int id_cab) { dgvAbonos.AutoGenerateColumns = false; if (dgvAbonos.Rows.Count > 0) { dgvAbonos.Rows.Clear(); } Ent_Abonos param = new Ent_Abonos(); param.id = id; param.id_cab = id_cab; List <Ent_Abonos> lstAbonos = BL_Ventas.getAbonos(param); var bindingList = new BindingList <Ent_Abonos>(lstAbonos); var source = new BindingSource(bindingList, null); dgvAbonos.DataSource = source; double total = dgvAbonos.Rows.Cast <DataGridViewRow>() .Sum(t => Convert.ToDouble(t.Cells["MONTO"].Value)); txtRecibido.Text = (total + ent_venta.monto_recibido).ToString("#0.00"); txtTotalRecibido.Text = (double.Parse(txtRecibido.Text)).ToString("#0.00"); txtSaldo.Text = (ent_venta.monto_total - double.Parse(txtRecibido.Text)).ToString("#0.00"); }
private void fillVentas() { dgvVentas.AutoGenerateColumns = false; if (dgvVentas.Rows.Count > 0) { dgvVentas.Rows.Clear(); } Ent_Venta entity = new Ent_Venta(); entity.cod_tienda = tienda; entity.nro_doc_str = txtNroDoc.Text; entity.tipo_venta = cboTipoVenta.SelectedValue.ToString(); entity.forma_pago = cboFormaPago.SelectedValue.ToString(); entity.emision = txtFecha.Text; entity.anulado = cboEstado.SelectedValue.ToString(); List <Ent_Venta> lstVentas = BL_Ventas.getConsultaVentas(entity); var bindingList = new BindingList <Ent_Venta>(lstVentas); var source = new BindingSource(bindingList, null); dgvVentas.DataSource = source; txtTotal.Text = dgvVentas.Rows.Count.ToString(); }
private void InicializarSistema() { fillMenuTipoVenta(); fillMenuTienda(); fillFormaPago(); fillMonedas(); ent_configuracion = new Ent_Configuracion(); ent_configuracion = BL_Configuracion.getConfiguracion(); ent_tienda = BL_Tienda.getTienda(ent_configuracion.TIENDA); lblRUC.Text = "R.U.C. " + ent_configuracion.RUC; lblRazonSocial.Text = ent_configuracion.RAZON_SOCIAL; Image logo = Image.FromFile("logo.png"); pbLogo.Image = logo; correlativo = BL_Ventas.getCorrelativo(tipo_venta); lblBienvenido.Text = "Bienvenid@ " + ent_usuario.nombres; lblRango.Text = (ent_usuario.rango == "A") ? "(Administrador)" : "(Cajero)"; lblTienda.Text = "Tienda: " + des_tienda; lblSerie.Text = "N° 001-" + correlativo; lblFecha.Text = DateTime.Now.ToString("dd/MM/yyyy"); dgvProductos.Columns[0].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; dgvProductos.Columns[2].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; dgvProductos.Columns[3].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; dgvProductos.Columns[4].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; cboFormaPago.SelectedIndex = 0; menuAdmin(); }
private void btnBuscar_Click(object sender, EventArgs e) { reiniciarCotizacion(); Ent_Venta ventas = new Ent_Venta(); if (txtDNI.Text != String.Empty) { ventas.nro_doc = int.Parse(txtDNI.Text); } if (cboTipo.SelectedValue == null) { ventas.tipo_cotizacion = String.Empty; } if (cboTipo.SelectedValue != null && cboTipo.SelectedValue.ToString() != String.Empty) { ventas.tipo_cotizacion = cboTipo.SelectedValue.ToString(); } ventas.cod_tienda = cod_tienda; List <Ent_Venta> lista_cotizacion = BL_Ventas.getConsultaCotizacion(ventas); dgvDocumentos.Rows.Clear(); foreach (Ent_Venta venta in lista_cotizacion) { dgvDocumentos.Rows.Add(venta.nro_doc_str, venta.id_cab, venta.tipo_cotizacion, venta.emision, venta.usuario, venta.cliente_doc, venta.cliente, venta.monto_total, venta.dias_alquiler, venta.moneda); } }
private void fillDatosVenta() { Ent_Venta entity = BL_Ventas.getCabeceraVenta(id_venta); if (entity.tipo_venta == "FA") { lblDNI.Text = "RUC"; lblNombres.Text = "Razón Social"; } else { lblDNI.Text = "DNI"; lblNombres.Text = "Nombres"; } txtTipoVenta.Text = entity.tipo_venta_des; txtNroDoc.Text = entity.nro_doc_str; txtDNI.Text = entity.cliente_doc; txtNombres.Text = entity.cliente; txtDireccion.Text = entity.direccion; txtFecha.Text = entity.emision; txtFormaPago.Text = entity.forma_pago_des; txtTelefono.Text = entity.telefono; txtUsuario.Text = entity.usuario; txtAnulado.Text = (entity.anulado == "1") ? "SI" : "NO"; txtMotivo.Text = entity.motivo_anul; txtFechaAnul.Text = entity.fecha_anul; txtusuarioAnul.Text = entity.usuario_anul; lblTotal.Text = entity.monto_total.ToString("#0.00"); Ent_Configuracion ent_configuracion = BL_Configuracion.getConfiguracion(); if (entity.tipo_venta.Equals("FA")) { txtSubTotal.Text = (Convert.ToDouble(lblTotal.Text) / Convert.ToDouble(ent_configuracion.IGV + 1)).ToString("#0.00"); txtIGV.Text = (Convert.ToDouble(lblTotal.Text) - Convert.ToDouble(txtSubTotal.Text)).ToString("#0.00"); } else { txtSubTotal.Text = "0.00"; txtIGV.Text = "0.00"; } txtRecibido.Text = entity.monto_recibido.ToString("#0.00"); if (entity.forma_pago == "CR") { lblVuelto.Text = "Saldo"; txtVuelto.Text = (entity.monto_total - entity.monto_recibido).ToString("#0.00"); } else { txtVuelto.Text = entity.monto_vuelto.ToString("#0.00"); } fillDetalles(); }
private void btnBuscar_Click(object sender, EventArgs e) { reiniciarCredito(); if (txtNroDocumento.Text == String.Empty) { MessageBox.Show("El número de documento no puede estar vacío.", "Atención", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtNroDocumento.Focus(); return; } int v_nro_doc = int.Parse(txtNroDocumento.Text.Substring(4, txtNroDocumento.Text.Length - 4)); string v_tipo_venta = cboTipoVenta.SelectedValue.ToString(); string v_fecha = txtFecha.Text; Ent_Venta res_venta = BL_Ventas.getVentaCredito(v_nro_doc, cod_tienda, v_tipo_venta, v_fecha); if (res_venta.nro_doc == 0) { MessageBox.Show("Documento no encontrado.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { ent_venta = res_venta; tbDetalles.Enabled = true; lblNroDocumento.Text = res_venta.nro_doc_str; lblNroDocumento2.Text = res_venta.nro_doc_str; lblTipoVenta.Text = res_venta.tipo_venta_des; txtDNI.Text = res_venta.cliente_doc; txtCliente.Text = res_venta.cliente; lblFecha.Text = res_venta.emision; txtEmail.Text = res_venta.email; txtTelefono.Text = res_venta.telefono; txtDireccion.Text = res_venta.direccion; if (res_venta.tipo_venta == "FA") { txtSubTotal.Text = Convert.ToDouble(res_venta.monto_total / (ent_configuracion.IGV + 1)).ToString("#0.00"); txtIGV.Text = (res_venta.monto_total - Convert.ToDouble(txtSubTotal.Text)).ToString("#0.00"); } txtTotal.Text = res_venta.monto_total.ToString("#0.00"); btnFinalizarVenta.Enabled = (res_venta.estado_credito == "P") ? true : false; if (v_tipo_venta == "FA") { lblDNI.Text = "RUC"; lblCliente.Text = "Razón Social"; } else { lblDNI.Text = "DNI"; lblCliente.Text = "Cliente"; } } fillDetalles(res_venta.id_cab.ToString()); fillAbonos(res_venta.id_cab, res_venta.nro_doc); }
void fillTrx() { List <Ent_Venta> lista = BL_Ventas.get_CotizacionAlerta(); foreach (Ent_Venta venta in lista) { dgvCotizacion.Rows.Add(venta.emision, venta.cliente_doc, venta.cliente, venta.telefono, venta.tipo_cotizacion, venta.dias_alquiler, venta.cantidad, venta.monto_total); } }
private void dgvVentas_CellContentClick(object sender, DataGridViewCellEventArgs e) { var senderGrid = (DataGridView)sender; if (e.ColumnIndex == 9) { string id = dgvVentas.Rows[e.RowIndex].Cells["ID"].Value.ToString(); frmDetalleVenta frm = new frmDetalleVenta(id); frm.ShowDialog(); } if (e.ColumnIndex == 11) { string nro_doc = dgvVentas.Rows[e.RowIndex].Cells["DOC"].Value.ToString(); string tipo = dgvVentas.Rows[e.RowIndex].Cells["TIPO_VENTA"].Value.ToString(); InvoicePDF pdf = new InvoicePDF(); ent_venta = new Ent_Venta(); ent_venta.nro_doc_str = dgvVentas.Rows[e.RowIndex].Cells["NRO_DOC"].Value.ToString(); ent_venta.tipo_venta = dgvVentas.Rows[e.RowIndex].Cells["TIPO_VENTA"].Value.ToString(); ent_venta.emision = dgvVentas.Rows[e.RowIndex].Cells["FECHA"].Value.ToString(); ent_venta.cliente = dgvVentas.Rows[e.RowIndex].Cells["NOMBRES"].Value.ToString(); ent_venta.cliente_doc = dgvVentas.Rows[e.RowIndex].Cells["DNI"].Value.ToString(); ent_venta.direccion = dgvVentas.Rows[e.RowIndex].Cells["DIRECCION"].Value.ToString(); ent_venta.monto_total = Convert.ToDouble(dgvVentas.Rows[e.RowIndex].Cells["TOTAL"].Value.ToString()); ent_venta.monto_subtotal = Convert.ToDouble(ent_venta.monto_total / (ent_configuracion.IGV + 1)); ent_venta.monto_igv = (ent_venta.monto_total - Convert.ToDouble(ent_venta.monto_subtotal)); ent_venta.monto_descuento = Convert.ToDouble(dgvVentas.Rows[e.RowIndex].Cells["DESCUENTO"].Value.ToString());; ent_venta.nro_doc = Convert.ToInt32(dgvVentas.Rows[e.RowIndex].Cells["DOC"].Value.ToString()); ent_venta.moneda = dgvVentas.Rows[e.RowIndex].Cells["MONEDA"].Value.ToString(); ent_venta.lstProductos = BL_Ventas.getDetalleVenta(nro_doc); if (tipo == "BO") { pdf.createBoleta(ent_configuracion, ent_venta); } else { pdf.createFactura(ent_configuracion, ent_venta); } /*String filename = "invoices\\" + (tipo == "BO" ? "boleta" : "factura") + "_" + nro_doc + ".pdf"; * if (File.Exists(filename)) * { * Process.Start(filename); * } else * { * MessageBox.Show((tipo == "BO" ? "Boleta" : "Factura") + " no encontrada.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); * }*/ } }
public void fillFormaPago() { List <Ent_FormaPago> items = new List <Ent_FormaPago>(); var formapago = BL_Ventas.getFormaPago(); items.AddRange(formapago); cboFormaPago.DataSource = items; cboFormaPago.ValueMember = "codigo"; cboFormaPago.DisplayMember = "descripcion"; }
private void fillMotivos() { List <Ent_Motivos> items = new List <Ent_Motivos>(); var motivos = BL_Ventas.getMotivos(); items.AddRange(motivos); lstMotivos.DataSource = items; lstMotivos.ValueMember = "codigo"; lstMotivos.DisplayMember = "descripcion"; }
private void fillTipoVenta() { List <Ent_TipoVentas> items = new List <Ent_TipoVentas>(); var tipo_venta = BL_Ventas.getTipoVenta(String.Empty); items.AddRange(tipo_venta); cboTipoVenta.DataSource = items; cboTipoVenta.ValueMember = "codigo"; cboTipoVenta.DisplayMember = "descripcion"; }
private void finalizarCredito() { string result = BL_Ventas.finalizarCredito(ent_venta.id); if (result == "1") { MessageBox.Show("¡Crédito finalizado exitosamente!", "Finalizar Crédito", MessageBoxButtons.OK, MessageBoxIcon.Information); btnFinalizarVenta.Enabled = false; } else { MessageBox.Show("¡Ocurrió un error al finalizar el crédito!", "Finalizar Crédito", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void fillDetalles() { dgvDetalles.AutoGenerateColumns = false; if (dgvDetalles.Rows.Count > 0) { dgvDetalles.Rows.Clear(); } List <Ent_Productos> lstDetalles = BL_Ventas.getDetalleVenta(id_venta); var bindingList = new BindingList <Ent_Productos>(lstDetalles); var source = new BindingSource(bindingList, null); dgvDetalles.DataSource = source; }
private void btnEliminar_Click(object sender, EventArgs e) { var confirm = MessageBox.Show("¿Está seguro que desea eliminar la cotización?", "Atención", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (confirm == DialogResult.Yes) { String result = BL_Ventas.delCotizacion(id_cab); if (result.Equals("1")) { MessageBox.Show("¡Cotización eliminada!.", "Consulta Cotización", MessageBoxButtons.OK, MessageBoxIcon.Information); btnBuscar_Click(new object(), new EventArgs()); } else { MessageBox.Show(result, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void fillDetalles(string id) { dgvDetalle.AutoGenerateColumns = false; if (dgvDetalle.Rows.Count > 0) { dgvDetalle.Rows.Clear(); } List <Ent_Productos> lstDetalles = BL_Ventas.getDetalleVenta(id); var bindingList = new BindingList <Ent_Productos>(lstDetalles); var source = new BindingSource(bindingList, null); dgvDetalle.DataSource = source; txtTotal.Text = dgvDetalle.Rows.Count.ToString(); }
private void procesarIngresarAlmacen() { Ent_Venta venta = new Ent_Venta(); venta.cod_tienda = cod_tienda; venta.cantidad = sumarCantidad(); venta.usuario = usuario; venta.tipo_ingreso_almacen = cboTipo.SelectedValue.ToString(); venta.fecha_fin = dtpFechaSalida.Value.ToString("dd/MM/yyyy"); foreach (DataGridViewRow row in dgvProductos.Rows) { Ent_Productos prd = new Ent_Productos(); prd.id = int.Parse(row.Cells["ID"].Value.ToString()); prd.nombre = row.Cells["DESCRIPCION"].Value.ToString(); prd.cantidad = int.Parse(row.Cells["CANTIDAD"].Value.ToString()); prd.precio = float.Parse(row.Cells["PU"].Value.ToString()); venta.lstProductos.Add(prd); } try { string result = BL_Ventas.procesarIngresoAlmacen(venta); if (result == "1") { MessageBox.Show("Venta Realizada con Éxito!.", "Venta", MessageBoxButtons.OK, MessageBoxIcon.Information); reiniciarVenta(); } else { MessageBox.Show(result, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { MessageBox.Show("Error en el proceso de compra.\n\n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void fillDetalles(string id) { dgvProductos.AutoGenerateColumns = false; if (dgvProductos.Rows.Count > 0) { dgvProductos.Rows.Clear(); } if (id == "VentasSys.EL.Ent_Venta") { return; } List <Ent_Productos> lstDetalles = BL_Ventas.getDetalleVenta(id); var bindingList = new BindingList <Ent_Productos>(lstDetalles); var source = new BindingSource(bindingList, null); dgvProductos.DataSource = source; }
private void fillMenuTipoVenta() { menuTipoVenta.DropDownItems.Clear(); List <Ent_TipoVentas> lstTipoVentas = BL_Ventas.getTipoVenta(String.Empty); ToolStripMenuItem[] items = new ToolStripMenuItem[lstTipoVentas.Count]; int i = 0; lstTipoVentas.ForEach(delegate(Ent_TipoVentas tipo_venta) { items[i] = new ToolStripMenuItem(); items[i].Name = tipo_venta.id; items[i].Tag = tipo_venta.codigo; items[i].Text = tipo_venta.descripcion; items[i].Click += new EventHandler(MenuVentasTipoItemClickHandler); i++; }); menuTipoVenta.DropDownItems.AddRange(items); }
private void anularVenta(Ent_Anular anular) { try { string result = BL_Ventas.anularVenta(anular); if (result == "1") { MessageBox.Show("¡Venta anulada exitosamente!", "Anular Venta", MessageBoxButtons.OK, MessageBoxIcon.Information); fillDocumentos(); reiniciarAnular(); } else { MessageBox.Show("¡Ocurrió un error al anular la venta!\n" + result, "Anular Venta", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { MessageBox.Show("Error: " + ex.Message, "Anular Venta", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void cambiarTipoVenta(string tipo_venta_des) { try { correlativo = BL_Ventas.getCorrelativo(tipo_venta); lblTipoVenta.Text = tipo_venta_des; lblSerie.Text = "N° 001-" + correlativo; } catch (Exception ex) { log.Error("Error al obtener correlativo: " + ex.Message, System.Reflection.MethodBase.GetCurrentMethod().Name); } if (tipo_venta == "FA") { lblCliente.Text = "Razón Social:"; lblDNI.Text = "R.U.C.:"; txtApellidos.Visible = false; lblApellidos.Visible = false; txtNombres.Width = 328; } else { lblCliente.Text = "Cliente:"; lblDNI.Text = "DNI:"; txtApellidos.Visible = true; lblApellidos.Visible = true; txtNombres.Width = 122; } txtNombres.Text = String.Empty; txtDNI.Text = String.Empty; txtDireccion.Text = String.Empty; sumarTotal(); log.Info("Cambio Tipo Venta: " + tipo_venta, System.Reflection.MethodBase.GetCurrentMethod().Name); log.Info("Serie " + lblSerie.Text, System.Reflection.MethodBase.GetCurrentMethod().Name); }
private void fillDocumentos() { dgvDocumentos.AutoGenerateColumns = false; if (dgvDocumentos.Rows.Count > 0) { dgvDocumentos.Rows.Clear(); } if (dgvDetalle.Rows.Count > 0) { dgvDetalle.Rows.Clear(); } Ent_Venta param_venta = new Ent_Venta(); param_venta.cod_tienda = cod_tienda; if (txtNroDocumento.Text != String.Empty) { param_venta.nro_doc = int.Parse(txtNroDocumento.Text); } if (cboTipoVenta.SelectedValue == null) { param_venta.tipo_venta = String.Empty; } if (cboTipoVenta.SelectedValue != null && cboTipoVenta.SelectedValue.ToString() != String.Empty) { param_venta.tipo_venta = cboTipoVenta.SelectedValue.ToString(); } List <Ent_Venta> lstVenta = BL_Ventas.getVentas(param_venta); var bindingList = new BindingList <Ent_Venta>(lstVenta); var source = new BindingSource(bindingList, null); dgvDocumentos.DataSource = source; }
private void fillVentas() { dgvVentas.AutoGenerateColumns = false; if (dgvVentas.Rows.Count > 0) { dgvVentas.Rows.Clear(); } Ent_Venta entity = new Ent_Venta(); entity.cliente_doc = txtDNI.Text; entity.cliente = txtNombre.Text; entity.emision = txtFecha.Text; List <Ent_Venta> lstVentas = BL_Ventas.getVentasPorCliente(entity); var bindingList = new BindingList <Ent_Venta>(lstVentas); var source = new BindingSource(bindingList, null); dgvVentas.DataSource = source; }
private void fillNroDoc() { List <Ent_Venta> items = new List <Ent_Venta>(); Ent_Venta venta = new Ent_Venta(); venta.cod_tienda = cod_tienda; venta.tipo_venta = (cboTipoDocumento.SelectedValue == null) ? "BO" : cboTipoDocumento.SelectedValue.ToString(); if (venta.tipo_venta == "VentasSys.EL.Ent_TipoVentas") { return; } var ventas = BL_Ventas.getVentas(venta); items.AddRange(ventas); cboNroDocumento.DataSource = items; cboNroDocumento.ValueMember = "id_cab"; cboNroDocumento.DisplayMember = "nro_doc_str"; }
public frmGuiaRemision(string _cod_tienda) { InitializeComponent(); cod_tienda = _cod_tienda; ent_configuracion = new Ent_Configuracion(); ent_configuracion = BL_Configuracion.getConfiguracion(); lblRUC.Text = "R.U.C. " + ent_configuracion.RUC; lblRazonSocial.Text = ent_configuracion.RAZON_SOCIAL; txtDireccionPartida.Text = ent_configuracion.DIRECCION; txtTransRuc.Text = ent_configuracion.RUC; txtTransCliente.Text = ent_configuracion.RAZON_SOCIAL; Image logo = Image.FromFile("logo.png"); pbLogo.Image = logo; txtFechaEmision.Text = DateTime.Now.ToString("dd/MM/yyyy"); txtFechaTraslado.Text = DateTime.Now.ToString("dd/MM/yyyy"); correlativo = BL_Ventas.getCorrelativo("GR"); lblNroDoc.Text = "001-" + correlativo; fillTipoDocumento(); fillMotivos(); fillNroDoc(); }
private void fillDetalles(string id) { dgvDetalle.AutoGenerateColumns = false; if (dgvDetalle.Rows.Count > 0) { dgvDetalle.Rows.Clear(); } lstDetalles = BL_Ventas.getDetalleCotizacion(id); lista_producto = lstDetalles; if (lstDetalles != null) { cotizacion.lstProductos = lstDetalles; } var bindingList = new BindingList <Ent_Productos>(lstDetalles); var source = new BindingSource(bindingList, null); dgvDetalle.DataSource = source; }
private void grabarAbono() { double monto = double.Parse(txtAmortizar.Text); Ent_Abonos abono = new Ent_Abonos(); abono.id = ent_venta.id_cab; abono.id_cab = ent_venta.nro_doc; abono.cod_tienda = cod_tienda; abono.usuario = usuario; abono.monto = monto; string res = BL_Ventas.setAbono(abono); if (res.Equals("1")) { fillAbonos(abono.id, abono.id_cab); txtAmortizar.Text = "0.00"; } else { MessageBox.Show("Error al grabar el abono.\n" + res, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void fillReporte() { DataTable dt = new DataTable(); DataSet ds = new DataSet(); string fecha = String.Empty; string mes = String.Empty; if (rbFecha.Checked) { fecha = txtFecha.Text; mes = String.Empty; } else { mes = cboMes.SelectedValue.ToString() + "/" + txtYear.Text; fecha = String.Empty; } string tienda = cboTiendas.SelectedValue.ToString(); string cat = cboCategoria.SelectedValue.ToString(); BL_Ventas.getReporteVentasxProductos(fecha, mes, tienda, cat, ref ds, ref dt); rpvVentasProductos.ProcessingMode = ProcessingMode.Local; rpvVentasProductos.LocalReport.ReportPath = "Reportes/VentasxProductos.rdlc"; rpvVentasProductos.LocalReport.DataSources.Clear(); ReportDataSource source = new ReportDataSource("dsReporteVentasxProducto", dt); source.Value = ds.Tables[0]; rpvVentasProductos.LocalReport.DataSources.Add(source); rpvVentasProductos.RefreshReport(); }
private void procesarCotizacion() { Ent_Venta venta = new Ent_Venta(); venta.cod_tienda = cod_tienda; venta.tipo_venta = tipo_venta; venta.cantidad = sumarCantidad(); venta.cliente_doc = txtDesRuc.Text; venta.emision = DateTime.Now.ToString("dd/MM/yyyy"); venta.cliente = txtDesCliente.Text; venta.email = txtEmail.Text; venta.usuario = usuario; venta.tipo_cotizacion = cboTipo.SelectedValue.ToString(); venta.dias_alquiler = int.Parse(txtDias.Text); venta.monto_subtotal = double.Parse(txtSubTotal.Text); venta.monto_igv = double.Parse(txtIGV.Text); venta.monto_total = total; venta.denominacion = txtDenominación.Text; venta.observacion = txtObservacion.Text; venta.moneda = cboMoneda.SelectedValue.ToString(); bool existe_cliente = BL_Clientes.existeCliente(venta.cliente_doc); //save customer if doesnt exists if (!existe_cliente) { var confirm = MessageBox.Show("¿Desea guardar el cliente en el sistema?", "Atención", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (confirm == DialogResult.Yes) { Ent_Clientes nuevo_cliente = new Ent_Clientes(); nuevo_cliente.dni = txtDesRuc.Text; nuevo_cliente.nombres = txtDesCliente.Text; nuevo_cliente.apellidos = ""; nuevo_cliente.direccion = ""; nuevo_cliente.telefono = ""; nuevo_cliente.email = txtEmail.Text; nuevo_cliente.tipo = (nuevo_cliente.dni.Length > 8) ? "E" : "N"; nuevo_cliente.posible = "1"; try { string _result = BL_Clientes.insertarCliente(nuevo_cliente); } catch (Exception ex) { MessageBox.Show("Ocurrió un error al grabar al cliente, sin embargo, el proceso de compra continuará.\n\n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { } } foreach (DataGridViewRow row in dgvProductos.Rows) { Ent_Productos prd = new Ent_Productos(); prd.cod_producto = row.Cells["CODIGO"].Value.ToString(); prd.id = int.Parse(row.Cells["ID"].Value.ToString()); prd.nombre = row.Cells["DESCRIPCION"].Value.ToString(); prd.cantidad = int.Parse(row.Cells["CANTIDAD"].Value.ToString()); prd.precio = float.Parse(row.Cells["PU"].Value.ToString()); prd.monto_total = float.Parse(row.Cells["IMPORTE"].Value.ToString()); venta.lstProductos.Add(prd); } try { string id_cab = ""; string result = BL_Ventas.procesarCotizacion(venta, out id_cab); venta.id_cab = Convert.ToInt32(id_cab); Email email = new Email(); email.Send_Email(venta, _ent_tienda, ent_configuracion, txtObservacion.Text, adjunto); if (result == "1") { MessageBox.Show("Cotización Realizada con Éxito!.", "Cotización", MessageBoxButtons.OK, MessageBoxIcon.Information); InvoicePDF pdf = new InvoicePDF(); pdf.createCotizacion(ent_configuracion, venta); reiniciarVenta(); } else { MessageBox.Show(result, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { MessageBox.Show("Error en el proceso de cotización.\n\n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnEmitir_Click(object sender, EventArgs e) { var confirm = MessageBox.Show("¿Está seguro que desea emitir la guía de remisión?", "Atención", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (confirm == DialogResult.Yes) { if (txtDesCliente.Text.Equals(String.Empty)) { MessageBox.Show("El nombre de cliente o razón social no puede estar vacío.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (txtDesRuc.Text.Equals(String.Empty)) { MessageBox.Show("El RUC no puede estar vacío.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (txtDireccionLlegada.Text.Equals(String.Empty)) { MessageBox.Show("La dirección de llegada no puede estar vacío.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } string cod_motivo = String.Empty; foreach (object itemChecked in lstMotivos.CheckedItems) { cod_motivo = ((VentasSys.EL.Ent_Motivos)(itemChecked)).codigo; } if (cod_motivo.Equals(String.Empty)) { MessageBox.Show("Debe seleccionar un motivo.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } Ent_GuiaRemision entity = new Ent_GuiaRemision(); entity.nro_guia = BL_Ventas.getCorrelativo("GR"); entity.cod_tienda = cod_tienda; entity.fecha_traslado = txtFechaTraslado.Text; entity.cantidad = 1; entity.destinatario_ruc = txtDesRuc.Text; entity.ref_tipo_doc = cboTipoDocumento.SelectedValue.ToString(); entity.ref_nro_doc = cboNroDocumento.SelectedValue.ToString(); entity.motivo = cod_motivo; try { string _result = BL_Ventas.emitirGuiaRemision(entity); if (_result == "1") { MessageBox.Show("Guía de Remisión Emitida con Éxito!.", "Guía de Remisión", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Ocurrió un error al emitir la guía.\n\n" + _result, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { MessageBox.Show("Ocurrió un error al emitir la guía.\n\n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void procesarCompra() { forma_pago = cboFormaPago.SelectedValue.ToString(); Ent_Venta venta = new Ent_Venta(); venta.nro_doc = int.Parse(correlativo); venta.nro_doc_str = lblSerie.Text; venta.cod_tienda = cod_tienda; venta.tipo_venta = tipo_venta; venta.forma_pago = forma_pago; venta.cantidad = sumarCantidad(); venta.monto_total = total; venta.monto_subtotal = double.Parse(txtSubTotal.Text); venta.monto_igv = double.Parse(txtIGV.Text); venta.monto_recibido = double.Parse(txtRecibido.Text); venta.monto_vuelto = double.Parse(txtVuelto.Text); venta.monto_descuento = double.Parse(txtDescuento.Text); venta.cliente_doc = txtDNI.Text; venta.cliente = txtNombres.Text + " " + txtApellidos.Text; venta.direccion = txtDireccion.Text; venta.usuario = ent_usuario.username; venta.fecha_inicio = dtpFechaInicio.Value.ToShortDateString(); venta.fecha_fin = dtpFechaEntrega.Value.ToShortDateString(); venta.moneda = cboMoneda.SelectedValue.ToString(); bool existe_cliente = BL_Clientes.existeCliente(venta.cliente_doc); //save customer if doesnt exists if (!existe_cliente) { log.Info("Cliente " + txtDNI.Text + " no existe en la base de datos.", System.Reflection.MethodBase.GetCurrentMethod().Name); var confirm = MessageBox.Show("¿Desea guardar el cliente en el sistema?", "Atención", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (confirm == DialogResult.Yes) { Ent_Clientes nuevo_cliente = new Ent_Clientes(); nuevo_cliente.dni = txtDNI.Text; nuevo_cliente.nombres = txtNombres.Text; nuevo_cliente.apellidos = txtApellidos.Text; nuevo_cliente.direccion = txtDireccion.Text; nuevo_cliente.telefono = txtTelefono.Text; nuevo_cliente.email = txtEmail.Text; nuevo_cliente.tipo = (tipo_venta == "FA") ? "E" : "N"; nuevo_cliente.posible = "1"; try { string _result = BL_Clientes.insertarCliente(nuevo_cliente); if (_result == "1") { log.Info("Cliente " + nuevo_cliente.dni + " grabado con éxito.", System.Reflection.MethodBase.GetCurrentMethod().Name); } else { log.Error("Error al grabar cliente: " + _result, System.Reflection.MethodBase.GetCurrentMethod().Name); } } catch (Exception ex) { MessageBox.Show("Ocurrió un error al grabar al cliente, sin embargo, el proceso de compra continuará.\n\n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); log.Error("Error al grabar cliente: " + ex.Message, System.Reflection.MethodBase.GetCurrentMethod().Name); } } else { log.Info("Cliente " + txtDNI.Text + " no se guardará en la base de datos.", System.Reflection.MethodBase.GetCurrentMethod().Name); } } foreach (DataGridViewRow row in dgvProductos.Rows) { Ent_Productos prd = new Ent_Productos(); prd.id = int.Parse(row.Cells["ID"].Value.ToString()); prd.nombre = row.Cells["DESCRIPCION"].Value.ToString(); prd.cantidad = int.Parse(row.Cells["CANTIDAD"].Value.ToString()); prd.precio = float.Parse(row.Cells["PU"].Value.ToString()); venta.lstProductos.Add(prd); } try { string result = BL_Ventas.procesarVenta(venta); if (result == "1") { MessageBox.Show("Venta Realizada con Éxito!.", "Venta", MessageBoxButtons.OK, MessageBoxIcon.Information); InvoicePDF pdf = new InvoicePDF(); if (venta.tipo_venta == "BO") { pdf.createBoleta(ent_configuracion, venta); } else { pdf.createFactura(ent_configuracion, venta); } log.Info("Venta " + lblSerie.Text + " realizada con éxito.", System.Reflection.MethodBase.GetCurrentMethod().Name); string resumen = "\n-----------------------------------\n" + "Resumen Venta:\n" + "Serie: " + lblSerie.Text + "\n" + "Tipo Venta: " + tipo_venta + "\n" + "Forma de Pago: " + cboFormaPago.Text + "\n" + "Cliente: " + txtDNI.Text + "\n" + "Productos:\n"; foreach (DataGridViewRow item in dgvProductos.Rows) { resumen += " - " + item.Cells["CODIGO"].Value.ToString() + " | " + item.Cells["DESCRIPCION"].Value.ToString() + " | " + item.Cells["CANTIDAD"].Value.ToString() + " | " + item.Cells["PU"].Value.ToString() + " | " + item.Cells["IMPORTE"].Value.ToString() + "\n"; } resumen += "Subtotal: " + txtSubTotal.Text + "\n" + "IGV: " + txtIGV.Text + "\n" + "TOTAL: " + txtTotal.Text + "\n" + "Recibido: " + txtRecibido.Text + "\n" + "Vuelto: " + txtVuelto.Text + "\n" + "-----------------------------------\n\n"; log.Info(resumen, System.Reflection.MethodBase.GetCurrentMethod().Name); reiniciarVenta(); } else { MessageBox.Show(result, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { MessageBox.Show("Error en el proceso de compra.\n\n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); log.Error("Error en el proceso de compra: " + ex.Message, System.Reflection.MethodBase.GetCurrentMethod().Name); } }