Beispiel #1
0
        private void btnThem_Click_1(object sender, EventArgs e)
        {
            LTUDQL1DataContext themnd = new LTUDQL1DataContext();
            USER us = new USER();

            us.f_HoTen       = txtHoTen.Text;
            us.f_MaSo        = txtMaSo.Text;
            us.f_Email       = txtEmail.Text;
            us.f_GioiTinh    = txtGioiTinh.Text;
            us.f_NgaySinh    = txtNgaySinh.Text;
            us.f_Phone       = txtPhone.Text;
            us.f_TenDangNhap = txtTenDangNhap.Text;
            us.f_MatKhau     = txtMatKhau.Text;
            us.f_IDPhanQuyen = int.Parse(txtIDPhanQuyen.Text.ToString());
            if (us.f_HoTen == "" && us.f_TenDangNhap == "" && us.f_MaSo == "" && us.f_Email == "" && us.f_NgaySinh == "" && us.f_MatKhau == "")
            {
                MessageBox.Show("Không được bỏ trống !!!");
                return;
            }
            else
            {
                themnd.USERs.InsertOnSubmit(us);
                themnd.SubmitChanges();
                MessageBox.Show("Tạo thành công người Dùng!!!");
                LoadData();
            }
            CleanTextBox();
        }
        private void btn_TaoKyThi_Click(object sender, EventArgs e)
        {
            LTUDQL1DataContext themkt = new LTUDQL1DataContext();
            KyThi kt = new KyThi();

            kt.MaKT     = txtmakt.Text;
            kt.Ngay     = txtmant.Text;
            kt.MaDT     = txtmadt.Text;
            kt.ThoiGian = txttg.Text;
            kt.MaHV     = txtmahv.Text;

            if (kt.MaKT == "" && kt.MaHV == "")
            {
                MessageBox.Show("Không được bỏ trống Mã Kỳ Thi và Mã Học Viên!!!");
                return;
            }
            else
            {
                themkt.KyThis.InsertOnSubmit(kt);
                themkt.SubmitChanges();
                MessageBox.Show("Tạo thành công kỳ thi thử!!!");
                LoadData();
            }

            CleanTextBox();
        }
        private void BtnDangKy_Click(object sender, EventArgs e)
        {
            var hoten       = txtHoTen.Text;
            var maso        = txtMaSo.Text;
            var email       = txtEmail.Text;
            var ngaysinh    = datengaysinh.Text;
            var gioitinh    = cbbGioiTinh.Text;
            var phone       = txtPhone.Text;
            var tendangnhap = txttendangnhap.Text;
            var matkhau     = txtmatkhau.Text;
            var phanquyen   = int.Parse(cbbPhanQuyen.Text.ToString());

            using (var db = new LTUDQL1DataContext())
            {
                if (db.USERs.SingleOrDefault(u => u.f_TenDangNhap == tendangnhap) != null)
                {
                    MessageBox.Show("User đã tồn tại!");
                    return;
                }
                db.USERs.InsertOnSubmit(new USER
                {
                    f_HoTen       = hoten,
                    f_MaSo        = maso,
                    f_Email       = email,
                    f_GioiTinh    = gioitinh,
                    f_MatKhau     = matkhau,
                    f_NgaySinh    = ngaysinh,
                    f_Phone       = phone,
                    f_TenDangNhap = tendangnhap,
                    f_IDPhanQuyen = phanquyen
                });
                db.SubmitChanges();
            }



            if (txtmatkhau.Text == txtxacnhanmatkhau.Text)
            {
                MessageBox.Show("Đăng ký thành công!");
            }
            else if (txtxacnhanmatkhau.Text != txtmatkhau.Text)
            {
                MessageBox.Show("Mật khẩu xác nhận không trùng!");
                txtxacnhanmatkhau.Focus();
                txtxacnhanmatkhau.SelectAll();
            }
        }
        private void btn_sua_Click(object sender, EventArgs e)
        {
            LTUDQL1DataContext suakt = new LTUDQL1DataContext();
            KyThi kt = new KyThi();

            kt          = suakt.KyThis.Where(u => u.MaKT == txtmakt.Text).Where(u => u.MaHV == txtmahv.Text).Single();
            kt.MaKT     = txtmakt.Text;
            kt.Ngay     = txtmant.Text;
            kt.MaDT     = txtmadt.Text;
            kt.ThoiGian = txttg.Text;
            kt.MaHV     = txtmahv.Text;

            suakt.SubmitChanges();
            LoadData();
            MessageBox.Show("UpDate thành công!!!");
            CleanTextBox();
        }
        private void btn_sua_Click(object sender, EventArgs e)
        {
            LTUDQL1DataContext Suadt = new LTUDQL1DataContext();
            DeThi dt = new DeThi();

            dt = Suadt.DeThis.Where(u => u.MaDK == txtMaDK.Text).Where(u => u.MaDT == txtMaDT.Text).Single();

            dt.MaDT = txtMaDT.Text;
            dt.MaBD = txtMaBD.Text;
            dt.MaCH = txtMaCH.Text;
            dt.MaDK = txtMaDK.Text;

            Suadt.SubmitChanges();
            MessageBox.Show("Update Success!!!");
            LoadData();
            CleanTextBox();
        }
