public List<Registro_Horario> findAll() { List<Registro_Horario> depto = null; String query = "SELECT a.personal_id_personal,a.fecha, a.hora_llegada, a.hora_salida FROM registro_horario AS a "+ "INNER JOIN personal AS b "+ "ON(a.personal_id_personal = b.id_personal) "+ "WHERE b.id_personal = "+this.personal_id_personal; MySqlConnection con = null; try { con = new Conexion().GetConexion(); con.Open(); MySqlCommand sqlCom = new MySqlCommand(query, con); MySqlDataReader res = sqlCom.ExecuteReader(); depto = new List<Registro_Horario>(); while (res.Read()) { Registro_Horario rows = new Registro_Horario(res.GetInt32(0), res.GetString(1), res.GetString(2),res.GetString(3)); depto.Add(rows); } con.Close(); return depto; } catch (Exception ex) { con.Close(); Console.WriteLine("EEROR " + ex.Message); return depto; } }
public int Delete() { String query = "DELETE FROM departamento where id_departamento = " + this.id; MySqlConnection con = null; try { con = new Conexion().GetConexion(); con.Open(); MySqlCommand sqlCom = new MySqlCommand(query, con); return sqlCom.ExecuteNonQuery(); } catch (Exception ex) { con.Close(); Console.WriteLine("EEROR " + ex.Message); return 0; } }
public int save() { String query = "insert into departamento (nombre, id_jefe) values('" + this.name + "'," + int.Parse(this.rut_jefe) + ")"; MySqlConnection con = null; try { con = new Conexion().GetConexion(); con.Open(); MySqlCommand sqlCom = new MySqlCommand(query, con); return(sqlCom.ExecuteNonQuery()); } catch (Exception ex) { con.Close(); Console.WriteLine("EEROR " + ex.Message); return(0); } }
public int update() { String query = "update departamento set nombre='" + this.name + "', id_jefe= " + this.rut_jefe + " where id_departamento = " + this.id; MySqlConnection con = null; try { con = new Conexion().GetConexion(); con.Open(); MySqlCommand sqlCom = new MySqlCommand(query, con); return(sqlCom.ExecuteNonQuery()); } catch (Exception ex) { con.Close(); Console.WriteLine("EEROR " + ex.Message); return(0); } }
public int Delete() { String query = "DELETE FROM departamento where id_departamento = " + this.id; MySqlConnection con = null; try { con = new Conexion().GetConexion(); con.Open(); MySqlCommand sqlCom = new MySqlCommand(query, con); return(sqlCom.ExecuteNonQuery()); } catch (Exception ex) { con.Close(); Console.WriteLine("EEROR " + ex.Message); return(0); } }
public int update() { String query = "update departamento set nombre='" + this.name + "', id_jefe= " + this.rut_jefe+ " where id_departamento = " + this.id; MySqlConnection con = null; try { con = new Conexion().GetConexion(); con.Open(); MySqlCommand sqlCom = new MySqlCommand(query, con); return sqlCom.ExecuteNonQuery(); } catch (Exception ex) { con.Close(); Console.WriteLine("EEROR " + ex.Message); return 0; } }
public int save() { String query = "insert into departamento (nombre, id_jefe) values('" + this.name + "'," + int.Parse(this.rut_jefe) + ")"; MySqlConnection con = null; try { con = new Conexion().GetConexion(); con.Open(); MySqlCommand sqlCom = new MySqlCommand(query, con); return sqlCom.ExecuteNonQuery(); } catch (Exception ex) { con.Close(); Console.WriteLine("EEROR " + ex.Message); return 0; } }
public List<Departamento> findAll_administrativo() { List<Departamento> depto = null; String query = "select id_departamento, nombre, IFNULL(id_jefe,'Asignar jefe') as id_jefe from departamento"; MySqlConnection con = null; try { con = new Conexion().GetConexion(); con.Open(); MySqlCommand sqlCom = new MySqlCommand(query, con); MySqlDataReader res = sqlCom.ExecuteReader(); depto = new List<Departamento>(); while (res.Read()) { Departamento rows = new Departamento(res.GetInt32(0), res.GetString(1), res.GetString(2)); depto.Add(rows); } con.Close(); return depto; } catch (Exception ex) { con.Close(); Console.WriteLine("EEROR " + ex.Message); return depto; } }