public int AddOptionSelection(SelectionDetail selection) { StudentOptionChoice s = new StudentOptionChoice() { StudentNumber = selection.StudentNumber, FirstName = selection.FirstName, LastName = selection.LastName, FirstChoice = selection.FirstChoice, SecondChoice = selection.SecondChoice, ThirdChoice = selection.ThirdChoice, FourthChoice = selection.FourthChoice, CreateDate = DateTime.Now.Date, Year = Convert.ToInt32(ConfigurationManager.AppSettings["Year"]) }; cxt.AddToStudentOptionChoices(s); cxt.SaveChanges(); return s.ChoiceId; }
private void SubmitButton_Click(object sender, RoutedEventArgs e) { string results = String.Empty; if ((results = isValidInput()).Equals(String.Empty)) { SelectionDetail selection = new SelectionDetail() { StudentNumber = StudentNumber.Text, FirstName = FirstName.Text, LastName = LastName.Text, FirstChoice = FirstOption.SelectedValue.ToString(), SecondChoice = SecondOption.SelectedValue.ToString(), ThirdChoice = ThirdOption.SelectedValue.ToString(), FourthChoice = FourthOption.SelectedValue.ToString() }; StudentOptionsService.StudentOptionsServiceClient prxy = new StudentOptionsService.StudentOptionsServiceClient(); prxy.AddOptionSelectionCompleted += new EventHandler<AddOptionSelectionCompletedEventArgs>(prxy_AddOptionSelectionCompleted); prxy.AddOptionSelectionAsync(selection); } else { ErrorWindow ew = new ErrorWindow(results); ew.Show(); } }
protected void BtnSaveClick(object sender, EventArgs e) { var surveyQuestionswithOptions = OrderProvider.GetCustomerSurvey(DistributorID); SelectionDetail selection; var lstselection = new List <SelectionDetail>(); int surveyID = SessionInfo.surveyDetails.SurveyId; int SkuQuentity = SessionInfo.surveyDetails.SurveySKUQuantity; string freeSKU = SessionInfo.surveyDetails.SurveySKU; if (surveyQuestionswithOptions != null) { foreach (var q in surveyQuestionswithOptions) { selection = new SelectionDetail(); var answerChkList = (from option in q.ListSurveyOptions let optionControl = plQuestion.FindControl("chkOption" + option.Id) as CheckBox where optionControl != null where optionControl.Checked select option.Id).ToList(); var answerTxtList = (from option in q.ListSurveyOptions let optionControl = plQuestion.FindControl("txtOption" + option.Id) as TextBox where optionControl != null select optionControl.Text).ToList(); var answerRdList = (from option in q.ListSurveyOptions let optionControl = plQuestion.FindControl("rdOption" + option.Id) as RadioButton where optionControl != null where optionControl.Checked select option.Id).ToList(); if (answerChkList != null && answerChkList.Any()) { foreach (var i in answerChkList) { selection = new SelectionDetail(); selection.QuestionId = q.Id; selection.OptionSelectionID = i; lstselection.Add(selection); CaptureComment(selection, plQuestion, q, i); } } else if (answerTxtList != null && answerTxtList.Any() && !string.IsNullOrEmpty(answerTxtList[0])) { selection.QuestionId = q.Id; selection.Feedback = answerTxtList[0]; lstselection.Add(selection); } else if (answerRdList != null && answerRdList.Any()) { foreach (var i in answerRdList) { selection.QuestionId = q.Id; selection.OptionSelectionID = i; lstselection.Add(selection); CaptureComment(selection, plQuestion, q, i); } } } var noOfQuestions = lstselection.GroupBy(qst => qst.QuestionId) .Select(grp => grp.First()) .ToList(); if (noOfQuestions.Count() == surveyQuestionswithOptions.Count()) { var result = OrderProvider.SubmitCustomerSurvey(DistributorID, surveyID, lstselection); if ((result == null) || (result.Status != ServiceResponseStatusType.Success)) { lblErrorMessage.Text = "无法提交。请重试"; lblErrorMessage.Visible = true; } else { lblErrorMessage.Text = ""; lblErrorMessage.Visible = false; OrderProvider.AddFreeGift(freeSKU, SkuQuentity, (ProductsBase).ProductInfoCatalog.AllSKUs, ProductsBase.CurrentWarehouse, ShoppingCart); ScriptManager.RegisterStartupScript(this, GetType(), "popup", "alert('" + surveyMessage + "');" + "window.location='ShoppingCart.aspx';", true); } } else { lblErrorMessage.Text = "请填写所有领域"; lblErrorMessage.Visible = true; } } }