public DalSelectedEmployee MapToDal(SelectedEmployee entity)
 {
     return(new DalSelectedEmployee
     {
         Id = entity.id,
         EmployeeLib_id = entity.employeeLib_id,
         Employee_id = entity.employee_id
     });
 }
示例#2
0
 private void SetRole()
 {
     if (SelectedRole != null && SelectedEmployee != null)
     {
         SelectedEmployee.Role = DBContext.Instance.Roles.Single(e => e.Id == SelectedRole.Id);
         SelectedEmployee.Update();
         RaisePropertyChanged("SelectedEmployee");
     }
 }
示例#3
0
 public void UpdateEmployee()
 {
     if (SelectedEmployee != null)
     {
         ObjEmployee    = SelectedEmployee.ConvertFrom();
         ObjPerson      = ObjEmployee.Person;
         ObjClient      = new Client();
         SelectedClient = null;
         TypeUser       = true;
     }
 }
示例#4
0
 private bool CanExecuteAddEmployee()
 {
     if (SelectedEmployee == null)
     {
         return(false);
     }
     else
     {
         return(SelectedEmployee.IsValid());
     }
 }
 private void RequestSalary()
 {
     if (SelectedEmployee != null)
     {
         MessageBox.Show($"Зарплата сотрудника {SelectedEmployee.Name}: {SelectedEmployee.GetSalary(SelectedDate)} руб.", "", MessageBoxButton.OK, MessageBoxImage.Information);
     }
     else
     {
         MessageBox.Show("Не выбран сотрудник!", "", MessageBoxButton.OK, MessageBoxImage.Warning);
     }
 }
        private void ListViewOffice_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (e.AddedItems.Count != 0)
            {
                if (ListViewDepartments.SelectedItems.Count > 0)
                {
                    FormDepartment.Department         = null;
                    ListViewDepartments.SelectedIndex = -1;
                }

                FormEmployee.Employee = (Employee)SelectedEmployee.Clone();
            }
        }
