Beispiel #1
0
        private void AddButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                int    id      = Convert.ToInt32(ID_tb.Text);
                string date    = Date_tb.Text;
                string start   = Start_tb.Text;
                string end     = End_tb.Text;
                int    clas    = Convert.ToInt32(Class_tb.Text);
                int    room    = Convert.ToInt32(Room_tb.Text);
                int    trainer = Convert.ToInt32(Trainer_tb.Text);
                string info    = Info_tb.Text;

                string        connectionString = @"Data Source =.\SQLEXPRESS; Initial Catalog = FitnessCenter; Integrated Security = True";
                SqlConnection connection       = new SqlConnection(connectionString);
                connection.Open();
                string     cmdTxt  = $"INSERT INTO Schedule (ID_lesson, Date, StartTime, EndTime, ID_class, ID_room, ID_trainer, Information) VALUES ('{id}', '{date}', '{start}',  '{end}',  '{clas}',  '{room}',  '{trainer}',  '{info}')";
                SqlCommand command = new SqlCommand(cmdTxt, connection);
                int        number  = command.ExecuteNonQuery();
                MessageBox.Show("Изменения сохранены успешно!\nВставлено объектов: " + number, "Статус действия", MessageBoxButton.OK, MessageBoxImage.Information);

                ID_tb.Clear(); Date_tb.Clear(); Start_tb.Clear(); End_tb.Clear(); Class_tb.Clear(); Room_tb.Clear(); Trainer_tb.Clear(); Info_tb.Clear();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "ERROR!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
        private void AddButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                int    id     = Convert.ToInt32(ID_tb.Text);
                int    client = Convert.ToInt32(Client_tb.Text);
                int    abon   = Convert.ToInt32(Abon_tb.Text);
                string start  = Start_tb.Text;
                string end    = End_tb.Text;

                string        connectionString = @"Data Source =.\SQLEXPRESS; Initial Catalog = FitnessCenter; Integrated Security = True";
                SqlConnection connection       = new SqlConnection(connectionString);
                connection.Open();
                string     cmdTxt  = $"INSERT INTO AbonnementsSales (ID_card, ID_client, ID_abonnement, StartDate, EndDate) VALUES ('{id}', '{client}', '{abon}',  '{start}',  '{end}')";
                SqlCommand command = new SqlCommand(cmdTxt, connection);
                int        number  = command.ExecuteNonQuery();
                MessageBox.Show("Изменения сохранены успешно!\nВставлено объектов: " + number, "Статус действия", MessageBoxButton.OK, MessageBoxImage.Information);

                ID_tb.Clear(); Client_tb.Clear(); Abon_tb.Clear(); Start_tb.Clear(); End_tb.Clear();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "ERROR!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Beispiel #3
