public static List <ModelComprasP> Buscar(string pRancho, string pProducto, string pRemision) { List <ModelComprasP> _lista = new List <ModelComprasP>(); MySqlCommand _comando = new MySqlCommand(string.Format($"SELECT * FROM compras WHERE Rancho = '{pRancho}' OR TipoProducto = '{pProducto}' OR NoRemision='{pRemision}'"), ConexionMySql.ObtenerConexion()); MySqlDataReader _reader = _comando.ExecuteReader(); while (_reader.Read()) { ModelComprasP pComprasP = new ModelComprasP { IdCompra = _reader.GetInt32(0), Fecha = _reader.GetString(1), NoPipa = _reader.GetString(2), Proveedor = _reader.GetString(3), Rancho = _reader.GetString(4), NoRemision = _reader.GetString(5), FechaLlegada = _reader.GetString(6), Placas = _reader.GetString(7), Analista = _reader.GetString(8), Sello1 = _reader.GetString(9), Sello2 = _reader.GetString(10), TipoProducto = _reader.GetString(11), Densidad = _reader.GetDouble(12), Grasa = _reader.GetDouble(13), SNG = _reader.GetDouble(14), ST = _reader.GetDouble(15), Crioscopia = _reader.GetDouble(16), Proteina = _reader.GetDouble(17), Kilos = _reader.GetDouble(18), Litros = _reader.GetDouble(19) }; _lista.Add(pComprasP); } return(_lista); }
public static ModelComprasP ObtenerCompras(int pIdCompraP) { var pMs = new ModelComprasP(); var connec = ConexionMySql.ObtenerConexion(); var comando = new MySqlCommand($"SELECT * FROM compras WHERE IDCompra ='{pIdCompraP}'", connec); var reader = comando.ExecuteReader(); while (reader.Read()) { ComprasPSelect.IdCompra = reader.GetInt32(0); ComprasPSelect.Fecha = reader.GetString(1); ComprasPSelect.NoPipa = reader.GetString(2); ComprasPSelect.Proveedor = reader.GetString(3); ComprasPSelect.Rancho = reader.GetString(4); ComprasPSelect.NoRemision = reader.GetString(5); ComprasPSelect.FechaLlegada = reader.GetString(6); ComprasPSelect.Placas = reader.GetString(7); ComprasPSelect.Analista = reader.GetString(8); ComprasPSelect.Sello1 = reader.GetString(9); ComprasPSelect.Sello2 = reader.GetString(10); ComprasPSelect.TipoProducto = reader.GetString(11); ComprasPSelect.Densidad = reader.GetDouble(12); ComprasPSelect.Grasa = reader.GetDouble(13); ComprasPSelect.SNG = reader.GetDouble(14); ComprasPSelect.ST = reader.GetDouble(15); ComprasPSelect.Crioscopia = reader.GetDouble(16); ComprasPSelect.Proteina = reader.GetDouble(17); ComprasPSelect.Kilos = reader.GetDouble(18); ComprasPSelect.Litros = reader.GetDouble(19); } connec.Close(); return(pMs); }
/// <summary> /// metodo para agregar /// </summary> public static int Agregar(ModelComprasP pMcp) { var connec = ConexionMySql.ObtenerConexion(); var comando = new MySqlCommand($"INSERT INTO compras (Fecha, NoPipa, Proveedor, Rancho, NoRemision, FechaLlegada, Placas, Analista, Sello1, Sello2, TipoProducto, Densidad, Grasa, SNG, ST, Crioscopia, Proteina, Kilos, Litros) VALUES('{pMcp.Fecha}','{pMcp.NoPipa}','{pMcp.Proveedor}','{pMcp.Rancho}','{pMcp.NoRemision}','{pMcp.FechaLlegada}','{pMcp.Placas}','{pMcp.Analista}','{pMcp.Sello1}','{pMcp.Sello2}','{pMcp.TipoProducto}','{pMcp.Densidad}','{pMcp.Grasa}','{pMcp.SNG}','{pMcp.ST}','{pMcp.Crioscopia}','{pMcp.Proteina}','{pMcp.Kilos}','{pMcp.Litros}')", connec); var retorno = comando.ExecuteNonQuery(); return(retorno); }
//metodo para actualizar public static int Actualizar(ModelComprasP pMcp) { var conexion = ConexionMySql.ObtenerConexion(); var comando = new MySqlCommand($"UPDATE compras SET Fecha = '{pMcp.Fecha}', NoPipa = '{pMcp.NoPipa}', Proveedor = '{pMcp.Proveedor}', Rancho = '{pMcp.Rancho}', NoRemision = '{pMcp.NoRemision}', FechaLlegada = '{pMcp.FechaLlegada}', Placas = '{pMcp.Placas}', Analista = '{pMcp.Analista}', Sello1 = '{pMcp.Sello1}', Sello2 = '{pMcp.Sello2}', TipoProducto = '{pMcp.TipoProducto}', Densidad = '{pMcp.Densidad}', Grasa = '{pMcp.Grasa}', SNG = '{pMcp.SNG}', ST = '{pMcp.ST}', Crioscopia = '{pMcp.Crioscopia}', Proteina = '{pMcp.Proteina}', Kilos = '{pMcp.Kilos}', Litros = '{pMcp.Litros}' WHERE IDCompra = '{pMcp.IdCompra}'", conexion); var retorno = comando.ExecuteNonQuery(); conexion.Close(); return(retorno); }
public static List <ModelComprasP> Llenargrid() { var lista = new List <ModelComprasP>(); var connec = ConexionMySql.ObtenerConexion(); var comando = new MySqlCommand("SELECT * FROM compras", connec); var reader = comando.ExecuteReader(); while (reader.Read()) { var pModelComprasP = new ModelComprasP { IdCompra = reader.GetInt32(0), Fecha = reader.GetString(1), NoPipa = reader.GetString(2), Proveedor = reader.GetString(3), Rancho = reader.GetString(4), NoRemision = reader.GetString(5), FechaLlegada = reader.GetString(6), Placas = reader.GetString(7), Analista = reader.GetString(8), Sello1 = reader.GetString(9), Sello2 = reader.GetString(10), TipoProducto = reader.GetString(11), Densidad = reader.GetDouble(12), Grasa = reader.GetDouble(13), SNG = reader.GetDouble(14), ST = reader.GetDouble(15), Crioscopia = reader.GetDouble(16), Proteina = reader.GetDouble(17), Kilos = reader.GetDouble(18), Litros = reader.GetDouble(19) }; lista.Add(pModelComprasP); } return(lista); }