public PL_Employee GetLoggedInEmpDetails(Int64 EmpEID) { PL_Employee _temp = new PL_Employee(); using (SqlConnection myConnection = new SqlConnection(strConnection)) { using (SqlCommand myCommand = new SqlCommand("USP_LoggedInEmployee", myConnection)) { myCommand.CommandType = CommandType.StoredProcedure; if (EmpEID != 0) myCommand.Parameters.AddWithValue("@EmpEid", EmpEID); myConnection.Open(); using (SqlDataReader myReader = myCommand.ExecuteReader()) { if (myReader.HasRows) { if (myReader.Read()) { _temp = FillDataRecord(myReader); } myReader.Close(); } myReader.Close(); } } myConnection.Close(); } return _temp; }
private PL_Employee FillDataRecord(IDataRecord myDataRecord) { PL_Employee _emp = new PL_Employee(); if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("EmpEid"))) { _emp.EmpEid = myDataRecord.GetInt64(myDataRecord.GetOrdinal("EmpEid")); } if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("EmpId"))) { _emp.EmpId = myDataRecord.GetInt32(myDataRecord.GetOrdinal("EmpId")); } if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("VZID"))) { _emp.VZID = myDataRecord.GetString(myDataRecord.GetOrdinal("VZID")); } if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("EmpFirstName"))) { _emp.EmpFirstName = myDataRecord.GetString(myDataRecord.GetOrdinal("EmpFirstName")); } if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("EmpName"))) { _emp.EmpName = myDataRecord.GetString(myDataRecord.GetOrdinal("EmpName")); } if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("Email"))) { _emp.Email = myDataRecord.GetString(myDataRecord.GetOrdinal("Email")); } if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("Gender"))) { _emp.Gender = myDataRecord.GetString(myDataRecord.GetOrdinal("Gender")); } return _emp; }