Exemplo n.º 1
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Employees EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToEmployees(Employee employee)
 {
     base.AddObject("Employees", employee);
 }
Exemplo n.º 2
0
 /// <summary>
 /// Update or Insert Employee Information 
 /// </summary>
 /// <param name="obj">RadGridView selected item</param>
 private void updateEmployeeClick(object obj)
 {
     this.EmployeeUpdate.IsEnabled = false;
     Mouse.OverrideCursor = Cursors.Wait;
     try
     {
         if (obj!=null)
         {
             ModelEmployee selectedEmployee = obj as ModelEmployee;
             using (Cafeteria_Vernier_dbEntities CVDatabase = new Cafeteria_Vernier_dbEntities())
             {
                 var employeeExist = CVDatabase.Employees.FirstOrDefault(x => x.EmployeeID.Equals(selectedEmployee.Name));
                 if (employeeExist!=null)
                 {
                     if (this.LoginEmployee.Permissions.AsParallel().FirstOrDefault(x => x.Item.Equals("EmployeeEdit")) != null)
                     {
                         Mouse.OverrideCursor = null;
                         if (DXMessageBox.Show(CvVariables.ERROR_MESSAGES[1, 8], CvVariables.ERROR_MESSAGES[0, 0], MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
                         {
                             Mouse.OverrideCursor = Cursors.Wait;
                             var existinfPermissions = CVDatabase.EmployeePermissions.Where(x => x.EmployeeID.Equals(selectedEmployee.Name));
                             foreach (var permission in existinfPermissions)
                             {
                                 CVDatabase.EmployeePermissions.DeleteObject(permission);
                             }
                             employeeExist.Address = selectedEmployee.Address;
                             employeeExist.Password = String.IsNullOrEmpty(selectedEmployee.Password) ? employeeExist.Password : selectedEmployee.Password;
                             employeeExist.Phone = selectedEmployee.PhoneNmber;
                             employeeExist.UserImage = selectedEmployee.UserImage;
                             foreach (var permission in selectedEmployee.Permissions.Where(x=>x.Permission.Equals(true)))
                             {
                                employeeExist.EmployeePermissions.Add(new EmployeePermission { AutoInc=default(long),  EmployeeID=selectedEmployee.Name, Privilege=permission.Item, SettingPrivilage = permission.Setting });
                             }
                             CVDatabase.SaveChanges();
                             Mouse.OverrideCursor = null;
                             DXMessageBox.Show(CvVariables.ERROR_MESSAGESS[0, 2], CvVariables.SOFTWARE_NAME, MessageBoxButton.OK, MessageBoxImage.Information);
                         }
                         else
                         {
                             return;
                         }
                     }
                     else
                     {
                         Mouse.OverrideCursor = null;
                         DXMessageBox.Show(CvVariables.ERROR_MESSAGESS[0, 1], CvVariables.SOFTWARE_NAME, MessageBoxButton.OK, MessageBoxImage.Hand);
                     }
                 }
                 else
                 {
                     Employee newEmployee = new Employee { Address=selectedEmployee.Address, EmployeeID=selectedEmployee.Name, Password=selectedEmployee.Password, Phone=selectedEmployee.PhoneNmber, UserImage=selectedEmployee.UserImage };
                     foreach (var permission in selectedEmployee.Permissions.Where(x=>x.Permission.Equals(true)))
                     {
                         newEmployee.EmployeePermissions.Add(new EmployeePermission { AutoInc=default(long), EmployeeID=selectedEmployee.Name, Privilege=permission.Item, SettingPrivilage=permission.Setting });
                     }
                     CVDatabase.Employees.AddObject(newEmployee);
                     CVDatabase.SaveChanges();
                     Mouse.OverrideCursor = null;
                     DXMessageBox.Show(CvVariables.ERROR_MESSAGESS[0, 3], CvVariables.SOFTWARE_NAME, MessageBoxButton.OK, MessageBoxImage.Information);
                 }
             }
         }
         else
         {
             Mouse.OverrideCursor = null;
            DXMessageBox.Show(CvVariables.ERROR_MESSAGESS[0,4],CvVariables.ERROR_MESSAGES[0,0],MessageBoxButton.OK,MessageBoxImage.Hand);
         }
     }
     catch (Exception ErrorException)
     {
         LogFileWriter.ErrorToLog("Update Or Insert Click", ErrorException);
         Mouse.OverrideCursor = null;
         DXMessageBox.Show(ErrorException.Message,CvVariables.ERROR_MESSAGES[0,0],MessageBoxButton.OK,MessageBoxImage.Error);
     }
     finally
     {
         Mouse.OverrideCursor = null;
         this.EmployeeUpdate.IsEnabled = true;
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// Create a new Employee object.
 /// </summary>
 /// <param name="employeeID">Initial value of the EmployeeID property.</param>
 /// <param name="password">Initial value of the Password property.</param>
 public static Employee CreateEmployee(global::System.String employeeID, global::System.String password)
 {
     Employee employee = new Employee();
     employee.EmployeeID = employeeID;
     employee.Password = password;
     return employee;
 }