Esempio n. 1
0
 private void MarkAnswer(object sender, RoutedEventArgs e)
 {
     Data.Tasks buff = (sender as System.Windows.Controls.Button).DataContext as Data.Tasks;
     if (buff != null)
     {
         CurrentTaskView.ItemsSource = ViewModel.TasksViewModel.RefrashCurrentTask(buff);
         (CurrentTaskView.ItemsSource as ICollectionView).Refresh();
         CurrentTaskAnswerView.ItemsSource = ViewModel.TasksViewModel.RefrashCurrentTaskAnswers();
         (CurrentTaskAnswerView.ItemsSource as ICollectionView).Refresh();
         HideAllGrids();
         AnswerGrid.Visibility = Visibility.Visible;
         MarkGrid.Visibility   = Visibility.Visible;
     }
 }
        private void AnswerTheTask(object sender, RoutedEventArgs e)
        {
            System.Windows.Controls.Button b = sender as System.Windows.Controls.Button;
            Data.Tasks data = b.DataContext as Data.Tasks;

            HideAllGrids();
            Data.NewTaskAnswer.StudentID = Data.StudentUsr.ID;
            Data.NewTaskAnswer.TaskID    = data.ID;
            Data.NewTaskAnswer.TeacherID = data.TeacherID;

            CurrentDateBeginStr.Text = data.DateBeginStr;
            CurrentDateEndStr.Text   = data.DateEndStr;
            CurrentIMGS.Source       = data.IMGS;
            CurrentSubject.Text      = data.Subject;
            CurrentTaskText.Text     = data.TaskText;
            CurrentTitle.Text        = data.Title;
            CurrentLine.Visibility   = Visibility.Visible;

            AnswerGrid.Visibility = Visibility.Visible;
        }
Esempio n. 3
0
        public static List <Answer> GetAnswers()
        {
            Tasks           buff          = ViewModel.TasksViewModel.CurrentTask;
            string          connectString = "provider=Microsoft.ACE.Oledb.12.0;Data Source= " + System.AppDomain.CurrentDomain.BaseDirectory + "\\AducationBase.accdb;";
            OleDbConnection connection    = new OleDbConnection(connectString);
            string          query         = "SELECT Ответы.ID, Ответы.ЗаданиеID, Ответы.УчительID, Ответы.УченикID, Ответы.Дата, Ответы.ТекстОтвета, Ответы.ДопФайлы, Ответы.Оценка, Ответы.Комментарий" +
                                            " FROM Ответы WHERE( ((Ответы.ЗаданиеID) = " + buff.ID + " ) AND((Ответы.УчительID) = " + Data.TeacherUsr.ID + " ) );";
            OleDbCommand command = new OleDbCommand(query, connection);

            connection.Open();
            OleDbDataReader dataReader = command.ExecuteReader();
            List <Answer>   result     = new List <Answer>();

            System.IO.Directory.CreateDirectory("ImageBuffFolder");
            while (dataReader.Read())
            {
                try
                {
                    Answer buffAnswer = new Answer();
                    buffAnswer.ID         = (int)dataReader["ID"];
                    buffAnswer.TeacherID  = (int)dataReader["УчительID"];
                    buffAnswer.StudentID  = (int)dataReader["УченикID"];
                    buffAnswer.TaskID     = (int)dataReader["ЗаданиеID"];
                    buffAnswer.Date       = (DateTime)dataReader["Дата"];
                    buffAnswer.DateStr    = ((DateTime)(dataReader["Дата"])).ToLongDateString();
                    buffAnswer.AnswerText = (string)dataReader["ТекстОтвета"];
                    try
                    {
                        buffAnswer.Mark = (string)dataReader["Оценка"];
                    }
                    catch
                    {
                        buffAnswer.Mark = "Не оценено";
                    }
                    try
                    {
                        buffAnswer.Comment = (string)dataReader["Комментарий"];
                    }
                    catch
                    {
                        buffAnswer.Comment = "";
                    }
                    buffAnswer.GetFIO();
                    try
                    {
                        System.IO.MemoryStream memoryStream = new System.IO.MemoryStream();
                        memoryStream.Write((byte[])dataReader["ДопФайлы"], 0, ((byte[])dataReader["ДопФайлы"]).Length);
                        System.Drawing.Image image = System.Drawing.Image.FromStream(memoryStream);
                        image.Save(@"ImageBuffFolder\" + buffAnswer.ID + "answ.BMP");
                        memoryStream.Dispose();
                        ImageSourceConverter imageSourceConverter = new ImageSourceConverter();
                        buffAnswer.AnswerImage = new Image();
                        buffAnswer.AnswerImage.SetValue(System.Windows.Controls.Image.SourceProperty, imageSourceConverter.ConvertFromString(@"ImageBuffFolder\" + buffAnswer.ID + "answ.BMP"));
                        buffAnswer.IMGS = buffAnswer.AnswerImage.Source;
                    }
                    catch { }
                    result.Add(buffAnswer);
                }
                catch { }
            }
            try
            {
                NewTaskAnswer.TaskID = result[0].ID;
            }
            catch
            {
                NewTaskAnswer.TaskID = -1;
            }
            return(result);
        }