private void tabla_articulos_CellClick(object sender, DataGridViewCellEventArgs e) { if (tabla_articulos.Rows.Count != 0) { if (tabla_articulos.Columns[e.ColumnIndex].Name == "eli") { if (MessageBox.Show("¿Desea eliminar el producto?", "Pregunta", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk) == DialogResult.Yes) { registro.Remove(tabla_articulos.CurrentRow.Cells[12].Value.ToString()); tabla_articulos.Rows.RemoveAt(tabla_articulos.CurrentRow.Index); calcularTotal(); } } else if (tabla_articulos.Columns[e.ColumnIndex].Name == "modi") { if (MessageBox.Show("¿Desea modificar el detalle del producto?", "Pregunta", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk) == DialogResult.Yes) { auxiliares.producto_unica_presentacion frm = new auxiliares.producto_unica_presentacion(); frm.Idsp = tabla_articulos.CurrentRow.Cells[12].Value.ToString(); frm.lblExis.Text = tabla_articulos.CurrentRow.Cells[8].Value.ToString(); frm.lblNombre.Text = tabla_articulos.CurrentRow.Cells[2].Value.ToString(); frm.Idud = tabla_articulos.CurrentRow.Cells[13].Value.ToString(); frm.Idum = tabla_articulos.CurrentRow.Cells[14].Value.ToString(); frm.Codigo = tabla_articulos.CurrentRow.Cells[1].Value.ToString(); frm.PrecioCD = tabla_articulos.CurrentRow.Cells[6].Value.ToString(); frm.PrecioCM = tabla_articulos.CurrentRow.Cells[5].Value.ToString(); frm.Canti = tabla_articulos.CurrentRow.Cells[4].Value.ToString(); frm.Prese = tabla_articulos.CurrentRow.Cells[3].Value.ToString(); frm.Presenta = registro[tabla_articulos.CurrentRow.Cells[12].Value.ToString()]; registro.Remove(tabla_articulos.CurrentRow.Cells[12].Value.ToString()); frm.Modificar = true; frm.ShowDialog(); { if (frm.Listo) { try { registro.Add(frm.Idsp, frm.Presenta); DataRowView comprDetalle = (DataRowView)frm.listaPresentaciones.SelectedItem; DataRowView detalle = (DataRowView)frm.listaUDetalle.SelectedItem; DataRowView mayoreo = (DataRowView)frm.listaUMayoreo.SelectedItem; tabla_articulos.CurrentRow.Cells[1].Value = frm.Codigo; tabla_articulos.CurrentRow.Cells[2].Value = frm.lblNombre.Text; tabla_articulos.CurrentRow.Cells[3].Value = frm.listaPresentaciones.Text; tabla_articulos.CurrentRow.Cells[4].Value = frm.txtCantidad.Value.ToString(); tabla_articulos.CurrentRow.Cells[5].Value = frm.compraMayoreo.Value.ToString(); tabla_articulos.CurrentRow.Cells[6].Value = frm.compraDetalle.Value.ToString(); tabla_articulos.CurrentRow.Cells[7].Value = Math.Round(Convert.ToDouble(frm.compraMayoreo.Value) * Convert.ToInt32(frm.txtCantidad.Value), 2).ToString(); tabla_articulos.CurrentRow.Cells[8].Value = frm.lblExis.Text; tabla_articulos.CurrentRow.Cells[9].Value = mayoreo[3].ToString(); tabla_articulos.CurrentRow.Cells[10].Value = detalle[3].ToString(); tabla_articulos.CurrentRow.Cells[11].Value = comprDetalle[2].ToString(); tabla_articulos.CurrentRow.Cells[12].Value = frm.Idsp; tabla_articulos.CurrentRow.Cells[13].Value = frm.listaUDetalle.SelectedValue.ToString(); tabla_articulos.CurrentRow.Cells[14].Value = frm.listaUMayoreo.SelectedValue.ToString(); tabla_articulos.CurrentRow.Cells[15].Value = frm.ventaMayoreo.Value.ToString(); tabla_articulos.CurrentRow.Cells[16].Value = frm.ventaDetalle.Value.ToString(); cargar_tablas.correlativoTabla(tabla_articulos); calcularTotal(); } catch { MessageBox.Show("Ya se agrego ese producto al detalle", "Repetido", MessageBoxButtons.OK, MessageBoxIcon.Error); } txtBusqueda.Text = ""; tablad.Visible = false; } } } } } }
private void colocarPrecios() { try { DataGridViewRow seleccion = tablad.CurrentRow; auxiliares.producto_unica_presentacion frm = new auxiliares.producto_unica_presentacion(); frm.Idsp = seleccion.Cells[0].Value.ToString(); frm.lblExis.Text = seleccion.Cells[6].Value.ToString(); frm.lblNombre.Text = seleccion.Cells[2].Value.ToString(); frm.Idud = seleccion.Cells[14].Value.ToString(); frm.Idum = seleccion.Cells[15].Value.ToString(); frm.Codigo = seleccion.Cells[1].Value.ToString(); frm.ShowDialog(); if (frm.Listo) { try { registro.Add(frm.Idsp, frm.Presenta); if (!productoRepetidos(frm.Idsp)) { DataRowView comprDetalle = (DataRowView)frm.listaPresentaciones.SelectedItem; DataRowView detalle = (DataRowView)frm.listaUDetalle.SelectedItem; DataRowView mayoreo = (DataRowView)frm.listaUMayoreo.SelectedItem; tabla_articulos.Rows.Add( "", frm.Codigo, frm.lblNombre.Text, frm.listaPresentaciones.Text, frm.txtCantidad.Value.ToString(), frm.compraMayoreo.Value.ToString(), frm.compraDetalle.Value.ToString(), Math.Round(Convert.ToDouble(frm.compraMayoreo.Value) * Convert.ToInt32(frm.txtCantidad.Value), 2).ToString(), frm.lblExis.Text, mayoreo[3].ToString(), detalle[3].ToString(), comprDetalle[2].ToString(), frm.Idsp, frm.listaUDetalle.SelectedValue.ToString(), frm.listaUMayoreo.SelectedValue.ToString(), frm.ventaMayoreo.Value.ToString(), frm.ventaDetalle.Value.ToString(), comprDetalle[3].ToString(), Image.FromFile(Environment.CurrentDirectory + @"\\refresh.png"), Image.FromFile(Environment.CurrentDirectory + @"\\delete.png") ); cargar_tablas.correlativoTabla(tabla_articulos); calcularTotal(); } else { txtBusqueda.Text = ""; tablad.Visible = false; } } catch { MessageBox.Show("Ya se agrego ese producto al detalle", "Repetido", MessageBoxButtons.OK, MessageBoxIcon.Error); } txtBusqueda.Text = ""; tablad.Visible = false; } else { txtBusqueda.Text = ""; tablad.Visible = false; } } catch { } }