Beispiel #1
0
        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 SearchManzelSRahnComplete 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'" + cmt + "'";
            }
            else
            {
                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) + "',N'" + cmt + "'";
            }
            return(sql);
        }
        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 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);
                    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);
                }
            }
        }
Beispiel #3
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            this.Topmost  = false;
            errorOccurred = false;
            try
            {
                String sql = "EXEC SearchBaghVillaFSimple N'" + address_Txt.Text + "',N'" + area_Low.Text + "',N'"
                             + area_High.Text + "',N'" + owner.Text + "',N'"
                             + MyPriceTextBox.getStringFromMasked(price_Low.Text) + "',N'"
                             + MyPriceTextBox.getStringFromMasked(price_High.Text) + "'";

                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.BaghVillaForooshi;

                    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 == 24)
                        {
                            continue;
                        }
                        if ((area_Low.Text.Trim().Length != 0 || area_High.Text.Trim().Length != 0) && i == 3)
                        {
                            continue;
                        }
                        if (owner.Text.Trim().Length != 0 && i == 20)
                        {
                            continue;
                        }
                        dt.Columns.Remove(cols[i]);
                    }
                    res.gridView.DataSource = dt;
                    res.Show();
                }
            }
            catch (Exception)
            {
                errorOccurred = true;
                MessageBox.Show("خطا در اتصال و یا اجرای درخواست از پایگاه داده ها", "خطا", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Beispiel #4
0
        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);
        }
 void price_Tick(object sender, EventArgs e)
 {
     MyPriceTextBox.doMask(rahnl, rahn_Low);
     MyPriceTextBox.doMask(rahnh, rahn_High);
     MyPriceTextBox.doMask(ejarel, ejare_Low);
     MyPriceTextBox.doMask(ejareh, ejare_High);
     MyPriceTextBox.doMask(rahnoejarel, rahnoejare_Low);
     MyPriceTextBox.doMask(rahnoejareh, rahnoejare_High);
 }
        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);
            }
        }
Beispiel #7
0
        private void before_button_Click(object sender, RoutedEventArgs e)
        {
            if (index - 1 < 0)
            {
                return;
            }

            removeLbl.Visibility = Visibility.Hidden;
            Object[] obj = dt.Rows[--index].ItemArray;
            this.ID_Lbl.Content       = Codes.MaghazeEstijari + " - " + obj[0].ToString();
            this.date_Lbl.Content     = obj[1].ToString();
            this.textBox1.Text        = obj[2].ToString();
            this.textBox2.Text        = obj[3].ToString();
            this.textBox3.Text        = obj[4].ToString();
            this.textBox4.Text        = obj[5].ToString();
            this.textBox5.Text        = obj[6].ToString();
            this.textBox6.Text        = obj[7].ToString();
            this.textBox7.Text        = obj[8].ToString();
            this.textBox8.Text        = obj[9].ToString();
            this.textBox9.Text        = obj[10].ToString();
            this.textBox10.Text       = obj[11].ToString();
            this.textBox11.Text       = obj[12].ToString();
            this.textBox12.Text       = obj[13].ToString();
            this.textBox13.Text       = obj[14].ToString();
            this.textBox14.Text       = obj[15].ToString();
            this.textBox15.Text       = obj[16].ToString();
            this.textBox16.Text       = obj[17].ToString();
            this.textBox17.Text       = obj[18].ToString();
            this.textBox18.Text       = obj[19].ToString();
            this.textBox19.Text       = obj[20].ToString();
            this.textBox20.Text       = obj[21].ToString();
            this.textBox21.Text       = MyPriceTextBox.doMaskOnce(obj[22].ToString());
            this.textBox22.Text       = MyPriceTextBox.doMaskOnce(obj[23].ToString());
            this.textBox23.Text       = obj[24].ToString();
            this.checkBox1.IsChecked  = (bool)obj[25];
            this.checkBox2.IsChecked  = (bool)obj[26];
            this.checkBox3.IsChecked  = (bool)obj[27];
            this.checkBox4.IsChecked  = (bool)obj[28];
            this.checkBox5.IsChecked  = (bool)obj[29];
            this.checkBox6.IsChecked  = (bool)obj[30];
            this.checkBox7.IsChecked  = (bool)obj[31];
            this.checkBox8.IsChecked  = (bool)obj[32];
            this.checkBox9.IsChecked  = (bool)obj[33];
            this.checkBox10.IsChecked = (bool)obj[34];
            this.checkBox11.IsChecked = (bool)obj[35];
            this.checkBox12.IsChecked = (bool)obj[36];
            this.checkBox13.IsChecked = (bool)obj[37];
            this.checkBox14.IsChecked = (bool)obj[38];
            this.checkBox15.IsChecked = (bool)obj[39];
            this.checkBox16.IsChecked = (bool)obj[40];
            TextRange _RText = new TextRange(this.richTextBox1.Document.ContentStart, this.richTextBox1.Document.ContentEnd);

            _RText.Text             = obj[41].ToString();
            this.txt_Moarefino.Text = obj[42].ToString();
        }
        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);
        }
