示例#1
0
        private void insertIt()
        {
            TextRange _RText = new TextRange(richTextBox1.Document.ContentStart, richTextBox1.Document.ContentEnd);

            try
            {
                String sql = "EXEC InsertBaghVillaF '" + date_Lbl.Content
                             + "',N'" + textBox1.Text + "',N'" + textBox2.Text + "',N'" + textBox3.Text + "',N'" + textBox4.Text
                             + "',N'" + textBox5.Text + "',N'" + textBox6.Text + "',N'" + textBox7.Text + "',N'" + textBox8.Text
                             + "',N'" + textBox9.Text + "',N'" + textBox10.Text + "',N'" + textBox11.Text + "',N'" + textBox12.Text
                             + "',N'" + textBox13.Text + "',N'" + textBox14.Text + "',N'" + textBox15.Text + "',N'" + textBox16.Text
                             + "',N'" + textBox17.Text + "',N'" + textBox18.Text + "',N'" + textBox19.Text + "',N'" + textBox20.Text
                             + "',N'" + textBox21.Text + "',N'" + MyPriceTextBox.getStringFromMasked(textBox22.Text)
                             + "',N'" + MyPriceTextBox.getStringFromMasked(textBox23.Text)
                             + "'," + checkBox1.IsChecked + "," + checkBox2.IsChecked + "," + checkBox3.IsChecked
                             + "," + checkBox4.IsChecked + "," + checkBox5.IsChecked + "," + checkBox6.IsChecked
                             + "," + checkBox7.IsChecked + "," + checkBox8.IsChecked + "," + checkBox9.IsChecked
                             + "," + checkBox10.IsChecked + "," + checkBox11.IsChecked + "," + checkBox12.IsChecked
                             + "," + checkBox13.IsChecked + "," + checkBox14.IsChecked + "," + checkBox15.IsChecked
                             + "," + checkBox16.IsChecked + "," + checkBox17.IsChecked + "," + checkBox18.IsChecked
                             + "," + checkBox19.IsChecked + "," + checkBox20.IsChecked + "," + checkBox21.IsChecked
                             + "," + checkBox22.IsChecked + "," + checkBox23.IsChecked + "," + checkBox24.IsChecked
                             + "," + checkBox25.IsChecked + "," + checkBox26.IsChecked + "," + checkBox27.IsChecked
                             + "," + checkBox28.IsChecked + "," + checkBox29.IsChecked + "," + checkBox30.IsChecked
                             + ",N'" + _RText.Text + "',N'" + textBox24.Text + "'";

                DB.execSql(sql, 0);
                MessageBox.Show("رکورد جدید با موفقیت ثبت گردید", "ثبت", MessageBoxButton.OK, MessageBoxImage.Information);
                if (AgainCheckBox.IsChecked == false)
                {
                    Insert.BaghVillaF w = new Insert.BaghVillaF();
                    this.Close();
                    if (w.newId != null && w.newId.Length > 0)
                    {
                        w.Show();
                    }
                }
                else
                {
                    initLabels();
                }
            }
            catch (Exception)
            {
                MessageBox.Show("خطا در اتصال و یا اجرای درخواست از پایگاه داده ها", "خطا", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
        private void insert_button_Click(object sender, RoutedEventArgs e)
        {
            if (!isRed)
            {
                if (textBox20.Text.Trim() == "")
                {
                    isRed = true;
                    textBox20.Background = Brushes.Pink;
                }
                if (textBox21.Text.Trim() == "")
                {
                    isRed = true;
                    textBox21.Background = Brushes.Pink;
                }
                if (textBox23.Text.Trim() == "")
                {
                    isRed = true;
                    textBox23.Background = Brushes.Pink;
                }
            }
            else
            {
                TextRange _RText = new TextRange(richTextBox1.Document.ContentStart, richTextBox1.Document.ContentEnd);
                try
                {
                    String sql = "EXEC InsertBaghVillaF '" + date_Lbl.Content
                        + "',N'" + textBox1.Text + "',N'" + textBox2.Text + "',N'" + textBox3.Text + "',N'" + textBox4.Text
                        + "',N'" + textBox5.Text + "',N'" + textBox6.Text + "',N'" + textBox7.Text + "',N'" + textBox8.Text
                        + "',N'" + textBox9.Text + "',N'" + textBox10.Text + "',N'" + textBox11.Text + "',N'" + textBox12.Text
                        + "',N'" + textBox13.Text + "',N'" + textBox14.Text + "',N'" + textBox15.Text + "',N'" + textBox16.Text
                        + "',N'" + textBox17.Text + "',N'" + textBox18.Text + "',N'" + textBox19.Text + "',N'" + textBox20.Text
                        + "',N'" + textBox21.Text + "',N'" + MyPriceTextBox.getStringFromMasked(textBox22.Text)
                        + "',N'" + MyPriceTextBox.getStringFromMasked(textBox23.Text)
                        + "'," + checkBox1.IsChecked + "," + checkBox2.IsChecked + "," + checkBox3.IsChecked
                        + "," + checkBox4.IsChecked + "," + checkBox5.IsChecked + "," + checkBox6.IsChecked
                        + "," + checkBox7.IsChecked + "," + checkBox8.IsChecked + "," + checkBox9.IsChecked
                        + "," + checkBox10.IsChecked + "," + checkBox11.IsChecked + "," + checkBox12.IsChecked
                        + "," + checkBox13.IsChecked + "," + checkBox14.IsChecked + "," + checkBox15.IsChecked
                        + "," + checkBox16.IsChecked + "," + checkBox17.IsChecked + "," + checkBox18.IsChecked
                        + "," + checkBox19.IsChecked + "," + checkBox20.IsChecked + "," + checkBox21.IsChecked
                        + "," + checkBox22.IsChecked + "," + checkBox23.IsChecked + "," + checkBox24.IsChecked
                        + "," + checkBox25.IsChecked + "," + checkBox26.IsChecked + "," + checkBox27.IsChecked
                        + "," + checkBox28.IsChecked + "," + checkBox29.IsChecked + "," + checkBox30.IsChecked
                        + ",N'" + _RText.Text + "',N'" + textBox24.Text + "'";

                    DB.execSql(sql);
                    MessageBox.Show("رکورد جدید با موفقیت ثبت گردید", "ثبت", MessageBoxButton.OK, MessageBoxImage.Information);
                    if (AgainCheckBox.IsChecked == false)
                    {
                        Insert.BaghVillaF w = new Insert.BaghVillaF();
                        this.Close();
                        if (w.newId != null && w.newId.Length > 0) w.Show();
                    }
                    else
                    {
                        initLabels();
                    }
                }
                catch (Exception)
                {
                    MessageBox.Show("خطا در اتصال و یا اجرای درخواست از پایگاه داده ها", "خطا", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
        }