private void btnCrearVenta_Click(object sender, EventArgs e) { try { ClsDVenta ventas = new ClsDVenta(); tb_venta venta = new tb_venta(); venta.iDDocumento = Convert.ToInt32(comboBox1.SelectedValue.ToString()); venta.iDCliente = Convert.ToInt32(comboBox2.SelectedValue.ToString()); venta.iDUsuario = 1; venta.totalVenta = Convert.ToDecimal(txtTotalVenta.Text); venta.fecha = Convert.ToDateTime(dateTimePicker1.Text); ventas.save(venta); ClsDDetalle detalles = new ClsDDetalle(); tb_detalleVenta detalle = new tb_detalleVenta(); foreach (DataGridViewRow dtg in DtgVenta.Rows) { detalle.idVenta = Convert.ToInt32(txtNumeroDoc.Text); detalle.idProducto = Convert.ToInt32(dtg.Cells[0].Value.ToString()); detalle.precio = Convert.ToDecimal(dtg.Cells[2].Value.ToString()); detalle.cantidad = Convert.ToInt32(dtg.Cells[3].Value.ToString()); detalle.total = Convert.ToDecimal(dtg.Cells[4].Value.ToString()); detalles.guardardetalleventa(detalle); } ultimocorrelativoventa(); DtgVenta.Rows.Clear(); txtTotalVenta.Text = ""; txtCantidad.Text = ""; MessageBox.Show("save"); } catch (Exception error) { MessageBox.Show("error : " + error); } }
private void txtGuardarVenta_Click(object sender, EventArgs e) { try { ClsDVenta ventas = new ClsDVenta(); tb_venta venta = new tb_venta(); venta.iDDocumento = Convert.ToInt32(cbTipoDocumento.SelectedValue.ToString()); venta.iDCliente = Convert.ToInt32(cbCliente.SelectedValue.ToString()); venta.iDUsuario = 1; venta.totalVenta = Convert.ToDecimal(txtTotalFinal.Text); venta.fecha = Convert.ToDateTime(dtpFecha.Text); ventas.save(venta); ClsDDetalle clsD = new ClsDDetalle(); tb_detalleVenta tbDetalle = new tb_detalleVenta(); foreach (DataGridViewRow dtgV in dtgVenta.Rows) { tbDetalle.iDVenta = Convert.ToInt32(txtVenta.Text); tbDetalle.iDProducto = Convert.ToInt32(dtgV.Cells[0].Value.ToString()); tbDetalle.cantidad = Convert.ToInt32(dtgV.Cells[3].Value.ToString()); tbDetalle.precio = Convert.ToDecimal(dtgV.Cells[2].Value.ToString()); tbDetalle.total = Convert.ToDecimal(dtgV.Cells[4].Value.ToString()); } UltimoCorrelativoDeVenta(); dtgVenta.Rows.Clear(); txtTotalFinal.Text = ""; MessageBox.Show("Save"); } catch (Exception ex) { MessageBox.Show("Error" + ex); } }
private void btnFacturar_Click(object sender, EventArgs e) { using (sistema_ventasEntities bd = new sistema_ventasEntities()) { try { tb_venta tbV = new tb_venta(); tbV.idDocumento = Convert.ToInt32(cmbDocumento.SelectedValue); tbV.iDCliente = Convert.ToInt32(cmbClientes.SelectedValue); tbV.iDUsuario = 1; tbV.totalVenta = Convert.ToDecimal(lblTotal.Text); tbV.fecha = Convert.ToDateTime(dtpFecha.Text); bd.tb_venta.Add(tbV); bd.SaveChanges(); detalleVenta dete = new detalleVenta(); for (int i = 0; i < dgvVentas.RowCount; i++) { string idProducto = dgvVentas.Rows[i].Cells[0].Value.ToString(); int idConvertido = Convert.ToInt32(idProducto); string Cantidad = dgvVentas.Rows[i].Cells[3].Value.ToString(); int CantidadConvertido = Convert.ToInt32(Cantidad); string Precio = dgvVentas.Rows[i].Cells[2].Value.ToString(); decimal PrecioConvertido = Convert.ToDecimal(Precio); string Total = dgvVentas.Rows[i].Cells[4].Value.ToString(); decimal TotalConvertido = Convert.ToDecimal(Total); dete.idVenta = Convert.ToInt32(lblNumVenta.Text); dete.idProducto = idConvertido; dete.cantidad = CantidadConvertido; dete.precio = PrecioConvertido; dete.total = TotalConvertido; bd.detalleVenta.Add(dete); bd.SaveChanges(); } limpiar(); dgvVentas.Rows.Clear(); RetornarId(); cargarClientes(); cargarDocumentos(); lblTotal.Text = ""; } catch (Exception ex) { MessageBox.Show("No se han definido algunos valores"); } } }
private void button1_Click(object sender, EventArgs e) { using (sistema_ventasEntities db = new sistema_ventasEntities()) { tb_venta tb_v = new tb_venta(); String comboDocumento = cmbTipoDoc.SelectedValue.ToString(); String comboCliente = cmbCliente.SelectedValue.ToString(); tb_v.idDocumento = Convert.ToInt32(comboDocumento); tb_v.iDCliente = Convert.ToInt32(comboCliente); tb_v.iDUsuario = 1; tb_v.totalVenta = Convert.ToDecimal(txtTotalVenta.Text); tb_v.fecha = Convert.ToDateTime(dtpFecha.Text); db.tb_venta.Add(tb_v); db.SaveChanges(); detalleVenta dete = new detalleVenta(); for (int i = 0; i < dtvVentas.RowCount; i++) { String idProducto = dtvVentas.Rows[i].Cells[0].Value.ToString(); int idProductoConvertido = Convert.ToInt32(idProducto); String cantidad = dtvVentas.Rows[i].Cells[3].Value.ToString(); int cantidadConvertida = Convert.ToInt32(cantidad); String precio = dtvVentas.Rows[i].Cells[2].Value.ToString(); Decimal precioConvertido = Convert.ToDecimal(precio); String total = dtvVentas.Rows[i].Cells[4].Value.ToString(); Decimal totalConvertido = Convert.ToDecimal(total); dete.idVenta = Convert.ToInt32(txtNumVenta.Text); dete.idProducto = idProductoConvertido; dete.cantidad = cantidadConvertida; dete.precio = precioConvertido; dete.total = totalConvertido; db.detalleVenta.Add(dete); db.SaveChanges(); txtIdProdcuto.Text = ""; txtProducto.Text = ""; txtPrecioProducto.Text = ""; txtTotal.Text = ""; } } retornoId(); dtvVentas.Rows.Clear(); txtTotalVenta.Text = ""; }
public void save(tb_venta ventas) { using (sistema_ventasEntities db = new sistema_ventasEntities()) { tb_venta venta = new tb_venta(); venta.iDDocumento = ventas.iDDocumento; venta.iDCliente = ventas.iDCliente; venta.iDUsuario = ventas.iDUsuario; venta.totalVenta = ventas.totalVenta; venta.fecha = ventas.fecha; db.tb_venta.Add(venta); db.SaveChanges(); } }
private void button3_Click(object sender, EventArgs e) { using (sitema_ventasEntities bd = new sitema_ventasEntities()) { tb_venta tb_venta = new tb_venta(); String comboTipoDoc = cmbTipoDoc.SelectedValue.ToString(); String comboCliente = cmbClientes.SelectedValue.ToString(); tb_venta.idDocumento = int.Parse(comboTipoDoc); tb_venta.iDCliente = int.Parse(comboCliente); tb_venta.iDUsuario = 1; tb_venta.totalVenta = Convert.ToDecimal(txtTotalFinal.Text); tb_venta.fecha = Convert.ToDateTime(dtpFecha.Text); bd.tb_venta.Add(tb_venta); bd.SaveChanges(); detalleVenta dete = new detalleVenta(); for (int i = 0; i < dtvVentas.RowCount; i++) { String IdProducto = dtvVentas.Rows[i].Cells[0].Value.ToString(); int ProductosConvertidos = Convert.ToInt32(IdProducto); String cantidad = dtvVentas.Rows[i].Cells[3].Value.ToString(); int cantidadConvertida = Convert.ToInt32(cantidad); String precio = dtvVentas.Rows[i].Cells[2].Value.ToString(); Decimal PrecioConvertido = Convert.ToDecimal(precio); String total = dtvVentas.Rows[i].Cells[4].Value.ToString(); Decimal TotalConvertido = Convert.ToDecimal(total); dete.idVenta = Convert.ToInt32(txtIDNumeracion.Text); dete.idProducto = ProductosConvertidos; dete.cantidad = cantidadConvertida; dete.precio = PrecioConvertido; dete.total = TotalConvertido; bd.detalleVenta.Add(dete); bd.SaveChanges(); } } retornoid(); dtvVentas.Rows.Clear(); txtTotalFinal.Text = ""; }
private void btnVentas_Click(object sender, EventArgs e) { using (sistema_ventasEntities1 bd = new sistema_ventasEntities1()) { tb_venta tb_v = new tb_venta(); String combo = cmbTipoD.SelectedValue.ToString(); String comboCliente = cmbCliente.SelectedValue.ToString(); tb_v.idDocumento = Convert.ToInt32(combo); tb_v.iDCliente = Convert.ToInt32(comboCliente); tb_v.iDUsuario = 1; tb_v.totalVenta = Convert.ToDecimal(txtTot.Text); tb_v.fecha = Convert.ToDateTime(dtpFecha.Text); bd.tb_venta.Add(tb_v); bd.SaveChanges(); detalleVenta det = new detalleVenta(); for (int i = 0; i < dtgProductos.Rows.Count; i++) { String idProducto = dtgProductos.Rows[i].Cells[0].Value.ToString(); int idProductoConvertidos = Convert.ToInt32(idProducto); String cantidad = dtgProductos.Rows[i].Cells[3].Value.ToString(); int cantidadConvertidos = Convert.ToInt32(cantidad); String precio = dtgProductos.Rows[i].Cells[2].Value.ToString(); Decimal precioConvertidos = Convert.ToDecimal(precio); String total = dtgProductos.Rows[i].Cells[4].Value.ToString(); Decimal totalConvertidos = Convert.ToDecimal(total); det.idVenta = Convert.ToInt32(txtIDNumercion.Text); det.idProducto = idProductoConvertidos; det.cantidad = cantidadConvertidos; det.precio = precioConvertidos; det.total = totalConvertidos; bd.detalleVenta.Add(det); bd.SaveChanges(); } } retornarid(); dtgProductos.Rows.Clear(); txtTot.Text = ""; }
private void button1_Click(object sender, EventArgs e) { using (sistema_ventaEntities2 db = new sistema_ventaEntities2()) { tb_venta tv_v = new tb_venta(); string comboTipoDocumento = cmbTipoDocumento.SelectedValue.ToString(); string comboCliente = cmbCliente.SelectedValue.ToString(); tv_v.idDocumento = Convert.ToInt32(comboTipoDocumento); tv_v.iDCliente = Convert.ToInt32(comboCliente); tv_v.iDUsuario = 1; tv_v.totalVenta = Convert.ToDecimal(txtTOTALF.Text); tv_v.fecha = Convert.ToDateTime(dtpFecha.Text); db.tb_venta.Add(tv_v); db.SaveChanges(); detalleVenta dete = new detalleVenta(); for (int i = 0; i < dtvVenta.RowCount; i++) { string idProducto = dtvVenta.Rows[i].Cells[0].Value.ToString(); int idProductosConvertidos = Convert.ToInt32(idProducto); string cantidad = dtvVenta.Rows[i].Cells[3].Value.ToString(); int CantidadConvertidos = Convert.ToInt32(cantidad); string precio = dtvVenta.Rows[i].Cells[2].Value.ToString(); decimal PrecioConvertidos = Convert.ToDecimal(precio); string total = dtvVenta.Rows[i].Cells[4].Value.ToString(); decimal TotalConvertidos = Convert.ToDecimal(total); dete.idVenta = Convert.ToInt32(txtNumeroVenta.Text); dete.idProducto = idProductosConvertidos; dete.cantidad = CantidadConvertidos; dete.precio = PrecioConvertidos; dete.total = TotalConvertidos; db.detalleVenta.Add(dete); db.SaveChanges(); } } retornoid(); dtvVenta.Rows.Clear(); txtTOTALF.Text = ""; }
private void btnGuardarVenta_Click(object sender, EventArgs e) { using (sistema_ventasEntities1 bd = new sistema_ventasEntities1()) { tb_venta tb_v = new tb_venta(); String comboTipoDoc = comboBoxTipoDeDocumento.SelectedValue.ToString(); String comboCliente = comboBoxCliente.SelectedValue.ToString(); tb_v.idDocumento = Convert.ToInt32(comboTipoDoc); tb_v.iDCliente = Convert.ToInt32(comboCliente); tb_v.iDUsuario = 1; tb_v.totalVenta = Convert.ToDecimal(textBoxTotalFinal.Text); tb_v.fecha = Convert.ToDateTime(dtpFecha.Value); bd.tb_venta.Add(tb_v); bd.SaveChanges(); detalleVenta dete = new detalleVenta(); for (int i = 0; i < dtvProductos.RowCount; i++) { String idProducto = dtvProductos.Rows[i].Cells[0].Value.ToString(); // int idProductoConvertidos = Convert.ToInt32(idProducto); String cantidad = dtvProductos.Rows[i].Cells[3].Value.ToString(); int cantidadConvertidos = Convert.ToInt32(cantidad); String precio = dtvProductos.Rows[i].Cells[2].Value.ToString(); Decimal precioConvertidos = Convert.ToDecimal(precio); String total = dtvProductos.Rows[i].Cells[4].Value.ToString(); Decimal totalConvertidos = Convert.ToDecimal(total); dete.idVenta = Convert.ToInt32(textBoxNumeroDeVenta.Text); dete.idProducto = idProductoConvertidos; dete.cantidad = cantidadConvertidos; dete.precio = precioConvertidos; dete.total = totalConvertidos; bd.detalleVenta.Add(dete); bd.SaveChanges(); } } retornoid(); dtvProductos.Rows.Clear(); textBoxTotalFinal.Text = ""; }
private void bttnGuardarVenta_Click(object sender, EventArgs e) { using (AppVentaBDEntities db = new AppVentaBDEntities()) { tb_venta tb_v = new tb_venta(); String comboTipoDoc = cmbTipodocu.SelectedValue.ToString(); String comboCliente = cmbCliente.SelectedValue.ToString(); tb_v.idDocumento = Convert.ToInt32(comboTipoDoc); tb_v.iDCliente = Convert.ToInt32(comboCliente); tb_v.iDUsuario = 1; tb_v.totalVenta = Convert.ToDecimal(txtTotalFinal.Text); tb_v.fecha = Convert.ToDateTime(dtpFecha.Text); db.tb_venta.Add(tb_v); db.SaveChanges(); detalleVenta dete = new detalleVenta(); for (int i = 0; i < dgvVentas.RowCount; i++) { String idProducto = dgvVentas.Rows[i].Cells[0].Value.ToString(); int idProductosConvertidos = Convert.ToInt32(idProducto); String cantidad = dgvVentas.Rows[i].Cells[3].Value.ToString(); int cantidadConvertidos = Convert.ToInt32(cantidad); String precio = dgvVentas.Rows[i].Cells[2].Value.ToString(); Decimal precioConvertidos = Convert.ToDecimal(precio); String total = dgvVentas.Rows[i].Cells[4].Value.ToString(); Decimal totalConvertidos = Convert.ToInt32(total); dete.idVenta = Convert.ToInt32(txtIdNumeracion.Text); dete.idProducto = idProductosConvertidos; dete.cantidad = cantidadConvertidos; dete.precio = precioConvertidos; dete.total = totalConvertidos; db.detalleVenta.Add(dete); db.SaveChanges(); } } RetornoId(); dgvVentas.Rows.Clear(); txtTotalFinal.Text = ""; }
private void button1_Click_1(object sender, EventArgs e) { using (sistema_ventasEntities bd = new sistema_ventasEntities()) { tb_venta tb_v = new tb_venta(); String ComboDoc = cmbTipoDoc.SelectedValue.ToString(); String ComboCliente = cmbClientes.SelectedValue.ToString(); tb_v.idDocumento = Convert.ToInt32(ComboDoc); tb_v.iDCliente = Convert.ToInt32(ComboCliente); tb_v.iDUsuario = idUsuario; tb_v.totalVenta = Convert.ToDecimal(txtTotalPago.Text); tb_v.fecha = Convert.ToDateTime(dtpFecha.Text); bd.tb_venta.Add(tb_v); bd.SaveChanges(); detalleVenta dV = new detalleVenta(); for (int i = 0; i < dvgVentas.Rows.Count; i++) { String idProducto = dvgVentas.Rows[i].Cells[0].Value.ToString(); String precio = dvgVentas.Rows[i].Cells[2].Value.ToString(); String cantidad = dvgVentas.Rows[i].Cells[3].Value.ToString(); String total = dvgVentas.Rows[i].Cells[4].Value.ToString(); ; dV.idVenta = Convert.ToInt32(txtIdVenta.Text); dV.idProducto = Convert.ToInt32(idProducto); dV.cantidad = Convert.ToInt32(cantidad); dV.precio = Convert.ToDecimal(precio); dV.total = Convert.ToDecimal(total); bd.detalleVentas.Add(dV); bd.SaveChanges(); } } dvgVentas.Rows.Clear(); Retornoid(); txtTotalPago.Text = "0.00"; }
private void btnGuardarVenta_Click(object sender, EventArgs e) { try { ClsDVenta ventas = new ClsDVenta(); tb_venta venta = new tb_venta(); venta.iDDocumento = Convert.ToInt32(comBoxTipDocument.SelectedValue.ToString()); venta.iDCliente = Convert.ToInt32(comBoxCliente.SelectedValue.ToString()); venta.iDUsuario = 1; venta.totalVenta = Convert.ToDecimal(txtTotal.Text); venta.fecha = Convert.ToDateTime(dtpFecha.Text); ventas.save(venta); ClsDDetalle detalle = new ClsDDetalle(); tb_detalleVenta tbdetalle = new tb_detalleVenta(); foreach (DataGridViewRow dtgv in dgvVenta.Rows) { tbdetalle.iDVenta = Convert.ToInt32(txtNumeroVenta.Text); tbdetalle.iDProducto = Convert.ToInt32(dtgv.Cells[0].Value.ToString()); tbdetalle.cantidad = Convert.ToInt32(dtgv.Cells[3].Value.ToString()); tbdetalle.precio = Convert.ToDecimal(dtgv.Cells[2].Value.ToString()); tbdetalle.total = Convert.ToDecimal(dtgv.Cells[4].Value.ToString()); detalle.guardardetalleventa(tbdetalle); } ultimocorrelativodeventa(); dgvVenta.Rows.Clear(); txtTotalFinal.Text = ""; MessageBox.Show("Guardado"); } catch (Exception ex) { MessageBox.Show("Error " + ex); } }
private void btnGuardar_Click(object sender, EventArgs e) { if (dtvProductos.Rows.Count == 0) { MessageBox.Show("¡No ha ingresado ningun producto!", "Completar", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { using (sistemaVentasEntities bd = new sistemaVentasEntities()) { tb_venta venta = new tb_venta(); String comboDoc = cmbTipDoc.SelectedValue.ToString(); String comboCli = cmbCliente.SelectedValue.ToString(); venta.idDocumento = Convert.ToInt32(comboDoc); venta.iDCliente = Convert.ToInt32(comboCli); venta.iDUsuario = 8; venta.totalVenta = Convert.ToDecimal(lblTotalGeneral.Text); venta.fecha = Convert.ToDateTime(dtpFecha.Text); bd.tb_venta.Add(venta); bd.SaveChanges(); detalleVenta dventa = new detalleVenta(); for (int i = 0; i < dtvProductos.RowCount; i++) { String idProducto = dtvProductos.Rows[i].Cells[0].Value.ToString(); int idProdConvertido = Convert.ToInt32(idProducto); String Cantidad = dtvProductos.Rows[i].Cells[3].Value.ToString(); int cantidadConver = Convert.ToInt32(Cantidad); String Precio = dtvProductos.Rows[i].Cells[2].Value.ToString(); Decimal precioConver = Convert.ToDecimal(Precio); String Total = dtvProductos.Rows[i].Cells[4].Value.ToString(); Decimal totalConver = Convert.ToDecimal(Total); dventa.idVenta = Convert.ToInt32(txtNumVenta.Text); dventa.idProducto = idProdConvertido; dventa.cantidad = cantidadConver; dventa.precio = precioConver; dventa.total = totalConver; bd.detalleVenta.Add(dventa); bd.SaveChanges(); } MessageBox.Show("¡Venta Realizada con éxito!", "Guardado", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); dtvProductos.Rows.Clear(); if (dtvProductos.Rows.Count == 0) { lblTotalGeneral.Text = "0.00"; } } RetornoId(); } }