0
        private void ChangeButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                int    id    = Convert.ToInt32(ID_tb.Text);
                string login = Login_tb.Text;
                string pass  = Password_tb.Text;

                int    newid    = Convert.ToInt32(ID_tb_Copy.Text);
                string newlogin = Login_tb_Copy.Text;
                string newpass  = Password_tb_Copy.Text;

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

                string     cmdTxt1  = $"UPDATE Administrators SET Login = '******'  WHERE ID_admin = '{id}'";
                SqlCommand command1 = new SqlCommand(cmdTxt1, connection);
                string     cmdTxt2  = $"UPDATE Administrators SET Password = '******'  WHERE ID_admin = '{id}'";
                SqlCommand command2 = new SqlCommand(cmdTxt2, connection);

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

                ID_tb.Clear(); Login_tb.Clear(); Password_tb.Clear();
                ID_tb_Copy.Clear(); Login_tb_Copy.Clear(); Password_tb_Copy.Clear();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "ERROR!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
        private void ChangeButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                int    id       = Convert.ToInt32(ID_tb.Text);
                string surname  = Surname_tb.Text;
                string name     = Name_tb.Text;
                string patronym = Patronym_tb.Text;
                string date     = Date_tb.Text;
                string adres    = Adres_tb.Text;
                string phone    = Phone_tb.Text;
                string salary   = Salary_tb.Text;
                string spec     = Spec_tb.Text;

                int    newid       = Convert.ToInt32(ID_tb_Copy.Text);
                string newsurname  = Surname_tb_Copy.Text;
                string newname     = Name_tb_Copy.Text;
                string newpatronym = Patronym_tb_Copy.Text;
                string newdate     = Date_tb_Copy.Text;
                string newadres    = Adres_tb_Copy.Text;
                string newphone    = Phone_tb_Copy.Text;
                string newsalary   = Salary_tb_Copy.Text;
                string newspec     = Spec_tb_Copy.Text;


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

                string     cmdTxt1  = $"UPDATE Trainers SET Surname = '{newsurname}'  WHERE ID_trainer = '{id}'";
                SqlCommand command1 = new SqlCommand(cmdTxt1, connection);
                string     cmdTxt2  = $"UPDATE Trainers SET Name = '{newname}'  WHERE ID_trainer = '{id}'";
                SqlCommand command2 = new SqlCommand(cmdTxt2, connection);
                string     cmdTxt3  = $"UPDATE Trainers SET Patronymic = '{newpatronym}'  WHERE ID_trainer = '{id}'";
                SqlCommand command3 = new SqlCommand(cmdTxt3, connection);
                string     cmdTxt4  = $"UPDATE Trainers SET DateOfBirth = '{newdate}'  WHERE ID_trainer = '{id}'";
                SqlCommand command4 = new SqlCommand(cmdTxt4, connection);
                string     cmdTxt5  = $"UPDATE Trainers SET Address = '{newadres}'  WHERE ID_trainer = '{id}'";
                SqlCommand command5 = new SqlCommand(cmdTxt5, connection);
                string     cmdTxt6  = $"UPDATE Trainers SET PhoneNumber = '{newphone}'  WHERE ID_trainer = '{id}'";
                SqlCommand command6 = new SqlCommand(cmdTxt6, connection);
                string     cmdTxt7  = $"UPDATE Trainers SET Salary = '{newsalary}'  WHERE ID_trainer = '{id}'";
                SqlCommand command7 = new SqlCommand(cmdTxt7, connection);
                string     cmdTxt8  = $"UPDATE Trainers SET Specialization = '{newspec}'  WHERE ID_trainer = '{id}'";
                SqlCommand command8 = new SqlCommand(cmdTxt8, connection);


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


                ID_tb.Clear(); Date_tb.Clear(); Name_tb.Clear(); Patronym_tb.Clear(); Adres_tb.Clear(); Phone_tb.Clear(); Salary_tb.Clear(); Spec_tb.Clear(); Surname_tb.Clear();
                ID_tb_Copy.Clear(); Date_tb_Copy.Clear(); Name_tb_Copy.Clear(); Patronym_tb_Copy.Clear(); Adres_tb_Copy.Clear(); Phone_tb_Copy.Clear(); Salary_tb_Copy.Clear(); Spec_tb_Copy.Clear(); Surname_tb_Copy.Clear();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "ERROR!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
        private void AddButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                int    id       = Convert.ToInt32(ID_tb.Text);
                string surname  = Surname_tb.Text;
                string name     = Name_tb.Text;
                string patronym = Patronym_tb.Text;
                string date     = Date_tb.Text;
                string adres    = Adres_tb.Text;
                string phone    = Phone_tb.Text;
                string salary   = Salary_tb.Text;
                string spec     = Spec_tb.Text;

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

                ID_tb.Clear(); Date_tb.Clear(); Name_tb.Clear(); Patronym_tb.Clear(); Adres_tb.Clear(); Phone_tb.Clear(); Salary_tb.Clear(); Spec_tb.Clear(); Surname_tb.Clear();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "ERROR!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Beispiel #6
