private void btn_Devoluciones_Click(object sender, EventArgs e) { this.Hide(); FormDevoluciones dev = new FormDevoluciones(); dev.ShowDialog(); this.Close(); }
private void btnConfirmar_Click(object sender, EventArgs e) { if (dgv_ProdDev.Rows.Count == 0) { MessageBox.Show("No hay datos seleccionados", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { tran.CodConf = 1; FormConfirmacion conf = new FormConfirmacion(); conf.ShowDialog(); if (tran.CodConf == 2) { conexion.cmd = new SqlCommand("INSERT INTO Devoluciones(num_devolucion, num_factura, fecha_devolucion, " + "cod_empleado) values('" + txtDevolucion.Text.ToString() + "','" + mtb_Factura.Text.ToString() + "'," + "'" + dtp_Fecha.Value.ToShortDateString() + "','" + conexion.Cod_empleado + "')", conexion.sc); conexion.AbrirConexion(); conexion.cmd.ExecuteNonQuery(); conexion.CerrarConexion(); conexion.cmd = new SqlCommand("INSERT INTO DevolucionDetalle(num_devolucion, cod_producto, cantidad, motivo, cod_estado) " + "values('" + txtDevolucion.Text.ToString() + "',@codProd,@cantidad,@motivo,'1')", conexion.sc); foreach (DataGridViewRow row in dgv_ProdDev.Rows) { conexion.cmd.Parameters.Clear(); conexion.cmd.Parameters.AddWithValue("@codProd", Convert.ToString(row.Cells["columnaCodigo"].Value)); conexion.cmd.Parameters.AddWithValue("@cantidad", Convert.ToString(row.Cells["columnaCantidad"].Value)); conexion.cmd.Parameters.AddWithValue("@motivo", Convert.ToString(row.Cells["columnaMotivo"].Value)); conexion.AbrirConexion(); conexion.cmd.ExecuteNonQuery(); conexion.CerrarConexion(); } DialogResult result = MessageBox.Show("Se ingresara devulta al inventario?", "Inventario", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (result == DialogResult.Yes) { conexion.cmd = new SqlCommand("UPDATE Productos set existencia = existencia + @cantidad where cod_producto = @codProd", conexion.sc); foreach (DataGridViewRow row in dgv_ProdDev.Rows) { conexion.cmd.Parameters.Clear(); conexion.cmd.Parameters.AddWithValue("@codProd", Convert.ToString(row.Cells["columnaCodigo"].Value)); conexion.cmd.Parameters.AddWithValue("@cantidad", Convert.ToString(row.Cells["columnaCantidad"].Value)); conexion.AbrirConexion(); conexion.cmd.ExecuteNonQuery(); conexion.CerrarConexion(); } } this.Hide(); FormVentas ven = new FormVentas(); ven.ShowDialog(); this.Close(); } else { MessageBox.Show("No se pudo confirmar. Llame a su supervisor.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Warning); this.Hide(); FormDevoluciones dev = new FormDevoluciones(); dev.ShowDialog(); this.Close(); } } }