internal void AddEmployee(tblEmployee employee, tblAccount account, string dateOfBirth, tblEngagement Engagement) { using (HotelEntities1 context = new HotelEntities1()) { DateTime date = DateTime.ParseExact(dateOfBirth, "yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture); tblAccount newAccount = new tblAccount(); newAccount.FullName = account.FullName; newAccount.DateOfBirth = date; newAccount.Email = account.Email; newAccount.UserName = account.UserName; newAccount.Pass = account.Pass; context.tblAccounts.Add(newAccount); context.SaveChanges(); tblEmployee newManager = new tblEmployee(); newManager.AccountID = newAccount.AccountID; newManager.HotelFloor = employee.HotelFloor; newManager.Gender = employee.Gender; newManager.Cityzenship = employee.Cityzenship; newManager.EngagementID = Engagement.EngagementID; newManager.Salary = employee.Salary; context.tblEmployees.Add(newManager); context.SaveChanges(); } }
internal tblEmployee GetEmployee(string userName) { using (HotelEntities1 context = new HotelEntities1()) { tblAccount account = (from a in context.tblAccounts where a.UserName == userName select a).First(); tblEmployee employee = (from e in context.tblEmployees where e.AccountID == account.AccountID select e).First(); return(employee); } }
internal tblManager GetManager(string userName) { using (HotelEntities1 context = new HotelEntities1()) { tblAccount account = (from a in context.tblAccounts where a.UserName == userName select a).First(); tblManager manager = (from m in context.tblManagers where m.AccountID == account.AccountID select m).First(); return(manager); } }
internal List <tblEngagement> GetAllEngagements() { try { using (HotelEntities1 context = new HotelEntities1()) { List <tblEngagement> list = (from l in context.tblEngagements select l).ToList(); return(list); } } catch (Exception ex) { System.Diagnostics.Debug.Write("Exception" + ex.Message.ToString()); return(null); } }
internal bool IsManager(string userName, string password) { try { using (HotelEntities1 context = new HotelEntities1()) { tblAccount account = (from a in context.tblAccounts where a.UserName == userName && a.Pass == password select a).First(); tblManager manager = (from m in context.tblManagers where m.AccountID == account.AccountID select m).First(); } return(true); } catch { return(false); } }
internal bool IsEmployee(string userName, string password) { try { using (HotelEntities1 context = new HotelEntities1()) { tblAccount account = (from a in context.tblAccounts where a.UserName == userName && a.Pass == password select a).First(); tblEmployee employee = (from e in context.tblEmployees where e.AccountID == account.AccountID select e).First(); } return(true); } catch { return(false); } }
internal void AddManager(tblManager manager, tblAccount account, string dateOfBirth) { using (HotelEntities1 context = new HotelEntities1()) { DateTime date = DateTime.ParseExact(dateOfBirth, "yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture); tblAccount newAccount = new tblAccount(); newAccount.FullName = account.FullName; newAccount.DateOfBirth = date; newAccount.Email = account.Email; newAccount.UserName = account.UserName; newAccount.Pass = account.Pass; context.tblAccounts.Add(newAccount); context.SaveChanges(); tblManager newManager = new tblManager(); newManager.AccountID = newAccount.AccountID; newManager.HotelFloor = manager.HotelFloor; newManager.Experience = manager.Experience; newManager.QualificationsLevel = manager.QualificationsLevel; context.tblManagers.Add(newManager); context.SaveChanges(); } }