public static List <Pro_Venta> Cargar_Lista() { Pro_Venta pProducto = new Pro_Venta(); List <Pro_Venta> Lista = new List <Pro_Venta>(); DataTable retorno = new DataTable(); using (MySqlConnection conexion = Conexion.MiConexion()) { MySqlCommand comando = new MySqlCommand(string.Format( "Select * from Venta_Proceso"), conexion); MySqlDataReader reader = comando.ExecuteReader(); while (reader.Read()) { pProducto.Codigo = reader.GetInt64(0); pProducto.Nombre = reader.GetString(1); pProducto.Descripcion = reader.GetString(2); pProducto.TipoUnidad = reader.GetString(3); pProducto.Precio = reader.GetDouble(4); pProducto.Cantidad = reader.GetDouble(5); pProducto.PrecioUnitario = reader.GetDouble(6); Lista.Add(pProducto); } conexion.Close(); return(Lista); } }
public static List <Pro_Productos> CargarProductos() { List <Pro_Productos> ListaProductos = new List <Pro_Productos>(); using (MySqlConnection conexion = Conexion.MiConexion()) { string Consulta = "SELECT * FROM Productos"; MySqlCommand Comando = new MySqlCommand(Consulta, conexion); MySqlDataReader reader = Comando.ExecuteReader(); while (reader.Read()) { Pro_Productos pProducto = new Pro_Productos(); pProducto.Codigo = Convert.ToInt64(reader[0].ToString()); pProducto.Nombre = reader[1].ToString(); pProducto.Descripcion = reader[2].ToString(); pProducto.Precio = Convert.ToDouble(reader[3].ToString()); pProducto.Stock = Convert.ToDouble(reader[4].ToString()); pProducto.TipoUnidad = reader[5].ToString(); ListaProductos.Add(pProducto); } } return(ListaProductos); }
public static List <Pro_Proveedores> CargarProveedores() { List <Pro_Proveedores> ListaProveedores = new List <Pro_Proveedores>(); using (MySqlConnection conexion = Conexion.MiConexion()) { string Consulta = "SELECT * FROM Proveedores"; MySqlCommand Comando = new MySqlCommand(Consulta, conexion); MySqlDataReader reader = Comando.ExecuteReader(); while (reader.Read()) { Pro_Proveedores pProveedor = new Pro_Proveedores(); pProveedor.Id_Proveedor = Convert.ToInt32(reader[0].ToString()); pProveedor.Nombre = reader[1].ToString(); pProveedor.Apellido = reader[2].ToString(); pProveedor.Razon_Social = reader[3].ToString(); pProveedor.Direccion = reader[4].ToString(); pProveedor.TelefonoOficina = reader[5].ToString(); pProveedor.Celular = reader[6].ToString(); pProveedor.Email = reader[7].ToString(); ListaProveedores.Add(pProveedor); } } return(ListaProveedores); }
public static List <Pro_Usuarios> BuscarUsuarios_Nombre(String pNombre) { List <Pro_Usuarios> ListaUsuarios = new List <Pro_Usuarios>(); using (MySqlConnection conexion = Conexion.MiConexion()) { MySqlCommand comando = new MySqlCommand(string.Format( "Select Nombre, Apellido, Direccion, Usuario, Contrasena, Tipo from Usuarios where Nombre like '%{0}%'", pNombre), conexion); // "Select Codigo, Nombre, Descripcion, Precio from Clientes where Nombre={1}", pNombre), conexion); MySqlDataReader reader = comando.ExecuteReader(); while (reader.Read()) { Pro_Usuarios pUsuarios = new Pro_Usuarios(); pUsuarios.Nombre = reader[0].ToString(); pUsuarios.Apellido = reader[1].ToString(); pUsuarios.Direccion = reader[2].ToString(); pUsuarios.Usuario = reader[3].ToString(); pUsuarios.Contrasena = reader[4].ToString(); pUsuarios.Tipo = reader[5].ToString(); ListaUsuarios.Add(pUsuarios); } conexion.Close(); return(ListaUsuarios); } }
public static List <Pro_Proveedores> BuscarProveedores_Razon(String pRazon_Social) { List <Pro_Proveedores> Lista = new List <Pro_Proveedores>(); using (MySqlConnection conexion = Conexion.MiConexion()) { MySqlCommand comando = new MySqlCommand(string.Format( //"Select Codigo, Nombre, Descripcion, Precio from Clientes where Codigo like '%{0}%' or Nombre like '%{1}%'", pCodigo, pNombre), conexion); "Select Id_Proveedor, Nombre, Apellido, Razon_Social, Direccion, TelefonoOficina, Celular, Email from Proveedores where Razon_Social like '%{0}%'", pRazon_Social), conexion); MySqlDataReader reader = comando.ExecuteReader(); while (reader.Read()) { Pro_Proveedores pProveedor = new Pro_Proveedores(); pProveedor.Id_Proveedor = Convert.ToInt32(reader[0].ToString()); pProveedor.Nombre = reader[1].ToString(); pProveedor.Apellido = reader[2].ToString(); pProveedor.Razon_Social = reader[3].ToString(); pProveedor.Direccion = reader[4].ToString(); pProveedor.TelefonoOficina = reader[5].ToString(); pProveedor.Celular = reader[6].ToString(); pProveedor.Email = reader[7].ToString(); Lista.Add(pProveedor); } conexion.Close(); return(Lista); } }
public static List <Pro_Venta> BuscarProductos_Codigo_Venta(Int64 pCodigo) { Pro_Venta pProducto = new Pro_Venta(); //preciototal.Expression = "[Precio]*[Cantidad]"; List <Pro_Venta> Lista = new List <Pro_Venta>(); using (MySqlConnection conexion = Conexion.MiConexion()) { MySqlCommand comando = new MySqlCommand(string.Format( "Select Codigo, Nombre, Descripcion, TipoUnidad, Precio from Productos where Codigo={0}", pCodigo), conexion); MySqlDataReader reader = comando.ExecuteReader(); while (reader.Read()) { pProducto.Codigo = reader.GetInt64(0); pProducto.Nombre = reader.GetString(1); pProducto.Descripcion = reader.GetString(2); pProducto.TipoUnidad = reader.GetString(3); pProducto.Precio = reader.GetDouble(4); //pProducto.Cantidad = Convert.ToInt16(pCantidad); double preciototal = pProducto.Precio * pProducto.Cantidad; pProducto.PrecioTotal = Convert.ToDouble(preciototal); //pProducto.Cantidad = Convert.ToInt16(cantidad); Lista.Add(pProducto); } conexion.Close(); return(Lista); } }
public static List <Pro_Clientes> CargarClientes() { List <Pro_Clientes> ListaClientes = new List <Pro_Clientes>(); using (MySqlConnection conexion = Conexion.MiConexion()) { string Consulta = "SELECT * FROM Clientes"; MySqlCommand Comando = new MySqlCommand(Consulta, conexion); MySqlDataReader reader = Comando.ExecuteReader(); while (reader.Read()) { Pro_Clientes pCliente = new Pro_Clientes(); pCliente.Id_Cliente = Convert.ToInt32(reader[0].ToString()); pCliente.Nombre = reader[1].ToString(); pCliente.Apellido = reader[2].ToString(); pCliente.Direccion = reader[3].ToString(); pCliente.TelefonoCasa = reader[4].ToString(); pCliente.Celular = reader[5].ToString(); pCliente.Email = reader[6].ToString(); pCliente.Fecha_Nacimiento = reader[7].ToString(); ListaClientes.Add(pCliente); } } return(ListaClientes); }
public static List <Pro_Clientes> BuscarClientes_Email(String pEmail) { List <Pro_Clientes> Lista = new List <Pro_Clientes>(); using (MySqlConnection conexion = Conexion.MiConexion()) { MySqlCommand comando = new MySqlCommand(string.Format( //"Select Codigo, Nombre, Descripcion, Precio from Clientes where Codigo like '%{0}%' or Nombre like '%{1}%'", pCodigo, pNombre), conexion); "Select Id_Cliente, Nombre, Apellido, Direccion, TelefonoCasa, Celular, Email, FechaNacimiento from Clientes where Email like '%{0}%'", pEmail), conexion); MySqlDataReader reader = comando.ExecuteReader(); while (reader.Read()) { Pro_Clientes pCliente = new Pro_Clientes(); pCliente.Id_Cliente = Convert.ToInt32(reader[0].ToString()); pCliente.Nombre = reader[1].ToString(); pCliente.Apellido = reader[2].ToString(); pCliente.Direccion = reader[3].ToString(); pCliente.TelefonoCasa = reader[4].ToString(); pCliente.Celular = reader[5].ToString(); pCliente.Email = reader[6].ToString(); pCliente.Fecha_Nacimiento = reader[7].ToString(); Lista.Add(pCliente); } conexion.Close(); return(Lista); } }
public static List <Pro_Productos> BuscarProductos_Codigo(Int64 pCodigo) { List <Pro_Productos> Lista = new List <Pro_Productos>(); using (MySqlConnection conexion = Conexion.MiConexion()) { MySqlCommand comando = new MySqlCommand(string.Format( //"Select Codigo, Nombre, Descripcion, Precio from Productos where Codigo like '%{0}%' or Nombre like '%{1}%'", pCodigo, pNombre), conexion); "Select Codigo, Nombre, Descripcion, Precio, Stock, TipoUnidad from Productos where Codigo={0}", pCodigo), conexion); MySqlDataReader reader = comando.ExecuteReader(); while (reader.Read()) { Pro_Productos pProducto = new Pro_Productos(); pProducto.Codigo = reader.GetInt64(0); pProducto.Nombre = reader.GetString(1); pProducto.Descripcion = reader.GetString(2); pProducto.Precio = reader.GetDouble(3); pProducto.Stock = reader.GetInt16(4); pProducto.TipoUnidad = reader.GetString(5); Lista.Add(pProducto); } conexion.Close(); return(Lista); } }
public static int Eliminar(Int64 pCodigo) { int retorno = 0; using (MySqlConnection conexion = Conexion.MiConexion()) { MySqlCommand comando = new MySqlCommand(string.Format("Delete from Productos where Codigo={0}", pCodigo), conexion); retorno = comando.ExecuteNonQuery(); conexion.Close(); } return(retorno); }
public static int Eliminar(String pCliente) { int retorno = 0; using (MySqlConnection conexion = Conexion.MiConexion()) { MySqlCommand comando = new MySqlCommand(string.Format("Delete from Clientes where Email='{0}'", pCliente), conexion); retorno = comando.ExecuteNonQuery(); conexion.Close(); } return(retorno); }
public static int Borrar_Tabla_Venta_Proceso() { int retorno = 0; using (MySqlConnection conexion = Conexion.MiConexion()) { MySqlCommand comando = new MySqlCommand(string.Format("Delete From Venta_Proceso"), conexion); retorno = comando.ExecuteNonQuery(); conexion.Close(); } return(retorno); }
public static int AgregarVenta_Proceso(Pro_Venta pVenta) { int retorno = 0; using (MySqlConnection conexion = Conexion.MiConexion()) { MySqlCommand Comando = new MySqlCommand(string.Format("Insert Into Venta_Proceso (Codigo, Nombre, Descripcion, TipoUnidad, PrecioUnitario, Cantidad, Importe) values ('{0}','{1}','{2}','{3}','{4}','{5}','{6}')", pVenta.Codigo, pVenta.Nombre, pVenta.Descripcion, pVenta.TipoUnidad, pVenta.PrecioUnitario, pVenta.Cantidad, pVenta.Importe), conexion); retorno = Comando.ExecuteNonQuery(); conexion.Close(); } return(retorno); }
public static int Modificar(Pro_Clientes pCliente) { int retorno = 0; using (MySqlConnection conexion = Conexion.MiConexion()) { MySqlCommand comando = new MySqlCommand(string.Format("Update Clientes set Nombre='{0}', Apellido='{1}', Direccion='{2}', TelefonoCasa='{3}', Celular='{4}', Email='{5}' where Id_Cliente='{6}'", pCliente.Nombre, pCliente.Apellido, pCliente.Direccion, pCliente.TelefonoCasa, pCliente.Celular, pCliente.Email, pCliente.Id_Cliente), conexion); retorno = comando.ExecuteNonQuery(); conexion.Close(); } return(retorno); }
public static int Agregar(Pro_Clientes pCliente) { int retorno = 0; using (MySqlConnection conexion = Conexion.MiConexion()) { MySqlCommand Comando = new MySqlCommand(string.Format("Insert Into Clientes (Nombre, Apellido, Direccion, TelefonoCasa, Celular, Email, FechaNacimiento) values ('{0}','{1}','{2}','{3}','{4}','{5}','{6}')", pCliente.Nombre, pCliente.Apellido, pCliente.Direccion, pCliente.TelefonoCasa, pCliente.Celular, pCliente.Email, pCliente.Fecha_Nacimiento), conexion); retorno = Comando.ExecuteNonQuery(); conexion.Close(); } return(retorno); }
public static int Agregar(Pro_Proveedores pProveedor) { int retorno = 0; using (MySqlConnection conexion = Conexion.MiConexion()) { MySqlCommand Comando = new MySqlCommand(string.Format("Insert Into Proveedores (Nombre, Apellido, Razon_Social, Direccion, TelefonoOficina, Celular, Email) values ('{0}','{1}','{2}','{3}','{4}','{5}','{6}')", pProveedor.Nombre, pProveedor.Apellido, pProveedor.Razon_Social, pProveedor.Direccion, pProveedor.TelefonoOficina, pProveedor.Celular, pProveedor.Email), conexion); retorno = Comando.ExecuteNonQuery(); conexion.Close(); } return(retorno); }
public static int Modificar(Pro_Proveedores pProveedor) { int retorno = 0; using (MySqlConnection conexion = Conexion.MiConexion()) { MySqlCommand comando = new MySqlCommand(string.Format("Update Proveedores set Nombre='{0}', Apellido='{1}', Razon_Social='{2}', Direccion='{3}', TelefonoOficina='{4}', Celular='{5}', Email='{6}' where Email='{7}'", pProveedor.Nombre, pProveedor.Apellido, pProveedor.Razon_Social, pProveedor.Direccion, pProveedor.TelefonoOficina, pProveedor.Celular, pProveedor.Email, pProveedor.Email), conexion); retorno = comando.ExecuteNonQuery(); conexion.Close(); } return(retorno); }
public static int AgregarDetalleVenta(Pro_Venta pVenta) { int retorno = 0; using (MySqlConnection conexion = Conexion.MiConexion()) { MySqlCommand Comando = new MySqlCommand(string.Format("Insert Into Detalle_Ventas (Codigo, Cantidad, PrecioUnitario) values ('{0}','{1}','{2}')", pVenta.Codigo, pVenta.Cantidad, pVenta.Precio), conexion); retorno = Comando.ExecuteNonQuery(); conexion.Close(); } return(retorno); }
public static int Agregar(Pro_Usuarios pUsuario) { int retorno = 0; using (MySqlConnection conexion = Conexion.MiConexion()) { MySqlCommand Comando = new MySqlCommand(string.Format("Insert Into Usuarios (Nombre, Apellido, Direccion, Usuario, Contrasena, Tipo) values ('{0}','{1}','{2}','{3}','{4}','{5}')", pUsuario.Nombre, pUsuario.Apellido, pUsuario.Direccion, pUsuario.Usuario, pUsuario.Contrasena, pUsuario.Tipo), conexion); retorno = Comando.ExecuteNonQuery(); conexion.Close(); } return(retorno); }
public static int Modificar_Venta(Pro_Venta pVenta) { int retorno = 0; using (MySqlConnection conexion = Conexion.MiConexion()) { MySqlCommand comando = new MySqlCommand(string.Format("Update Venta_Proceso set Cantidad='{0}', Importe='{1}' where Codigo={2}", pVenta.Cantidad, pVenta.Importe, pVenta.Codigo), conexion); retorno = comando.ExecuteNonQuery(); conexion.Close(); } return(retorno); }
public static int Modificar(Pro_Usuarios pUsuario) { int retorno = 0; using (MySqlConnection conexion = Conexion.MiConexion()) { MySqlCommand comando = new MySqlCommand(string.Format("Update Usuarios set Nombre='{0}', Apellido='{1}', Direccion='{2}', Contrasena='{3}', Tipo='{4}' where Usuario='{5}'", pUsuario.Nombre, pUsuario.Apellido, pUsuario.Direccion, pUsuario.Contrasena, pUsuario.Tipo, pUsuario.Usuario), conexion); retorno = comando.ExecuteNonQuery(); conexion.Close(); } return(retorno); }
public static DataTable venta() { DataTable retorno = new DataTable(); using (MySqlConnection conexion = Conexion.MiConexion()) { string Consulta = "SELECT Codigo, Nombre, Descripcion, Precio FROM Productos"; MySqlCommand Comando = new MySqlCommand(Consulta, conexion); MySqlDataAdapter Adaptador = new MySqlDataAdapter(Comando); Adaptador.Fill(retorno); DataColumn dc = retorno.Columns.Add("PrecioTotal", typeof(decimal)); } return(retorno); }
public static int AgregarVenta(Pro_Venta pVenta) { int retorno = 0; using (MySqlConnection conexion = Conexion.MiConexion()) { MySqlCommand Comando = new MySqlCommand(string.Format("Insert Into Ventas (Cliente, Total, PagoCon, Cambio, Estado) values ('{0}','{1}','{2}','{3}','A')", pVenta.Cliente, pVenta.Total, pVenta.PagoCon, pVenta.Cambio), conexion); retorno = Comando.ExecuteNonQuery(); conexion.Close(); } return(retorno); }
public static int Modificar(Pro_Productos pProducto) { int retorno = 0; using (MySqlConnection conexion = Conexion.MiConexion()) { MySqlCommand comando = new MySqlCommand(string.Format("Update Productos set Nombre='{0}', Descripcion='{1}', Precio='{2}', Stock='{3}', TipoUnidad='{4}' where Codigo={5}", pProducto.Nombre, pProducto.Descripcion, pProducto.Precio, pProducto.Stock, pProducto.TipoUnidad, pProducto.Codigo), conexion); retorno = comando.ExecuteNonQuery(); conexion.Close(); } return(retorno); }
public static int Agregar(Pro_Productos pProducto) { int retorno = 0; using (MySqlConnection conexion = Conexion.MiConexion()) { MySqlCommand Comando = new MySqlCommand(string.Format("Insert Into Productos (Codigo, Nombre, Descripcion, Precio, Stock, TipoUnidad) values ('{0}', '{1}','{2}','{3}','{4}','{5}')", pProducto.Codigo, pProducto.Nombre, pProducto.Descripcion, pProducto.Precio, pProducto.Stock, pProducto.TipoUnidad), conexion); retorno = Comando.ExecuteNonQuery(); conexion.Close(); } return(retorno); }
public static int Modificar_Stock(Pro_Productos pProducto) { int retorno = 0; using (MySqlConnection conexion = Conexion.MiConexion()) { MySqlCommand comando = new MySqlCommand(string.Format("Update Productos set Stock='{0}' where Codigo={1}", pProducto.Stock, pProducto.Codigo), conexion); retorno = comando.ExecuteNonQuery(); conexion.Close(); } return(retorno); }
public static DataTable GenerarReporteDetalle() { DataTable retorno = new DataTable(); using (MySqlConnection conexion = Conexion.MiConexion()) { string Consulta = "SELECT DV.Codigo, P.Nombre, P.Descripcion, Cantidad, PrecioUnitario, TipoUnidad FROM Detalle_Ventas AS DV INNER JOIN Productos AS P ON DV.Codigo = P.Codigo;"; MySqlCommand Comando = new MySqlCommand(Consulta, conexion); MySqlDataAdapter Adaptador = new MySqlDataAdapter(Comando); Adaptador.Fill(retorno); } return(retorno); }
public static int Buscar(String NombreUsuario, String Contrasena) { int resultado = -1; MySqlConnection conexion = Conexion.MiConexion(); MySqlCommand comando = new MySqlCommand(string.Format( "SELECT * FROM Usuarios where Usuario ='{0}' and Contrasena ='{1}'", NombreUsuario, Contrasena), conexion); MySqlDataReader reader = comando.ExecuteReader(); while (reader.Read()) { resultado = 50; } conexion.Close(); return(resultado); }
public static string BuscarTipo(String NombreUsuario) { MySqlConnection conexion = Conexion.MiConexion(); MySqlCommand comando = new MySqlCommand(string.Format( "SELECT Tipo FROM Usuarios where Usuario ='{0}' LIMIT 1", NombreUsuario), conexion); MySqlDataReader reader = comando.ExecuteReader(); string Tipo = ""; while (reader.Read()) { Tipo = reader.GetString(0); } conexion.Close(); return(Tipo); }
public static bool Existe_Nombre(string Nombre) { string sql = @"SELECT COUNT(*) FROM Productos WHERE Nombre = @Nombre"; using (MySqlConnection conexion = Conexion.MiConexion()) { MySqlCommand command = new MySqlCommand(sql, conexion); command.Parameters.AddWithValue("Nombre", Nombre); int count = Convert.ToInt32(command.ExecuteScalar()); if (count == 0) { return(false); } else { return(true); } } }