Ejemplo n.º 1
0
        public static void FirstInit()
        {
            LoadSettings();
            db.FirstRun = true;

            db.Open();

            db.CreateDatabase(appSettings.ServerDatabase);
            db.FirstRun = false;
            db.Open();
            CreateTables();
            db.CreatedStoredProcs();

            User uxml = new User();

            uxml = db.FindUser("admin");

            if (object.ReferenceEquals(uxml, null))
                CreateAdmin();

            db.FirstRun = false;
            db.Close();
            db.Open();
            uxml.Dispose();
        }
Ejemplo n.º 2
0
 public void EditUser(User user)
 {
     this.DataContext = user;
 }
Ejemplo n.º 3
0
        public static LoginResult LoginUser(string username, string password)
        {
            oRep = db.FindUser(username);

            if (object.ReferenceEquals(oRep, null))
                return LoginResult.UserNotFound;

            if (oRep.ValidatePassword(password))
                return LoginResult.Success;
            else
                oRep = new User();

            password = string.Empty; // Clear password variable
            return LoginResult.InvalidPassword;
        }
Ejemplo n.º 4
0
        private static void CreateAdmin()
        {
            User rp = new User();

            rp.FirstName = "Admin";
            rp.LastName = "Admin";
            rp.isAdmin = true;
            rp.Username = "******";
            rp.Password = Password.CreateHash("password");

            rp.UserUpdated += new EventHandler(UpdateUser);
            rp.PerformUpdate();

            rp.Dispose();
        }
Ejemplo n.º 5
0
        public static bool LoadUser(string username, out User rp)
        {
            User r = new User();

            r = db.FindUser(username);

            rp = r;

            if (object.ReferenceEquals(r, null))
            {
                r.Dispose();
                return false;
            }
            else
            {
                //r.Dispose();
                return true;
            }
        }
Ejemplo n.º 6
0
 public void AddUser(User usr)
 {
     this.DataContext = usr;
 }
Ejemplo n.º 7
0
 public void AddUser(bool admin, User usr)
 {
     this.DataContext = usr;
 }
Ejemplo n.º 8
0
        private void CreateForm(User obj)
        {
            List<User> objList = new List<User>();

            objList.Add(obj);
            Grid rootGrid = new Grid();
            rootGrid.Margin = new Thickness(10.0);

            rootGrid.ColumnDefinitions.Add(
               new ColumnDefinition() { Width = new GridLength(100.0) });
            rootGrid.ColumnDefinitions.Add(
                 new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) });

            rootGrid.ColumnDefinitions.Add(
                new ColumnDefinition() { Width = new GridLength(100.0) });
            rootGrid.ColumnDefinitions.Add(
                   new ColumnDefinition() { Width = new GridLength(100.0) });

            PropertyInfo[] propertyInfos;
            propertyInfos = typeof(User).GetProperties();
            rootGrid.RowDefinitions.Add(CreateRowDefinition());
            int j = 1;

            foreach (PropertyInfo propertyInfo in propertyInfos)
            {
                if (propertyInfo.PropertyType.Name == "String")
                {

                    rootGrid.RowDefinitions.Add(CreateRowDefinition());

                    var Label = CreateTextBlock(propertyInfo.Name, j, 0);
                    rootGrid.Children.Add(Label);

                    var Textbox = CreateTextBox(j, 1);
                    rootGrid.Children.Add(Textbox);
                    j++;
                }
                if (propertyInfo.PropertyType.Name == "Boolean")
                {
                    rootGrid.RowDefinitions.Add(CreateRowDefinition());

                    var Label = CreateTextBlock(propertyInfo.Name, j, 0);
                    rootGrid.Children.Add(Label);

                    var Textbox = CreateCheckBox(j, 1);
                    rootGrid.Children.Add(Textbox);
                    j++;
                }

            }
            rootGrid.RowDefinitions.Add(CreateRowDefinition());
            var Button = CreateButton("Save", j + 1, 1);
            Button.Click += new RoutedEventHandler(button_Click);

            rootGrid.Children.Add(Button);
            LayoutRoot.Children.Add(rootGrid);
        }
Ejemplo n.º 9
0
 public void LoadUser(User usr)
 {
     usr.UserUpdated += new EventHandler(Globals.UpdateUser);
     editor.EditUser(usr);
 }