示例#7
0
        private void DeleteSelectedEmployee()
        {
            var confirmResult = MessageBox.Show("Bent u zeker dat u " + SelectedEmployee.Name.ToString() + " wenst te verwijderen?", "Medewerker verwijder waarchuwing", MessageBoxButton.YesNo);

            if (confirmResult == MessageBoxResult.Yes)
            {
                SelectedEmployee.IsArchived = true;
                RaisePropertyChanged("SelectedEmployee");
                SelectedEmployee.Update();
                SelectedEmployee = null;
                RefreshView();
            }
        }
        private async void SaveEmployee()
        {
            if (SelectedEmployee == null || !SelectedEmployee.IsValid())
            {
                Error = "Medewerker niet toegevoegd of gewijzigd, hou rekening met de meldingen.";
                return;
            }
            else
            {
                Error = "";
            }

            SelectedEmployee.Available = true;
            string input = JsonConvert.SerializeObject(SelectedEmployee);

            // check insert (no ID assigned) or update (already an ID assigned)
            if (SelectedEmployee.ID == 0)
            {
                using (HttpClient client = new HttpClient())
                {
                    client.SetBearerToken(ApplicationVM.token.AccessToken);
                    HttpResponseMessage response = await client.PostAsync("http://localhost:55853/api/employee", new StringContent(input, Encoding.UTF8, "application/json"));

                    if (response.IsSuccessStatusCode)
                    {
                        string output = await response.Content.ReadAsStringAsync();

                        SelectedEmployee.ID = Int32.Parse(output);
                    }
                    else
                    {
                        Console.WriteLine("error");
                    }
                }
            }
            else
            {
                using (HttpClient client = new HttpClient())
                {
                    client.SetBearerToken(ApplicationVM.token.AccessToken);
                    HttpResponseMessage response = await client.PutAsync("http://localhost:55853/api/employee", new StringContent(input, Encoding.UTF8, "application/json"));

                    if (!response.IsSuccessStatusCode)
                    {
                        Console.WriteLine("error");
                    }
                }
            }
        }
        public ActionResult AddOrEdit(int id = 0)
        {
            SelectedEmployee emp = new SelectedEmployee();

            using (DBModel db = new DBModel())
            {
                if (id != 0)
                {
                    emp = db.SelectedEmployees.Where(x => x.ID == id).FirstOrDefault();
                    //Multi Select DropDown
                    emp.SelectedIDArray = emp.SelectedEmployeeIDs.Split(',').ToArray();
                }
                emp.EmployeeCollection = db.Employees.ToList();
            }
            return(View(emp));
        }
 public ActionResult AddOrEdit(SelectedEmployee emp)
 {
     //multi select dropdown
     emp.SelectedEmployeeIDs = string.Join(",", emp.SelectedIDArray);
     using (DBModel db = new DBModel())
     {
         if (emp.ID == 0)
         {
             db.SelectedEmployees.Add(emp);
         }
         else
         {
             db.Entry(emp).State = EntityState.Modified;
         }
         db.SaveChanges();
     }
     return(RedirectToAction("AddOrEdit", new { id = 0 }));
 }
 private void DeleteEmployee()
 {
     try
     {
         if (MessageBox.Show("Are you sure you want to PERMANENTLY delete the Employee details?", "Delete Employee?", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes)
         {
             SelectedEmployee.Delete();
             EmployeeCollection.Remove(SelectedEmployee);
             MessageBox.Show("Thank you!  The Employee's details have been deleted!", "Delete Employee?", MessageBoxButton.OK, MessageBoxImage.Information);
         }
         else
         {
             return;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("An Error Occured, The Employee Details have not been deleted. Please Contact your System Administrator.", "Delete Employee?" + ex.Message);
     }
 }
        private void SaveEmployee()
        {
            if (String.IsNullOrEmpty(SelectedEmployee.FirstName))
            {
                MessageBox.Show("Please Enter First Name", "First Name Required", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            if (String.IsNullOrEmpty(SelectedEmployee.LastName)

                )
            {
                MessageBox.Show("Please Enter Last Name", "Last Name Required", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            if (String.IsNullOrEmpty(SelectedEmployee.MobileNumber))
            {
                MessageBox.Show("Please Enter Mobile Number", "Mobile Number Required", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            if (String.IsNullOrEmpty(SelectedEmployee.State))
            {
                MessageBox.Show("Please Enter State", "State Required", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            if (String.IsNullOrEmpty(SelectedEmployee.Suburb))
            {
                MessageBox.Show("Please Enter Suburb", "Suburb Required", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            if (String.IsNullOrEmpty(SelectedEmployee.PostCode))
            {
                MessageBox.Show("Please Enter Postcode", "Postcode Required", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            if (String.IsNullOrEmpty(SelectedEmployee.Gender))
            {
                MessageBox.Show("Please Enter Gender", "Gender Required", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            if (String.IsNullOrEmpty(SelectedEmployee.EmployeeType))
            {
                MessageBox.Show("Please Enter Employee Type", "Employee Type Required", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            if (String.IsNullOrEmpty(SelectedEmployee.Street))
            {
                MessageBox.Show("Please Enter Street", "Street Required", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            if (String.IsNullOrEmpty(SelectedEmployee.Email))
            {
                MessageBox.Show("Please Enter Email", "Email Required", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            if (!Regex.Match(SelectedEmployee.LastName, "^[a-zA-Z\\s\\,]*$").Success || String.IsNullOrEmpty(SelectedEmployee.LastName))
            {
                MessageBox.Show("Not a valid Last Name");

                return;
            }
            if (!Regex.Match(SelectedEmployee.FirstName, "^[a-zA-Z\\s\\,]*$").Success || String.IsNullOrEmpty(SelectedEmployee.LastName))
            {
                MessageBox.Show("Not a valid First Name");

                return;
            }


            if (!Regex.Match(SelectedEmployee.MobileNumber, "^0[0-9]{9}$").Success)
            {
                MessageBox.Show("Enter valid phone number.", "Phone Number",
                                MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            SelectedEmployee.UserID = Convert.ToInt32(SelectedEmployeeUserId);

            if (SelectedEmployee.EmployeeID == 0)
            {
                try
                {
                    SelectedEmployee.Insert();
                    MessageBox.Show("Thank you!  The new Employee's details have been added to the Database.", "Add Employee", MessageBoxButton.OK, MessageBoxImage.Information);
                }
                catch (Exception)
                {
                    MessageBox.Show("Something Went Wrong, But we Dont know what! Employee details was not added to the database");
                }
            }
            else
            {
                try
                {
                    SelectedEmployee.Update();
                    MessageBox.Show("The employee's details have been updated in the Database.", "Update Employee?", MessageBoxButton.OK, MessageBoxImage.Information);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("An Error Occured, The Employee Details were not updated. Please Contact your System Administrator.", "Update Employee?" + ex.Message);
                }
            }
            IsEnabledSave   = true;
            IsEnabledAdd    = true;
            IsEnabledDelete = true;
        }
        /// <summary>
        /// вывод отчета по работнику за данный период
        /// </summary>
        /// <param name="o"></param>
        private void OnEmplCommandExecuted(object o)
        {
            if (DateFrom > DateTo)
            {
                MessageBox.Show("Проверьте формат даты"); return;
            }
            if (SelectedEmployee == null)
            {
                MessageBox.Show("Выберите работника"); return;
            }

            string sql = "select FirmName, UNP, Category.NameCategory, [Name],Price, Store.[Count], TotalPrice, PurchaseDay, [Description] " +
                         "from Store " +
                         "join Firms on(Store.FirmID = Firms.FirmID) " +
                         "join Storage on(Store.StorageID= Storage.StorageID) " +
                         "join Category on(Storage.CategoryID= Category.CategoryID) " +
                         "where EmployeeID = (select EmployeeID from Employee where EmpLastName='" + SelectedEmployee.Split()[0] + "' and EmpFirstName = '" + SelectedEmployee.Split()[1] + "') " +
                         "and PurchaseDay>= '" + DateFrom + "' and PurchaseDay<= '" + DateTo + "'";

            (new EmpReport()).writeClass(DateFrom, DateTo, "reportPeople", "работнику", SelectedEmployee, sql, "Название", "УПН");
        }
示例#14
0
 private void UpdateSelectedEmployee()
 {
     SelectedEmployee.Update();
 }