Beispiel #9
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 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 InsertApartmanMaskooniF '" + 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) + "'," + 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
                                                      + ",N'" + _RText.Text + "',N'" + textBox22.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 || textBox7.IsFocused)
                        {
                            textBox1.Focus();
                        }
                        else if (textBox8.IsFocused)
                        {
                            textBox2.Focus();
                        }
                        else if (textBox9.IsFocused)
                        {
                            textBox8.Focus();
                        }
                        else if (textBox10.IsFocused)
                        {
                            textBox9.Focus();
                        }
                        else if (textBox11.IsFocused)
                        {
                            textBox5.Focus();
                        }
                        else if (textBox12.IsFocused)
                        {
                            textBox10.Focus();
                        }
                        else if (textBox13.IsFocused)
                        {
                            textBox12.Focus();
                        }
                        else if (textBox14.IsFocused)
                        {
                            textBox11.Focus();
                        }
                        else if (textBox15.IsFocused)
                        {
                            textBox14.Focus();
                        }
                        else if (textBox16.IsFocused)
                        {
                            textBox13.Focus();
                        }
                        else if (textBox17.IsFocused)
                        {
                            textBox16.Focus();
                        }
                        else if (textBox18.IsFocused)
                        {
                            textBox17.Focus();
                        }
                        else if (textBox20.IsFocused)
                        {
                            textBox18.Focus();
                        }
                        else if (textBox21.IsFocused)
                        {
                            textBox19.Focus();
                        }
                        else if (richTextBox1.IsFocused)
                        {
                            textBox20.Focus();
                        }
                        else if (textBox22.IsFocused)
                        {
                            checkBox15.Focus();
                        }
                    }
                    else if (e.Key == Key.Down)
                    {
                        if (textBox1.IsFocused)
                        {
                            textBox2.Focus();
                        }
                        else if (textBox2.IsFocused || textBox3.IsFocused)
                        {
                            textBox8.Focus();
                        }
                        else if (textBox4.IsFocused || textBox5.IsFocused)
                        {
                            textBox11.Focus();
                        }
                        else if (textBox6.IsFocused)
                        {
                            checkBox1.Focus();
                        }
                        else if (textBox7.IsFocused)
                        {
                            checkBox9.Focus();
                        }
                        else if (textBox8.IsFocused)
                        {
                            textBox9.Focus();
                        }
                        else if (textBox9.IsFocused)
                        {
                            textBox10.Focus();
                        }
                        else if (textBox10.IsFocused)
                        {
                            textBox12.Focus();
                        }
                        else if (textBox12.IsFocused)
                        {
                            textBox13.Focus();
                        }
                        else if (textBox13.IsFocused || textBox15.IsFocused)
                        {
                            textBox16.Focus();
                        }
                        else if (textBox11.IsFocused)
                        {
                            textBox14.Focus();
                        }
                        else if (textBox14.IsFocused)
                        {
                            textBox15.Focus();
                        }
                        else if (textBox16.IsFocused)
                        {
                            textBox17.Focus();
                        }
                        else if (textBox17.IsFocused)
                        {
                            textBox18.Focus();
                        }
                        else if (textBox18.IsFocused)
                        {
                            textBox20.Focus();
                        }
                        else if (textBox19.IsFocused)
                        {
                            textBox21.Focus();
                        }
                        else if (textBox20.IsFocused || textBox21.IsFocused)
                        {
                            richTextBox1.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)
                        {
                            textBox11.Focus();
                        }
                        else if (textBox9.IsFocused || textBox10.IsFocused)
                        {
                            textBox14.Focus();
                        }
                        else if (textBox12.IsFocused || textBox13.IsFocused)
                        {
                            textBox15.Focus();
                        }
                        else if (textBox18.IsFocused)
                        {
                            textBox19.Focus();
                        }
                        else if (textBox20.IsFocused)
                        {
                            textBox21.Focus();
                        }
                        else if (richTextBox1.IsFocused)
                        {
                            textBox22.Focus();
                        }
                        else if (textBox11.IsFocused || textBox14.IsFocused || textBox15.IsFocused || textBox16.IsFocused || textBox17.IsFocused || textBox19.IsFocused || textBox21.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 (textBox11.IsFocused)
                        {
                            textBox8.Focus();
                        }
                        else if (textBox14.IsFocused)
                        {
                            textBox9.Focus();
                        }
                        else if (textBox15.IsFocused)
                        {
                            textBox12.Focus();
                        }
                        else if (textBox19.IsFocused)
                        {
                            textBox18.Focus();
                        }
                        else if (textBox21.IsFocused)
                        {
                            textBox20.Focus();
                        }
                    }
                }
            }
        }
        private void next_button_Click(object sender, RoutedEventArgs e)
        {
            if (index + 1 >= dt.Rows.Count)
            {
                return;
            }

            removeLbl.Visibility = Visibility.Hidden;
            Object[] obj = dt.Rows[++index].ItemArray;
            this.ID_Lbl.Content       = Codes.ApartmanMaskooniForooshi.ToString() + " - " + obj[0].ToString();
            this.date_Lbl.Content     = obj[1].ToString();
            this.textBox1.Text        = obj[2].ToString();
            this.textBox2.Text        = obj[3].ToString();
            this.textBox3.Text        = obj[4].ToString();
            this.textBox4.Text        = obj[5].ToString();
            this.textBox5.Text        = obj[6].ToString();
            this.textBox6.Text        = obj[7].ToString();
            this.textBox7.Text        = obj[8].ToString();
            this.textBox8.Text        = obj[9].ToString();
            this.textBox9.Text        = obj[10].ToString();
            this.textBox10.Text       = obj[11].ToString();
            this.textBox11.Text       = obj[12].ToString();
            this.textBox12.Text       = obj[13].ToString();
            this.textBox13.Text       = obj[14].ToString();
            this.textBox14.Text       = obj[15].ToString();
            this.textBox15.Text       = obj[16].ToString();
            this.textBox16.Text       = obj[17].ToString();
            this.textBox17.Text       = obj[18].ToString();
            this.textBox18.Text       = obj[19].ToString();
            this.textBox19.Text       = obj[20].ToString();
            this.textBox20.Text       = MyPriceTextBox.doMaskOnce(obj[21].ToString());
            this.textBox21.Text       = MyPriceTextBox.doMaskOnce(obj[22].ToString());
            this.checkBox1.IsChecked  = (bool)obj[23];
            this.checkBox2.IsChecked  = (bool)obj[24];
            this.checkBox3.IsChecked  = (bool)obj[25];
            this.checkBox4.IsChecked  = (bool)obj[26];
            this.checkBox5.IsChecked  = (bool)obj[27];
            this.checkBox6.IsChecked  = (bool)obj[28];
            this.checkBox7.IsChecked  = (bool)obj[29];
            this.checkBox8.IsChecked  = (bool)obj[30];
            this.checkBox9.IsChecked  = (bool)obj[31];
            this.checkBox10.IsChecked = (bool)obj[32];
            this.checkBox11.IsChecked = (bool)obj[33];
            this.checkBox12.IsChecked = (bool)obj[34];
            this.checkBox13.IsChecked = (bool)obj[35];
            this.checkBox14.IsChecked = (bool)obj[36];
            this.checkBox15.IsChecked = (bool)obj[37];
            this.checkBox16.IsChecked = (bool)obj[38];
            this.checkBox17.IsChecked = (bool)obj[39];
            this.checkBox18.IsChecked = (bool)obj[40];
            this.checkBox19.IsChecked = (bool)obj[41];
            this.checkBox20.IsChecked = (bool)obj[42];
            this.checkBox21.IsChecked = (bool)obj[43];
            this.checkBox22.IsChecked = (bool)obj[44];
            this.checkBox23.IsChecked = (bool)obj[45];
            this.checkBox24.IsChecked = (bool)obj[46];
            this.checkBox25.IsChecked = (bool)obj[47];
            this.checkBox26.IsChecked = (bool)obj[48];
            this.checkBox27.IsChecked = (bool)obj[49];
            TextRange _RText = new TextRange(this.richTextBox1.Document.ContentStart, this.richTextBox1.Document.ContentEnd);

            _RText.Text         = obj[50].ToString();
            this.textBox22.Text = obj[51].ToString();
        }
