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

            try
            {
                String sql = "EXEC InsertManzelF '" + Lbl_Date.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'" + MyPriceTextBox.getStringFromMasked(textBox19.Text) + "',N'" + MyPriceTextBox.getStringFromMasked(textBox20.Text)
                             + "',N'" + MyPriceTextBox.getStringFromMasked(textBox21.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
                             + ",N'" + _RText.Text + "',N'" + txt_Moarefino.Text + "'";

                String    fid = DB.execSqlReturnScalar(sql).ToString();
                DataTable dt  = (DataTable)gridView.DataSource;
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    String sq = "EXEC InsertMajmooeF " + fid;

                    /*for (int j = 0; j < dt.Rows[i].ItemArray.Length; j++)
                     * {
                     *  sq += ","+dt.Rows[i].ItemArray[j].ToString();
                     * }*/
                    sq += ",N'" + dt.Rows[i].ItemArray[0].ToString() + "'";
                    sq += ",N'" + dt.Rows[i].ItemArray[1].ToString() + "'";
                    sq += "," + dt.Rows[i].ItemArray[2].ToString();
                    sq += "," + dt.Rows[i].ItemArray[3].ToString();
                    sq += ",N'" + dt.Rows[i].ItemArray[4].ToString() + "'";
                    sq += ",N'" + dt.Rows[i].ItemArray[5].ToString() + "'";
                    DB.execSql(sq, 0);
                }
                MessageBox.Show("رکورد جدید با موفقیت ثبت گردید", "ثبت", MessageBoxButton.OK, MessageBoxImage.Information);
                if (AgainCheckBox.IsChecked == false)
                {
                    Insert.HouseF w = new Insert.HouseF();
                    this.Close();
                    if (w.newId != null && w.newId.Length > 0)
                    {
                        w.Show();
                    }
                }
                else
                {
                    initLabels();
                }
            }
            catch (Exception)
            {
                MessageBox.Show("خطا در اتصال و یا اجرای درخواست از پایگاه داده ها", "خطا", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
예제 #2
0
        private void insert_button_Click(object sender, RoutedEventArgs e)
        {
            if (!isRed)
            {
                if (textBox14.Text.Trim() == "")
                {
                    isRed = true;
                    textBox14.Background = Brushes.Pink;
                }
                if (textBox15.Text.Trim() == "")
                {
                    isRed = true;
                    textBox15.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 InsertManzelF '" + Lbl_Date.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'" + MyPriceTextBox.getStringFromMasked(textBox19.Text) + "',N'" + MyPriceTextBox.getStringFromMasked(textBox20.Text)
                        + "',N'" + MyPriceTextBox.getStringFromMasked(textBox21.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
                        + ",N'" + _RText.Text + "',N'" + txt_Moarefino.Text + "'";

                    String fid = DB.execSqlReturnScalar(sql).ToString();
                    DataTable dt = (DataTable)gridView.DataSource;
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        String sq = "EXEC InsertMajmooeF " + fid;
                        /*for (int j = 0; j < dt.Rows[i].ItemArray.Length; j++)
                        {
                            sq += ","+dt.Rows[i].ItemArray[j].ToString();
                        }*/
                        sq += ",N'" + dt.Rows[i].ItemArray[0].ToString() + "'";
                        sq += ",N'" + dt.Rows[i].ItemArray[1].ToString() + "'";
                        sq += "," + dt.Rows[i].ItemArray[2].ToString();
                        sq += "," + dt.Rows[i].ItemArray[3].ToString();
                        sq += ",N'" + dt.Rows[i].ItemArray[4].ToString() + "'";
                        sq += ",N'" + dt.Rows[i].ItemArray[5].ToString() + "'";
                        DB.execSql(sq);
                    }
                    MessageBox.Show("رکورد جدید با موفقیت ثبت گردید", "ثبت", MessageBoxButton.OK, MessageBoxImage.Information);
                    if (AgainCheckBox.IsChecked == false)
                    {
                        Insert.HouseF w = new Insert.HouseF();
                        this.Close();
                        if (w.newId != null && w.newId.Length > 0) w.Show();
                    }
                    else
                    {
                        initLabels();
                    }
                }
                catch (Exception)
                {
                    MessageBox.Show("خطا در اتصال و یا اجرای درخواست از پایگاه داده ها", "خطا", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
        }