0
        private void ChangeButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                int    id      = Convert.ToInt32(ID_tb.Text);
                string date    = Date_tb.Text;
                string start   = Start_tb.Text;
                string end     = End_tb.Text;
                int    clas    = Convert.ToInt32(Class_tb.Text);
                int    room    = Convert.ToInt32(Room_tb.Text);
                int    trainer = Convert.ToInt32(Trainer_tb.Text);
                string info    = Info_tb.Text;

                int    newid      = Convert.ToInt32(NewID_tb.Text);
                string newdate    = NewDate_tb.Text;
                string newstart   = NewStart_tb.Text;
                string newend     = NewEnd_tb.Text;
                int    newclas    = Convert.ToInt32(NewClass_tb.Text);
                int    newroom    = Convert.ToInt32(NewRoom_tb.Text);
                int    newtrainer = Convert.ToInt32(NewTrainer_tb.Text);
                string newinfo    = NewInfo_tb.Text;


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

                string     cmdTxt1  = $"UPDATE Schedule SET Date = '{newdate}'  WHERE ID_lesson = '{id}'";
                SqlCommand command1 = new SqlCommand(cmdTxt1, connection);
                string     cmdTxt2  = $"UPDATE Schedule SET StartTime = '{newstart}'  WHERE ID_lesson = '{id}'";
                SqlCommand command2 = new SqlCommand(cmdTxt2, connection);
                string     cmdTxt3  = $"UPDATE Schedule SET EndTime = '{newend}'  WHERE ID_lesson = '{id}'";
                SqlCommand command3 = new SqlCommand(cmdTxt3, connection);
                string     cmdTxt4  = $"UPDATE Schedule SET ID_class = '{newclas}'  WHERE ID_lesson = '{id}'";
                SqlCommand command4 = new SqlCommand(cmdTxt4, connection);
                string     cmdTxt5  = $"UPDATE Schedule SET ID_class = '{newclas}'  WHERE ID_lesson = '{id}'";
                SqlCommand command5 = new SqlCommand(cmdTxt5, connection);
                string     cmdTxt6  = $"UPDATE Schedule SET ID_class = '{newclas}'  WHERE ID_lesson = '{id}'";
                SqlCommand command6 = new SqlCommand(cmdTxt6, connection);
                string     cmdTxt7  = $"UPDATE Schedule SET ID_class = '{newclas}'  WHERE ID_lesson = '{id}'";
                SqlCommand command7 = new SqlCommand(cmdTxt7, connection);


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


                ID_tb.Clear(); Date_tb.Clear(); Start_tb.Clear(); End_tb.Clear(); Class_tb.Clear(); Room_tb.Clear(); Trainer_tb.Clear(); Info_tb.Clear();
                NewID_tb.Clear(); NewDate_tb.Clear(); NewStart_tb.Clear(); NewEnd_tb.Clear(); NewClass_tb.Clear(); NewRoom_tb.Clear(); NewTrainer_tb.Clear(); NewInfo_tb.Clear();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "ERROR!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
        private void ChangeButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                int    id     = Convert.ToInt32(ID_tb.Text);
                int    client = Convert.ToInt32(Client_tb.Text);
                int    abon   = Convert.ToInt32(Abon_tb.Text);
                string start  = Start_tb.Text;
                string end    = End_tb.Text;

                int    newid     = Convert.ToInt32(NewID_tb.Text);
                int    newclient = Convert.ToInt32(NewClient_tb.Text);
                int    newabon   = Convert.ToInt32(NewAbon_tb.Text);
                string newstart  = NewStart_tb.Text;
                string newend    = NewEnd_tb.Text;


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

                string     cmdTxt1  = $"UPDATE AbonnementaSales SET ID_client = '{newclient}'  WHERE ID_card = '{id}'";
                SqlCommand command1 = new SqlCommand(cmdTxt1, connection);
                string     cmdTxt2  = $"UPDATE AbonnementsSales SET ID_abonnement = '{newabon}'  WHERE ID_card = '{id}'";
                SqlCommand command2 = new SqlCommand(cmdTxt2, connection);
                string     cmdTxt3  = $"UPDATE AbonnemensSales SET StartDate = '{newstart}'  WHERE ID_card = '{id}'";
                SqlCommand command3 = new SqlCommand(cmdTxt3, connection);
                string     cmdTxt4  = $"UPDATE AbonnemensSales SET EndDate = '{newend}'  WHERE ID_card = '{id}'";
                SqlCommand command4 = new SqlCommand(cmdTxt4, connection);


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


                ID_tb.Clear(); Client_tb.Clear(); Abon_tb.Clear(); Start_tb.Clear(); End_tb.Clear();
                NewID_tb.Clear(); NewClient_tb.Clear(); NewAbon_tb.Clear(); NewStart_tb.Clear(); NewEnd_tb.Clear();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "ERROR!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
        private void DeleteButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                int id = Convert.ToInt32(ID_tb.Text);

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

                ID_tb.Clear(); Client_tb.Clear(); Abon_tb.Clear(); Start_tb.Clear(); End_tb.Clear();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "ERROR!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
        private void AddButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                int    id   = Convert.ToInt32(ID_tb.Text);
                string name = Name_tb.Text;

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

                ID_tb.Clear();  Name_tb.Clear();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "ERROR!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Beispiel #10
0
        private void ChangeButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                int    id      = Convert.ToInt32(ID_tb.Text);
                string name    = Name_tb.Text;
                string price   = Price_tb.Text;
                string descrip = Descrip_tb.Text;

                int    newid      = Convert.ToInt32(NewID_tb.Text);
                string newname    = NewName_tb.Text;
                string newprice   = NewPrice_tb.Text;
                string newdescrip = NewDescrip_tb.Text;


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

                string     cmdTxt1  = $"UPDATE Abonnement SET Name = '{newname}'  WHERE ID_client = '{id}'";
                SqlCommand command1 = new SqlCommand(cmdTxt1, connection);
                string     cmdTxt2  = $"UPDATE Abonnement SET Price = '{newprice}'  WHERE ID_client = '{id}'";
                SqlCommand command2 = new SqlCommand(cmdTxt2, connection);
                string     cmdTxt3  = $"UPDATE Abonnement SET Description = '{newdescrip}'  WHERE ID_client = '{id}'";
                SqlCommand command3 = new SqlCommand(cmdTxt3, connection);


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


                ID_tb.Clear(); Name_tb.Clear(); Price_tb.Clear(); Descrip_tb.Clear();
                NewID_tb.Clear(); NewName_tb.Clear(); NewPrice_tb.Clear(); NewDescrip_tb.Clear();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "ERROR!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }