Esempio n. 1
0
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            if (cmbAnswer.SelectedValue != null)
            {
                StudioMResource.QandAForSupplier qa = new StudioMResource.QandAForSupplier();
                qa.SupplierBrandID   = int.Parse(cmbSupplier.SelectedValue.ToString());
                qa.SupplierBrandName = cmbSupplier.Text;
                qa.QuestionID        = int.Parse(cmbQuestion.SelectedValue.ToString());
                qa.QuestionText      = cmbQuestion.Text;
                qa.AnswerID          = int.Parse(cmbAnswer.SelectedValue.ToString());
                qa.AnswerText        = cmbAnswer.Text;

                foreach (var item in sr.StudioMQuestion)
                {
                    if (item.QuestionID == int.Parse(cmbQuestion.SelectedValue.ToString()))
                    {
                        qa.AnswerType = item.AnswerType;
                        break;
                    }
                }

                sr.AddStudioMAttributes(qa);
            }
            else
            {
                MessageBox.Show("Please select an answer for the question.");
            }
        }
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            int idx = dataGrid2.SelectedIndex;

            if ((cmbAnswer.Text.ToUpper().Contains("SINGLE SELECTION") || cmbAnswer.Text.ToUpper().Contains("MULTIPLE SELECTION")))
            {
                if (cmbAnswer.SelectedValue == null)
                {
                    MessageBox.Show("Please select an answer for the question.");
                }
                return;
            }

            StudioMResource.QandAForSupplier qa = new StudioMResource.QandAForSupplier();
            qa.SupplierBrandID   = int.Parse(cmbSupplier.SelectedValue.ToString());
            qa.SupplierBrandName = cmbSupplier.Text;
            qa.QuestionID        = int.Parse(cmbQuestion.SelectedValue.ToString());
            qa.QuestionText      = cmbQuestion.Text;
            qa.Mandatory         = currentquestionmandatory;
            if (cmbAnswer.SelectedValue != null)
            {
                qa.AnswerID   = int.Parse(cmbAnswer.SelectedValue.ToString());
                qa.AnswerText = cmbAnswer.Text;
            }
            else
            {
                qa.AnswerID   = 0;
                qa.AnswerText = "";
            }


            foreach (var item in rs.StudioMQuestion)
            {
                if (item.QuestionID == int.Parse(cmbQuestion.SelectedValue.ToString()))
                {
                    qa.AnswerType = item.AnswerType;
                    break;
                }
            }

            rs.AddStudioMAttributes(qa, idx);
        }
 private void btnDelete_Click(object sender, RoutedEventArgs e)
 {
     StudioMResource.QandAForSupplier qa = ((FrameworkElement)sender).DataContext as StudioMResource.QandAForSupplier;
     rs.RemoveStudioMAttributes(qa);
 }