private Int32 EjecutartransaccionEliminarProductos(conexiones_BD.clases.sucursales_productos sp, conexiones_BD.clases.productos p) { Int32 numeroFilas = 1; MySqlTransaction trans = null; if (base.conectar()) { try { trans = base.Conec.BeginTransaction(); MySqlCommand comando = new MySqlCommand(); comando.Connection = base.Conec; comando.Transaction = trans; comando.CommandText = sp.sentenciaElim().ToString(); comando.ExecuteNonQuery(); Console.WriteLine(sp.sentenciaElim().ToString()); comando.CommandText = p.sentenciaElim().ToString(); comando.ExecuteNonQuery(); Console.WriteLine(p.sentenciaElim().ToString()); trans.Commit(); } catch (MySqlException e) { Console.WriteLine(e.Message); trans.Rollback(); numeroFilas = -1; } } return(numeroFilas); }
public conexiones_BD.clases.sucursales_productos sucp(string id_borrar) { conexiones_BD.clases.sucursales_productos sp = null; doc.Load(rutaXml); XmlNodeList prese_pro = doc.SelectNodes("productos/sucursal_producto"); XmlNode pre_p; foreach (XmlNode item in prese_pro) { if (item.SelectSingleNode("codigo_productos").InnerText == id_borrar) { pre_p = item; sp = new conexiones_BD.clases.sucursales_productos( pre_p.SelectSingleNode("idsucursal").InnerText, pre_p.SelectSingleNode("idproducto").InnerText, pre_p.SelectSingleNode("idutilidadM").InnerText, pre_p.SelectSingleNode("idutilidadD").InnerText, pre_p.SelectSingleNode("idestante").InnerText, pre_p.SelectSingleNode("existencias").InnerText, pre_p.SelectSingleNode("precio_ventaD").InnerText, pre_p.SelectSingleNode("precio_compraD").InnerText, pre_p.SelectSingleNode("precio_ventaM").InnerText, pre_p.SelectSingleNode("precio_compraM").InnerText, pre_p.SelectSingleNode("k").InnerText, "1" ); } } return(sp); }
private void btnGuardar_Click(object sender, EventArgs e) { utilitarios.maneja_fechas fe = new utilitarios.maneja_fechas(); if (!validar()) { pro = new conexiones_BD.clases.productos( txtCodigo.Text, txtnombreP.Text.ToUpper(), fe.fechaMysql(fecha), "60", "53"); sp = new conexiones_BD.clases.sucursales_productos( sesion.DatosRegistro[1], "0", "2", "4", "1", "1000", precio.Value.ToString(), "0.0", "0.0", "0.0", "1"); op = new conexiones_BD.operaciones(); if (op.transaccionProductos_Presentaciones_Proveedores(generaProveedores(), generaPresentaciones(), pro, sp) > 0) { MessageBox.Show("El producto se ingreso", "Exíto", MessageBoxButtons.OK, MessageBoxIcon.Information); ingresado = true; xm._AñadirProductos(txtCodigo.Text, txtnombreP.Text.ToUpper(), fe.fechaMysql(fecha), "60", "53", Convert.ToInt16(sesion.DatosRegistro[0])); xm._AñadirSucursal_productos(sesion.DatosRegistro[1], "0", "2", "4", "1", "1000", precio.Value.ToString(), "0.0", "0.0", "0.0", "1", txtCodigo.Text, Convert.ToInt16(sesion.DatosRegistro[0])); xm._AñadirProvedores_productos("2", "0", txtCodigo.Text, Convert.ToInt16(sesion.DatosRegistro[0])); xm._AñadirPrese_prod("0", "1", "1", precio.Value.ToString(), "2", "2", txtCodigo.Text, Convert.ToInt16(sesion.DatosRegistro[0])); this.Close(); } else { MessageBox.Show("El producto no se pudo ingresar", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void modifica() { utilitarios.maneja_fechas fe = new utilitarios.maneja_fechas(); string kar = "2"; if (!validar()) { if (!validarExistencias()) { if (chkKardex.Checked) { kar = "1"; } sp = new conexiones_BD.clases.sucursales_productos( this.idsucusal_producto, listaSucursal.SelectedValue.ToString(), this.idproducto, listaMayoreo.SelectedValue.ToString(), listaUtilidadDetalle.SelectedValue.ToString(), listaEstante.SelectedValue.ToString(), existencias.Value.ToString(), precioVD.Value.ToString(), precioCD.Value.ToString(), precioVM.Value.ToString(), precioCM.Value.ToString(), kar); pro = new conexiones_BD.clases.productos( txtCodigo.Text, txtnombreP.Text.ToUpper(), fe.fechaMysql(fecha), listaCategoria.SelectedValue.ToString(), listaMarca.SelectedValue.ToString(), this.idproducto); op = new conexiones_BD.operaciones(); if (op.EjecutartransaccionModificarProducto(sp, pro) > 0) { cargarTablas(); MessageBox.Show("Se actualizo con exíto", "Exíto", MessageBoxButtons.OK, MessageBoxIcon.Information); vaciar(); habilitar(false); } } } }
private void elimina() { try { sp = new conexiones_BD.clases.sucursales_productos(idsucusal_producto); pro = new conexiones_BD.clases.productos(idproducto); op = new conexiones_BD.operaciones(); if (op.EjecutartransaccionEliminarProducto(sp, pro) > 0) { cargarTablas(); MessageBox.Show("El producto se elimino con exíto", "Exíto", MessageBoxButtons.OK, MessageBoxIcon.Information); vaciar(); habilitar(false); } else { MessageBox.Show("No se puede eliminar es posible que tenga dependencias", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch { } }
private void guarda() { utilitarios.maneja_fechas fe = new utilitarios.maneja_fechas(); string kar = "2"; if (!validar()) { if (!validarExistencias()) { pro = new conexiones_BD.clases.productos( txtCodigo.Text, txtnombreP.Text.ToUpper(), fe.fechaMysql(fecha), listaCategoria.SelectedValue.ToString(), listaMarca.SelectedValue.ToString()); if (chkKardex.Checked) { kar = "1"; } sp = new conexiones_BD.clases.sucursales_productos( listaSucursal.SelectedValue.ToString(), "0", listaMayoreo.SelectedValue.ToString(), listaUtilidadDetalle.SelectedValue.ToString(), listaEstante.SelectedValue.ToString(), existencias.Value.ToString(), precioVD.Value.ToString(), precioCD.Value.ToString(), precioVM.Value.ToString(), precioCM.Value.ToString(), kar); op = new conexiones_BD.operaciones(); if (op.transaccionProductos_Presentaciones_Proveedores(generaProveedores(), generaPresentaciones(), pro, sp) > 0) { MessageBox.Show("Los productos se ingresarón", "Exíto", MessageBoxButtons.OK, MessageBoxIcon.Information); xm._AñadirProductos(txtCodigo.Text, txtnombreP.Text.ToUpper(), fe.fechaMysql(fecha), listaCategoria.SelectedValue.ToString(), listaMarca.SelectedValue.ToString(), Convert.ToInt16(sesion.DatosRegistro[0])); xm._AñadirSucursal_productos( listaSucursal.SelectedValue.ToString(), "0", listaMayoreo.SelectedValue.ToString(), listaUtilidadDetalle.SelectedValue.ToString(), listaEstante.SelectedValue.ToString(), existencias.Value.ToString(), precioVD.Value.ToString(), precioCD.Value.ToString(), precioVM.Value.ToString(), precioCM.Value.ToString(), kar, txtCodigo.Text, Convert.ToInt16(sesion.DatosRegistro[0])); this.generarProveedoresBase_datos(); this.generaPresentancionesBase(); vaciar(); } else { MessageBox.Show("Los productos no se pudierón ingresar", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
public Int32 EjecutartransaccionModificarProducto(conexiones_BD.clases.sucursales_productos sp, conexiones_BD.clases.productos p) { return(EjecutartransaccionModificarProductos(sp, p)); }