private void chkChecked_Checked(object sender, RoutedEventArgs e)
        {
            if (cmbBook.SelectedIndex == -1 || cmbBase.SelectedIndex == -1)
            {
                MainWindow.main.showGrowlNotification(AppVariable.Fill_All_Data_KEY);
            }
            else
            {
                var row         = dataGrid.ContainerFromElement(sender as DependencyObject);
                var MyTextBlock = FindElement.FindVisualChildByName <TextBlock>(row, "txtStatus");

                dynamic selectedItem = dataGrid.SelectedItems[0];
                var     selectedChk  = sender as ToggleButton;
                string  newStatus    = string.Empty;
                switch ((selectedChk).Tag.ToString())
                {
                case "exc":
                    newStatus = "خیلی خوب";
                    break;

                case "good":

                    newStatus = "خوب";
                    break;

                case "nbad":
                    newStatus = "قابل قبول";
                    break;

                case "bad":
                    newStatus = "نیاز به تلاش بیشتر";
                    break;
                }
                if (MyTextBlock.Text == "ثبت نشده")
                {
                    if (isQuestion.IsChecked == true)
                    {
                        addQuestion((long)selectedItem.BaseId, (long)selectedItem.Id, cmbBook.SelectedItem.ToString());
                    }

                    insertedScoreId        = addScore((long)selectedItem.Id, cmbBook.SelectedItem.ToString(), txtDate.SelectedDate.ToString(), newStatus, (txtDesc.Text == string.Empty ? "بدون توضیحات" : txtDesc.Text));
                    MyTextBlock.Foreground = new SolidColorBrush(Colors.Green);
                    MyTextBlock.Text       = newStatus + " ثبت شده ";
                }
                else
                {
                    updateScore(insertedScoreId, (long)selectedItem.Id, newStatus, txtDate.SelectedDate.ToString(), cmbBook.SelectedItem.ToString(), (txtDesc.Text == string.Empty ? "بدون توضیحات" : txtDesc.Text));
                }

                var DeleteQuestion = _initialCollection.Where(x => x.Id == (long)selectedItem.Id).FirstOrDefault();
                _initialCollection.Remove(DeleteQuestion);

                if (!_initialCollection.Any())
                {
                    deleteQuestion((long)cmbBase.SelectedValue, cmbBook.SelectedItem.ToString());
                }
            }
        }
Пример #2
0
        private void chkChecked_Checked(object sender, RoutedEventArgs e)
        {
            var row = dataGrid.ContainerFromElement(sender as DependencyObject);

            Arthas.Controls.Metro.MetroTextBlock MyTextBlock = FindElement.FindVisualChildByName <Arthas.Controls.Metro.MetroTextBlock>(row, "txtStatus");
            dynamic selectedItem = dataGrid.SelectedItems[0];
            var     element      = FindElement.FindElementByName <ComboBox>(cmbBook, "cmbBook");

            switch ((sender as Arthas.Controls.Metro.MetroSwitch).Tag.ToString())
            {
            case "exc":
                if (MyTextBlock.Text == "ثبت نشده")
                {
                    MyTextBlock.Foreground = new SolidColorBrush(Colors.Green);
                    MyTextBlock.Text       = "ثبت شده";
                    if (isQuestion.IsChecked == true)
                    {
                        addQuestion((long)selectedItem.BaseId, (long)selectedItem.Id, element.SelectedItem.ToString());
                    }

                    addScore((long)selectedItem.Id, element.SelectedItem.ToString(), strDate, "خیلی خوب", (txtDesc.Text == string.Empty ? "بدون توضیحات" : txtDesc.Text));
                }
                break;

            case "good":
                if (MyTextBlock.Text == "ثبت نشده")
                {
                    MyTextBlock.Foreground = new SolidColorBrush(Colors.Green);
                    MyTextBlock.Text       = "ثبت شده";
                    if (isQuestion.IsChecked == true)
                    {
                        addQuestion((long)selectedItem.BaseId, (long)selectedItem.Id, element.SelectedItem.ToString());
                    }

                    addScore((long)selectedItem.Id, element.SelectedItem.ToString(), strDate, "خوب", (txtDesc.Text == string.Empty ? "بدون توضیحات" : txtDesc.Text));
                }
                break;

            case "nbad":
                if (MyTextBlock.Text == "ثبت نشده")
                {
                    MyTextBlock.Foreground = new SolidColorBrush(Colors.Green);
                    MyTextBlock.Text       = "ثبت شده";
                    if (isQuestion.IsChecked == true)
                    {
                        addQuestion((long)selectedItem.BaseId, (long)selectedItem.Id, element.SelectedItem.ToString());
                    }

                    addScore((long)selectedItem.Id, element.SelectedItem.ToString(), strDate, "قابل قبول", (txtDesc.Text == string.Empty ? "بدون توضیحات" : txtDesc.Text));
                }
                break;

            case "bad":
                if (MyTextBlock.Text == "ثبت نشده")
                {
                    MyTextBlock.Foreground = new SolidColorBrush(Colors.Green);
                    MyTextBlock.Text       = "ثبت شده";
                    if (isQuestion.IsChecked == true)
                    {
                        addQuestion((long)selectedItem.BaseId, (long)selectedItem.Id, element.SelectedItem.ToString());
                    }

                    addScore((long)selectedItem.Id, element.SelectedItem.ToString(), strDate, "نیاز به تلاش بیشتر", (txtDesc.Text == string.Empty ? "بدون توضیحات" : txtDesc.Text));
                }
                break;
            }
            var DeleteQuestion = _initialCollection.Where(x => x.Id == (long)selectedItem.Id).FirstOrDefault();

            _initialCollection.Remove(DeleteQuestion);

            if (!_initialCollection.Any())
            {
                deleteQuestion((long)cmbBase.SelectedValue, element.SelectedItem.ToString());
            }
        }