public UserCabinet()
        {
            InitializeComponent();
            Password.PasswordChar        = '*';
            Oldpassword.PasswordChar     = '*';
            Confirmpassword.PasswordChar = '*';
            Sex.DropDownStyle            = ComboBoxStyle.DropDownList;

            InsertLinq insertLinq = new InsertLinq();

            var persons = insertLinq.GetPeople();

            #region Load User information
            foreach (var person in persons)
            {
                if (person.Hash == LoginForm.Counter)
                {
                    Surname.Text     = person.SurName;
                    NamePerson.Text  = person.Name;
                    SecondName.Text  = person.SecondName;
                    Age.Text         = person.Age.ToString();
                    Sex.Text         = person.Sex;
                    PhoneNumber.Text = person.PhoneNumber.ToString();
                    CityField.Text   = person.City;
                    Login            = person.Login;
                    Email.Text       = person.Email;
                }
            }
            #endregion
        }
Exemple #2
0
        private void Enter_Click(object sender, EventArgs e)
        {
            InsertLinq insertLinq = new InsertLinq();
            var        persons    = insertLinq.GetPeople();
            Exception  error      = new Exception();

            #region Сhecking the existence of the account
            try
            {
                foreach (var person in persons)
                {
                    if ((Login.Text + Password.Text).GetHashCode() == person.Hash)
                    {
                        Counter = (Login.Text + Password.Text).GetHashCode();
                        MenuForm menuform = new MenuForm();
                        Hide();
                        menuform.Show();
                    }
                }

                throw error;
            }
            catch
            {
                ErrorUser.Visible = true;
                ErrorUser.Text    = ("Користувача з таким логіном і паролем не знайдено");
                Login.Text        = "";
            }
            #endregion
        }
        public FlightForm()
        {
            InitializeComponent();

            var companys = insertLinq.GetCompany();
            var persons  = insertLinq.GetPeople();

            //Загрузка доступеих компаній та типів номерів з БД
            foreach (var company in companys)
            {
                TCompany.Items.Add(company.Company);
            }
            foreach (var person in persons)
            {
                if (person.Hash == LoginForm.Counter)
                {
                    SurnameField.Text = person.SurName;
                    NameField.Text    = person.Name;
                    From.Text         = person.City;
                }
            }
        }
Exemple #4
0
        public HotelForm()
        {
            InitializeComponent();
            var hotels = insertLinq.GetHotelList();
            var rooms  = insertLinq.GetRoomsList();
            var people = insertLinq.GetPeople();

            foreach (var h in hotels)
            {
                HotelName.Items.Add(h.HotelName);
            }
            foreach (var r in rooms)
            {
                RoomFormat.Items.Add(r.RoomType);
            }
            foreach (var p in people)
            {
                if (p.Hash == LoginForm.Counter)
                {
                    Person.Text = p.Name + " " + p.SurName + " " + p.SecondName;
                }
            }
        }
        private void Registration_Click(object sender, EventArgs e)
        {
            int Counter = 0;

            Error.Text = "";
            InsertLinq insertLinq = new InsertLinq();
            Exception  error      = new Exception();

            //Geting all users
            var persons = insertLinq.GetPeople();

            try
            {
                foreach (var person in persons)
                {
                    if (Login.Text == person.Login)
                    {
                        Counter = 0;
                        throw error;
                    }
                }
                if (Password.Text == Confirmpassword.Text)
                {
                    #region Creating new user
                    Person p = new Person()
                    {
                        Login       = Login.Text,
                        Hash        = Convert.ToInt32((Login.Text + Password.Text).GetHashCode()),
                        SurName     = Surname.Text,
                        Name        = NamePerson.Text,
                        SecondName  = SecondName.Text,
                        Age         = Convert.ToInt32(Age.Text),
                        Sex         = Sex.SelectedItem.ToString(),
                        PhoneNumber = PhoneNumber.Text,
                        City        = CityField.Text,
                        Email       = Email.Text
                    };
                    #endregion

                    #region Validation
                    //Валідація всіх заповнених полів
                    var results = new List <ValidationResult>();
                    var context = new ValidationContext(p);
                    if (!Validator.TryValidateObject(p, context, results, true))
                    {
                        foreach (var oo in results)
                        {
                            Error.Text += " *" + oo.ErrorMessage + "*\n";
                        }
                    }
                    else
                    {
                        insertLinq.Insert(p);
                        Hide();
                        loginform.Show();
                    }
                    #endregion
                }
                else
                {
                    Counter = 2; throw error;
                }
            }
            catch
            {
                if (Counter == 0)
                {
                    Error.Text = "Користувач з таким іменем вже існує";
                }
                else
                {
                    if (Counter == 2)
                    {
                        Error.Text = "Паролі не спывпадають";
                    }
                    else
                    {
                        Error.Text = ("Перевірте чи всі поля заповнені");
                    }
                }
            }
        }