예제 #1
0
파일: Globals.cs 프로젝트: qsqurrl/TCMAP
        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();
        }
예제 #2
0
 public void EditUser(User user)
 {
     this.DataContext = user;
 }
예제 #3
0
파일: Globals.cs 프로젝트: qsqurrl/TCMAP
        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;
        }
예제 #4
0
파일: Globals.cs 프로젝트: qsqurrl/TCMAP
        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();
        }
예제 #5
0
파일: Globals.cs 프로젝트: qsqurrl/TCMAP
        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;
            }
        }
예제 #6
0
 public void AddUser(User usr)
 {
     this.DataContext = usr;
 }
예제 #7
0
 public void AddUser(bool admin, User usr)
 {
     this.DataContext = usr;
 }
예제 #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);
        }
예제 #9
0
 public void LoadUser(User usr)
 {
     usr.UserUpdated += new EventHandler(Globals.UpdateUser);
     editor.EditUser(usr);
 }