Exemplo n.º 1
0
        private void authB_Click(object sender, EventArgs e)
        {
            if (loginTB.Text == "" || passTB.Text == "")
            {
                errorLabel.Visible = true;
                return;
            }
            waitLabel.Visible = true;
            Refresh();
            authB.Enabled = false;
            var res = Model.Authorization(loginTB.Text, passTB.Text);
            if (res)
            {
                var user = Model.Instance.Users.SingleOrDefault(a => a.AspnetUserLogin == loginTB.Text);
                if (user == null)
                {
                    var uu = Model.Instance.client.GetUserFromLogin(loginTB.Text);
                    var coach = Model.Instance.Users.SingleOrDefault(a => a.ID == uu.CoachId);
                    if (uu.CoachId != 0)
                    {
                        if (coach == null)
                        {
                            var u = Model.Instance.client.GetUserFromId(uu.CoachId);
                            var aspnetuser = Model.Instance.client.Getaspnet_Users(u.AspnetUserId);
                            coach = new User(u.Id, u.FirstName, u.Name, u.Patronumic, u.DateBirth, aspnetuser.UserName, u.AspnetUserId, u.Right, null, null);
                            Model.Instance.Users.Add(coach);
                        }
                    }
                    user = new User(uu.Id, uu.FirstName, uu.Name, uu.Patronumic, uu.DateBirth, loginTB.Text, uu.AspnetUserId, uu.Right, coach, passTB.Text);
                    Model.Instance.Users.Add(user);
                }
                Model.Instance.CurrentUser = user;
                Model.Instance.Synchronization();
                user.UpdatePass(passTB.Text);
                Form form;
                if (user.Right == 2)
                    form = new Form_Input_Admin();
                else// if (user.Right == 1)
                    form = new Form_Input();
                Hide();
                form.ShowDialog();
                Close();
            } // переход на главную форму
            if (!res)
            {
                errorLabel.Visible = true;

                waitLabel.Visible = false;
                Refresh();
                authB.Enabled = true;
            }
        }
Exemplo n.º 2
0
        private void RegB_Click(object sender, EventArgs e)
        {
            if (Validation())
            {
                try
                {
                    RegB.Enabled = false;
                    waitLabel.Visible = true;
                    Refresh();
                    MembershipCreateStatus status;
                    var res = Model.Instance.client.AddUser(out status, SecondNameTB.Text, NameTB.Text, LastNameTB.Text, DataBirthDTP.Value, LoginTB.Text, PassTB.Text, (CoachCB.SelectedItem as ComboBoxItem).Id);
                    if (status == MembershipCreateStatus.Success)
                    {
                        var coach = Model.Instance.Users.SingleOrDefault(a => a.ID == res.CoachId);
                        if (res.CoachId != 0)
                        {
                            if (coach == null)
                            {
                                var u = Model.Instance.client.GetUserFromId(res.CoachId);
                                var aspnetuser = Model.Instance.client.Getaspnet_Users(res.AspnetUserId);
                                coach = new User(u.Id, u.FirstName, u.Name, u.Patronumic, u.DateBirth, aspnetuser.UserName, u.AspnetUserId, u.Right, null, null);
                                Model.Instance.Users.Add(coach);
                            }
                        }
                        Model.Instance.Users.Add(new User(res.Id, res.FirstName, res.Name, res.Patronumic, res.DateBirth, LoginTB.Text, res.AspnetUserId, res.Right, coach, PassTB.Text));

                    }
                    else if (status == MembershipCreateStatus.DuplicateUserName)
                    {
                        RegB.Enabled = true;
                        waitLabel.Visible = false;
                        Refresh();
                        MessageBox.Show("Данный логин уже используется в системе.");
                        return;
                    }
                    Model.Instance.SaveBinaryFormat();
                    MessageBox.Show("Вы успешно зарегистрировались!");
                    Close();
                }
                catch (Exception ee)
                {
                    MessageBox.Show("Регистрация не удалась.");
                    RegB.Enabled = true;
                    waitLabel.Visible = false;
                }

            }
        }
Exemplo n.º 3
0
 public void Update(string firstName, string name, string patronymic, DateTime dateBirth, string userLogin, Guid userId, byte right, User coach)
 {
     _firstName = firstName;
     _name = name;
     _patronumic = patronymic;
     _dateBirth = dateBirth;
     _aspnetUserLogin = userLogin;
     _aspnetUserId = userId;
     _right = right;
     _userCoach = coach;
 }
Exemplo n.º 4
0
 public User(int id, string firstName, string name, string patronymic, DateTime dateBirth, string userLogin, Guid userId, byte right, User coach, string pass)
 {
     _id = id;
     _firstName = firstName;
     _name = name;
     _patronumic = patronymic;
     _dateBirth = dateBirth;
     _aspnetUserLogin = userLogin;
     _aspnetUserId = userId;
     _right = right;
     _userCoach = coach;
     _pass = pass;
 }
Exemplo n.º 5
0
 public void Update(double value, Discipline discipline, int periodDays, string description, User owner)
 {
     _value = value;
     _discipline = discipline;
     _periodDays = periodDays;
     _description = description;
     _owner = owner;
 }
Exemplo n.º 6
0
 public Goal(int id, double value, Discipline discipline, short periodDays, string description, User owner)
 {
     if (id == 0)
     {
         try
         {
             var res = Model.Instance.client.AddGoal(discipline.ID, periodDays, value, description, owner.ID);
             _id = res.Id;
         }
         catch (Exception e)
         {
             _id = --lastID;
         }
     }
     else
         _id = id;
     _value = value;
     _discipline = discipline;
     _periodDays = periodDays;
     _description = description;
     _owner = owner;
 }
Exemplo n.º 7
0
 public void Update(User user, Goal goal, DateTime dateStart)
 {
     _user = user;
     _goal = goal;
     _dateStart = dateStart;
 }
Exemplo n.º 8
0
 public User_Goal(int id, User user, Goal goal, DateTime dateStart)
 {
     if (id == 0)
     {
         var res = Model.Instance.client.AddUsers_Goals(user.ID, goal.ID, dateStart);
         _id = res.Id;
     }
     else
         _id = id;
     _user = user;
     _goal = goal;
     _dateStart = dateStart;
 }