コード例 #1
0
ファイル: mainLogIn.xaml.cs プロジェクト: mercaditu/ERP
        private void auth_Login(string u, string p)
        {
            Dispatcher.BeginInvoke((Action)(() => { this.Cursor = Cursors.AppStarting; }));
            Dispatcher.BeginInvoke((Action)(() => { progBar.IsIndeterminate = true; }));

            try
            {
                entity.Properties.Settings Settings = new entity.Properties.Settings();
                if (Settings.company_ID == 0)
                {
                    using (db db = new db())
                    {
                        Settings.company_ID = db.app_company.FirstOrDefault().id_company;
                        Settings.Save();
                    }
                }


                Cognitivo.Properties.Settings ViewSettings = new Properties.Settings();
                CurrentSession.ConnectionString = ViewSettings.MySQLconnString;
                CurrentSession.Start(u, p);

                if (CurrentSession.User != null)
                {
                    Dispatcher.BeginInvoke((Action)(() =>
                    {
                        if (chbxRemember.IsChecked == true)
                        {
                            Settings.user_UserName = tbxUser.Text;
                            Settings.Save();
                        }
                    }));

                    myWindow.is_LoggedIn = true;
                    Dispatcher.BeginInvoke((Action)(() => myFrame.Navigate(new mainMenu_Corporate())));
                }
                else
                {
                    Dispatcher.BeginInvoke((Action)(() => { tbxUser.Focus(); }));
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.InnerException.ToString(), "Cognitivo ERP", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            finally
            {
                Dispatcher.BeginInvoke((Action)(() => { this.Cursor = Cursors.Arrow; }));
                Dispatcher.BeginInvoke((Action)(() => { progBar.IsIndeterminate = false; }));
                taskAuth = null;
            }
        }
コード例 #2
0
ファイル: mainLogIn.xaml.cs プロジェクト: mercaditu/ERP
        private void check_createdb()
        {
            using (var db = new db())
            {
                bool db_exists = db.Database.Exists();

                if (!db_exists)
                {
                    Dispatcher.BeginInvoke((Action)(() => { myFrame.Navigate(new StartUp()); }));
                }
                else
                {
                    string      company_Alias = string.Empty;
                    app_company app_company   = db.app_company.Where(x => x.id_company == entity.CurrentSession.Id_Company).FirstOrDefault();

                    if (app_company != null)
                    {
                        if (!string.IsNullOrEmpty(app_company.alias))
                        {
                            company_Alias = app_company.alias;
                        }
                        else
                        {
                            company_Alias = app_company.name;
                        }
                    }

                    entity.Properties.Settings Settings = new entity.Properties.Settings();
                    Settings.company_Name = company_Alias;
                    Dispatcher.BeginInvoke((Action)(() =>
                    {
                        Settings.Save();
                    }));
                }
            }
        }