コード例 #1
0
ファイル: SurveyPage.xaml.cs プロジェクト: naf73/Survey
 private void ManageSurvey_Click(object sender, RoutedEventArgs e)
 {
     if (!int.TryParse(SurveyTime.Text, out int time))
     {
         MessageBox.Show(LangPages.MBox.TimeEntryError);
         return;
     }
     if (time <= 0)
     {
         MessageBox.Show("Ошибка ввода времени");
     }
     if (string.IsNullOrEmpty(SurveyName.Text))
     {
         MessageBox.Show(LangPages.MBox.ErrorEnteringPollName);
         return;
     }
     if ((bool)ManageSurvey.Tag)
     {
         _survey.Name = SurveyName.Text;
         _survey.Time = time;
         surveyController.Add(_survey);
         ManageSurvey.Tag      = false;
         GridSurvey.Visibility = Visibility.Visible;
     }
     else
     {
         _survey.Name = SurveyName.Text;
         _survey.Time = time;
         surveyController.Edit(_survey);
     }
 }
コード例 #2
0
ファイル: MainForm.cs プロジェクト: CRiSTi107/EasySurvey
        private void addNewToolStripMenuItem_Click(object sender, EventArgs e)
        {
            MaterialMessageInput.MessageBoxResultInput result = MaterialMessageInput.Show("Ce nume are noul chestionar?", "Easy Survey - Add New Survey", MaterialMessageInput.MessageBoxButtonsInput.OKCancel, addSurvey: true);

            if (result == MaterialMessageInput.MessageBoxResultInput.OK)
            {
                using (SurveyController surveyController = new SurveyController())
                {
                    string SurveyName = MaterialMessageInput.Answer;

                    Survey newSurvey = new Survey {
                        SurveyName = SurveyName
                    };
                    surveyController.Add(ref newSurvey);
                    Surveys.Add(newSurvey);
                    ListViewItem newSurveyItem = new ListViewItem(listView_AllSurveys.Groups["default"])
                    {
                        Tag = newSurvey.SurveyID.ToString(), Text = newSurvey.SurveyName
                    };
                    listView_AllSurveys.Items.Add(newSurveyItem);
                    int SurveyIndex = listView_AllSurveys.Items.Count - 1;
                    listView_AllSurveys.Items[SurveyIndex].Selected = true;
                    listView_AllSurveys.Items[SurveyIndex].Focused  = true;
                    listView_AllSurveys.Items[SurveyIndex].EnsureVisible();
                }
            }
        }
コード例 #3
0
ファイル: UnitTestDB.cs プロジェクト: naf73/Survey
        public void InitDB()
        {
            if (userController.Get().Count == 0)
            {
                userController.AddAdmin();
                categoryController.Add(new Category()
                {
                    Name = "Техника безопасности"
                });
                categoryController.Add(new Category()
                {
                    Name = "Техника пожарной безопасности"
                });

                Category category = categoryController.Get()[0];

                for (int k = 0; k < 3; k++)
                {
                    List <Question> questions = new List <Question>();

                    for (int i = 0; i < 10; i++)
                    {
                        List <Answer> answers = new List <Answer>();
                        for (int j = 0; j < 3; j++)
                        {
                            if (j == 0)
                            {
                                answers.Add(new Answer()
                                {
                                    Text      = string.Format("{0} {1}", j, RandomString(23)),
                                    IsTrue    = true,
                                    IsDeleted = false
                                });
                            }
                            else
                            {
                                answers.Add(new Answer()
                                {
                                    Text      = string.Format("{0} {1}", j, RandomString(23)),
                                    IsTrue    = false,
                                    IsDeleted = false
                                });
                            }
                        }
                        questions.Add(new Question()
                        {
                            Text      = string.Format("{0} {1} ", i, RandomString(34)),
                            Answer    = answers,
                            IsDeleted = false,
                            Foto      = ConvertPicture.BitmapImageToByteArray(new BitmapImage(new Uri(@"C:\Users\Alex\source\repos\Survey\Survey\Pictures\Hamster.jpg", UriKind.Relative)))
                        });
                    }

                    surveyController.Add(new Survey.Model.Survey()
                    {
                        Name       = string.Format("{0} {1}", k, RandomString(25)),
                        CategoryId = category.Id,
                        Time       = 1,
                        Question   = questions
                    });
                }
            }
        }