Esempio n. 1
0
        private void PopulateCompanyData()
        {
            CompanyListResponse response = new CompanySQLiteRepository()
                                           .GetCompanies(null);

            List <CompanyViewModel> companies = new List <CompanyViewModel>()
            {
                new CompanyViewModel()
                {
                    CompanyName = ((string)Application.Current.FindResource("Odaberite_firmuTriTacke"))
                }
            };

            if (response.Success)
            {
                companies.AddRange(response.Companies ?? new List <CompanyViewModel>());
            }
            else
            {
                companies = new List <CompanyViewModel>()
                {
                    new CompanyViewModel()
                    {
                        CompanyName = ((string)Application.Current.FindResource("Greška_pri_učitavanju_podatakaUzvičnik"))
                    }
                };
                MainWindow.ErrorMessage = response.Message;
            }

            CompaniesFromDB           = new ObservableCollection <CompanyViewModel>(companies ?? new List <CompanyViewModel>());
            UserRolesItemForm.Company = CompaniesFromDB.FirstOrDefault();
        }
        public LoginWindow()
        {
            companyService        = DependencyResolver.Kernel.Get <ICompanyService>();
            authenticationService = DependencyResolver.Kernel.Get <IAuthenticationService>();

            InitializeComponent();

            notifier = new Notifier(cfg =>
            {
                cfg.PositionProvider = new WindowPositionProvider(
                    parentWindow: Application.Current.MainWindow,
                    corner: Corner.TopRight,
                    offsetX: 10,
                    offsetY: 10);

                cfg.LifetimeSupervisor = new TimeAndCountBasedLifetimeSupervisor(
                    notificationLifetime: TimeSpan.FromSeconds(3),
                    maximumNotificationCount: MaximumNotificationCount.FromCount(3));

                cfg.Dispatcher = Application.Current.Dispatcher;
            });

            SQLiteInitializer.Initalize(false);

            // Set company combobox
            List <CompanyViewModel> companiesFromDb = new List <CompanyViewModel>();

            try
            {
                companiesFromDb.Add(new CompanyViewModel()
                {
                    CompanyName = "Odaberite firmu", CompanyCode = 0
                });
                CompanyListResponse response = new CompanySQLiteRepository().GetCompanies();//companyService.GetCompanies();
                if (response.Success && response.Companies != null && response.Companies.Count > 0)
                {
                    companiesFromDb.AddRange(response.Companies.OrderBy(x => x.CompanyName));
                }
                else
                {
                    response = companyService.GetCompanies();
                    if (response.Success)
                    {
                        var companyTmp = response.Companies.OrderBy(x => x.CompanyName).ToList();
                        if (companyTmp != null && companyTmp.Count > 0)
                        {
                            companiesFromDb.AddRange(companyTmp);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                companiesFromDb = new List <CompanyViewModel>();
                companiesFromDb.Add(new CompanyViewModel()
                {
                    CompanyName = "Greška u povezivanju sa bazom!", CompanyCode = 0
                });
            }

            //cbxCompanies.ItemsSource = companiesFromDb;
            //cbxCompanies.SelectedIndex = 0;

            // Set focus
            txtUsername.Focus();

            InitializeUpdater();
        }
Esempio n. 3
0
        public LoginWindow()
        {
            companyService        = DependencyResolver.Kernel.Get <ICompanyService>();
            authenticationService = DependencyResolver.Kernel.Get <IAuthenticationService>();
            userService           = DependencyResolver.Kernel.Get <IUserService>();
            compUserService       = DependencyResolver.Kernel.Get <ICompanyUserService>();

            InitializeComponent();

            this.DataContext = this;

            notifier = new Notifier(cfg =>
            {
                cfg.PositionProvider = new WindowPositionProvider(
                    parentWindow: Application.Current.MainWindow,
                    corner: Corner.TopRight,
                    offsetX: 10,
                    offsetY: 10);

                cfg.LifetimeSupervisor = new TimeAndCountBasedLifetimeSupervisor(
                    notificationLifetime: TimeSpan.FromSeconds(3),
                    maximumNotificationCount: MaximumNotificationCount.FromCount(3));

                cfg.Dispatcher = Application.Current.Dispatcher;
            });

            SQLiteInitializer.Initalize(false);

            new CompanySQLiteRepository().Sync(companyService);
            new UserSQLiteRepository().Sync(userService);
            new CompanyUserSQLiteRepository().Sync(compUserService);

            // Set company combobox
            List <CompanyViewModel> companiesFromDb = new List <CompanyViewModel>();

            try
            {
                companiesFromDb.Add(new CompanyViewModel()
                {
                    CompanyName = "Odaberite firmu", CompanyCode = "0"
                });
                CompanyListResponse response = companyService.GetCompanies();
                if (response.Success && response.Companies != null && response.Companies.Count > 0)
                {
                    companiesFromDb.AddRange(response.Companies.OrderBy(x => x.CompanyName));
                }
            }
            catch (Exception ex)
            {
                CompanyListResponse response = new CompanySQLiteRepository().GetCompanies(null);//companyService.GetCompanies();
                if (response.Success && response.Companies != null && response.Companies.Count > 0)
                {
                    companiesFromDb.AddRange(response.Companies.OrderBy(x => x.CompanyName));
                }
            }

            CompaniesFromDB = new ObservableCollection <CompanyViewModel>(companiesFromDb ?? new List <CompanyViewModel>());
            CurrentCompany  = CompaniesFromDB.FirstOrDefault();
            // Set focus
            txtUsername.Focus();

            InitializeUpdater();
        }