public static ProgramacionDetPro Fetch(int id) { ProgramacionDetPro m_entidad = new ProgramacionDetPro(); 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 = "pro_programadetpro_traerregistro"; command.Parameters.Add(new MySqlParameter("@n_id", id)); connection.Open(); using (MySqlDataReader reader = command.ExecuteReader()) { if (reader.Read()) { m_entidad = SetObject(reader); } } } } return(m_entidad); }
public static ObservableListSource <ProgramacionDetPro> FetchList(int n_idpro) { ObservableListSource <ProgramacionDetPro> m_listentidad = new ObservableListSource <ProgramacionDetPro>(); 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 = "pro_programadetpro_listar_2"; command.Parameters.Add(new MySqlParameter("@n_idpro", n_idpro)); connection.Open(); using (MySqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { ProgramacionDetPro m_entidad = SetObject(reader); m_listentidad.Add(m_entidad); } } } } return(m_listentidad); }
private static ProgramacionDetPro SetObject(MySqlDataReader reader) { var prog = new ProgramacionDetPro { n_idpro = reader.GetInt32("n_idpro"), n_idordpro = reader.GetInt32("n_idordpro"), n_idite = reader.GetInt32("n_idite"), n_idrec = reader.GetInt32("n_idrec"), n_idunimed = reader.GetInt32("n_idunimed"), n_can = reader.GetDouble("n_can"), d_fchent = reader.GetDateTime("d_fchent"), d_fchpro = reader.GetDateTime("d_fchpro"), n_idres = reader.GetInt32("n_idres"), n_idlin = reader.GetInt32("n_idlin"), c_desite = reader.GetString("c_desite"), c_desres = reader.GetString("c_desres") }; if (reader["c_desordpro"] != DBNull.Value) { prog.c_desordpro = reader.GetString("c_desordpro"); } if (reader["c_deslin"] != DBNull.Value) { prog.c_deslin = reader.GetString("c_deslin"); } if (reader["c_desrec"] != DBNull.Value) { prog.c_desrec = reader.GetString("c_desrec"); } if (reader["h_horini"] != DBNull.Value) { prog.h_horini = Convert.ToDateTime(reader.GetString("h_horini")); } else { prog.h_horini = Convert.ToDateTime(new DateTime(prog.d_fchpro.Year, prog.d_fchpro.Month, prog.d_fchpro.Day, 8, 0, 0)); } if (reader["h_horfin"] != DBNull.Value) { prog.h_horfin = Convert.ToDateTime(reader.GetString("h_horfin")); } else { prog.h_horfin = Convert.ToDateTime(new DateTime(prog.d_fchpro.Year, prog.d_fchpro.Month, prog.d_fchpro.Day, 9, 0, 0)); } return(prog); }