Advertisement
DrAungWinHtut

Exam designer in CS

Mar 23rd, 2022
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.51 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using System.IO;
  11.  
  12. namespace Exam_System
  13. {
  14.     public partial class frmQdesign : Form
  15.     {
  16.         public frmQdesign()
  17.         {
  18.             InitializeComponent();
  19.         }
  20.  
  21.         private void frmQdesign_FormClosing(object sender, FormClosingEventArgs e)
  22.         {
  23.             Application.Exit();
  24.         }
  25.  
  26.         private void btnExit_Click(object sender, EventArgs e)
  27.         {
  28.             Application.Exit();
  29.         }
  30.  
  31.         private void btnAdd_Click(object sender, EventArgs e)
  32.         {
  33.             string sFname = txtFname.Text;
  34.             string sQ = txtQ.Text;
  35.             string sA1 = txtA1.Text;
  36.             string sA2 = txtA2.Text;
  37.             string sA3 = txtA3.Text;
  38.             string sA4 = txtA4.Text;
  39.             string sCA = txtCA.Text;
  40.  
  41.             string sQuestion = "\nN#" + sQ + "#" + sA1 + "#" + sA2 + "#" + sA3 + "#" + sA4 + "#" + sCA;
  42.  
  43.             if (File.Exists (sFname ))
  44.             {
  45.                 using (StreamWriter sw = new StreamWriter(sFname,true ))
  46.                 {
  47.                     sw.WriteLine(sQuestion );
  48.                 }
  49.             }
  50.             else
  51.             {
  52.                 MessageBox.Show("Invalid File");
  53.                 txtFname.SelectAll();
  54.                 txtFname.Focus();
  55.             }
  56.  
  57.  
  58.         }
  59.     }
  60. }
  61.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement