コード例 #1
0
ファイル: Window1.xaml.cs プロジェクト: 663021/SALON
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Window5 a = new Window5();

            if (ch2.IsChecked == true)
            {
                a.Tag = "true";
            }
            if (ch2.IsChecked == false)
            {
                a.Tag = "false";
            }

            a.Show();
            this.Close();
        }
コード例 #2
0
ファイル: Window5.xaml.cs プロジェクト: 663021/SALON
        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("INSERT INTO [Салон] (Клиент,Телефон,Мастер,Салон,Услуга,Цена,Дата)VALUES(@1,@2,@3,@4,@5,@6,@7)", 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);

            await command1.ExecuteNonQueryAsync();

            MessageBox.Show("Запись успешно добалена!");

            Window5 a = new Window5();

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