Exemplo n.º 1
0
        /// <summary>
        /// Set primary content to display
        /// </summary>
        private void setContentDataGrid()
        {
            try
            {
                currentDataGrid.Tag = dataGridTag;
                dynamic obj = null;
                dynamic sourceDataGrid = null;
                switch (dataGridTag)
                {
                    case "Products":
                        var products = conn.Products.Where(a=> a.IsAlive).ToList();
                        currentDataGrid.ItemsSource = sourceDataGrid = products;
                        obj = new Product();
                        break;
                    case "Clients":
                        var clients = conn.Clients.Where(a => a.IsAlive).ToList();
                        currentDataGrid.ItemsSource = sourceDataGrid = clients;
                        obj = new Client();
                        break;
                    case "Providers":
                        var providers = conn.Providers.Where(a => a.IsAlive).ToList();
                        currentDataGrid.ItemsSource = sourceDataGrid = providers;
                        obj = new Provider();
                        break;
                    case "Users":
                        var users = conn.Users.Where(a => a.IsAlive).ToList();
                        currentDataGrid.ItemsSource = sourceDataGrid = users;
                        collectionViewSource.Source = new[]
                            {
                                new { ID = 0 , Name = "Administrador"  },
                                new { ID = 1 , Name = "Vendedor de mostrador"  }
                            }.ToList();
                        obj = new User();
                        break;
                }
                if (currentDataGrid.Items.Count <= 1)
                {
                    sourceDataGrid = currentDataGrid.ItemsSource;
                    sourceDataGrid.Add(obj);
                }
            }
            catch (Exception exc)
            {
                System.Text.StringBuilder message = new System.Text.StringBuilder();

                message.Append(exc.Message);

                if (exc.InnerException != null)
                {
                    message.Append("\n" + exc.InnerException.Message);
                }

                displayText(message.ToString(), false);
            }
            finally
            {
                GC.Collect();
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Inititalize new instance of current window
 /// </summary>
 public AccountStatus(Window window, Client client)
 {
     this.Client = client;
     this.Owner = Owner;
     InitializeComponent();
 }