Ejemplo n.º 1
0
        private void SaveFile()
        {
            StudentExamResult ser = new StudentExamResult(ChemTest.name, min, sec, mark, right, wrong, rightAnswPurc, wrongAnswPurc);

            XmlSerializer  serializer = new XmlSerializer(typeof(StudentExamResult));
            SaveFileDialog dialog     = saveFileDialog1;

            dialog.InitialDirectory = Environment.SpecialFolder.MyComputer.ToString();
            dialog.Filter           = "Файл результату|*.res|Всі файли|*.*";

            dialog.FileName = $"Результат {ChemTest.name} ({DateTime.Now.ToShortDateString()})";

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                using (Stream fs = File.Create(dialog.FileName))
                {
                    serializer.Serialize(fs, ser);
                }
            }
            string fileName = dialog.FileName;
            string MY_EXT   = ".res";

            if (!MY_EXT.Equals(Path.GetExtension(fileName), StringComparison.OrdinalIgnoreCase))
            {
                fileName += MY_EXT;
            }
        }
        public fStudentExamResultViewer(StudentExamResult examResult, string path)
        {
            InitializeComponent();
            btnOpen.BackgroundImage          = Image.FromFile(@"sys\img\btn\open.png");
            openFileDialog1.InitialDirectory = Environment.SpecialFolder.MyComputer.ToString();

            tbxPath.Text = path;
            ser          = examResult;
            InitializeDataGridView();
            AddRowsDataGridView();
        }
        private void OpenFile()
        {
            XmlSerializer serializer = new XmlSerializer(typeof(StudentExamResult));

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                using (Stream fs = File.OpenRead(openFileDialog1.FileName))
                {
                    ser = (StudentExamResult)serializer.Deserialize(fs);
                }
                tbxPath.Text = Path.GetFullPath(openFileDialog1.FileName);
            }
        }
Ejemplo n.º 4
0
        private void btnCheckStudent_Click(object sender, EventArgs e)
        {
            StudentExamResult ser = new StudentExamResult();

            XmlSerializer serializer = new XmlSerializer(typeof(StudentExamResult));

            if (odialog.ShowDialog() == DialogResult.OK)
            {
                using (Stream fs = File.OpenRead(odialog.FileName))
                {
                    ser = (StudentExamResult)serializer.Deserialize(fs);
                }
                fStudentExamResultViewer fserv = new fStudentExamResultViewer(ser, Path.GetFullPath(openFileDialog1.FileName));

                fserv.ShowDialog();
            }
        }