public gEmployee get(string id) { EmployeePersistence ge = new EmployeePersistence(); gEmployee emp = ge.getEmployee(id); return(emp); }
public gEmployee getEmployee(string als) { gEmployee e = new gEmployee(); MySql.Data.MySqlClient.MySqlDataReader getReader = null; string getString = "SELECT * FROM Emp_details WHERE eAlias = '" + als.ToString() + "';"; MySql.Data.MySqlClient.MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand(getString, conn); getReader = cmd.ExecuteReader(); if (getReader.Read()) { e.Alias = getReader.IsDBNull(0) == false?getReader.GetString(0) : null; e.GIN = getReader.IsDBNull(1) == false?getReader.GetString(1) : null; e.DisplayName = getReader.IsDBNull(2) == false?getReader.GetString(2) : null; e.UserPrincipalName = getReader.IsDBNull(3) == false?getReader.GetString(3) : null; e.JobCode = getReader.IsDBNull(4) == false?getReader.GetString(4) : null; e.MobilePhone = getReader.IsDBNull(5) == false?getReader.GetString(5) : null; e.GOLDMedalOwner = getReader.IsDBNull(6) == false?getReader.GetString(6) : null; e.QuestOTC = getReader.IsDBNull(7) == false?getReader.GetFloat(7) : 0; e.Country = getReader.IsDBNull(8) == false?getReader.GetString(8) : null; e.Department = getReader.IsDBNull(9) == false?getReader.GetString(9) : null; e.Entity = getReader.IsDBNull(10) == false?getReader.GetString(10) : null; e.ProgramID = getReader.IsDBNull(11) == false?getReader.GetString(11) : null; e.CardNo = getReader.IsDBNull(12) == false?getReader.GetString(12) : null; e.PIN = getReader.IsDBNull(13) == false?getReader.GetString(13) : null; return(e); } else { return(null); } }
public bool deleteEmployee(string als) { gEmployee e = new gEmployee(); MySql.Data.MySqlClient.MySqlDataReader getReader = null; string getString = "SELECT * FROM employees WHERE Alias = '" + als.ToString() + "';"; MySql.Data.MySqlClient.MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand(getString, conn); getReader = cmd.ExecuteReader(); if (getReader.Read()) { getReader.Close(); getString = "DELETE FROM employees WHERE Alias = '" + als.ToString() + "';"; cmd = new MySql.Data.MySqlClient.MySqlCommand(getString, conn); cmd.ExecuteNonQuery(); return(true); } else { return(false); } }