Exemplo n.º 1
0
 private void btnSua_Click(object sender, EventArgs e)
 {
     if (lvChuDe.SelectedItems.Count > 0)
     {
         int ma_ChuDe = (int)lvChuDe.SelectedItems[0].Tag;
         _0864186_TracNghiemDataContext db = new _0864186_TracNghiemDataContext();
         ChuDe chuDe = db.ChuDes.Single(cd => cd.maChuDe == ma_ChuDe);
         txtNoiDungChuDe.Focus();
         chuDe.tenChuDe = txtNoiDungChuDe.Text;
         db.SubmitChanges();
         LoadDuLieu();
         txtNoiDungChuDe.ResetText();
     }
 }
Exemplo n.º 2
0
 private void btnXoa_Click(object sender, EventArgs e)
 {
     if (lvChuDe.SelectedItems.Count > 0)
     {
         int ma_ChuDe = (int)lvChuDe.SelectedItems[0].Tag;
         _0864186_TracNghiemDataContext db = new _0864186_TracNghiemDataContext();
         ChuDe chuDe = db.ChuDes.Single(cd => cd.maChuDe == ma_ChuDe);
         var   ds    = from cauHoi in db.CauHois where cauHoi.maChuDe == ma_ChuDe select cauHoi;
         db.CauHois.DeleteAllOnSubmit(ds);
         db.ChuDes.DeleteOnSubmit(chuDe);
         db.SubmitChanges();
         LoadDuLieu();
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// Hien thi du lieu khi chon trong listview
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void lvHienThiCauHoi_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e)
 {
     if (lvHienThiCauHoi.SelectedItems.Count > 0)
     {
         btnThem.Enabled = false;
         int ma_CauHoi = (int)lvHienThiCauHoi.SelectedItems[0].Tag;
         _0864186_TracNghiemDataContext db = new _0864186_TracNghiemDataContext();
         CauHoi cauHoi = db.CauHois.Single(ch => ch.maCauHoi == ma_CauHoi);
         txtNoiDungCauHoi.Text = cauHoi.noiDung;
         txtDapAnA.Text        = cauHoi.dapAnA;
         txtDapAnB.Text        = cauHoi.dapAnB;
         txtDapAnC.Text        = cauHoi.dapAnC;
         txtDapAnD.Text        = cauHoi.dapAnD;
         HienDapAnDung();
         int   temp  = (int)cauHoi.maChuDe;
         ChuDe chuDe = db.ChuDes.Single(cd => cd.maChuDe == cauHoi.maChuDe);
         cbbChuDe.Text = chuDe.tenChuDe;
         //cbbChuDe.Items[temp - 1];
     }
 }
Exemplo n.º 4
0
        private void btnThem_Click(object sender, EventArgs e)
        {
            _0864186_TracNghiemDataContext db = new _0864186_TracNghiemDataContext();
            ChuDe chuDe = new ChuDe();

            if (txtNoiDungChuDe.Text == "")
            {
                DialogResult r = MessageBox.Show("Vui lòng nhập nội dung chủ đề", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                //int temp = TaoMaChuDe();
                //chuDe.maChuDe = temp;
                chuDe.tenChuDe = txtNoiDungChuDe.Text;

                db.ChuDes.InsertOnSubmit(chuDe);
                db.SubmitChanges();
                LoadDuLieu();
                txtNoiDungChuDe.ResetText();
            }
        }
 partial void DeleteChuDe(ChuDe instance);
 partial void UpdateChuDe(ChuDe instance);
 partial void InsertChuDe(ChuDe instance);