public Employee getObject(string id) { Employee e = new Employee(); SqlDataReader reader = MyConnect.getReader("select * from Employee where ID_Emp=N'" + id + "'"); while (reader.Read()) { Image image = null; if (!reader.IsDBNull(6)) { image = ImageSQL.ByteArrayToImage((byte[])reader[6]); } e = new Employee(reader.GetString(0), reader.GetString(1), reader.GetDateTime(2), reader.GetBoolean(3), reader.GetString(4), long.Parse(reader.GetInt64(5).ToString()), image); } reader.Close(); return(e); }
//Get list emp public List <Employee> getList() { List <Employee> mList = new List <Employee>(); try { SqlDataReader reader = MyConnect.getReader("select * from Employee"); while (reader.Read()) { Image image = null; if (!reader.IsDBNull(6)) { image = ImageSQL.ByteArrayToImage((byte[])reader[6]); } Employee e = new Employee(reader.GetString(0), reader.GetString(1), reader.GetDateTime(2), reader.GetBoolean(3), reader.GetString(4), long.Parse(reader.GetInt64(5).ToString()), image); mList.Add(e); } MyConnect.Disconncet(); reader.Close(); } catch { return(null); } return(mList); }