Beispiel #12
0
        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'" + MyPriceTextBox.getStringFromMasked(textBox19.Text)
                               + "'",                   "N'" + MyPriceTextBox.getStringFromMasked(textBox20.Text)
                               + "'",                   "N'" + textBox21.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()
                               ,                        checkBox16.IsChecked.ToString(), checkBox17.IsChecked.ToString(), checkBox18.IsChecked.ToString()
                               ,                        checkBox19.IsChecked.ToString(), checkBox20.IsChecked.ToString(), checkBox21.IsChecked.ToString()
                               ,                        checkBox22.IsChecked.ToString(), checkBox23.IsChecked.ToString(), checkBox24.IsChecked.ToString()
                               ,                        checkBox25.IsChecked.ToString(), checkBox26.IsChecked.ToString(), checkBox27.IsChecked.ToString()
                               ,                        "N'" + _RText.Text + "'",        "N'" + textBox22.Text + "'" };

                SearchSQL sq = new SearchSQL(s, "SearchApartmanMaskooniS");
                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.ApartmanMaskooniEstijari;

                    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 (textBox21.Text.Trim().Length == 0)
                        {
                            dt.Columns.Remove(cols[22]);
                        }
                        if (checkBox1.IsChecked == false)
                        {
                            dt.Columns.Remove(cols[23]);
                        }
                        if (checkBox2.IsChecked == false)
                        {
                            dt.Columns.Remove(cols[24]);
                        }
                        if (checkBox3.IsChecked == false)
                        {
                            dt.Columns.Remove(cols[25]);
                        }
                        if (checkBox4.IsChecked == false)
                        {
                            dt.Columns.Remove(cols[26]);
                        }
                        if (checkBox5.IsChecked == false)
                        {
                            dt.Columns.Remove(cols[27]);
                        }
                        if (checkBox6.IsChecked == false)
                        {
                            dt.Columns.Remove(cols[28]);
                        }
                        if (checkBox7.IsChecked == false)
                        {
                            dt.Columns.Remove(cols[29]);
                        }
                        if (checkBox8.IsChecked == false)
                        {
                            dt.Columns.Remove(cols[30]);
                        }
                        if (checkBox9.IsChecked == false)
                        {
                            dt.Columns.Remove(cols[31]);
                        }
                        if (checkBox10.IsChecked == false)
                        {
                            dt.Columns.Remove(cols[32]);
                        }
                        if (checkBox11.IsChecked == false)
                        {
                            dt.Columns.Remove(cols[33]);
                        }
                        if (checkBox12.IsChecked == false)
                        {
                            dt.Columns.Remove(cols[34]);
                        }
                        if (checkBox13.IsChecked == false)
                        {
                            dt.Columns.Remove(cols[35]);
                        }
                        if (checkBox14.IsChecked == false)
                        {
                            dt.Columns.Remove(cols[36]);
                        }
                        if (checkBox15.IsChecked == false)
                        {
                            dt.Columns.Remove(cols[37]);
                        }
                        if (checkBox16.IsChecked == false)
                        {
                            dt.Columns.Remove(cols[38]);
                        }
                        if (checkBox17.IsChecked == false)
                        {
                            dt.Columns.Remove(cols[39]);
                        }
                        if (checkBox18.IsChecked == false)
                        {
                            dt.Columns.Remove(cols[40]);
                        }
                        if (checkBox19.IsChecked == false)
                        {
                            dt.Columns.Remove(cols[41]);
                        }
                        if (checkBox20.IsChecked == false)
                        {
                            dt.Columns.Remove(cols[42]);
                        }
                        if (checkBox21.IsChecked == false)
                        {
                            dt.Columns.Remove(cols[43]);
                        }
                        if (checkBox22.IsChecked == false)
                        {
                            dt.Columns.Remove(cols[44]);
                        }
                        if (checkBox23.IsChecked == false)
                        {
                            dt.Columns.Remove(cols[45]);
                        }
                        if (checkBox24.IsChecked == false)
                        {
                            dt.Columns.Remove(cols[46]);
                        }
                        if (checkBox25.IsChecked == false)
                        {
                            dt.Columns.Remove(cols[47]);
                        }
                        if (checkBox26.IsChecked == false)
                        {
                            dt.Columns.Remove(cols[48]);
                        }
                        if (checkBox27.IsChecked == false)
                        {
                            dt.Columns.Remove(cols[49]);
                        }
                        if (_RText.Text == "\r\n")
                        {
                            dt.Columns.Remove(cols[50]);
                        }
                        if (textBox22.Text.Length == 0)
                        {
                            dt.Columns.Remove(cols[51]);
                        }
                    }
                    res.gridView.DataSource = dt;
                    res.dbIndex             = DBComboBox.SelectedIndex;
                    res.Show();
                }
            }
            catch (Exception)
            {
                errorOccurred = true;
                MessageBox.Show("خطا در اتصال و یا اجرای درخواست از پایگاه داده ها", "خطا", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Beispiel #13
0
 void price_Tick(object sender, EventArgs e)
 {
     MyPriceTextBox.doMask(rahn, textBox19);
     MyPriceTextBox.doMask(ejare, textBox20);
 }
 void price_Tick(object sender, EventArgs e)
 {
     MyPriceTextBox.doMask(pricel, price_Low);
     MyPriceTextBox.doMask(priceh, price_High);
 }
Beispiel #15
0
        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 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.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
                    {
                        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)
                        {
                            textBox8.Focus();
                        }
                        else if (textBox10.IsFocused)
                        {
                            textBox9.Focus();
                        }
                        else if (textBox11.IsFocused)
                        {
                            textBox5.Focus();
                        }
                        else if (textBox12.IsFocused)
                        {
                            textBox10.Focus();
                        }
                        else if (textBox13.IsFocused)
                        {
                            textBox11.Focus();
                        }
                        else if (textBox14.IsFocused)
                        {
                            textBox13.Focus();
                        }
                        else if (textBox15.IsFocused)
                        {
                            textBox14.Focus();
                        }
                        else if (textBox16.IsFocused)
                        {
                            textBox15.Focus();
                        }
                        else if (textBox17.IsFocused)
                        {
                            textBox16.Focus();
                        }
                        else if (textBox18.IsFocused || textBox19.IsFocused)
                        {
                            textBox17.Focus();
                        }
                        else if (textBox20.IsFocused)
                        {
                            textBox18.Focus();
                        }
                        else if (textBox21.IsFocused)
                        {
                            textBox19.Focus();
                        }
                        else if (textBox22.IsFocused)
                        {
                            textBox20.Focus();
                        }
                        else if (richTextBox1.IsFocused)
                        {
                            textBox22.Focus();
                        }
                        else if (textBox23.IsFocused)
                        {
                            checkBox15.Focus();
                        }
                    }
                    else if (e.Key == Key.Down)
                    {
                        if (textBox1.IsFocused)
                        {
                            textBox2.Focus();
                        }
                        else if (textBox2.IsFocused || textBox3.IsFocused)
                        {
                            textBox8.Focus();
                        }
                        else if (textBox4.IsFocused || textBox5.IsFocused)
                        {
                            textBox11.Focus();
                        }
                        else if (textBox6.IsFocused)
                        {
                            checkBox1.Focus();
                        }
                        else if (textBox7.IsFocused)
                        {
                            checkBox9.Focus();
                        }
                        else if (textBox8.IsFocused)
                        {
                            textBox9.Focus();
                        }
                        else if (textBox9.IsFocused)
                        {
                            textBox10.Focus();
                        }
                        else if (textBox10.IsFocused)
                        {
                            textBox12.Focus();
                        }
                        else if (textBox12.IsFocused || textBox15.IsFocused)
                        {
                            textBox16.Focus();
                        }
                        else if (textBox11.IsFocused)
                        {
                            textBox13.Focus();
                        }
                        else if (textBox13.IsFocused)
                        {
                            textBox14.Focus();
                        }
                        else if (textBox14.IsFocused)
                        {
                            textBox15.Focus();
                        }
                        else if (textBox16.IsFocused)
                        {
                            textBox17.Focus();
                        }
                        else if (textBox17.IsFocused)
                        {
                            textBox18.Focus();
                        }
                        else if (textBox18.IsFocused)
                        {
                            textBox20.Focus();
                        }
                        else if (textBox19.IsFocused)
                        {
                            textBox21.Focus();
                        }
                        else if (textBox20.IsFocused || textBox21.IsFocused)
                        {
                            textBox22.Focus();
                        }
                        else if (textBox22.IsFocused || textBox23.IsFocused)
                        {
                            richTextBox1.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)
                        {
                            textBox11.Focus();
                        }
                        else if (textBox9.IsFocused)
                        {
                            textBox13.Focus();
                        }
                        else if (textBox10.IsFocused)
                        {
                            textBox14.Focus();
                        }
                        else if (textBox12.IsFocused)
                        {
                            textBox15.Focus();
                        }
                        else if (textBox18.IsFocused)
                        {
                            textBox19.Focus();
                        }
                        //else if (textBox20.IsFocused) textBox21.Focus();
                        else if (textBox22.IsFocused)
                        {
                            textBox23.Focus();
                        }
                        else if (richTextBox1.IsFocused)
                        {
                            textBox23.Focus();
                        }
                        else if (textBox11.IsFocused || textBox13.IsFocused || textBox14.IsFocused || textBox15.IsFocused || textBox16.IsFocused || textBox17.IsFocused || textBox19.IsFocused || textBox21.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 (textBox11.IsFocused)
                        {
                            textBox8.Focus();
                        }
                        else if (textBox13.IsFocused)
                        {
                            textBox9.Focus();
                        }
                        else if (textBox14.IsFocused)
                        {
                            textBox10.Focus();
                        }
                        else if (textBox15.IsFocused)
                        {
                            textBox12.Focus();
                        }
                        else if (textBox19.IsFocused)
                        {
                            textBox18.Focus();
                        }
                        //else if (textBox21.IsFocused) textBox20.Focus();
                        else if (textBox23.IsFocused)
                        {
                            textBox22.Focus();
                        }
                    }
                    else if (e.Key == Key.Escape)
                    {
                        TextRange _text = new TextRange(richTextBox1.Document.ContentStart, richTextBox1.Document.ContentEnd);
                        if (_text.Text.Trim() == "" && textBox1.Text.Trim() == "" && textBox2.Text.Trim() == "" && textBox3.Text.Trim() == "" && textBox4.Text.Trim() == "" && textBox5.Text.Trim() == "" && textBox6.Text.Trim() == "" && textBox7.Text.Trim() == "" && textBox8.Text.Trim() == "" && textBox9.Text.Trim() == "" && textBox10.Text.Trim() == "" && textBox11.Text.Trim() == "" && textBox12.Text.Trim() == "" && textBox13.Text.Trim() == "" && textBox14.Text.Trim() == "" && textBox15.Text.Trim() == "" && textBox16.Text.Trim() == "" && textBox17.Text.Trim() == "" && textBox18.Text.Trim() == "" && textBox19.Text.Trim() == "" && textBox20.Text.Trim() == "" && textBox21.Text.Trim() == "" && textBox22.Text.Trim() == "" && textBox23.Text.Trim() == "")
                        {
                            Close();
                            return;
                        }
                        MessageBoxResult res = MessageBox.Show("آیا می خواهید صفحه ی ثبت را ببندید ؟", "ثبت", MessageBoxButton.YesNo, MessageBoxImage.Question);
                        if (res == MessageBoxResult.Yes)
                        {
                            Close();
                        }
                    }
                }
            }
        }
        private void search_button_Click(object sender, RoutedEventArgs e)
        {
            this.Topmost = false;
            try
            {
                String sql = "EXEC SearchApartmanMaskooniFSimple N'" + address_Txt.Text + "',N'" + metraj_Low.Text + "',N'"
                             + metraj_High.Text + "',N'" + bedrooms_Low.Text + "',N'" + bedrooms_High.Text + "',N'" + vahedha_Low.Text
                             + "',N'" + vahedha_High.Text + "',N'" + sakht_Low.Text + "',N'" + sakht_High.Text + "',N'" + owner.Text
                             + "',N'" + MyPriceTextBox.getStringFromMasked(price_Low.Text) + "',N'" + MyPriceTextBox.getStringFromMasked(price_High.Text) + "'";

                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.dt    = dt.Copy();
                    res.which = Codes.ApartmanMaskooniForooshi;
                    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 == 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 ((vahedha_Low.Text.Trim().Length != 0 || vahedha_High.Text.Trim().Length != 0) && i == 10)
                        {
                            continue;
                        }
                        if ((sakht_Low.Text.Trim().Length != 0 || sakht_High.Text.Trim().Length != 0) && i == 8)
                        {
                            continue;
                        }
                        if (owner.Text.Trim().Length != 0 && i == 19)
                        {
                            continue;
                        }
                        if ((price_Low.Text.Trim().Length != 0 || price_High.Text.Trim().Length != 0) && i == 22)
                        {
                            continue;
                        }
                        dt.Columns.Remove(cols[i]);
                    }
                    res.gridView.DataSource = dt;
                    res.Show();
                }
            }
            catch (Exception)
            {
                MessageBox.Show("خطا در اتصال و یا اجرای درخواست از پایگاه داده ها", "خطا", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Beispiel #17
0
        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 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.execSqlReturnScalarInArchive(sqlForArchive).ToString();
                            DataTable dt2 = (DataTable)gridView.DataSource;
                            for (int i = 0; i < dt2.Rows.Count; i++)
                            {
                                String sq = "EXEC InsertMajmooeS " + sid;

                                /*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)
                        {
                            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 (textBox7.IsFocused)
                        {
                            textBox6.Focus();
                        }
                        else if (textBox12.IsFocused)
                        {
                            textBox10.Focus();
                        }
                        else if (textBox13.IsFocused)
                        {
                            textBox8.Focus();
                        }
                        else if (textBox14.IsFocused || textBox15.IsFocused)
                        {
                            textBox18.Focus();
                        }
                        else if (textBox18.IsFocused)
                        {
                            gridView.Focus();
                        }
                        else if (textBox16.IsFocused)
                        {
                            textBox14.Focus();
                        }
                        else if (textBox17.IsFocused)
                        {
                            textBox15.Focus();
                        }
                        else if (richTextBox1.IsFocused)
                        {
                            textBox16.Focus();
                        }
                        else if (txt_Moarefino.IsFocused)
                        {
                            checkBox14.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)
                        {
                            textBox7.Focus();
                        }
                        else if (textBox7.IsFocused || textBox11.IsFocused || textBox10.IsFocused)
                        {
                            textBox12.Focus();
                        }
                        else if (textBox8.IsFocused || textBox9.IsFocused)
                        {
                            textBox13.Focus();
                        }
                        else if (textBox12.IsFocused || textBox13.IsFocused)
                        {
                            gridView.Focus();
                        }
                        else if (textBox14.IsFocused)
                        {
                            textBox16.Focus();
                        }
                        else if (textBox15.IsFocused)
                        {
                            textBox17.Focus();
                        }
                        else if (textBox18.IsFocused)
                        {
                            textBox14.Focus();
                        }
                        else if (textBox16.IsFocused || textBox17.IsFocused)
                        {
                            richTextBox1.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 (textBox8.IsFocused)
                        {
                            textBox9.Focus();
                        }
                        else if (textBox9.IsFocused)
                        {
                            textBox10.Focus();
                        }
                        else if (textBox10.IsFocused)
                        {
                            textBox11.Focus();
                        }
                        else if (textBox11.IsFocused)
                        {
                            textBox7.Focus();
                        }
                        else if (textBox13.IsFocused)
                        {
                            textBox12.Focus();
                        }
                        else if (textBox14.IsFocused && !gridView.Focused)
                        {
                            textBox15.Focus();
                        }
                        //else if (textBox16.IsFocused) textBox17.Focus();
                        else if (richTextBox1.IsFocused)
                        {
                            txt_Moarefino.Focus();
                        }
                        else if (textBox15.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 (textBox9.IsFocused)
                        {
                            textBox8.Focus();
                        }
                        else if (textBox10.IsFocused)
                        {
                            textBox9.Focus();
                        }
                        else if (textBox11.IsFocused)
                        {
                            textBox10.Focus();
                        }
                        else if (textBox7.IsFocused)
                        {
                            textBox11.Focus();
                        }
                        else if (textBox12.IsFocused)
                        {
                            textBox13.Focus();
                        }
                        else if (textBox15.IsFocused && !gridView.Focused)
                        {
                            textBox14.Focus();
                        }
                        //else if (textBox17.IsFocused) textBox16.Focus();
                        else if (txt_Moarefino.IsFocused)
                        {
                            richTextBox1.Focus();
                        }
                    }
                    else if (e.Key == Key.RightCtrl || e.Key == Key.LeftCtrl)
                    {
                        textBox18.Focus();
                    }
                }
            }
        }
        private void search_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)
                        {
                            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.HouseEstijari;

                    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 == 17 || i == 18)
                        {
                            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.Show();
                }
            }
            catch (Exception)
            {
                errorOccurred = true;
                MessageBox.Show("خطا در اتصال و یا اجرای درخواست از پایگاه داده ها", "خطا", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
 void price_Tick(object sender, EventArgs e)
 {
     MyPriceTextBox.doMask(pricemeter, textBox20);
     MyPriceTextBox.doMask(pricetotal, textBox21);
 }
Beispiel #20
0
        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 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) + "',N'" + cmt + "'";


                if (Show3D_checkBox.IsChecked == true)    // 3d result
                {
                    Result3D  res = new Result3D();
                    DataTable dt  = DB.execSqlReturnDataTable(sql, DBComboBox.SelectedIndex);
                    res.dt = dt;
                    res.Show();
                }
                else    // usual result
                {
                    ResultWindow res = new ResultWindow();
                    res.session = session;
                    DataTable dt = DB.execSqlReturnDataTable(sql, DBComboBox.SelectedIndex);
                    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.dbIndex             = DBComboBox.SelectedIndex;
                    res.Show();
                }
            }
            catch (Exception)
            {
                errorOccurred = true;
                MessageBox.Show("خطا در اتصال و یا اجرای درخواست از پایگاه داده ها", "خطا", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Beispiel #21
0
        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 EditManzelS " + 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'" + 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 + "'";

                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 RemoveMajmooeBySID " + id;
                DB.execSql(remsql, 0);

                DataTable dt2 = (DataTable)gridView.DataSource;
                for (int i = 0; i < dt2.Rows.Count; i++)
                {
                    String sq = "EXEC InsertMajmooeS " + 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] = MyPriceTextBox.getStringFromMasked(textBox16.Text);
            dr[18] = MyPriceTextBox.getStringFromMasked(textBox17.Text);
            dr[19] = textBox18.Text;
            dr[20] = checkBox1.IsChecked;
            dr[21] = checkBox2.IsChecked;
            dr[22] = checkBox3.IsChecked;
            dr[23] = checkBox4.IsChecked;
            dr[24] = checkBox5.IsChecked;
            dr[25] = checkBox6.IsChecked;
            dr[26] = checkBox7.IsChecked;
            dr[27] = checkBox8.IsChecked;
            dr[28] = checkBox9.IsChecked;
            dr[29] = checkBox10.IsChecked;
            dr[30] = checkBox11.IsChecked;
            dr[31] = checkBox12.IsChecked;
            dr[32] = checkBox13.IsChecked;
            dr[33] = checkBox14.IsChecked;
            dr[34] = _RText.Text;
            dr[35] = txt_Moarefino.Text;
            dr.EndEdit();

            dt.Rows.RemoveAt(index);
            dt.Rows.InsertAt(dr, index);

            editing = false;
            price.Stop();
        }
        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 EditApartmanMaskooniF " + 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'" + 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 + "," + 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
                             + ",N'" + _RText.Text + "',N'" + textBox22.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] = 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] = checkBox15.IsChecked;
            dr[38] = checkBox16.IsChecked;
            dr[39] = checkBox17.IsChecked;
            dr[40] = checkBox18.IsChecked;
            dr[41] = checkBox19.IsChecked;
            dr[42] = checkBox20.IsChecked;
            dr[43] = checkBox21.IsChecked;
            dr[44] = checkBox22.IsChecked;
            dr[45] = checkBox23.IsChecked;
            dr[46] = checkBox24.IsChecked;
            dr[47] = checkBox25.IsChecked;
            dr[48] = checkBox26.IsChecked;
            dr[49] = checkBox27.IsChecked;
            dr[50] = _RText.Text;
            dr[51] = textBox22.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 _text = new TextRange(comments.Document.ContentStart, comments.Document.ContentEnd);
            String    cmt   = _text.Text;

            cmt = cmt.Remove(cmt.Length - 2);
            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)
                        {
                            MessageBox.Show("لطفا در این حالت که می خواهید از فیلد رهن و اجاره استفاده بنمایید هر دو طرف آن را پر بفرمایید", "خطا", MessageBoxButton.OK, MessageBoxImage.Error);
                            return;
                        }
                        sql = model2(low, high);
                    }
                }
                else
                {
                    sql = model1();
                }

                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.MaghazeEstijari;
                    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 || i == 23)
                        {
                            continue;
                        }
                        if ((metraj_Low.Text.Trim().Length != 0 || metraj_High.Text.Trim().Length != 0) && i == 3)
                        {
                            continue;
                        }
                        if (owner.Text.Trim().Length != 0 && i == 20)
                        {
                            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);
            }
        }