private void AddClientButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                int    id         = Convert.ToInt32(ID_textbox.Text);
                string surname    = Surname_textbox.Text;
                string name       = Name_textbox.Text;
                string patronymic = Patronymic_textbox.Text;
                string phone      = Phone_textbox.Text;
                string data       = DataBirth_textbox.Text;
                string adres      = Address_textbox.Text;
                string login      = Login_textbox.Text;
                string password   = Password_textbox.Text;

                string        connectionString = @"Data Source =.\SQLEXPRESS; Initial Catalog = FitnessCenter; Integrated Security = True";
                SqlConnection connection       = new SqlConnection(connectionString);
                connection.Open();
                string     cmdTxt  = $"INSERT INTO Clients (ID_client, Surname, Name, Patronymic, PhoneNumber, DateOfBirth, Address, Login, Password) VALUES ('{id}', '{surname}', '{name}', '{patronymic}', '{phone}', '{data}', '{adres}', '{login}', '{password}')";
                SqlCommand command = new SqlCommand(cmdTxt, connection);
                int        number  = command.ExecuteNonQuery();
                MessageBox.Show("Изменения сохранены успешно!\nВставлено объектов: " + number, "Статус действия", MessageBoxButton.OK, MessageBoxImage.Information);

                ID_textbox.Clear(); Surname_textbox.Clear(); Name_textbox.Clear(); Patronymic_textbox.Clear();
                Phone_textbox.Clear(); DataBirth_textbox.Clear(); Address_textbox.Clear(); Login_textbox.Clear();
                Password_textbox.Clear();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "ERROR!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Exemplo n.º 2
0
        private void Username_textbox_TextChanged(object sender, EventArgs e)
        {
            Password_textbox.Clear();
            string IsRemPass = string.Empty;

            IsChange = false;
            XmlNodeList xNodeList = xml.GetNodeList("UserList/UserInfo", xmlpath);

            foreach (XmlNode node in xNodeList)
            {
                if (Username_textbox.Text == node.SelectSingleNode("UserName").InnerText)
                {
                    if (node.SelectSingleNode("IsRemPass").InnerText == "true")
                    {
                        Password_textbox.Text   = node.SelectSingleNode("PassWord").InnerText;
                        remain_password.Checked = true;
                    }
                    else
                    {
                        remain_password.Checked = false;
                    }
                    if (node.SelectSingleNode("IsAutoLogin").InnerText == "true")
                    {
                        Password_textbox.Text = node.SelectSingleNode("PassWord").InnerText;
                    }
                    //xml.ChangeAttribute(node, "UserList/UserInfo", "IsLast", "false", xmlpath);
                    break;
                }
            }
            IsChange = true;
        }
        private void SingUp_button_Click(object sender, EventArgs e)
        {
            Login_textbox.Clear();
            Password_textbox.Clear();
            Guest_checkbox.Checked = false;
            Regestration reg = new Regestration(connect_sql);

            reg.ShowDialog();
        }
        private void ChangeClientButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                int    old_id         = Convert.ToInt32(ID_textbox.Text);
                string old_surname    = Surname_textbox.Text;
                string old_name       = Name_textbox.Text;
                string old_patronymic = Patronymic_textbox.Text;
                string old_phone      = Phone_textbox.Text;
                string old_data       = DataBirth_textbox.Text;
                string old_adres      = Address_textbox.Text;
                string old_login      = Login_textbox.Text;
                string old_password   = Password_textbox.Text;

                int    id         = Convert.ToInt32(NewID_textbox.Text);
                string surname    = NewSurname_textbox.Text;
                string name       = NewName_textbox.Text;
                string patronymic = NewPatronymic_textbox.Text;
                string phone      = Phone_textbox.Text;
                string data       = NewDateBirth_textbox.Text;
                string adres      = NewAddress_textbox.Text;


                string        connectionString = @"Data Source =.\SQLEXPRESS; Initial Catalog = FitnessCenter; Integrated Security = True";
                SqlConnection connection       = new SqlConnection(connectionString);
                connection.Open();

                string     cmdTxt1  = $"UPDATE Clients SET Surname = '{surname}'  WHERE ID_client = '{old_id}'";
                SqlCommand command1 = new SqlCommand(cmdTxt1, connection);
                string     cmdTxt2  = $"UPDATE Clients SET Name = '{name}'  WHERE ID_client = '{old_id}'";
                SqlCommand command2 = new SqlCommand(cmdTxt2, connection);
                string     cmdTxt3  = $"UPDATE Clients SET Patronymic = '{patronymic}'  WHERE ID_client = '{old_id}'";
                SqlCommand command3 = new SqlCommand(cmdTxt3, connection);
                string     cmdTxt4  = $"UPDATE Clients SET PhoneNumber = '{phone}'  WHERE ID_client = '{old_id}'";
                SqlCommand command4 = new SqlCommand(cmdTxt4, connection);
                string     cmdTxt5  = $"UPDATE Clients SET DateOfBirth = '{data}'  WHERE ID_client = '{old_id}'";
                SqlCommand command5 = new SqlCommand(cmdTxt5, connection);
                string     cmdTxt6  = $"UPDATE Clients SET Address = '{adres}'  WHERE ID_client = '{old_id}'";
                SqlCommand command6 = new SqlCommand(cmdTxt6, connection);

                command1.ExecuteNonQuery(); command2.ExecuteNonQuery(); command3.ExecuteNonQuery(); command4.ExecuteNonQuery(); command5.ExecuteNonQuery(); command6.ExecuteNonQuery();
                MessageBox.Show("Изменения сохранены успешно!", "Статус действия", MessageBoxButton.OK, MessageBoxImage.Information);


                ID_textbox.Clear(); Surname_textbox.Clear(); Name_textbox.Clear(); Patronymic_textbox.Clear();
                Phone_textbox.Clear(); DataBirth_textbox.Clear(); Address_textbox.Clear(); Login_textbox.Clear();
                Password_textbox.Clear();
                NewID_textbox.Clear(); NewSurname_textbox.Clear(); NewName_textbox.Clear(); NewPatronymic_textbox.Clear();
                NewPhone_textbox.Clear(); NewDateBirth_textbox.Clear(); NewAddress_textbox.Clear();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "ERROR!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
 private void Guest_checkbox_CheckedChanged(object sender, EventArgs e)
 {
     if (Guest_checkbox.Checked == true)
     {
         Login_textbox.Clear();
         Password_textbox.Clear();
         Login_textbox.Enabled    = false;
         Password_textbox.Enabled = false;
     }
     else
     {
         Login_textbox.Enabled    = true;
         Password_textbox.Enabled = true;
     }
 }
