public static CostoProduccionDet Fetch(int id) { CostoProduccionDet m_entidad = new CostoProduccionDet(); using (MySqlConnection connection = new MySqlConnection( ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString)) { using (MySqlCommand command = new MySqlCommand()) { command.Connection = connection; command.CommandType = System.Data.CommandType.StoredProcedure; command.CommandText = "con_costoproddet_obtenerregistro"; command.Parameters.Add(new MySqlParameter("@n_id", id)); connection.Open(); using (MySqlDataReader reader = command.ExecuteReader()) { if (reader.Read()) { m_entidad = SetObject(reader); m_entidad.IsNew = false; } } } } return(m_entidad); }
public static CostoProduccionDet SetObject(MySqlDataReader reader) { CostoProduccionDet costoProduccionDet = new CostoProduccionDet { n_id = reader.GetInt32("n_id"), n_idcostoprod = reader.GetInt32("n_idcostoprod"), n_idparteprod = reader.GetInt32("n_idparteprod"), n_factdist = reader.GetDouble("n_factdist"), n_costomp = reader.GetDouble("n_costomp"), n_costomod = reader.GetDouble("n_costomod"), n_costocif = reader.GetDouble("n_costocif"), n_can = reader.GetDouble("n_can"), n_idpro = reader.GetInt32("n_idpro"), c_desparteprod = reader.GetString("c_desparteprod"), n_idrec = reader.GetInt32("n_idrec"), c_descodprod = reader.GetString("c_descodprod"), c_desprod = reader.GetString("c_desprod"), c_desrec = reader.GetString("c_desrec"), c_desunimed = reader.GetString("c_desunimed") }; if (!reader.IsDBNull(reader.GetOrdinal("n_idmov"))) { costoProduccionDet.n_idmov = reader.GetInt32("n_idmov"); } return(costoProduccionDet); }
public static ObservableListSource <CostoProduccionDet> FetchList(int n_idcostoprod) { ObservableListSource <CostoProduccionDet> m_listentidad = new ObservableListSource <CostoProduccionDet>(); using (MySqlConnection connection = new MySqlConnection( ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString)) { using (MySqlCommand command = new MySqlCommand()) { command.Connection = connection; command.CommandType = System.Data.CommandType.StoredProcedure; command.CommandText = "con_costoproddet_listar"; command.Parameters.Add(new MySqlParameter("@n_idcostoprod", n_idcostoprod)); connection.Open(); using (MySqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { CostoProduccionDet m_entidad = SetObject(reader); m_entidad.IsNew = false; m_listentidad.Add(m_entidad); } } } } return(m_listentidad); }