Esempio n. 1
0
        private async void Button_Click_1(object sender, RoutedEventArgs e)
        {
            if (combo.Text == "")
            {
                combo.Background = Brushes.Red;
                combo.Opacity    = 0.2;
                return;
            }
            if (label_time.Text == "")
            {
                label_time.Background = Brushes.Red;
                label_time.Opacity    = 0.4;
                return;
            }
            if (textBox_Copy.Text == "")
            {
                textBox_Copy.Background = Brushes.Red;
                textBox_Copy.Opacity    = 0.4;
                return;
            }
            if (textBox_Copyy.Text == "")
            {
                textBox_Copyy.Background = Brushes.Red;
                textBox_Copyy.Opacity    = 0.4;
                return;
            }
            if (textBox_Copy3.Text == "0")
            {
                textBox_Copy3.Background = Brushes.Red;
                textBox_Copy3.Opacity    = 0.4;
                return;
            }
            if (textBox_Copy1.Text == "")
            {
                textBox_Copy1.Background = Brushes.Red;
                textBox_Copy1.Opacity    = 0.4;
                return;
            }
            if (textBox_Copy2.Text == "")
            {
                textBox_Copy2.Background = Brushes.Red;
                textBox_Copy2.Opacity    = 0.4;
                return;
            }

            SqlConnection = new OleDbConnection(connectString);
            SqlConnection.Open();

            OleDbDataReader sqlReader = null;

            OleDbCommand command1 = new OleDbCommand("SELECT * FROM [Салон]", SqlConnection);

            sqlReader = command1.ExecuteReader();

            while (sqlReader.Read())
            {
                if ((textBox_Copy.Text + ":" + textBox_Copyy.Text + " " + label_time.Text) == Convert.ToString(sqlReader["Дата"]))
                {
                    MessageBox.Show("Это время занято другой записью");
                    return;
                }
            }

            command1 = new OleDbCommand("UPDATE [Салон] SET Клиент=@1,Телефон=@2,Мастер=@3,Салон=@4,Услуга=@5,Цена=@6,Дата=@7 WHERE Дата=@8", SqlConnection);
            command1.Parameters.AddWithValue("1", textBox_Copy1.Text);
            command1.Parameters.AddWithValue("2", textBox_Copy2.Text);
            command1.Parameters.AddWithValue("3", combo.Text);


            if (this.Tag.ToString() == "false")
            {
                command1.Parameters.AddWithValue("4", false);
            }
            else
            {
                command1.Parameters.AddWithValue("4", true);
            }

            string for_str = "";

            for (int i = 0; i < strArr.Count(); i++)
            {
                if (strArr[i] != null)
                {
                    for_str += strArr[i] + "/";
                }
            }
            command1.Parameters.AddWithValue("5", for_str);
            command1.Parameters.AddWithValue("6", Convert.ToInt32(textBox_Copy3.Text));
            command1.Parameters.AddWithValue("7", textBox_Copy.Text + ":" + textBox_Copyy.Text + " " + label_time.Text);

            command1.Parameters.AddWithValue("8", this.Tag.ToString());

            await command1.ExecuteNonQueryAsync();

            MessageBox.Show("Запись успешно изменена!");

            Window1 a = new Window1();

            a.Show();
            this.Close();
        }