private void insertIt() { TextRange _RText = new TextRange(richTextBox1.Document.ContentStart, richTextBox1.Document.ContentEnd); try { String sql = "EXEC InsertApartmanEdariS '" + 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'" + MyPriceTextBox.getStringFromMasked(textBox20.Text) + "',N'" + MyPriceTextBox.getStringFromMasked(textBox21.Text) + "',N'" + textBox22.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 + ",N'" + _RText.Text + "',N'" + textBox23.Text + "'"; DB.execSql(sql, 0); MessageBox.Show("رکورد جدید با موفقیت ثبت گردید", "ثبت", MessageBoxButton.OK, MessageBoxImage.Information); if (AgainCheckBox.IsChecked == false) { Insert.ApartmanEdariS w = new Insert.ApartmanEdariS(); 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 (textBox18.Text.Trim() == "") { isRed = true; textBox18.Background = Brushes.Pink; } if (textBox19.Text.Trim() == "") { isRed = true; textBox19.Background = Brushes.Pink; } if (textBox20.Text.Trim() == "") { isRed = true; textBox20.Background = Brushes.Pink; } if (textBox21.Text.Trim() == "") { isRed = true; textBox21.Background = Brushes.Pink; } } else { TextRange _RText = new TextRange(richTextBox1.Document.ContentStart, richTextBox1.Document.ContentEnd); try { String sql = "EXEC InsertApartmanEdariS '" + 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'" + MyPriceTextBox.getStringFromMasked(textBox20.Text) + "',N'" + MyPriceTextBox.getStringFromMasked(textBox21.Text) + "',N'" + textBox22.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 + ",N'" + _RText.Text + "',N'" + textBox23.Text + "'"; DB.execSql(sql); MessageBox.Show("رکورد جدید با موفقیت ثبت گردید", "ثبت", MessageBoxButton.OK, MessageBoxImage.Information); if (AgainCheckBox.IsChecked == false) { Insert.ApartmanEdariS w = new Insert.ApartmanEdariS(); this.Close(); if (w.newId != null && w.newId.Length > 0) w.Show(); } else { initLabels(); } } catch (Exception) { MessageBox.Show("خطا در اتصال و یا اجرای درخواست از پایگاه داده ها", "خطا", MessageBoxButton.OK, MessageBoxImage.Error); } } }