/// <summary> /// /// </summary> /// <param name="FechaI"></param> /// <param name="FechaF"></param> /// <returns></returns> public List <ReporteVentaPeriodo> getReporteVentasPeriodo(String FechaI, String FechaF) { ConexionMySQL con = null; try { List <ReporteVentaPeriodo> lista = new List <ReporteVentaPeriodo>(); con = new ConexionMySQL(); DataSet dat = con.LLenaComboGrid("call Reporte_Ventas_Periodo('" + FechaI + "','" + FechaF + "')" + ";"); DataTable dt = dat.Tables[0]; ReporteVentaPeriodo datos; foreach (DataRow r in dt.Rows) { datos = new ReporteVentaPeriodo(); datos.idCompra = (Int32)r.ItemArray[0]; datos.Fecha = (DateTime)r.ItemArray[1]; datos.Cantidad_Venta = (Decimal)r.ItemArray[2]; datos.NombreUsuario = (String)r.ItemArray[3]; lista.Add(datos); } return(lista); } catch (Exception ex) { throw new Exception("No se pudo traer el reporte"); } }
public bool Update(Suppliers proveedor) { bool result = false; MySqlConnection conexion = null; try { string sql = string.Format( "UPDATE Suppliers SET CompanyName ='{0}',ContactName ='{1}',ContactTitle ='{2}',Address ='{3}',City ='{4}',PostalCode ='{5}',Country ='{6}',Phone ='{7}' WHERE SupplierID = {8}", proveedor.CompanyName, proveedor.ContactName, proveedor.ContactTitle, proveedor.Address, proveedor.City, proveedor.PostalCode, proveedor.Country, proveedor.Phone, proveedor.SupplierID); conexion = ConexionMySQL.ObtenerConexion(); MySqlCommand cmd = new MySqlCommand(sql, conexion); int resultquery = cmd.ExecuteNonQuery(); if (resultquery == 1) { result = true; } } catch { throw; } finally { if (conexion != null) { conexion.Close(); } } return(result); }
public List <ReporteCliente> getReporteCliente(int anio, int mes) { ConexionMySQL con = null; try { List <ReporteCliente> lista = new List <ReporteCliente>(); con = new ConexionMySQL(); DataSet dat = con.LLenaComboGrid("call Reporte_Compras_Cliente('" + anio + "','" + mes + "')" + ";"); DataTable dt = dat.Tables[0]; ReporteCliente datos; foreach (DataRow r in dt.Rows) { datos = new ReporteCliente(); datos.idUsuario = (String)r.ItemArray[0]; datos.NombreUsuario = (String)r.ItemArray[1]; datos.Cantidad_Compras = (Int64)r.ItemArray[2]; datos.Cantidad_Total = (Decimal)r.ItemArray[3]; lista.Add(datos); } return(lista); } catch (Exception ex) { throw new Exception("No se pudo traer el reporte"); } }
/// <summary> /// Obtenemos una lista de todos los Productos en caso de requerirla /// </summary> /// <returns></returns> public List <Producto> getAll() { try { List <Producto> lista = new List <Producto>(); ConexionMySQL con = new ConexionMySQL(); DataSet dat = con.LLenaComboGrid("SELECT * FROM Producto" + ";"); DataTable dt = dat.Tables[0]; Producto datos; foreach (DataRow r in dt.Rows) { datos = new Producto(); datos.IdProducto = (int)r.ItemArray[0]; datos.Nombre = (String)r.ItemArray[1]; datos.Precio = (Decimal)r.ItemArray[2]; datos.Descripcion = (String)r.ItemArray[3]; datos.Categoria = (String)r.ItemArray[4]; lista.Add(datos); } return(lista); } catch (Exception ex) { throw new Exception("Error al obtener datos del Producto"); } }
public List <ProductsCategorySupplier> RetrieveAll() { List <ProductsCategorySupplier> productos = new List <ProductsCategorySupplier>(); try { string sql = "SELECT P.ProductID, P.ProductName, P.QuantityPerUnit, P.UnitPrice, P.CategoryID, P.SupplierID, P.UnitsInStock, P.UnitsOnOrder, P.ReorderLevel, P.Discontinued, C.CategoryName, S.CompanyName FROM Products as P"; sql += " INNER JOIN Categories as C ON P.CategoryID = C.CategoryID INNER JOIN Suppliers as S ON P.SupplierID = S.SupplierID "; MySqlConnection conexion = ConexionMySQL.ObtenerConexion(); MySqlCommand cmd = new MySqlCommand(sql, conexion); MySqlDataReader rd = cmd.ExecuteReader(); while (rd.Read()) { ProductsCategorySupplier producto = new ProductsCategorySupplier() { ProductID = rd.GetInt32(0), ProductName = rd.GetString(1), QuantityPerUnit = rd.GetString(2), UnitPrice = rd.GetDecimal(3), CategoryID = rd.GetInt32(4), SupplierID = rd.GetInt32(5), UnitsInStock = rd.GetInt16(6), UnitsOnOrder = rd.GetInt16(7), ReorderLevel = rd.GetInt16(8), Discontinued = rd.GetBoolean(9), CategoryName = rd.GetString(10), CompanyName = rd.GetString(11) }; productos.Add(producto); } conexion.Close(); return(productos); } catch { throw; } }
public List <Suppliers> RetrieveAll() { List <Suppliers> proveedores = new List <Suppliers>(); try { string sql = "SELECT SupplierID,CompanyName,ContactName,ContactTitle,Address,City,PostalCode,Country,Phone FROM Suppliers"; MySqlConnection conexion = ConexionMySQL.ObtenerConexion(); MySqlCommand cmd = new MySqlCommand(sql, conexion); MySqlDataReader rd = cmd.ExecuteReader(); while (rd.Read()) { Suppliers proveedor = new Suppliers() { SupplierID = rd.GetInt32(0), CompanyName = rd.GetString(1), ContactName = rd.GetString(2), ContactTitle = rd.GetString(3), Address = rd.GetString(4), City = rd.GetString(5), //Region = rd.GetString(6), PostalCode = rd.GetString(6), Country = rd.GetString(7), Phone = rd.GetString(8) //Fax = rd.GetString(9) }; proveedores.Add(proveedor); } conexion.Close(); return(proveedores); } catch { throw; } }
/// <summary> /// Obtenemos una lista de todos los Productos en caso de requerirla /// </summary> /// <returns></returns> public List <Compra> getAll() { try { List <Compra> lista = new List <Compra>(); ConexionMySQL con = new ConexionMySQL(); DataSet dat = con.LLenaComboGrid("SELECT * FROM Compra" + ";"); DataTable dt = dat.Tables[0]; Compra datos; foreach (DataRow r in dt.Rows) { datos = new Compra(); datos.idCompra = (int)r.ItemArray[0]; datos.idUsuario = (int)r.ItemArray[1]; datos.Descripcion = (String)r.ItemArray[2]; lista.Add(datos); } return(lista); } catch (Exception ex) { throw new Exception("Error al obtener datos de las compras"); } }
/// <summary> /// Obtenemos una lista de todas las Notas en caso de requerirla /// </summary> /// <returns></returns> public List <Nota> getAll(int id) { try { List <Nota> lista = new List <Nota>(); ConexionMySQL con = new ConexionMySQL(); DataSet dat = con.LLenaComboGrid("SELECT * FROM Nota where Idusuario=" + id + ";"); DataTable dt = dat.Tables[0]; Nota datos; foreach (DataRow r in dt.Rows) { datos = new Nota(); datos.IdNota = (int)r.ItemArray[0]; datos.Descripcion = (String)r.ItemArray[1]; lista.Add(datos); } return(lista); } catch (Exception ex) { throw new Exception("Error al obtener datos del Nota"); } }
public bool Update(Categories categoria) { bool result = false; MySqlConnection conexion = null; try { string sql = string.Format( "UPDATE Categories SET CategoryName ='{0}',Description ='{1}' WHERE categoryid={2}", categoria.CategoryName, categoria.Description, categoria.CategoryID); conexion = ConexionMySQL.ObtenerConexion(); MySqlCommand cmd = new MySqlCommand(sql, conexion); int resultquery = cmd.ExecuteNonQuery(); if (resultquery == 1) { result = true; } } catch { throw; } finally { if (conexion != null) { conexion.Close(); } } return(result); }
public List <Categories> RetrieveAll() { List <Categories> categorias = new List <Categories>(); try { string sql = "SELECT CategoryID,CategoryName,Description FROM Categories"; MySqlConnection conexion = ConexionMySQL.ObtenerConexion(); MySqlCommand cmd = new MySqlCommand(sql, conexion); MySqlDataReader rd = cmd.ExecuteReader(); while (rd.Read()) { Categories categoria = new Categories() { CategoryID = rd.GetInt32(0), CategoryName = rd.GetString(1), Description = rd.GetString(2) }; categorias.Add(categoria); } conexion.Close(); return(categorias); } catch { throw; } }
public bool Update(Products producto) { bool result = false; MySqlConnection conexion = null; try { string sql = string.Format( "UPDATE Products SET ProductName ='{0}', SupplierID ='{1}', CategoryID ='{2}', QuantityPerUnit ='{3}', UnitPrice ='{4}', UnitsInStock ='{5}', UnitsOnOrder ='{6}', ReorderLevel ='{7}', Discontinued ='{8}' WHERE productid={9}", producto.ProductName, producto.SupplierID, producto.CategoryID, producto.QuantityPerUnit, producto.UnitPrice, producto.UnitsInStock, producto.UnitsOnOrder, producto.ReorderLevel, producto.Discontinued, producto.ProductID); conexion = ConexionMySQL.ObtenerConexion(); MySqlCommand cmd = new MySqlCommand(sql, conexion); int resultquery = cmd.ExecuteNonQuery(); if (resultquery == 1) { result = true; } } catch { throw; } finally { if (conexion != null) { conexion.Close(); } } return(result); }
/// <summary> /// Obtendremos un carrito en base al usuario actual para traer todos los productos que ha escogido /// </summary> /// <param name="id"></param> /// <returns></returns> public List <Carritos> getOne(int id) { ConexionMySQL con = null; try { List <Carritos> lista = new List <Carritos>(); con = new ConexionMySQL(); DataSet dat = con.LLenaComboGrid("select c.idUsuario,dp.idproducto,c.NombreProd,c.FechaCompra,dp.precio," + "dp.cantidad, dp.precio*Cantidad as total " + "from carrito c join detalleproducto dp on c.idcarrito=dp.idcarrito" + " where idusuario=" + id + " group by idproducto;"); DataTable dt = dat.Tables[0]; Carritos datos; foreach (DataRow r in dt.Rows) { datos = new Carritos(); datos.idUsuario = (int)r.ItemArray[0]; datos.idProducto = (int)r.ItemArray[1]; datos.NombreProducto = (String)r.ItemArray[2]; datos.FechaCompra = (DateTime)r.ItemArray[3]; datos.Precio = (decimal)r.ItemArray[4]; datos.cantidad = (int)r.ItemArray[5]; datos.Total = (decimal)r.ItemArray[6]; lista.Add(datos); } return(lista); } catch (Exception ex) { throw new Exception("No se pudo traer el carrito"); } }
public bool Delete(int ProductID) { bool result = false; MySqlConnection conexion = null; try { string sql = string.Format( "DELETE FROM Products WHERE ProductID={0}", ProductID); conexion = ConexionMySQL.ObtenerConexion(); MySqlCommand cmd = new MySqlCommand(sql, conexion); int resultquery = cmd.ExecuteNonQuery(); if (resultquery == 1) { result = true; } } catch { throw; } finally { if (conexion != null) { conexion.Close(); } } return(result); }
/// <summary> /// Usaremos el metodo de eliminar para poder quitar elementos de nuestro carrito /// </summary> /// <param name="id"></param> /// <returns></returns> public bool delete(int id) { ConexionMySQL conexion = new ConexionMySQL(); try { String SQL = "DELETE FROM carrito WHERE" + " idCarrito= '" + id + "';"; MySqlCommand sqlcom = new MySqlCommand(); sqlcom.CommandText = SQL; conexion.EjecutaSQLComando(sqlcom); return(true); } catch (Exception) { return(false); } }
/// <summary> /// se utilizara este metodo para eliminar todo lo que se encuentra en el carrito para la proxima compra /// </summary> /// <param name="id"></param> /// <returns></returns> public bool deleteAll(int id) { ConexionMySQL conexion = new ConexionMySQL(); try { String SQL = "DELETE FROM carrito WHERE" + " idusuario= " + id + ";"; MySqlCommand sqlcom = new MySqlCommand(); sqlcom.CommandText = SQL; conexion.EjecutaSQLComando(sqlcom); return(true); } catch (Exception) { throw new Exception("Error al eliminar carrito"); } }
/// <summary> /// Usaremos el metodo de eliminar para poder quitar elementos de nuestro carrito /// </summary> /// <param name="id"></param> /// <returns></returns> public bool delete() { ConexionMySQL conexion = new ConexionMySQL(); try { String SQL = "DELETE FROM detalleproducto;"; MySqlCommand sqlcom = new MySqlCommand(); sqlcom.CommandText = SQL; conexion.EjecutaSQLComando(sqlcom); return(true); } catch (Exception) { return(false); } }
/// <summary> /// Metodo utilizado para eliminar un producto de la lista /// </summary> /// <param name="id"></param> /// <returns></returns> public bool delete(int id) { ConexionMySQL conexion = new ConexionMySQL(); try { String SQL = "DELETE FROM Producto WHERE" + " idProducto= '" + id + "';"; MySqlCommand sqlcom = new MySqlCommand(); sqlcom.CommandText = SQL; conexion.EjecutaSQLComando(sqlcom); return(true); } catch (Exception) { throw new Exception("No se pudo eliminar el Producto"); } }
public wfrAlerta(Acuses[] Resoluciones) { InitializeComponent(); CargarEncabezados(); if (Resoluciones.Length > 0) { string strSQL; dgAlerta.Rows.Clear(); dgAlerta.Rows.Add(Resoluciones.Length); CConexionMySQL = new ConexionMySQL(); CargarValores(); Acuerdos.CConexionMySQL.ConnectionString = "Server=" + Acuerdos.strServidor + ";Database=" + Acuerdos.strCentro + ";Uid=" + Acuerdos.strUid + ";Pwd=" + Acuerdos.strPwd + ";Connection Timeout=6000;port=" + Acuerdos.strPuerto + ";"; CConexionMySQL.Conectar(); int i = 0; foreach (DataGridViewRow row in dgAlerta.Rows) { if (i < Resoluciones.Length) { string resultado = ""; resultado = Acuerdos.InsertarResoluciones(Resoluciones[i].Expediente, Resoluciones[i].IdentificadorNotificacion.ToString(), Resoluciones[i].Resolucion); // strSQL = "insert into resoluciones_rp(resorp_numero_expe,resorp_id_Noti,resorp_uri,resorp_fecha) values " + //"('" + Resoluciones[i].Expediente + "','" + Resoluciones[i].IdentificadorNotificacion + "','" + Resoluciones[i].Resolucion + "','" + DateTime.Now.ToString("yyyy/MM/dd") + "')"; // CConexionMySQL.EjecutaComando(strSQL); row.Cells["Id"].Value = Resoluciones[i].IdentificadorNotificacion; row.Cells["Expediente"].Value = Resoluciones[i].Expediente; row.Cells["Uri"].Value = Resoluciones[i].Resolucion; i++; } } // CConexionMySQL.Desconectar(); } else { MessageBox.Show("No se encontraron Resoluciones del RPP", "Mensaje del sistema", MessageBoxButtons.OK, MessageBoxIcon.Information); Application.Exit(); } }
public bool Create(Products producto) { bool result = false; try { string sql = string.Format("INSERT INTO Products (ProductName, SupplierID, CategoryID, QuantityPerUnit, UnitPrice, UnitsInStock, UnitsOnOrder, ReorderLevel, Discontinued) VALUES ('{0}','{1}','{2}','{3}', '{4}','{5}','{6}','{7}','{8}')", producto.ProductName, producto.SupplierID, producto.CategoryID, producto.QuantityPerUnit, producto.UnitPrice, producto.UnitsInStock, producto.UnitsOnOrder, producto.ReorderLevel, producto.Discontinued); MySqlConnection conexion = ConexionMySQL.ObtenerConexion(); MySqlCommand cmd = new MySqlCommand(sql, conexion); int resultquery = cmd.ExecuteNonQuery(); if (resultquery == 1) { result = true; } } catch { throw; } return(result); }
public bool Create(Categories categoria) { bool result = false; try { string sql = string.Format("INSERT INTO Categories (CategoryName,Description) VALUES ('{0}','{1}')", categoria.CategoryName, categoria.Description); MySqlConnection conexion = ConexionMySQL.ObtenerConexion(); MySqlCommand cmd = new MySqlCommand(sql, conexion); int resultquery = cmd.ExecuteNonQuery(); if (resultquery == 1) { result = true; } } catch { throw; } return(result); }
public bool Create(Suppliers proveedor) { bool result = false; try { string sql = string.Format("INSERT INTO Suppliers (CompanyName,ContactName,ContactTitle,Address,City,PostalCode,Country,Phone) VALUES ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}')", proveedor.CompanyName, proveedor.ContactName, proveedor.ContactTitle, proveedor.Address, proveedor.City, proveedor.PostalCode, proveedor.Country, proveedor.Phone); MySqlConnection conexion = ConexionMySQL.ObtenerConexion(); MySqlCommand cmd = new MySqlCommand(sql, conexion); int resultquery = cmd.ExecuteNonQuery(); if (resultquery == 1) { result = true; } } catch { throw; } return(result); }