internal static int Agregar(MySqlConnection con, DAOProveedores proveedor) { int retorno = 0; MySqlCommand comando = new MySqlCommand(string.Format("INSERT INTO proveedores (id_proveedor,nombre,rfc,telefono,estatus) values ('{0}','{1}','{2}','{3}','{4}')", proveedor.id, proveedor.nombre, proveedor.rfc, proveedor.telefono, proveedor.estatus), con); retorno = comando.ExecuteNonQuery(); return(retorno); }
public static int Agregar(MySqlConnection con, DAOProductos Productos, DAOProveedores nombre_proveedor) { int retorno = 0; MySqlCommand comando = new MySqlCommand(string.Format("INSERT INTO productos (id_producto,nombre,precio_compra,precio_venta,id_proveedor,cantidad,stock_minimo,stock_maximo) values ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}')", Productos.id, Productos.nombre, Productos.precio_compra, Productos.precio_venta, nombre_proveedor.id, Productos.cantidad, Productos.stock_minimo, Productos.stock_maximo), con); retorno = comando.ExecuteNonQuery(); return(retorno); }
internal static int Modificar(MySqlConnection con, DAOProveedores proveedor) { int retorno = 0; MySqlCommand comando = new MySqlCommand(string.Format("UPDATE proveedores SET nombre='{0}',rfc='{1}',telefono='{2}',estatus='{3}' where id_proveedor='{4}' ", proveedor.nombre, proveedor.rfc, proveedor.telefono, proveedor.estatus, proveedor.id), con); retorno = comando.ExecuteNonQuery(); return(retorno); }
internal static int Modificar(MySqlConnection con, DAOProductos Productos, DAOProveedores nombre_proveedor) { int retorno = 0; MySqlCommand comando = new MySqlCommand(string.Format("UPDATE productos SET nombre='{0}',precio_compra='{1}',precio_venta='{2}',estatus='{3}',id_proveedor='{4}',cantidad='{5}',stock_minimo='{6}',stock_maximo='{7}' where id_producto='{8}' ", Productos.nombre, Productos.precio_compra, Productos.precio_venta, Productos.estatus, nombre_proveedor.id, Productos.cantidad, Productos.stock_minimo, Productos.stock_maximo, Productos.id), con); retorno = comando.ExecuteNonQuery(); return(retorno); }
private void btn_AgregarProducto_Click(object sender, EventArgs e) { { if (MessageBox.Show("Seguro que desea Agregar?", "Confirmación Agregar", MessageBoxButtons.YesNo) == DialogResult.Yes) { try { if (con.Abrirconexion() == true) { DAOProductos Producto = new DAOProductos(); Producto.nombre = txt_nombre.Text; nombre_proveedor.nombre = cb_proveedor.Text; DAOProveedores.Buscarid(con.con, nombre_proveedor); Producto.precio_compra = float.Parse(txt_precio_compra.Text); Producto.precio_venta = float.Parse(txt_precio_venta.Text); Producto.stock_minimo = int.Parse(txt_stock_minimo.Text); Producto.stock_maximo = int.Parse(txt_stock_maximo.Text); Producto.cantidad = int.Parse(txt_cantidad.Text); int resultado = DAOProductos.Agregar(con.con, Producto, nombre_proveedor); if (resultado > 0) { txt_nombre.Clear(); txt_precio_compra.Clear(); txt_precio_venta.Clear(); txt_stock_maximo.Clear(); txt_stock_minimo.Clear(); txt_cantidad.Clear(); } } } catch (MySql.Data.MySqlClient.MySqlException ex) { MessageBox.Show(ex.Message); } this.Close(); Catalogos.formulario.Productos.Show(); Catalogos.formulario.Productos.ListarProductos(con.con, ""); Catalogos.formulario.AgregarProducto = null; // Catalogos.formulario.Productos.Show(); //Catalogos.formulario.Productos.ListarProductos(con.con, ""); con.Cerrarconexion(); } } }
public static int Buscarid(MySqlConnection con, DAOProveedores nombre) { MySqlCommand comando = new MySqlCommand(string.Format("select id_proveedor from proveedores where nombre ='{0}';", nombre.nombre), con); MySqlDataReader reader = comando.ExecuteReader(); while (reader.Read()) { nombre.id = reader.GetInt32(0); } reader.Close(); return(nombre.id); }
private void btn_comprar_Click(object sender, EventArgs e) { if (precio_comp.id != int.Parse(dgvComprar.CurrentRow.Cells[0].Value.ToString())) { MessageBox.Show("Calcule el total del nuevo producto"); } else if (txt_Cantidad.Text == "0" || txt_Cantidad.Text == "") { MessageBox.Show("Ingrese una cantidad valida.."); } else { if (MessageBox.Show("Seguro que desea Agregar?", "Confirmación Agregar", MessageBoxButtons.YesNo) == DialogResult.Yes) { try { if (con.Abrirconexion() == true) { DAOComprar Comprar = new DAOComprar(); Comprar.proveedor = dgvComprar.CurrentRow.Cells[5].Value.ToString(); Comprar.producto = dgvComprar.CurrentRow.Cells[1].Value.ToString(); Comprar.cantidad = int.Parse(txt_Cantidad.Text); DateTime localDate = DateTime.Now; Comprar.fecha_compra = localDate.ToString(); Comprar.total = total; int resultado = DAOComprar.Agregar(con.con, Comprar); if (resultado > 0) { txt_Cantidad.Clear(); lbl_total.Text = "______"; MessageBox.Show("Compra Almacenada!"); txt_Cantidad.Text = "1"; } } } catch (MySql.Data.MySqlClient.MySqlException ex) { MessageBox.Show(ex.Message); } con.Cerrarconexion(); } } }
private void btn_AgregarProveedor_Click(object sender, EventArgs e) { if (MessageBox.Show("Seguro que desea Modificar?", "Confirmación Modificar", MessageBoxButtons.YesNo) == DialogResult.Yes) { try { if (con.Abrirconexion() == true) { DAOProveedores Proveedor = new DAOProveedores(); Proveedor.nombre = txt_nombre.Text; Proveedor.rfc = txt_rfc.Text; Proveedor.telefono = txt_telefono.Text; Proveedor.estatus = cb_estatus.Text; Proveedor.id = Convert.ToInt32(id); int resultado = DAOProveedores.Modificar(con.con, Proveedor); if (resultado > 0) { cb_estatus.Text = ""; txt_telefono.Clear(); txt_nombre.Clear(); txt_rfc.Clear(); } } } catch (MySql.Data.MySqlClient.MySqlException ex) { MessageBox.Show(ex.Message); } this.Close(); Catalogos.formulario.Proveedores.Show(); Catalogos.formulario.Proveedores.ListarProveedores(con.con, ""); Catalogos.formulario.ModificarProveedor = null; con.Cerrarconexion(); } }
public static IList <DAOProveedores> Buscar(MySqlConnection con, string Nombre) { List <DAOProveedores> lista = new List <DAOProveedores>(); MySqlCommand comando = new MySqlCommand(string.Format("SELECT id_proveedor,nombre,rfc,telefono,estatus from proveedores where nombre LIKE ('%{0}%')", Nombre), con); MySqlDataReader reader = comando.ExecuteReader(); while (reader.Read()) { DAOProveedores Proveedor = new DAOProveedores(); Proveedor.id = reader.GetInt32(0); Proveedor.nombre = reader.GetString(1); Proveedor.rfc = reader.GetString(2); Proveedor.telefono = reader.GetString(3); Proveedor.estatus = reader.GetString(4); lista.Add(Proveedor); } return(lista); }
public void ListarProveedores(MySqlConnection con, string Nombre) { dgvProveedores.DataSource = DAOProveedores.Buscar(con, Nombre); dgvProveedores.AutoResizeColumns(); }