private void Window_KeyUp(object sender, KeyEventArgs e) { if (!changeMode) { if (e.Key == Key.Right || e.Key == Key.Up) { next_button_Click(null, null); } else if (e.Key == Key.Left || e.Key == Key.Down) { before_button_Click(null, null); } else if (e.Key == Key.Escape) { Close(); } else if (e.Key == Key.Enter) { if (msgShow) { msgShow = false; return; } changeCombo.Visibility = Visibility.Visible; changeCombo.Focus(); changeMode = true; } } else // now we are in changeMode { if (e.Key == Key.Escape) { goOutFromChangeMode(); if (editing) { makeNonEditableAll(); editButton.Visibility = Visibility.Hidden; editing = false; price.Stop(); } } else if (e.Key == Key.Enter) { if (msgShow) { msgShow = false; return; } if (editing) { editButton_Click(null, null); return; } if (changeCombo.SelectedIndex == 2) // cancel { goOutFromChangeMode(); } else if (changeCombo.SelectedIndex == 1) // remove { try { String str = (String)ID_Lbl.Content; String mode = ""; int ind = 0; while (str[ind] != '-') { mode += str[ind++]; } mode.TrimEnd(); String sql = "EXEC RemoveByID " + str.Substring(ind + 1).TrimStart() + "," + mode; DB.execSql(sql); TextRange _RText = new TextRange(richTextBox1.Document.ContentStart, richTextBox1.Document.ContentEnd); String sqlForArchive = "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.execSqlInArchive(sqlForArchive); dt.Rows.RemoveAt(index); msgShow = true; MessageBox.Show("ملک مورد نظر با موفقیت حذف گردید", "حذف", MessageBoxButton.OK, MessageBoxImage.Information); goOutFromChangeMode(); tw.Close(); removeLbl.Content = "این ملک حذف گردیده است و برای آخرین بار در این فرم آن را ملاحظه می فرمایید"; removeLbl.Visibility = Visibility.Visible; } catch (Exception) { msgShow = true; MessageBox.Show("خطا در اتصال و یا اجرای درخواست از پایگاه داده ها", "خطا", MessageBoxButton.OK, MessageBoxImage.Error); } } else // edit { textBox1.Focus(); changeCombo.Visibility = Visibility.Hidden; editButton.Visibility = Visibility.Visible; editing = true; makeEditableAll(); price.Start(); } } if (editing) { if (e.Key == Key.Up) { if (textBox2.IsFocused || textBox3.IsFocused || textBox4.IsFocused || textBox5.IsFocused || textBox6.IsFocused) { textBox1.Focus(); } else if (textBox7.IsFocused) { textBox8.Focus(); } else if (textBox8.IsFocused) { textBox7.Focus(); } else if (textBox9.IsFocused) { textBox2.Focus(); } else if (textBox10.IsFocused) { textBox9.Focus(); } else if (textBox11.IsFocused) { textBox10.Focus(); } else if (textBox14.IsFocused) { textBox11.Focus(); } else if (textBox13.IsFocused) { textBox5.Focus(); } else if (textBox12.IsFocused) { textBox13.Focus(); } else if (textBox15.IsFocused) { textBox12.Focus(); } else if (textBox16.IsFocused) { textBox15.Focus(); } else if (textBox17.IsFocused) { textBox14.Focus(); } else if (textBox18.IsFocused) { textBox17.Focus(); } else if (textBox19.IsFocused) { textBox18.Focus(); } else if (textBox20.IsFocused || textBox21.IsFocused) { textBox19.Focus(); } else if (textBox22.IsFocused) { textBox20.Focus(); } else if (textBox23.IsFocused) { textBox21.Focus(); } else if (richTextBox1.IsFocused) { textBox22.Focus(); } else if (textBox24.IsFocused) { checkBox20.Focus(); } else if (checkBox20.IsFocused) { checkBox9.Focus(); } } else if (e.Key == Key.Down) { if (textBox1.IsFocused) { textBox2.Focus(); } else if (textBox2.IsFocused || textBox3.IsFocused) { textBox9.Focus(); } else if (textBox4.IsFocused || textBox5.IsFocused || textBox6.IsFocused) { textBox13.Focus(); } else if (textBox7.IsFocused) { checkBox11.Focus(); } else if (textBox8.IsFocused) { textBox7.Focus(); } else if (textBox9.IsFocused) { textBox10.Focus(); } else if (textBox10.IsFocused) { textBox11.Focus(); } else if (textBox11.IsFocused) { textBox14.Focus(); } else if (textBox12.IsFocused) { textBox15.Focus(); } else if (textBox13.IsFocused) { textBox12.Focus(); } else if (textBox14.IsFocused || textBox16.IsFocused) { textBox17.Focus(); } else if (textBox15.IsFocused) { textBox16.Focus(); } else if (textBox17.IsFocused) { textBox18.Focus(); } else if (textBox18.IsFocused) { textBox19.Focus(); } else if (textBox19.IsFocused) { textBox20.Focus(); } else if (textBox20.IsFocused) { textBox22.Focus(); } else if (textBox21.IsFocused) { textBox23.Focus(); } else if (textBox22.IsFocused || textBox23.IsFocused) { richTextBox1.Focus(); } else if (textBox24.IsFocused) { richTextBox1.Focus(); } } else if (e.Key == Key.Left) { if (textBox1.IsFocused) { textBox8.Focus(); } else if (textBox2.IsFocused) { textBox3.Focus(); } else if (textBox3.IsFocused) { textBox4.Focus(); } else if (textBox4.IsFocused) { textBox5.Focus(); } else if (textBox5.IsFocused) { textBox6.Focus(); } else if (textBox6.IsFocused) { textBox7.Focus(); } else if (textBox9.IsFocused) { textBox13.Focus(); } else if (textBox10.IsFocused) { textBox12.Focus(); } else if (textBox11.IsFocused) { textBox15.Focus(); } else if (textBox14.IsFocused) { textBox16.Focus(); } else if (textBox20.IsFocused) { textBox21.Focus(); } else if (textBox22.IsFocused) { textBox23.Focus(); } else if (richTextBox1.IsFocused) { textBox24.Focus(); } else if (textBox13.IsFocused || textBox12.IsFocused || textBox15.IsFocused || textBox16.IsFocused || textBox17.IsFocused || textBox18.IsFocused || textBox19.IsFocused || textBox21.IsFocused || textBox23.IsFocused) { checkBox1.Focus(); } } else if (e.Key == Key.Right) { if (textBox8.IsFocused) { textBox1.Focus(); } else if (textBox3.IsFocused) { textBox2.Focus(); } else if (textBox4.IsFocused) { textBox3.Focus(); } else if (textBox5.IsFocused) { textBox4.Focus(); } else if (textBox6.IsFocused) { textBox5.Focus(); } else if (textBox7.IsFocused) { textBox6.Focus(); } else if (textBox13.IsFocused) { textBox9.Focus(); } else if (textBox12.IsFocused) { textBox10.Focus(); } else if (textBox15.IsFocused) { textBox11.Focus(); } else if (textBox16.IsFocused) { textBox14.Focus(); } else if (textBox21.IsFocused) { textBox20.Focus(); } else if (textBox23.IsFocused) { textBox22.Focus(); } else if (textBox24.IsFocused) { textBox23.Focus(); } } } } }
private void editButton_Click(object sender, RoutedEventArgs e) { makeNonEditableAll(); String id = ((String)ID_Lbl.Content); int ind = id.IndexOf('-'); id = id.Substring(ind + 1); TextRange _RText = new TextRange(richTextBox1.Document.ContentStart, richTextBox1.Document.ContentEnd); try { String sql = "EXEC EditApartmanEdariF " + id + ",'" + 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 + ",N'" + _RText.Text + "',N'" + textBox24.Text + "'"; DB.execSql(sql); msgShow = true; MessageBox.Show("رکورد با موفقیت ویرایش گردید", "ویرایش", MessageBoxButton.OK, MessageBoxImage.Information); } catch (Exception) { msgShow = true; MessageBox.Show("خطا در اتصال و یا اجرای درخواست از پایگاه داده ها", "خطا", MessageBoxButton.OK, MessageBoxImage.Error); return; } tw.Close(); editButton.Visibility = Visibility.Hidden; goOutFromChangeMode(); DataRow dr = dt.NewRow(); dr.BeginEdit(); dr[0] = id; dr[1] = date_Lbl.Content; dr[2] = textBox1.Text; dr[3] = textBox2.Text; dr[4] = textBox3.Text; dr[5] = textBox4.Text; dr[6] = textBox5.Text; dr[7] = textBox6.Text; dr[8] = textBox7.Text; dr[9] = textBox8.Text; dr[10] = textBox9.Text; dr[11] = textBox10.Text; dr[12] = textBox11.Text; dr[13] = textBox12.Text; dr[14] = textBox13.Text; dr[15] = textBox14.Text; dr[16] = textBox15.Text; dr[17] = textBox16.Text; dr[18] = textBox17.Text; dr[19] = textBox18.Text; dr[20] = textBox19.Text; dr[21] = textBox20.Text; dr[22] = textBox21.Text; dr[23] = MyPriceTextBox.getStringFromMasked(textBox22.Text); dr[24] = MyPriceTextBox.getStringFromMasked(textBox23.Text); dr[25] = checkBox1.IsChecked; dr[26] = checkBox2.IsChecked; dr[27] = checkBox3.IsChecked; dr[28] = checkBox4.IsChecked; dr[29] = checkBox5.IsChecked; dr[30] = checkBox6.IsChecked; dr[31] = checkBox7.IsChecked; dr[32] = checkBox8.IsChecked; dr[33] = checkBox9.IsChecked; dr[34] = checkBox10.IsChecked; dr[35] = checkBox11.IsChecked; dr[36] = checkBox12.IsChecked; dr[37] = checkBox13.IsChecked; dr[38] = checkBox14.IsChecked; dr[39] = checkBox15.IsChecked; dr[40] = _RText.Text; dr[41] = textBox24.Text; dr.EndEdit(); dt.Rows.RemoveAt(index); dt.Rows.InsertAt(dr, index); editing = false; price.Stop(); }
private void search_button_Click(object sender, RoutedEventArgs e) { this.Topmost = false; errorOccurred = false; TextRange _RText = new TextRange(richTextBox1.Document.ContentStart, richTextBox1.Document.ContentEnd); try { String tr = _RText.Text.TrimEnd(); tr = tr.TrimStart(); if (tr == "\r\n") { tr = ""; } String date = (MaskedDate.Text[0] == '_') ? "" : MaskedDate.Text; String[] s = { "'" + ID_Txt.Text + "'", "N'" + date + "'", "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.ToString(), checkBox2.IsChecked.ToString(), checkBox3.IsChecked.ToString(), checkBox4.IsChecked.ToString(), checkBox5.IsChecked.ToString(), checkBox6.IsChecked.ToString(), checkBox7.IsChecked.ToString(), checkBox8.IsChecked.ToString(), checkBox9.IsChecked.ToString(), checkBox10.IsChecked.ToString(), checkBox11.IsChecked.ToString(), checkBox12.IsChecked.ToString(), checkBox13.IsChecked.ToString(), checkBox14.IsChecked.ToString(), checkBox15.IsChecked.ToString(), "N'" + _RText.Text + "'", "N'" + textBox23.Text + "'" }; SearchSQL sq = new SearchSQL(s, "SearchApartmanEdariS"); DataTable dt = sq.getResult(DBComboBox.SelectedIndex); if (Show3D_checkBox.IsChecked == true) { Result3D res3d = new Result3D(); res3d.dt = dt; res3d.Show(); } else { ResultWindow res = new ResultWindow(); res.session = session; res.which = Codes.ApartmanEdariEstijari; if (dt != null) { res.dt = dt.Copy(); if (cols == null) { cols = new string[dt.Columns.Count]; for (int i = 0; i < cols.Length; i++) { cols[i] = dt.Columns[i].ColumnName; } } if (MaskedDate.Text == "____/__/__") { dt.Columns.Remove(cols[1]); } if (textBox2.Text.Trim().Length == 0) { dt.Columns.Remove(cols[3]); } if (textBox3.Text.Trim().Length == 0) { dt.Columns.Remove(cols[4]); } if (textBox4.Text.Trim().Length == 0) { dt.Columns.Remove(cols[5]); } if (textBox5.Text.Trim().Length == 0) { dt.Columns.Remove(cols[6]); } if (textBox6.Text.Trim().Length == 0) { dt.Columns.Remove(cols[7]); } if (textBox7.Text.Trim().Length == 0) { dt.Columns.Remove(cols[8]); } if (textBox8.Text.Trim().Length == 0) { dt.Columns.Remove(cols[9]); } if (textBox9.Text.Trim().Length == 0) { dt.Columns.Remove(cols[10]); } if (textBox10.Text.Trim().Length == 0) { dt.Columns.Remove(cols[11]); } if (textBox11.Text.Trim().Length == 0) { dt.Columns.Remove(cols[12]); } if (textBox12.Text.Trim().Length == 0) { dt.Columns.Remove(cols[13]); } if (textBox13.Text.Trim().Length == 0) { dt.Columns.Remove(cols[14]); } if (textBox14.Text.Trim().Length == 0) { dt.Columns.Remove(cols[15]); } if (textBox15.Text.Trim().Length == 0) { dt.Columns.Remove(cols[16]); } if (textBox16.Text.Trim().Length == 0) { dt.Columns.Remove(cols[17]); } if (textBox17.Text.Trim().Length == 0) { dt.Columns.Remove(cols[18]); } if (textBox18.Text.Trim().Length == 0) { dt.Columns.Remove(cols[19]); } if (textBox19.Text.Trim().Length == 0) { dt.Columns.Remove(cols[20]); } if (textBox22.Text.Trim().Length == 0) { dt.Columns.Remove(cols[23]); } if (checkBox1.IsChecked == false) { dt.Columns.Remove(cols[24]); } if (checkBox2.IsChecked == false) { dt.Columns.Remove(cols[25]); } if (checkBox3.IsChecked == false) { dt.Columns.Remove(cols[26]); } if (checkBox4.IsChecked == false) { dt.Columns.Remove(cols[27]); } if (checkBox5.IsChecked == false) { dt.Columns.Remove(cols[28]); } if (checkBox6.IsChecked == false) { dt.Columns.Remove(cols[29]); } if (checkBox7.IsChecked == false) { dt.Columns.Remove(cols[30]); } if (checkBox8.IsChecked == false) { dt.Columns.Remove(cols[31]); } if (checkBox9.IsChecked == false) { dt.Columns.Remove(cols[32]); } if (checkBox10.IsChecked == false) { dt.Columns.Remove(cols[33]); } if (checkBox11.IsChecked == false) { dt.Columns.Remove(cols[34]); } if (checkBox12.IsChecked == false) { dt.Columns.Remove(cols[35]); } if (checkBox13.IsChecked == false) { dt.Columns.Remove(cols[36]); } if (checkBox14.IsChecked == false) { dt.Columns.Remove(cols[37]); } if (checkBox15.IsChecked == false) { dt.Columns.Remove(cols[38]); } if (_RText.Text == "\r\n") { dt.Columns.Remove(cols[39]); } if (textBox23.Text.Length == 0) { dt.Columns.Remove(cols[40]); } } res.gridView.DataSource = dt; res.dbIndex = DBComboBox.SelectedIndex; res.Show(); } } catch (Exception) { errorOccurred = true; MessageBox.Show("خطا در اتصال و یا اجرای درخواست از پایگاه داده ها", "خطا", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void Button_Click(object sender, RoutedEventArgs e) { this.Topmost = false; errorOccurred = false; try { String sql; if (rahn_High.Text.Trim().Length == 0 && rahn_Low.Text.Trim().Length == 0 && ejare_High.Text.Trim().Length == 0 && ejare_Low.Text.Trim().Length == 0) { if (rahnoejare_Low.Text.Trim().Length == 0 && rahnoejare_High.Text.Trim().Length == 0) { sql = model1(); } else { String low = MyPriceTextBox.getStringFromMasked(rahnoejare_Low.Text); String high = MyPriceTextBox.getStringFromMasked(rahnoejare_High.Text); if (low.Trim().Length == 0 || high.Trim().Length == 0) { errorOccurred = true; MessageBox.Show("لطفا در این حالت که می خواهید از فیلد رهن و اجاره استفاده بنمایید هر دو طرف آن را پر بفرمایید", "خطا", MessageBoxButton.OK, MessageBoxImage.Error); return; } sql = model2(low, high); } } else { sql = model1(); } DataTable dt = DB.execSqlReturnDataTable(sql); if (Show3D_checkBox.IsChecked == true) { Result3D res3d = new Result3D(); res3d.dt = dt; res3d.Show(); } else { ResultWindow res = new ResultWindow(); res.which = Codes.ApartmanMaskooniEstijari; res.dt = dt.Copy(); if (cols == null) { cols = new string[dt.Columns.Count]; for (int i = 0; i < cols.Length; i++) { cols[i] = dt.Columns[i].ColumnName; } } for (int i = 1; i < cols.Length; i++) { if (i == 2 || i == 20 || i == 21) { continue; } if ((metraj_Low.Text.Trim().Length != 0 || metraj_High.Text.Trim().Length != 0) && i == 3) { continue; } if ((bedrooms_Low.Text.Trim().Length != 0 || bedrooms_High.Text.Trim().Length != 0) && i == 5) { continue; } if (owner.Text.Trim().Length != 0 && i == 18) { continue; } dt.Columns.Remove(cols[i]); } res.gridView.DataSource = dt; res.Show(); } } catch (Exception) { errorOccurred = true; MessageBox.Show("خطا در اتصال و یا اجرای درخواست از پایگاه داده ها", "خطا", MessageBoxButton.OK, MessageBoxImage.Error); } }
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 (textBox16.Text.Trim() == "") { isRed = true; textBox16.Background = Brushes.Pink; } if (textBox17.Text.Trim() == "") { isRed = true; textBox17.Background = Brushes.Pink; } } else { TextRange _RText = new TextRange(richTextBox1.Document.ContentStart, richTextBox1.Document.ContentEnd); try { String sql = "EXEC InsertManzelS '" + 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'" + MyPriceTextBox.getStringFromMasked(textBox16.Text) + "',N'" + MyPriceTextBox.getStringFromMasked(textBox17.Text) + "',N'" + textBox18.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 sid = DB.execSqlReturnScalar(sql).ToString(); DataTable dt = (DataTable)gridView.DataSource; for (int i = 0; i < dt.Rows.Count; i++) { String sq = "EXEC InsertMajmooeS " + sid; /*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.HouseS w = new Insert.HouseS(); this.Close(); if (w.newId != null && w.newId.Length > 0) { w.Show(); } } else { initLabels(); } } catch (Exception) { MessageBox.Show("خطا در اتصال و یا اجرای درخواست از پایگاه داده ها", "خطا", MessageBoxButton.OK, MessageBoxImage.Error); } } }
private void insertIt() { TextRange _RText = new TextRange(richTextBox1.Document.ContentStart, richTextBox1.Document.ContentEnd); try { String sql = "EXEC InsertMaghazeF '" + 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'" + 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 + ",N'" + _RText.Text + "',N'" + txt_Moarefino.Text + "'"; DB.execSql(sql, 0); MessageBox.Show("رکورد جدید با موفقیت ثبت گردید", "ثبت", MessageBoxButton.OK, MessageBoxImage.Information); if (AgainCheckBox.IsChecked == false) { Insert.MaghazeF w = new Insert.MaghazeF(); this.Close(); if (w.newId != null && w.newId.Length > 0) { w.Show(); } } else { initLabels(); } } catch (Exception) { MessageBox.Show("خطا در اتصال و یا اجرای درخواست از پایگاه داده ها", "خطا", MessageBoxButton.OK, MessageBoxImage.Error); } }
private String model1() // when user fill rahn_low rahn_high ejare_low ejare_high { String sql = "EXEC SearchApartmanMaskooniSSimple N'" + address_Txt.Text + "',N'" + metraj_Low.Text + "',N'" + metraj_High.Text + "',N'" + bedrooms_Low.Text + "',N'" + bedrooms_High.Text + "',N'" + owner.Text + "',N'" + MyPriceTextBox.getStringFromMasked(rahn_Low.Text) + "',N'" + MyPriceTextBox.getStringFromMasked(rahn_High.Text) + "',N'" + MyPriceTextBox.getStringFromMasked(ejare_Low.Text) + "',N'" + MyPriceTextBox.getStringFromMasked(ejare_High.Text) + "'"; return(sql); }
private void Window_KeyUp(object sender, KeyEventArgs e) { if (!changeMode) { if (e.Key == Key.Right || e.Key == Key.Up) { next_button_Click(null, null); } else if (e.Key == Key.Left || e.Key == Key.Down) { before_button_Click(null, null); } else if (e.Key == Key.Escape) { Close(); } else if (e.Key == Key.Enter) { if (msgShow) { msgShow = false; return; } changeCombo.Visibility = Visibility.Visible; changeCombo.Focus(); changeMode = true; } } else // now we are in changeMode { if (e.Key == Key.Escape) { goOutFromChangeMode(); if (editing) { makeNonEditableAll(); editButton.Visibility = Visibility.Hidden; editing = false; price.Stop(); } } else if (e.Key == Key.Enter) { if (msgShow) { msgShow = false; return; } if (editing) { editButton_Click(null, null); return; } if (changeCombo.SelectedIndex == 2) // cancel { goOutFromChangeMode(); } else if (changeCombo.SelectedIndex == 1) // remove { if (dbIndex != 0) { msgShow = true; MessageBox.Show("اطلاعات آرشیو به منظور حفظ رکوردها حذف نمی گردند.", "خطای حذف داده های آرشیو", MessageBoxButton.OK, MessageBoxImage.Error); return; } if (!session.allowDelete) { goOutFromChangeMode(); MessageBox.Show("شما اجازه دسترسی به این قسمت را ندارید", "عدم اجازه دسترسی", MessageBoxButton.OK, MessageBoxImage.Warning); return; } try { String str = (String)ID_Lbl.Content; String mode = ""; int ind = 0; while (str[ind] != '-') { mode += str[ind++]; } mode.TrimEnd(); String sql = "EXEC RemoveByID " + str.Substring(ind + 1).TrimStart() + "," + mode; DB.execSql(sql, 0); TextRange _RText = new TextRange(richTextBox1.Document.ContentStart, richTextBox1.Document.ContentEnd); String sqlForArchive = "EXEC InsertManzelF '" + 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'" + 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.execSqlReturnScalarInArchive(sqlForArchive).ToString(); DataTable dt2 = (DataTable)gridView.DataSource; for (int i = 0; i < dt2.Rows.Count; i++) { String sq = "EXEC InsertMajmooeF " + fid; /*for (int j = 0; j < dt2.Rows[i].ItemArray.Length; j++) * { * sq += ","+dt2.Rows[i].ItemArray[j].ToString(); * }*/ sq += ",N'" + dt2.Rows[i].ItemArray[0].ToString() + "'"; sq += ",N'" + dt2.Rows[i].ItemArray[1].ToString() + "'"; sq += "," + dt2.Rows[i].ItemArray[2].ToString(); sq += "," + dt2.Rows[i].ItemArray[3].ToString(); sq += ",N'" + dt2.Rows[i].ItemArray[4].ToString() + "'"; sq += ",N'" + dt2.Rows[i].ItemArray[5].ToString() + "'"; DB.execSqlInArchive(sq); } dt.Rows.RemoveAt(index); msgShow = true; MessageBox.Show("ملک مورد نظر با موفقیت حذف گردید", "حذف", MessageBoxButton.OK, MessageBoxImage.Information); goOutFromChangeMode(); tw.Close(); removeLbl.Content = "این ملک حذف گردیده است و برای آخرین بار در این فرم آن را ملاحظه می فرمایید"; removeLbl.Visibility = Visibility.Visible; } catch (Exception) { msgShow = true; MessageBox.Show("خطا در اتصال و یا اجرای درخواست از پایگاه داده ها", "خطا", MessageBoxButton.OK, MessageBoxImage.Error); } } else // edit { if (!session.allowEdit) { goOutFromChangeMode(); MessageBox.Show("شما اجازه دسترسی به این قسمت را ندارید", "عدم اجازه دسترسی", MessageBoxButton.OK, MessageBoxImage.Warning); return; } textBox1.Focus(); changeCombo.Visibility = Visibility.Hidden; editButton.Visibility = Visibility.Visible; editing = true; makeEditableAll(); price.Start(); } } if (editing) { if (e.Key == Key.Up) { if (textBox2.IsFocused || textBox3.IsFocused || textBox4.IsFocused || textBox5.IsFocused || textBox6.IsFocused || textBox7.IsFocused) { textBox1.Focus(); } else if (textBox8.IsFocused) { textBox2.Focus(); } else if (textBox9.IsFocused) { textBox3.Focus(); } else if (textBox10.IsFocused) { textBox4.Focus(); } else if (textBox11.IsFocused) { textBox5.Focus(); } else if (textBox12.IsFocused) { textBox6.Focus(); } else if (textBox13.IsFocused) { textBox7.Focus(); } else if (textBox14.IsFocused || textBox15.IsFocused) { textBox18.Focus(); } else if (textBox16.IsFocused) { gridView.Focus(); } else if (textBox17.IsFocused) { textBox16.Focus(); } else if (textBox18.IsFocused) { textBox17.Focus(); } else if (textBox19.IsFocused) { textBox14.Focus(); } else if (textBox20.IsFocused) { textBox15.Focus(); } else if (richTextBox1.IsFocused) { textBox19.Focus(); } else if (txt_Moarefino.IsFocused) { textBox21.Focus(); } else if (textBox21.IsFocused) { checkBox7.Focus(); } } else if (e.Key == Key.Down) { if (textBox1.IsFocused) { textBox2.Focus(); } else if (textBox2.IsFocused) { textBox8.Focus(); } else if (textBox3.IsFocused) { textBox9.Focus(); } else if (textBox4.IsFocused) { textBox10.Focus(); } else if (textBox5.IsFocused) { textBox11.Focus(); } else if (textBox6.IsFocused) { textBox12.Focus(); } else if (textBox7.IsFocused) { textBox13.Focus(); } else if (textBox8.IsFocused || textBox9.IsFocused || textBox10.IsFocused || textBox11.IsFocused || textBox12.IsFocused) { gridView.Focus(); } else if (textBox13.IsFocused) { checkBox1.Focus(); } else if (textBox14.IsFocused) { textBox19.Focus(); } else if (textBox15.IsFocused) { textBox20.Focus(); } else if (textBox16.IsFocused) { textBox17.Focus(); } else if (textBox17.IsFocused) { textBox18.Focus(); } else if (textBox18.IsFocused) { textBox14.Focus(); } else if (textBox19.IsFocused || textBox20.IsFocused) { richTextBox1.Focus(); } else if (textBox21.IsFocused) { txt_Moarefino.Focus(); } } else if (e.Key == Key.Left) { if (textBox2.IsFocused) { textBox3.Focus(); } else if (textBox3.IsFocused) { textBox4.Focus(); } else if (textBox4.IsFocused) { textBox5.Focus(); } else if (textBox5.IsFocused) { textBox6.Focus(); } else if (textBox6.IsFocused) { textBox7.Focus(); } else if (textBox8.IsFocused) { textBox9.Focus(); } else if (textBox9.IsFocused) { textBox10.Focus(); } else if (textBox10.IsFocused) { textBox11.Focus(); } else if (textBox11.IsFocused) { textBox12.Focus(); } else if (textBox12.IsFocused) { textBox13.Focus(); } else if (textBox14.IsFocused && !gridView.Focused) { textBox15.Focus(); } //else if (textBox19.IsFocused) textBox20.Focus(); //else if (textBox20.IsFocused) textBox21.Focus(); else if (richTextBox1.IsFocused) { txt_Moarefino.Focus(); } else if (textBox16.IsFocused || textBox17.IsFocused || textBox18.IsFocused) { checkBox1.Focus(); } } else if (e.Key == Key.Right) { if (textBox3.IsFocused) { textBox2.Focus(); } else if (textBox4.IsFocused) { textBox3.Focus(); } else if (textBox5.IsFocused) { textBox4.Focus(); } else if (textBox6.IsFocused) { textBox5.Focus(); } else if (textBox7.IsFocused) { textBox6.Focus(); } else if (textBox9.IsFocused) { textBox8.Focus(); } else if (textBox10.IsFocused) { textBox9.Focus(); } else if (textBox11.IsFocused) { textBox10.Focus(); } else if (textBox12.IsFocused) { textBox11.Focus(); } else if (textBox13.IsFocused) { textBox12.Focus(); } else if (textBox15.IsFocused && !gridView.Focused) { textBox14.Focus(); } //else if (textBox20.IsFocused) textBox19.Focus(); //else if (textBox21.IsFocused) textBox20.Focus(); else if (txt_Moarefino.IsFocused) { richTextBox1.Focus(); } } else if (e.Key == Key.RightCtrl || e.Key == Key.LeftCtrl) { textBox16.Focus(); } } } }
private void editButton_Click(object sender, RoutedEventArgs e) { makeNonEditableAll(); String id = ((String)ID_Lbl.Content); int ind = id.IndexOf('-'); id = id.Substring(ind + 1); TextRange _RText = new TextRange(richTextBox1.Document.ContentStart, richTextBox1.Document.ContentEnd); try { String sql = "EXEC EditManzelF " + id + ",'" + 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'" + 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 + "'"; DB.execSql(sql, dbIndex); String str = (String)ID_Lbl.Content; String mode = ""; ind = 0; while (str[ind] != '-') { mode += str[ind++]; } mode.TrimEnd(); String remsql = "EXEC RemoveMajmooeByFID " + id; DB.execSql(remsql, 0); DataTable dt2 = (DataTable)gridView.DataSource; for (int i = 0; i < dt2.Rows.Count; i++) { String sq = "EXEC InsertMajmooeF " + id; /*for (int j = 0; j < dt2.Rows[i].ItemArray.Length; j++) * { * sq += ","+dt2.Rows[i].ItemArray[j].ToString(); * }*/ sq += ",N'" + dt2.Rows[i].ItemArray[0].ToString() + "'"; sq += ",N'" + dt2.Rows[i].ItemArray[1].ToString() + "'"; sq += "," + dt2.Rows[i].ItemArray[2].ToString(); sq += "," + dt2.Rows[i].ItemArray[3].ToString(); sq += ",N'" + dt2.Rows[i].ItemArray[4].ToString() + "'"; sq += ",N'" + dt2.Rows[i].ItemArray[5].ToString() + "'"; DB.execSql(sq, 0); } msgShow = true; MessageBox.Show("رکورد با موفقیت ویرایش گردید", "ویرایش", MessageBoxButton.OK, MessageBoxImage.Information); } catch (Exception) { msgShow = true; MessageBox.Show("خطا در اتصال و یا اجرای درخواست از پایگاه داده ها", "خطا", MessageBoxButton.OK, MessageBoxImage.Error); return; } tw.Close(); editButton.Visibility = Visibility.Hidden; goOutFromChangeMode(); DataRow dr = dt.NewRow(); dr.BeginEdit(); dr[0] = id; dr[1] = date_Lbl.Content; dr[2] = textBox1.Text; dr[3] = textBox2.Text; dr[4] = textBox3.Text; dr[5] = textBox4.Text; dr[6] = textBox5.Text; dr[7] = textBox6.Text; dr[8] = textBox7.Text; dr[9] = textBox8.Text; dr[10] = textBox9.Text; dr[11] = textBox10.Text; dr[12] = textBox11.Text; dr[13] = textBox12.Text; dr[14] = textBox13.Text; dr[15] = textBox14.Text; dr[16] = textBox15.Text; dr[17] = textBox16.Text; dr[18] = textBox17.Text; dr[19] = textBox18.Text; dr[20] = MyPriceTextBox.getStringFromMasked(textBox19.Text); dr[21] = MyPriceTextBox.getStringFromMasked(textBox20.Text); dr[22] = MyPriceTextBox.getStringFromMasked(textBox21.Text); dr[23] = checkBox1.IsChecked; dr[24] = checkBox2.IsChecked; dr[25] = checkBox3.IsChecked; dr[26] = checkBox4.IsChecked; dr[27] = checkBox5.IsChecked; dr[28] = checkBox6.IsChecked; dr[29] = checkBox7.IsChecked; dr[30] = checkBox8.IsChecked; dr[31] = checkBox9.IsChecked; dr[32] = checkBox10.IsChecked; dr[33] = checkBox11.IsChecked; dr[34] = checkBox12.IsChecked; dr[35] = checkBox13.IsChecked; dr[36] = checkBox14.IsChecked; dr[37] = _RText.Text; dr[38] = txt_Moarefino.Text; dr.EndEdit(); dt.Rows.RemoveAt(index); dt.Rows.InsertAt(dr, index); editing = false; price.Stop(); }
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); } } }
private void search_button_Click(object sender, RoutedEventArgs e) { this.Topmost = false; errorOccurred = false; TextRange _text = new TextRange(comments.Document.ContentStart, comments.Document.ContentEnd); String cmt = _text.Text; cmt = cmt.Remove(cmt.Length - 2); try { String sql = "EXEC SearchManzelFSimple N'" + address_Txt.Text + "',N'" + metraj_Low.Text + "',N'" + metraj_High.Text + "',N'" + zirbanaa_Low.Text + "',N'" + zirbanaa_High.Text + "',N'" + tabaghaat_Low.Text + "',N'" + tabaghaat_High.Text + "',N'" + vahed_Low.Text + "',N'" + vahed_High.Text + "',N'" + owner.Text + "',N'" + MyPriceTextBox.getStringFromMasked(price_Low.Text) + "',N'" + MyPriceTextBox.getStringFromMasked(price_High.Text) + "',N'" + cmt + "'"; DataTable dt = DB.execSqlReturnDataTable(sql, DBComboBox.SelectedIndex); if (Show3D_checkBox.IsChecked == true) { Result3D res3d = new Result3D(); res3d.dt = dt; res3d.Show(); } else { ResultWindow res = new ResultWindow(); res.session = session; res.which = Codes.HouseForooshi; res.dt = dt.Copy(); if (cols == null) { cols = new string[dt.Columns.Count]; for (int i = 0; i < cols.Length; i++) { cols[i] = dt.Columns[i].ColumnName; } } for (int i = 1; i < cols.Length; i++) { if (i == 2 || i == 22) { continue; } if ((metraj_Low.Text.Trim().Length != 0 || metraj_High.Text.Trim().Length != 0) && i == 7) { continue; } if ((zirbanaa_Low.Text.Trim().Length != 0 || zirbanaa_High.Text.Trim().Length != 0) && i == 6) { continue; } if ((tabaghaat_Low.Text.Trim().Length != 0 || tabaghaat_High.Text.Trim().Length != 0) && i == 9) { continue; } if ((vahed_Low.Text.Trim().Length != 0 || vahed_High.Text.Trim().Length != 0) && i == 10) { continue; } if (owner.Text.Trim().Length != 0 && i == 15) { continue; } dt.Columns.Remove(cols[i]); } res.gridView.DataSource = dt; res.dbIndex = DBComboBox.SelectedIndex; res.Show(); } } catch (Exception) { errorOccurred = true; MessageBox.Show("خطا در اتصال و یا اجرای درخواست از پایگاه داده ها", "خطا", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void search_button_Click(object sender, RoutedEventArgs e) { this.Topmost = false; errorOccurred = false; try { String sql = "EXEC SearchApartmanEdariFSimple N'" + address_Txt.Text + "',N'" + metraj_Low.Text + "',N'" + metraj_High.Text + "',N'" + bedrooms_Low.Text + "',N'" + bedrooms_High.Text + "',N'" + owner.Text + "',N'" + sanad.Text + "',N'" + MyPriceTextBox.getStringFromMasked(price_Low.Text) + "',N'" + MyPriceTextBox.getStringFromMasked(price_High.Text) + "'"; if (Show3D_checkBox.IsChecked == true) // 3d result { Result3D res = new Result3D(); DataTable dt = DB.execSqlReturnDataTable(sql); res.dt = dt; res.Show(); } else // usual result { ResultWindow res = new ResultWindow(); DataTable dt = DB.execSqlReturnDataTable(sql); res.dt = dt.Copy(); res.which = Codes.ApartmanEdariForooshi; res.Show(); if (cols == null) { cols = new string[dt.Columns.Count]; for (int i = 0; i < cols.Length; i++) { cols[i] = dt.Columns[i].ColumnName; } } for (int i = 1; i < cols.Length; i++) { if (i == 2 || i == 24) { continue; } if ((metraj_Low.Text.Trim().Length != 0 || metraj_High.Text.Trim().Length != 0) && i == 3) { continue; } if ((bedrooms_Low.Text.Trim().Length != 0 || bedrooms_High.Text.Trim().Length != 0) && i == 5) { continue; } if (owner.Text.Trim().Length != 0 && i == 21) { continue; } if (sanad.Text.Trim().Length != 0 && i == 17) { continue; } dt.Columns.Remove(cols[i]); } res.gridView.DataSource = dt; res.Show(); } } catch (Exception) { errorOccurred = true; MessageBox.Show("خطا در اتصال و یا اجرای درخواست از پایگاه داده ها", "خطا", MessageBoxButton.OK, MessageBoxImage.Error); } }
private String model1() // when user fill rahn_low rahn_high ejare_low ejare_high { String sql = ""; TextRange _text = new TextRange(comments.Document.ContentStart, comments.Document.ContentEnd); String cmt = _text.Text; cmt = cmt.Remove(cmt.Length - 2); if (WndConfig.getConfig().rahn_complete&& ejare_Low.Text.Trim().Length == 0 && ejare_High.Text.Trim().Length == 0 && (rahn_Low.Text.Trim().Length != 0 || rahn_High.Text.Trim().Length != 0)) // rahn e complete { sql = "EXEC SearchApartmanMaskooniSRahnComplete N'" + address_Txt.Text + "',N'" + metraj_Low.Text + "',N'" + metraj_High.Text + "',N'" + bedrooms_Low.Text + "',N'" + bedrooms_High.Text + "',N'" + owner.Text + "',N'" + MyPriceTextBox.getStringFromMasked(rahn_Low.Text) + "',N'" + MyPriceTextBox.getStringFromMasked(rahn_High.Text) + "',N'" + cmt + "'"; } else { sql = "EXEC SearchApartmanMaskooniSSimple N'" + address_Txt.Text + "',N'" + metraj_Low.Text + "',N'" + metraj_High.Text + "',N'" + bedrooms_Low.Text + "',N'" + bedrooms_High.Text + "',N'" + owner.Text + "',N'" + MyPriceTextBox.getStringFromMasked(rahn_Low.Text) + "',N'" + MyPriceTextBox.getStringFromMasked(rahn_High.Text) + "',N'" + MyPriceTextBox.getStringFromMasked(ejare_Low.Text) + "',N'" + MyPriceTextBox.getStringFromMasked(ejare_High.Text) + "',N'" + cmt + "'"; } return(sql); }
private String model1() // when user fill rahn_low rahn_high ejare_low ejare_high { String sql = "EXEC SearchManzelSSimple N'" + address_Txt.Text + "',N'" + metraj_Low.Text + "',N'" + metraj_High.Text + "',N'" + zirbanaa_Low.Text + "',N'" + zirbanaa_High.Text + "',N'" + tabaghaat_Low.Text + "',N'" + tabaghaat_High.Text + "',N'" + vahed_Low.Text + "',N'" + vahed_High.Text + "',N'" + owner.Text + "',N'" + MyPriceTextBox.getStringFromMasked(rahn_Low.Text) + "',N'" + MyPriceTextBox.getStringFromMasked(rahn_High.Text) + "',N'" + MyPriceTextBox.getStringFromMasked(ejare_Low.Text) + "',N'" + MyPriceTextBox.getStringFromMasked(ejare_High.Text) + "'"; return(sql); }