private void Detalle_dtgrdvw_CellClick(object sender, DataGridViewCellEventArgs e) { if (this.Detalle_dtgrdvw.Columns[e.ColumnIndex].Name == "eliminar") { long subtotal_v = 0; long iva_v = 0; long total_facv = 0; Lógica.Clase_Detalle_venta dtv = new Clase_Detalle_venta(); int pocision = Detalle_dtgrdvw.CurrentRow.Index; int id_Detalle = int.Parse(Detalle_dtgrdvw[0, pocision].Value.ToString()); int resultado = dtv.Eliminar_Detalle_Venta(id_Detalle); if (resultado > 0) { int posicion = Detalle_dtgrdvw.CurrentRow.Index; obj_mensajes.Eliminar(); Detalle_dtgrdvw.Rows.RemoveAt(pocision); foreach (DataGridViewRow row in Detalle_dtgrdvw.Rows) { subtotal_v += Convert.ToInt64(row.Cells["Subtotalclm"].Value); } subtotaltxt.Text = subtotal_v.ToString(); iva_v = subtotal_v * 19 / 100; ivatxt.Text = iva_v.ToString(); total_facv = subtotal_v + iva_v; Totaltxt.Text = total_facv.ToString(); } } }
private void editar_Detallebtn_Click(object sender, EventArgs e) { if (det_nulbl.Text == "" || productotxt.Text == "" || valor_unitariotxt.Text == "" || cantidad_Txt.Text == "") { obj_mensajes.Campos_vacios(); } else { try { long subtotal_v = 0; long iva_v = 0; long total_facv = 0; Lógica.Clase_Detalle_venta dt = new Clase_Detalle_venta(); int producto = int.Parse(productotxt.SelectedValue.ToString()); int numero_fac = int.Parse(Numero_Factxt.Text); int cantidad = int.Parse(cantidad_Txt.Text); long valor = long.Parse(valor_unitariotxt.Text); long subtotal = valor * cantidad; int id_Detalle = int.Parse(det_nulbl.Text); int resultado = dt.Modificar_Detalle_venta(id_Detalle, producto, numero_fac, cantidad, valor, subtotal); if (resultado > 0) { obj_mensajes.Modificar(); int posicion = Detalle_dtgrdvw.CurrentRow.Index; Detalle_dtgrdvw[1, posicion].Value = productotxt.Text; Detalle_dtgrdvw[2, posicion].Value = long.Parse(valor.ToString()); Detalle_dtgrdvw[3, posicion].Value = int.Parse(cantidad.ToString()); Detalle_dtgrdvw[4, posicion].Value = long.Parse(subtotal.ToString()); foreach (DataGridViewRow row in Detalle_dtgrdvw.Rows) { subtotal_v += Convert.ToInt64(row.Cells["Subtotalclm"].Value); } subtotaltxt.Text = subtotal_v.ToString(); iva_v = subtotal_v * 19 / 100; ivatxt.Text = iva_v.ToString(); total_facv = subtotal_v + iva_v; Totaltxt.Text = total_facv.ToString(); limpiar(); } } catch (SqlException ex) { MessageBox.Show("" + ex); } } }
private void guardar_detallebtn_Click(object sender, EventArgs e) { if (productotxt.Text == "" || valor_unitariotxt.Text == "" || cantidad_Txt.Text == "") { obj_mensajes.Campos_vacios(); } else { try { long subtotal_v = 0; long iva_v = 0; long total_facv = 0; Lógica.Clase_Detalle_venta dt = new Clase_Detalle_venta(); int producto = int.Parse(productotxt.SelectedValue.ToString()); int numero_fac = int.Parse(Numero_Factxt.Text); int cantidad = int.Parse(cantidad_Txt.Text); long valor = long.Parse(valor_unitariotxt.Text); long subtotal = valor * cantidad; int resultado = dt.ingresar_detalle_Venta(producto, numero_fac, cantidad, valor, subtotal); if (resultado > 0) { obj_mensajes.Agregar(); DataTable detalle_no = Lógica.Clase_Detalle_venta.IdentityVenta(); det_nulbl.Text = detalle_no.Rows[0][0].ToString(); Detalle_dtgrdvw.Rows.Add(det_nulbl.Text, productotxt.Text, valor_unitariotxt.Text, cantidad_Txt.Text, subtotal); foreach (DataGridViewRow row in Detalle_dtgrdvw.Rows) { subtotal_v += Convert.ToInt64(row.Cells["Subtotalclm"].Value); } subtotaltxt.Text = subtotal_v.ToString(); iva_v = subtotal_v * 19 / 100; ivatxt.Text = iva_v.ToString(); total_facv = subtotal_v + iva_v; Totaltxt.Text = total_facv.ToString(); limpiar(); } } catch (SqlException ex) { MessageBox.Show("" + ex); } } }