Example #1
0
        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
        }
Example #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
        }
Example #3
0
        private void SaveChanges_Click(object sender, EventArgs e)
        {
            InsertLinq insertLinq = new InsertLinq();

            if (Oldpassword.Text != "")
            {
                int h = (Login + Oldpassword.Text).GetHashCode();
                if (h == LoginForm.Counter)
                {
                    if (Password.Text == Confirmpassword.Text)
                    {
                        int Hash = (Login + Password.Text).GetHashCode();
                        insertLinq.Change(Hash, Surname.Text, NamePerson.Text, SecondName.Text, Age.Text, Sex.Text, PhoneNumber.Text, CityField.Text, Email.Text);
                        MenuForm menuForm = new MenuForm();
                        Hide();
                        menuForm.Show();
                    }
                }
            }
            else
            {
                Person p = new Person()
                {
                    Login       = "******",
                    Hash        = 1,
                    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
                };
                #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.Change(Surname.Text, NamePerson.Text, SecondName.Text, Age.Text, Sex.Text, PhoneNumber.Text, CityField.Text, Email.Text);
                    MenuForm menuForm = new MenuForm();
                    Hide();
                    menuForm.Show();
                }
                #endregion
            }
        }
Example #4
0
        public ValidationHotel()
        {
            InitializeComponent();
            InsertLinq insertLinq = new InsertLinq();
            var        hotel      = insertLinq.GetHotel();

            foreach (var h in hotel)
            {
                if (h.HName + h.HNameHotel + h.HRoomFormat + h.HFrom + h.HTo == HotelForm.Counter)
                {
                    HotelName.Text  = h.HNameHotel;
                    RoomFormat.Text = h.HRoomFormat;
                    Date.Text       = h.HFrom + "-" + h.HTo;
                    Person.Text     = h.HName;
                }
            }
        }
        public ValidationTicket()
        {
            InitializeComponent();
            InsertLinq insertLinq = new InsertLinq();

            var tickets = insertLinq.GetTickets();

            foreach (var ticket in tickets)
            {
                if ((ticket.TName + ticket.TFrom + ticket.TTo + ticket.TDateFlight) == FlightForm.Counter)
                {
                    NameofPassenger.Text = ticket.TName;
                    From.Text            = ticket.TFrom;
                    To.Text           = ticket.TTo;
                    Date.Text         = ticket.TDateFlight;
                    FlightNumber.Text = ticket.TFlightNumber;
                    Seat.Text         = ticket.TSeat;
                    Gate.Text         = ticket.TGate;
                }
            }
        }
        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 = ("Перевірте чи всі поля заповнені");
                    }
                }
            }
        }