Esempio n. 1
0
        private void btnAdministrateRoles_Click(object sender, RoutedEventArgs e)
        {
            if (dgOrders.SelectedIndex == -1)
            {
                MessageBox.Show("Please select an order");
                return;
            }

            ObservableCollection <object> list = (ObservableCollection <object>)dgOrders.ItemsSource;

            var order = (Order)list[dgOrders.SelectedIndex];

            AdministrateRolesWindow window = new AdministrateRolesWindow(this, order, user);

            window.ShowDialog();
        }
Esempio n. 2
0
        public CreateOrderRelationWindow(AdministrateRolesWindow administrateRolesWindow, Order order, OrderRole orderRole)
        {
            InitializeComponent();

            this.administrateRolesWindow = administrateRolesWindow;
            this.orderRole = orderRole;
            this.order     = order;

            WebserviceObject wsObj = WebserviceCalls.GetUsers();

            List <User> usersList = new List <User>();

            if (wsObj.Success)
            {
                foreach (User obj in (List <object>)wsObj.Response)
                {
                    usersList.Add(obj);
                }
            }
            else
            {
                MessageBox.Show(wsObj.Response.ToString());
            }

            ObservableCollection <object> oList = new ObservableCollection <object>(usersList);

            dgUsers.ItemsSource = oList;

            wsObj = WebserviceCalls.GetRoles();

            List <Role> rolesList = new List <Role>();

            if (wsObj.Success)
            {
                foreach (Role obj in (List <object>)wsObj.Response)
                {
                    rolesList.Add(obj);
                }
            }
            else
            {
                MessageBox.Show(wsObj.Response.ToString());
            }

            oList = new ObservableCollection <object>(rolesList);

            dgRoles.ItemsSource = oList;

            if (orderRole != null)
            {
                Title             = "TimeRegistrationApp - Update order relation";
                btnCreate.Content = "Update order relation";

                var user = usersList.Where(x => x.UserId == orderRole.UserId).FirstOrDefault();

                dgUsers.SelectedItem = user;

                var role = rolesList.Where(x => x.RoleId == orderRole.RoleId).FirstOrDefault();

                dgRoles.SelectedItem = role;

                dgUsers.IsEnabled = false;
            }
        }