Beispiel #1
0
        private void DGV_Employee_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            try
            {
                if (RoleType == "Administrator" || RoleType == "Manager")
                {
                    if (DGV_Employee.Items.IsEmpty)
                    {
                        ademploy = new AddEmployee();
                        Employee_page.Navigate(ademploy);
                    }

                    else
                    {
                        upEmploy = new UpdateEmployee();
                        object item = DGV_Employee.SelectedItem;
                        upEmploy.txt_Firstname.Text = (DGV_Employee.SelectedCells[3].Column.GetCellContent(item) as TextBlock).Text;
                        upEmploy.txt_Surname.Text   = (DGV_Employee.SelectedCells[4].Column.GetCellContent(item) as TextBlock).Text;
                        upEmploy.txt_IDnumber.Text  = (DGV_Employee.SelectedCells[5].Column.GetCellContent(item) as TextBlock).Text;
                        upEmploy.txt_Username.Text  = (DGV_Employee.SelectedCells[1].Column.GetCellContent(item) as TextBlock).Text;
                        upEmploy.txt_Password.Text  = (DGV_Employee.SelectedCells[2].Column.GetCellContent(item) as TextBlock).Text;
                        ID                  = (DGV_Employee.SelectedCells[0].Column.GetCellContent(item) as TextBlock).Text;
                        upEmploy.ID         = ID;
                        upEmploy.Department = Department;

                        Employee_page.Navigate(upEmploy);
                    }
                }
            }
            catch (Exception)
            {
            }
        }
        private void Can_AddEmployee_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            ViewEmploy = new ViewEmployee();
            AddEmploy  = new AddEmployee();

            ViewEmploy.Employee_page = null;
            DependencyObject currParent = VisualTreeHelper.GetParent(this);

            while (currParent != null && ViewEmploy.Employee_page == null)
            {
                ViewEmploy.Employee_page = currParent as Frame;
                currParent = VisualTreeHelper.GetParent(currParent);
            }

            if (ViewEmploy.Employee_page != null)
            {
                AddEmploy.Department = Department;
                ViewEmploy.Employee_page.Navigate(AddEmploy);
            }
        }