private void Modificar() { Modelo.Venta a = new Modelo.Venta(); a.id = venta.id; a.nrofactura = txt_factura.Text; a.remito = long.Parse(txt_remito.Text); if (combo_cobrada.SelectedIndex == 0) { a.cobrada = true; } else { a.cobrada = false; } if (ControladorFuncVariadas.validarTextBoxVacios(txt_remito, txt_factura)) { if (ControlVentas.ModificarVenta(a) == 1) { MessageBox.Show("Se actualizaron los datos correctamente"); modificar = true; this.Close(); } else { Console.WriteLine("Error en el update"); } } }
private void btn_presupuesto_Click_1(object sender, EventArgs e) { try { Cursor.Current = Cursors.WaitCursor; if (cuit.Text != "") { if (dgv_tabla.Rows.Count != 0) { Omega3.Modelo.Venta venta = new Modelo.Venta(); venta.documento = long.Parse(cuit.Text); venta.medio_de_pago = Convert.ToInt32(combo_pago.SelectedValue.ToString()); if (combo_pago.Text == "Cheque" || combo_pago.Text == "Cuenta Corriente") { venta.fecha_vencimiento_cheque = fecha_pago.Value; } venta.nrofactura = "0"; venta.tipo_factura = Convert.ToString(combo_comprobante.SelectedValue); venta.fecha_venta = DateTime.Now; Factura_Negro factura = new Factura_Negro(); factura.Nombre = razon.Text; factura.Documento = cuit.Text; factura.Direccion = domicilio.Text; factura.Fecha = DateTime.Now; panel_principal.SelectedIndex = 0; //MessageBox.Show("Venta realizada correctamente!"); long lastidventa; lastidventa = ControlVentas.AgregarVenta(dgv_tabla, venta, 1); Informes.Presupuesto presupuesto = new Informes.Presupuesto(lastidventa); presupuesto.WindowState = FormWindowState.Maximized; presupuesto.ShowDialog(); dgv_tabla.Rows.Clear(); dgv_tabla.Refresh(); limpiarParteCliente(); lista.Clear(); this.Close(); } else { MessageBox.Show("No hay ningun producto agregado"); } } else { panel_principal.SelectedIndex = 0; MessageBox.Show("Aún no se seleccionó un cliente"); } } catch (Exception ex) { MessageBox.Show("Hubo un error, contactar con el administrador: " + ex.ToString()); } finally { Cursor.Current = Cursors.Default; } }
//Reescribimos el comportamiento WindProc para que se pueda mover la ventana sin los bordes private void Venta_1_Load(object sender, EventArgs e) { elemento_clase = 0; crearColumnasDgv_Tabla(); DisableTab(tab_venta, false); ControlVentas.llenarMedios_de_Pago(combo_pago); ControlVenta.llenarClientes(combo_cliente); ControlVentas.llenarProductosCombo(combo_producto); button5.Enabled = false; buscar_cuit.Text = "Buscar por CUIT o DNI"; buscar_cuit.ForeColor = Color.Gray; dgv_tabla.SelectionMode = DataGridViewSelectionMode.FullRowSelect; combo_iva.SelectedIndex = 1; txt_ventas_cantidad.Text = "1"; combo_cliente.ForeColor = Color.Gray; combo_cliente.SelectedIndex = -1; combo_cliente.Text = "Buscar por Razón Social"; }
public void construirTabla() { var categoria = new DataGridViewTextBoxColumn(); var preciocompra = new DataGridViewTextBoxColumn(); var precioventa = new DataGridViewTextBoxColumn(); categoria.HeaderText = "Categoria"; categoria.Name = "Categoria"; categoria.DataPropertyName = "Categoria"; categoria.ReadOnly = true; preciocompra.Name = "Precio Compra"; preciocompra.HeaderText = "Precio Compra"; preciocompra.DataPropertyName = "Precio Compra"; preciocompra.ReadOnly = true; precioventa.HeaderText = "Precio Venta"; precioventa.Name = "Precio Venta"; precioventa.DataPropertyName = "Precio Venta"; precioventa.ReadOnly = true; dgv_tabla.Columns.AddRange(new DataGridViewColumn[] { categoria, preciocompra, precioventa }); String query = "SELECT categoria_producto.categoria as 'Categoria',sum(round(subtotal, 2)) as 'Precio Venta',sum(round(if (productos.dolar = 0,productos.precio_compra* detalle_venta.cantidad,productos.precio_compra * (select valor from valor_dolar where id = 1) *detalle_venta.cantidad),2)) as 'Precio Compra'FROM detalle_venta INNER JOIN productos on detalle_venta.codigo = productos.cod_producto INNER JOIN categoria_producto on productos.id_categoria = categoria_producto.id GROUP BY productos.id_categoria"; ControlVentas.llenarVentasPorCategoria(dgv_tabla, query); Controlador.ControlVentas.armarExcelVentasPorCategoria(dgv_tabla); }
private void btn_factura_Click(object sender, EventArgs e) { Omega3.Modelo.Venta venta = new Modelo.Venta(); venta.documento = long.Parse(cuit.Text); venta.medio_de_pago = Convert.ToInt32(combo_pago.SelectedValue.ToString()); if (combo_pago.Text == "Cheque") { venta.fecha_vencimiento_cheque = fecha_pago.Value; } venta.nrofactura = "0"; //venta.tipo_factura = 0; venta.fecha_venta = DateTime.Now; Factura_Negro factura = new Factura_Negro(); factura.Nombre = razon.Text; factura.Documento = cuit.Text; factura.Direccion = domicilio.Text; factura.Fecha = DateTime.Now; //ControlVentas.AgregarVenta(dgv_tabla, venta); ControlVentas.generarFacturaNegro(dgv_tabla, factura); }
private long guardarVentaEnBlanco() { long lastinserted = 0; if (cuit.Text != "") { if (dgv_tabla.Rows.Count != 0) { Omega3.Modelo.Venta venta = new Modelo.Venta(); venta.ordendeCompra = "0"; venta.remito = 0; if (txt_ordenDeCompra.Text.Trim() != "" || !string.IsNullOrEmpty(txt_ordenDeCompra.Text)) { venta.ordendeCompra = txt_ordenDeCompra.Text; } if (txt_remito.Text.Trim() != "" || !string.IsNullOrEmpty(txt_remito.Text)) { venta.remito = long.Parse(txt_remito.Text); } venta.documento = long.Parse(cuit.Text); venta.medio_de_pago = Convert.ToInt32(combo_pago.SelectedValue.ToString()); if (combo_pago.Text == "Cheque" || combo_pago.Text == "Cuenta Corriente") { venta.fecha_vencimiento_cheque = fecha_pago.Value; } venta.nrofactura = "0"; venta.tipo_factura = Convert.ToString(combo_comprobante.SelectedValue); venta.fecha_venta = DateTime.Now; panel_principal.SelectedIndex = 0; MessageBox.Show("Venta realizada correctamente!"); lastinserted = ControlVentas.AgregarVenta(dgv_tabla, venta); dgv_tabla.Rows.Clear(); dgv_tabla.Refresh(); //limpiarParteCliente(); //lista.Clear(); } else { MessageBox.Show("No hay ningun producto agregado"); } } else { panel_principal.SelectedIndex = 0; MessageBox.Show("Aún no se seleccionó un cliente"); } return(lastinserted); }
private void btn_factura_Click(object sender, EventArgs e) { long ultimoid; ultimoid = guardarVentaEnBlanco(); ControlVentas controlventas = new ControlVentas(); Cliente cliente = new Cliente(); Omega3.Modelo.Venta venta = new Omega3.Modelo.Venta(); ControlVenta control = new ControlVenta(); try { Cursor.Current = Cursors.WaitCursor; if (ultimoid != 0) { venta.remito = 0; venta.ordendeCompra = "0"; venta.tipo_factura = Convert.ToString(combo_comprobante.SelectedValue); venta.medio_de_pago = Convert.ToInt32(combo_pago.SelectedValue); if (txt_remito.Text.Trim() != "" || !string.IsNullOrEmpty(txt_remito.Text)) { venta.remito = long.Parse(txt_remito.Text); } if (txt_ordenDeCompra.Text.Trim() != "" || !string.IsNullOrEmpty(txt_ordenDeCompra.Text)) { venta.ordendeCompra = txt_ordenDeCompra.Text; } cliente = ControlCliente.obtenerCliente(long.Parse(cuit.Text)); cliente.Documento = long.Parse(cuit.Text); string id_comprobante = string.Empty; id_comprobante = control.Facturar(venta, cliente, listado_articulos); var task = Task.Factory.StartNew(() => controlventas.ActualizarFacturaYUrl(id_comprobante, ultimoid)); limpiarParteCliente(); lista.Clear(); elemento_clase = 0; this.Close(); } else { MessageBox.Show("Hubo un error al insertar en la base de datos."); } } catch (Exception ex) { MessageBox.Show("Hubo un error", Convert.ToString(ex)); } finally { Cursor.Current = Cursors.Default; } }
private void FinalizarReparacion_Load(object sender, EventArgs e) { lbl_cliente.Text = cliente.Razon; lbl_dni.Text = Convert.ToString(cliente.Documento); lbl_email.Text = cliente.Mail_contacto; lbl_telefono.Text = Convert.ToString(cliente.Telefono); lbl_total.Text = Convert.ToString(total); ControlVentas.llenarComboComprobante(combo_comprobante, cliente.Impositiva_Id); ControlVentas.llenarMedios_de_Pago(combo_medio_de_pago); }
private void CrearCliente_Load(object sender, EventArgs e) { txt_documento.MaxLength = 8; ControlVentas.llenarCondicion(combo_condicion); ControlCliente.llenarProvincias(combo_provincia); ControlCliente.llenarTipoDocumento(combo_documento); ControlCliente.llenarListas(combo_lista); combo_provincia.SelectedIndex = -1; combo_lista.SelectedIndex = -1; }
private void combo_producto_SelectedIndexChanged(object sender, EventArgs e) { Producto a = new Producto(); txt_ventas_codigo.Text = combo_producto.SelectedValue.ToString(); a = ControlVentas.llenarInformacionProducto(combo_producto.SelectedValue.ToString()); combo_producto.Text = a.Nombre_producto; txt_ventas_precio.Text = a.Precio_venta.ToString(); calcularSubtotal(); }
public void construirTabla() { var producto = new DataGridViewTextBoxColumn(); var codigo = new DataGridViewTextBoxColumn(); var cantidad = new DataGridViewTextBoxColumn(); var preciocompra = new DataGridViewTextBoxColumn(); var precioventa = new DataGridViewTextBoxColumn(); var total = new DataGridViewTextBoxColumn(); var fecha = new DataGridViewTextBoxColumn(); producto.HeaderText = "Producto"; producto.Name = "Producto"; producto.DataPropertyName = "Producto"; producto.ReadOnly = true; codigo.Name = "Codigo"; codigo.HeaderText = "Codigo"; codigo.DataPropertyName = "Codigo"; codigo.ReadOnly = true; cantidad.HeaderText = "Cantidad"; cantidad.Name = "Cantidad"; cantidad.DataPropertyName = "Cantidad"; cantidad.ReadOnly = true; preciocompra.HeaderText = "Precio Compra"; preciocompra.Name = "Precio Compra"; preciocompra.DataPropertyName = "Precio Compra"; preciocompra.ReadOnly = true; precioventa.HeaderText = "Precio Venta"; precioventa.Name = "Precio Venta"; precioventa.DataPropertyName = "Precio Venta"; precioventa.ReadOnly = true; total.HeaderText = "Total"; total.Name = "Total"; total.DataPropertyName = "Total"; total.ReadOnly = true; fecha.HeaderText = "Fecha"; fecha.Name = "Fecha"; fecha.DataPropertyName = "Fecha"; fecha.ReadOnly = true; dgv_tabla.Columns.AddRange(new DataGridViewColumn[] { producto, codigo, cantidad, preciocompra, precioventa, total, fecha }); String query = "SELECT productos.producto as 'Producto',productos.cod_producto as 'Codigo',detalle_venta.cantidad as 'Cantidad',productos.precio_compra as 'Precio Compra',detalle_venta.subtotal / detalle_venta.cantidad as 'Precio Venta',detalle_venta.subtotal as 'Total',date(venta.fecha_venta) as 'Fecha' FROM detalle_venta INNER JOIN productos on detalle_venta.codigo = productos.cod_producto INNER JOIN venta on detalle_venta.id_venta = venta.id WHERE date(venta.fecha_venta) BETWEEN '" + inicio + "' and '" + fin + "'"; Console.WriteLine(query); ControlVentas.llenarVentasPorCategoria(dgv_tabla, query); Controlador.ControlVentas.armarExcelProductosVendidos(dgv_tabla); }
private void CierreDeCaja_Load(object sender, EventArgs e) { decimal total; txt_vendido.Text = Convert.ToString(Controlador.ControlVentas.Total_Vendido_Hoy()); txt_reparado.Text = Convert.ToString(Controlador.ControlVentas.Total_Reparado_Hoy()); txt_retirado.Text = Convert.ToString(Controlador.ControlVentas.Total_Erogaciones_hoy()); total = ControlVentas.Total_Vendido_Hoy() + ControlVentas.Total_Reparado_Hoy() - ControlVentas.Total_Erogaciones_hoy(); txt_total.Text = Convert.ToString(total); }
public ListarPresupuestos() { InitializeComponent(); ControlVentas.construirTablaPresupuestos(dgv_tabla); calcularTamanio(); txt_desde.Value = DateTime.Now.Date; txt_hasta.Value = DateTime.Now.Date; //Tamaño minimo para que no se bugueen los componentes. this.MinimumSize = new Size(930, this.Size.Height); }
private void btn_presupuesto_Click(object sender, EventArgs e) { if (cuit.Text != "") { if (dgv_tabla.Rows.Count != 0) { Omega3.Modelo.Venta venta = new Modelo.Venta(); venta.documento = long.Parse(cuit.Text); venta.medio_de_pago = Convert.ToInt32(combo_pago.SelectedValue.ToString()); if (combo_pago.Text == "Cheque") { venta.fecha_vencimiento_cheque = fecha_pago.Value; } venta.nrofactura = "0"; venta.tipo_factura = ""; venta.fecha_venta = DateTime.Now; Factura_Negro factura = new Factura_Negro(); factura.Nombre = razon.Text; factura.Documento = cuit.Text; factura.Direccion = domicilio.Text; factura.Fecha = DateTime.Now; panel_principal.SelectedIndex = 0; MessageBox.Show("Presupuesto realizado correctamente!"); // ControlVentas.AgregarVenta(dgv_tabla, venta); ControlVentas.generarFacturaNegro(dgv_tabla, factura); dgv_tabla.Rows.Clear(); dgv_tabla.Refresh(); limpiarParteCliente(); lista.Clear(); } else { MessageBox.Show("No hay ningun producto agregado"); } } else { panel_principal.SelectedIndex = 0; MessageBox.Show("Aún no se seleccionó un cliente"); } }
public Ventas_Realizadas() { InitializeComponent(); //this.FormBorderStyle = FormBorderStyle.FixedSingle; ControlVentas.construirTablaVentasRealizadas(dgv_tabla); calcularTamanio(); this.MinimumSize = new Size(1250, this.Height); txt_desde.Value = DateTime.Now.Date; txt_hasta.Value = DateTime.Now.Date; }
private void button2_Click(object sender, EventArgs e) { Cliente a = new Cliente(); if (combo_cliente.SelectedIndex == -1) { if (buscar_cuit.Text != "Buscar por CUIT o DNI" && (buscar_cuit.Text.Trim() != "" || !string.IsNullOrEmpty(buscar_cuit.Text))) { if (ControlCliente.validardocumento(long.Parse(buscar_cuit.Text))) { a = ControlVentas.obtenerCliente(long.Parse(buscar_cuit.Text)); razon.Text = a.Razon; domicilio.Text = a.Direccion; iva.Text = a.Impositiva; email.Text = a.Mail_contacto; cuit.Text = Convert.ToString(a.Documento); lbl_lista.Text = Convert.ToString(a.Lista); lista_cliente = a.Lista / 100; ControlVentas.llenarComboComprobante(combo_comprobante, a.Impositiva_Id); } else { MessageBox.Show("El documento " + buscar_cuit.Text + " no corresponde a ningún cliente."); iniciarBusquedaCuit(); buscar_cuit.Focus(); } } else { MessageBox.Show("Debe seleccionar un cliente, escribir un DNI/C.U.I.T"); } } else { a = ControlVentas.obtenerCliente(combo_cliente.Text); razon.Text = a.Razon; domicilio.Text = a.Direccion; iva.Text = a.Impositiva; email.Text = a.Mail_contacto; cuit.Text = Convert.ToString(a.Documento); lbl_lista.Text = Convert.ToString(a.Lista); lista_cliente = a.Lista / 100; ControlVentas.llenarComboComprobante(combo_comprobante, a.Impositiva_Id); } button5.Enabled = true; }
private void button1_Click(object sender, EventArgs e) { Cliente cliente = new Cliente(); if (combo_cliente.SelectedIndex != -1) { cliente = ControlVentas.obtenerCliente(combo_cliente.Text); Deuda deuda = ControlAdministracion.obtenerDeudas(cliente.Documento); lbl_dni.Text = cliente.Razon; lbl_comprado.Text = deuda.total_comprado; lbl_pagado.Text = deuda.total_pagado; lbl_deuda.Text = deuda.deuda; } else { MessageBox.Show("No hay ningún cliente valido seleccionado."); } }
private void btn_buscar_cuit_Click(object sender, EventArgs e) { var cliente = new Cliente(); if (ControlCliente.validardocumento(long.Parse(buscar_cuit.Text))) { cliente = ControlVentas.obtenerCliente(long.Parse(buscar_cuit.Text)); Deuda deuda = ControlAdministracion.obtenerDeudas(cliente.Documento); lbl_dni.Text = cliente.Razon; lbl_comprado.Text = deuda.total_comprado; lbl_pagado.Text = deuda.total_pagado; lbl_deuda.Text = deuda.deuda; } else { MessageBox.Show("El documento " + buscar_cuit.Text + " no corresponde a ningún cliente."); //iniciarBusquedaCuit(); buscar_cuit.Focus(); } }
private void txt_ventas_codigo_KeyDown(object sender, KeyEventArgs e) { if (txt_ventas_codigo.Text != "") { if (e.KeyCode == Keys.Enter) { Producto a = new Producto(); a = ControlVentas.llenarInformacionProducto(txt_ventas_codigo.Text); combo_producto.Text = a.Nombre_producto; txt_ventas_precio.Text = a.Precio_venta.ToString(); calcularSubtotal(); button1.Focus(); } } else { MessageBox.Show("El campo código no puede estar vacío"); txt_ventas_codigo.Focus(); } }
private void Modificar_Cliente_Load(object sender, EventArgs e) { ControlCliente.llenarProvincias(combo_provincia); ControlCliente.llenarListas(combo_lista); ControlVentas.llenarCondicion(combo_condicion); cliente = ControlCliente.obtenerCliente(cliente.Documento); //lleno los textbox txt_documento.Text = Convert.ToString(cliente.Documento); txt_razon_social.Text = cliente.Razon; txt_direccion.Text = cliente.Direccion; txt_telefono.Text = Convert.ToString(cliente.Telefono); combo_provincia.SelectedValue = cliente.Cod_provincia; txt_cod_postal.Text = Convert.ToString(cliente.Codigo_postal); txt_contacto.Text = cliente.Contacto; txt_localidad.Text = cliente.Localidad; txt_mail_contacto.Text = cliente.Mail_contacto; combo_lista.SelectedValue = cliente.Lista; combo_condicion.SelectedValue = cliente.Impositiva_Id; txt_limite.Text = Convert.ToString(cliente.Maximo_credito); txt_plazo.Text = cliente.Plazo; txt_flete.Text = cliente.Flete; txt_nombre1.Text = cliente.Nombre1; txt_nombre2.Text = cliente.Nombre2; txt_nombre3.Text = cliente.Nombre3; txt_email1.Text = cliente.Email1; txt_email2.Text = cliente.Email2; txt_email3.Text = cliente.Email3; txt_telefono1.Text = cliente.Telefono1; txt_telefono2.Text = cliente.Telefono2; txt_telefono3.Text = cliente.Telefono3; }
private void dgv_tabla_CellContentClick(object sender, DataGridViewCellEventArgs e) { string url = string.Empty; string nrofactura = string.Empty; foreach (DataGridViewRow item in this.dgv_tabla.SelectedRows) { if (e.ColumnIndex == dgv_tabla.Columns["URL"].Index) //2nd column - DGV_ImageColumn { if (dgv_tabla.Rows[dgv_tabla.CurrentCell.RowIndex].Cells["Link"].Value.ToString().Trim() != "" || !string.IsNullOrEmpty(dgv_tabla.Rows[dgv_tabla.CurrentCell.RowIndex].Cells["Link"].Value.ToString())) { try { // System.Diagnostics.Process.Start(dgv_tabla.Rows[dgv_tabla.CurrentCell.RowIndex].Cells["Link"].Value.ToString()); url = dgv_tabla.Rows[dgv_tabla.CurrentCell.RowIndex].Cells["Link"].Value.ToString(); nrofactura = dgv_tabla.Rows[dgv_tabla.CurrentCell.RowIndex].Cells["Nro Factura"].Value.ToString(); using (WebClient webClient = new WebClient()) { try { Cursor.Current = Cursors.WaitCursor; webClient.DownloadFile(url, Path.GetTempPath() + "Factura_" + nrofactura + ".pdf"); System.Diagnostics.Process.Start(Path.GetTempPath() + "Factura_" + nrofactura + ".pdf"); } catch (FileLoadException ex) { Console.Write(ex); } } } catch (Exception ex) { MessageBox.Show("Excepción detectada -> " + ex.ToString() + " comuniquese con su proveedor de software"); } finally { Cursor.Current = Cursors.Default; } } else { ControlVentas.mostrarFacturaNegro(long.Parse(dgv_tabla.Rows[dgv_tabla.CurrentCell.RowIndex].Cells["Id"].Value.ToString())); } } } }
private void Presupuesto_Load(object sender, EventArgs e) { dataGridView1.DataSource = ControlPresupuesto.FillDgv(); dataGridView1.AutoGenerateColumns = false; dataGridView1.Columns[0].DataPropertyName = "Numero"; dataGridView1.Columns[1].DataPropertyName = "Cod"; dataGridView1.Columns[2].DataPropertyName = "Descripcion"; dataGridView1.Columns[3].DataPropertyName = "Cantidad"; dataGridView1.Columns[4].DataPropertyName = "Precio"; dataGridView1.Columns[5].DataPropertyName = "Importe"; ControlVentas.llenarMedios_de_Pago(combo_pago); ControlVenta.llenarClientes(combo_cliente); ControlVentas.llenarProductosCombo(combo_producto); filtro_cuit.Text = "Buscar por CUIT o DNI"; filtro_cuit.ForeColor = Color.Gray; dgv_tabla.SelectionMode = DataGridViewSelectionMode.FullRowSelect; }
private void btn_buscar_Click(object sender, EventArgs e) { Cliente a = new Cliente(); if (combo_cliente.Text == "") { a = ControlVentas.obtenerCliente(long.Parse(filtro_cuit.Text)); razon.Text = a.Razon; domicilio.Text = a.Direccion; iva.Text = a.Impositiva; email.Text = a.Mail_contacto; cuit.Text = Convert.ToString(a.Documento); } else { a = ControlVentas.obtenerCliente(combo_cliente.Text); razon.Text = a.Razon; domicilio.Text = a.Direccion; iva.Text = a.Impositiva; email.Text = a.Mail_contacto; cuit.Text = Convert.ToString(a.Documento); } }
private void btn_no_factura_Click(object sender, EventArgs e) { if (cuit.Text != "") { if (dgv_tabla.Rows.Count != 0) { Omega3.Modelo.Venta venta = new Modelo.Venta(); venta.remito = 0; venta.ordendeCompra = "0"; if (txt_remito.Text.Trim() != "" || !string.IsNullOrEmpty(txt_remito.Text)) { venta.remito = long.Parse(txt_remito.Text); } if (txt_ordenDeCompra.Text.Trim() != "" || !string.IsNullOrEmpty(txt_ordenDeCompra.Text)) { venta.ordendeCompra = txt_ordenDeCompra.Text; } venta.documento = long.Parse(cuit.Text); venta.medio_de_pago = Convert.ToInt32(combo_pago.SelectedValue.ToString()); if (combo_pago.Text == "Cheque" || combo_pago.Text == "Cuenta Corriente") { venta.fecha_vencimiento_cheque = fecha_pago.Value; } venta.nrofactura = "0"; venta.tipo_factura = Convert.ToString(combo_comprobante.SelectedValue); venta.fecha_venta = DateTime.Now; Factura_Negro factura = new Factura_Negro(); factura.Nombre = razon.Text; factura.Documento = cuit.Text; factura.Direccion = domicilio.Text; factura.Fecha = DateTime.Now; panel_principal.SelectedIndex = 0; MessageBox.Show("Venta realizada correctamente!"); ControlVentas.AgregarVenta(dgv_tabla, venta); ControlVentas.generarFacturaNegro(dgv_tabla, factura); dgv_tabla.Rows.Clear(); dgv_tabla.Refresh(); limpiarParteCliente(); lista.Clear(); this.Close(); } else { MessageBox.Show("No hay ningun producto agregado"); } } else { panel_principal.SelectedIndex = 0; MessageBox.Show("Aún no se seleccionó un cliente"); } }
private void btn_Agregar_Click_1(object sender, EventArgs e) { long valor_codigo; Decimal valor_bonificacion; int valor_cantidad; string valor_producto; Decimal valor_iva; Decimal valor_iva_cero; Decimal valor_precio; Decimal valor_lista; Decimal valor_subtotal; if (txt_ventas_codigo.Text.Trim() != "" || !string.IsNullOrEmpty(txt_ventas_codigo.Text)) { valor_codigo = long.Parse(txt_ventas_codigo.Text); valor_bonificacion = Convert.ToDecimal(txt_ventas_lista.Text); valor_cantidad = Convert.ToInt32(txt_ventas_cantidad.Text); valor_producto = combo_producto.Text; valor_iva = Convert.ToDecimal(combo_iva.Text); valor_iva_cero = valor_iva; //if (valor_iva == 0) { valor_iva_cero = 1; } valor_precio = Convert.ToDecimal(txt_ventas_precio.Text); valor_lista = Convert.ToDecimal(lbl_lista.Text); valor_subtotal = Convert.ToDecimal(txt_ventas_subtotal.Text); Producto a = new Producto(); bool aux = false; if (combo_producto.SelectedIndex != -1) { foreach (var producto in lista) { if (producto.Cod_producto == valor_codigo) { MessageBox.Show("El producto que intenta agregar, ya se encuentra en la venta."); aux = true; calcularSubtotal(); } } if (!aux) { if (ControlVentas.chequearStock(valor_codigo) >= valor_cantidad) { lista.Add(new Producto { Cod_producto = valor_codigo, Cantidad = (ControlVentas.chequearStock(valor_codigo)) - (valor_cantidad) }); dgv_tabla.Rows.Add(txt_ventas_cantidad.Text, valor_codigo, valor_producto, txt_ventas_precio.Text, combo_iva.Text, txt_ventas_subtotal.Text, txt_ventas_lista.Text, null, Convert.ToString(elemento_clase)); calcularTotalVenta(); listado_articulos.Add(new Detalle_Facturante { elemento = elemento_clase, Bonificacion = valor_bonificacion, cantidad = valor_cantidad, codigo = valor_codigo.ToString(), detalle = valor_producto, gravado = true, iva = valor_iva, /*precio_unitario = valor_precio * (valor_lista / 100 + 1), * total = valor_precio * (valor_lista / 100 + 1) * Convert.ToDecimal(txt_ventas_cantidad.Text)*/ precio_unitario = (valor_subtotal / (valor_iva_cero / 100 + 1)) / valor_cantidad, total = valor_subtotal / (valor_iva_cero / 100 + 1) }); elemento_clase++; limpiarCamposCabecera(); } else { DialogResult dialogresult = MessageBox.Show("\t No se dispone del stock suficiente\n ¿Desea agregar el producto a la venta de todas maneras?", "¡Alerta!", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); if (dialogresult == DialogResult.Yes) { dgv_tabla.Rows.Add(txt_ventas_cantidad.Text, valor_codigo, valor_producto, txt_ventas_precio.Text, combo_iva.Text, txt_ventas_subtotal.Text, txt_ventas_lista.Text, null, Convert.ToString(elemento_clase)); calcularTotalVenta(); listado_articulos.Add(new Detalle_Facturante { elemento = elemento_clase, Bonificacion = valor_bonificacion, cantidad = valor_cantidad, codigo = valor_codigo.ToString(), detalle = valor_producto, gravado = true, iva = valor_iva, //precio_unitario = valor_precio * (valor_lista / 100 + 1), //total = valor_precio * (valor_lista / 100 + 1) * Convert.ToDecimal(txt_ventas_cantidad.Text) precio_unitario = (valor_subtotal / (valor_iva_cero / 100 + 1)) / valor_cantidad, total = valor_subtotal / (valor_iva_cero / 100 + 1) }); elemento_clase++; limpiarCamposCabecera(); } else if (dialogresult == DialogResult.No) { MessageBox.Show("El producto no fue agregado"); } } } txt_ventas_codigo.Focus(); txt_ventas_subtotal.Text = ""; } else { MessageBox.Show("Debe seleccionar un producto"); } } }
private void btn_exportar_Click(object sender, EventArgs e) { // MessageBox.Show(dgv_tabla.Rows[1].Cells["Cobrada"].Value.ToString()); ControlVentas.armarExcelVentasRealizadas(dgv_tabla); }