Beispiel #6
0
        private void btnSua_Click_1(object sender, EventArgs e)
        {
            LTUDQL1DataContext sua = new LTUDQL1DataContext();
            USER us = new USER();

            us               = sua.USERs.Where(u => u.f_MaSo == txtMaSo.Text).Single();
            us.f_HoTen       = txtHoTen.Text;
            us.f_Email       = txtEmail.Text;
            us.f_GioiTinh    = txtGioiTinh.Text;
            us.f_NgaySinh    = txtNgaySinh.Text;
            us.f_Phone       = txtPhone.Text;
            us.f_TenDangNhap = txtTenDangNhap.Text;
            us.f_MatKhau     = txtMatKhau.Text;
            us.f_IDPhanQuyen = int.Parse(txtIDPhanQuyen.Text.ToString());

            sua.SubmitChanges();
            MessageBox.Show("UpDate thành công!!!");
            LoadData();
            CleanTextBox();
        }
        private void btn_Sua_Click(object sender, System.EventArgs e)
        {
            LTUDQL1DataContext themCauHoi = new LTUDQL1DataContext();
            CauHoi             ch         = new CauHoi();

            ch           = themCauHoi.CauHois.Where(u => u.MaCH == txtMaCH.Text).Single();
            ch.MaCH      = txtMaCH.Text;
            ch.CapHoc    = txtCaphoc.Text;
            ch.MonHoc    = txtMH.Text;
            ch.NoiDung   = txtND.Text;
            ch.DapAnA    = txtDAA.Text;
            ch.DapAnB    = txtDAB.Text;
            ch.DapAnC    = txtDAC.Text;
            ch.DapAnD    = txtDAD.Text;
            ch.DapAnDung = txtDA.Text;

            themCauHoi.SubmitChanges();
            LoadData();
            MessageBox.Show("Update success!!!");
            CleanTextBox();
        }
        private void btn_them_Click(object sender, EventArgs e)
        {
            LTUDQL1DataContext themdt = new LTUDQL1DataContext();
            DeThi dt = new DeThi();

            dt.MaDT = txtMaDT.Text;
            dt.MaBD = txtMaBD.Text;
            dt.MaCH = txtMaCH.Text;
            dt.MaDK = txtMaDK.Text;

            if (dt.MaDK == "" && dt.MaDT == "")
            {
                MessageBox.Show("Insert Fail!!!");
                return;
            }
            themdt.DeThis.InsertOnSubmit(dt);
            themdt.SubmitChanges();
            MessageBox.Show("Insert Success!!!");
            LoadData();
            CleanTextBox();
        }