Exemple #1
0
        private void SuaKyThiForm_Load(object sender, EventArgs e)
        {
            qltn        = Utils.QLTN.getInstance();
            kythi       = qltn.KyThis.Where(i => i.id == kythiid).First();
            kythicustom = new KyThiCusTom(kythi);
            kythicustom.PropertyChanged += Kythicustom_PropertyChanged;

            var TenkythiBinding   = new Binding("Text", kythicustom, "Tenkythi", true);
            var NgaybatdauBinding = new Binding("Value", kythicustom, "Ngaybatdau", true);
            var SongayBinding     = new Binding("Value", kythicustom, "Songay", true);

            txtTen.DataBindings.Add(TenkythiBinding);
            dtNgayBD.DataBindings.Add(NgaybatdauBinding);
            numericSoNgay.DataBindings.Add(SongayBinding);

            getData();
            loadLoaiKyThi();
            cb.SelectedIndex = kythi.loaikythi == true ? 0 : 1;

            loadDeThi();
            checkLVDeThi   = true;
            checkLVHocSinh = true;

            if (cb.SelectedIndex == 0)
            {
                checkbox.Checked = true;
                checkbox.Enabled = false;
            }
        }
Exemple #2
0
 public static string getPassword(string userName)
 {
     using (var db = new QLTNDataContext())
     {
         return(db.TaiKhoans.Where(account => account.TenDangNhap == userName).Single().MatKhau);
     }
 }
Exemple #3
0
 public static bool isRegisterd(string userName)
 {
     using (var db = new QLTNDataContext())
     {
         return((db.TaiKhoans.Where(account => account.TenDangNhap == userName).SingleOrDefault() == null) ? false : true);
     }
 }
Exemple #4
0
 public static void AddRequest(CauHoi request)
 {
     using (var db = new QLTNDataContext())
     {
         db.CauHois.InsertOnSubmit(request);
         db.SubmitChanges();
     }
 }
Exemple #5
0
 public static List <CauHoi> LoadQuestion()
 {
     using (var db = new QLTNDataContext())
     {
         return((from cauHoi in db.CauHois
                 select cauHoi).Take(40).ToList());
     }
 }
Exemple #6
0
 public static void Register(TaiKhoan account)
 {
     using (var db = new QLTNDataContext())
     {
         db.TaiKhoans.InsertOnSubmit(account);
         db.SubmitChanges();
     }
 }
Exemple #7
0
 private void AddTest_Load(object sender, EventArgs e)
 {
     using (var db = new QLTNDataContext())
     {
         var data = db.CauHois;
         this.dgvQuestions.DataSource = data;
     }
 }
Exemple #8
0
 void LoadQuestForm()
 {
     using (var db = new QLTNDataContext())
     {
         var Tests = db.DeThis.Select(dt => dt.IdDe).Distinct();
         this.cbbTestId.DataSource            = Tests;
         this.cbbTestId.SelectedIndexChanged += CbbTestId_SelectedIndexChanged;
     }
 }
Exemple #9
0
        bool KiemTraDeThi(DeThi dt, QLTNDataContext qltn)
        {
            var hstg = qltn.HocSinhThamGias.Where(i => i.dethiid == dt.id && i.thoigianlambai != null).ToList();
            var hslb = qltn.HocSinhLamBais.Where(i => i.dethiid == dt.id).ToList();

            if (hstg.Count > 0 || hslb.Count > 0)
            {
                return(false);
            }
            return(true);
        }
Exemple #10
0
 private void CbbTestId_SelectedIndexChanged(object sender, EventArgs e)
 {
     //load lai ds cac cau hoi cua de thi
     using (var db = new QLTNDataContext())
     {
         this.dgvQuestions.DataSource = db.BoDeThis
                                        .Where(quest => quest.IdDe == cbbTestId.SelectedValue.ToString())
                                        .Join(db.CauHois, quest => quest.IdCauHoi, ch => ch.IdCauHoi,
                                              (quest, ch) => ch).ToList();
     }
 }
Exemple #11
0
 private void btnCreateTest_Click(object sender, EventArgs e)
 {
     if (txtBoDeThi.Text == "")
     {
         MessageBox.Show("Chưa nhập bộ đề thi", "Thông báo");
         return;
     }
     else if (nipTime.Text == "")
     {
         MessageBox.Show("Chưa nhập thời gian", "Thông báo");
         return;
     }
     else
     {
         using (var db = new QLTNDataContext())
         {
             var result = db.DeThis.Where(dethi => dethi.IdDe == txtBoDeThi.Text).SingleOrDefault();
             if (result != null)
             {
                 MessageBox.Show("Mã đề đã tồn tại", "Thông báo");
                 return;
             }
         }
     }
     using (var create = new QLTNDataContext())
     {
         create.DeThis.InsertOnSubmit(new DeThi()
         {
             GVRaDe   = "giaovien",
             IdDe     = txtBoDeThi.Text,
             ThoiGian = 20//int.Parse(nipTime.Text)
         });
         foreach (string quest in listQuestions)
         {
             create.BoDeThis.InsertOnSubmit(new BoDeThi
             {
                 IdCauHoi = int.Parse(quest),
                 IdDe     = txtBoDeThi.Text
             });
         }
         create.SubmitChanges();
         //create.add
         MessageBox.Show("Bạn đã thêm thành công");
         //ResetInput(checkedButton);
     }
 }