public static CostoProduccionCue Fetch(int id) { CostoProduccionCue m_entidad = new CostoProduccionCue(); 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_costoprodcue_traerregistro"; 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 ObservableListSource <CostoProduccionCue> FetchList(int n_idcostoprod) { ObservableListSource <CostoProduccionCue> m_listentidad = new ObservableListSource <CostoProduccionCue>(); 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_costoprodcue_listar"; command.Parameters.Add(new MySqlParameter("@n_idcostoprod", n_idcostoprod)); connection.Open(); using (MySqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { CostoProduccionCue m_entidad = SetObject(reader); m_entidad.IsNew = false; m_listentidad.Add(m_entidad); } } } } return(m_listentidad); }
public static ObservableListSource <CostoProduccionCue> TraerListaPorConfiguracion(int n_idemp , int n_anotra , int n_mesini , int n_mesfin , int n_idconfigval) { // Se trae la lista de cuenta de la configuracion ConfigVal configVal = ConfigVal.Fetch(n_idconfigval); //Se trae el listado de cuentas del periodo DataTable DtResul = new DataTable(); 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_diario_balancecomprobacion_v2"; command.Parameters.Add(new MySqlParameter("@n_idemp", n_idemp)); command.Parameters.Add(new MySqlParameter("@n_anotra", n_anotra)); command.Parameters.Add(new MySqlParameter("@n_mesini", n_mesini)); command.Parameters.Add(new MySqlParameter("@n_mesfin", n_mesfin)); command.Parameters.Add(new MySqlParameter("@n_idlib", 0)); connection.Open(); MySqlDataAdapter adp = new MySqlDataAdapter(command); adp.Fill(DtResul); } } //Se agregan registros ObservableListSource <CostoProduccionCue> m_listentidad = new ObservableListSource <CostoProduccionCue>(); foreach (var configValCue in configVal.ConfigValCues) { //Se busca el registro en la tabla DataRow row = DtResul.AsEnumerable() .SingleOrDefault(r => r.Field <int>("n_idcue") == configValCue.n_idcue); if (row != null) { CostoProduccionCue m_entidad = new CostoProduccionCue(); m_entidad.n_idcue = Convert.ToInt32(row["n_idcue"]); //m_entidad.n_impt = Convert.ToDouble(row["n_movperhab"]); m_entidad.n_impt = Convert.ToDouble(row["n_movperdeb"]) / 7; //Se pone en duro debido a lo solicitado por Agrovado m_entidad.c_descue = configValCue.c_descue; m_listentidad.Add(m_entidad); } } return(m_listentidad); }