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 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 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(); } } } } }