Exemplo n.º 6
0
 private void Login_Button_Click(object sender, RoutedEventArgs e)
 {
     if (database.verifyUser(Username_textbox.Text.Trim(),
                             Password_textbox.Password.ToString().Trim()))
     {
         homePage = new HomePage();
         homePage.StartPage(Username_textbox.Text, database);
         this.Close();
     }
     else
     {
         Username_textbox.Clear();
         Password_textbox.Clear();
         status.Text = "Wrong username or password.";
     }
 }
        private void DeleteClientButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                int id = Convert.ToInt32(ID_textbox.Text);

                string        connectionString = @"Data Source =.\SQLEXPRESS; Initial Catalog = FitnessCenter; Integrated Security = True";
                SqlConnection connection       = new SqlConnection(connectionString);
                connection.Open();
                string     cmdTxt  = $"DELETE FROM Clients WHERE ID_client = '{id}'";
                SqlCommand command = new SqlCommand(cmdTxt, connection);
                int        number  = command.ExecuteNonQuery();
                MessageBox.Show("Изменения сохранены успешно!\nУдалено объектов: " + number, "Статус действия", MessageBoxButton.OK, MessageBoxImage.Information);

                ID_textbox.Clear(); Surname_textbox.Clear(); Name_textbox.Clear(); Patronymic_textbox.Clear();
                Phone_textbox.Clear(); DataBirth_textbox.Clear(); Address_textbox.Clear(); Login_textbox.Clear();
                Password_textbox.Clear();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "ERROR!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Exemplo n.º 8
0
 private void label4_Click(object sender, EventArgs e)
 {
     Email_textbox.Clear();
     Password_textbox.Clear();
     Email_textbox.Focus();
 }
 private void Enter_button_Click(object sender, EventArgs e)
 {
     if (Guest_checkbox.Checked == true)
     {
         Add_form add = new Add_form(connect_sql);
         add.ShowDialog();
         Guest_checkbox.Checked = false;
     }
     else if (Guest_checkbox.Checked == false)
     {
         if (Login_textbox.Text.Length == 0 && Password_textbox.Text.Length != 0)
         {
             MessageBox.Show("Поле 'Логін' не заповнено!", "Помилка", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         else if (Login_textbox.Text.Length != 0 && Password_textbox.Text.Length == 0)
         {
             MessageBox.Show("Поле 'Пароль' не заповнено!", "Помилка", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         else if (Login_textbox.Text.Length == 0 && Password_textbox.Text.Length == 0)
         {
             MessageBox.Show("Поля 'Логін' і 'Пароль' не заповнено!", "Помилка", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         else if (Password_textbox.Text.Length != 0 && Login_textbox.Text.Length != 0)
         {
             SqlCommand command_sql = connect_sql.CreateCommand();
             command_sql.CommandType = CommandType.Text;
             string access;
             command_sql.CommandText = "SELECT COUNT(*) FROM Таблиця_входу WHERE Логін = '" + Login_textbox.Text + "'and Пароль =  '" + Password_textbox.Text + "';";
             command_sql.ExecuteNonQuery();
             string res   = command_sql.ExecuteScalar().ToString();
             int    count = Convert.ToInt32(res);
             if (count == 1)
             {
                 command_sql.CommandText = "SELECT Рівень_доступу FROM Таблиця_входу WHERE Логін = '" + Login_textbox.Text + "'and Пароль =  '" + Password_textbox.Text + "';";
                 access = command_sql.ExecuteScalar().ToString();
                 main_menu menu = new main_menu(connect_sql);
                 MainForm  main = new MainForm(connect_sql);
                 Add_form  add  = new Add_form(connect_sql);
                 if (access == "Високий")
                 {
                     menu.enter_level(access);
                     main.enter_level(access);
                     menu.ShowDialog();
                 }
                 if (access == "Середній")
                 {
                     menu.enter_level(access);
                     main.enter_level(access);
                     menu.ShowDialog();
                 }
                 if (access == "Низький")
                 {
                     menu.enter_level(access);
                     main.enter_level(access);
                     add.ShowDialog();
                 }
                 Login_textbox.Clear();
                 Password_textbox.Clear();
             }
             else
             {
                 Password_textbox.Clear();
                 MessageBox.Show("Невірний логін чи пароль!", "Помилка", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
         }
     }
 }