コード例 #1
0
        private void txtMSSV_Leave(object sender, EventArgs e)
        {
            string   masv = txtMSSV.Text;
            SINHVIEN sv   = db.SINHVIENs.Where(p => p.MASV == masv).SingleOrDefault();

            if (sv != null)
            {
                lbHoTen.Text      = sv.HOTEN;
                lbHoTen.ForeColor = Color.Black;
            }
            else
            {
                lbHoTen.Text      = "Mã sinh viên không tồn tại";
                lbHoTen.ForeColor = Color.Red;
            }
        }
コード例 #2
0
        //Hiển thị data lên các textbox
        private void bindingDiem(string maSV, string maMH)
        {
            txtMSSV.Text = maSV;

            SINHVIEN sv = db.SINHVIENs.Where(p => p.MASV == maSV).SingleOrDefault();
            KETQUA   kq = db.KETQUAs.Where(p => p.MASV == maSV && p.MAHP == maMH).SingleOrDefault();
            HOCPHAN  hp = db.HOCPHANs.Where(p => p.MAHP == maMH).SingleOrDefault();

            cbbMon.Text   = hp.TENHP;
            lbMaMon.Text  = maMH;
            lbTinChi.Text = hp.TINCHI.ToString();
            lblHocKy.Text = hp.HOCKY.ToString();

            nudDiemQT.Text  = kq.DIEMQT.ToString();
            nudDiemThi.Text = kq.DIEMTHI.ToString();
            lbHoTen.Text    = sv.HOTEN;
        }
コード例 #3
0
        private void cbb_SinhVien_LopHoc_SelectedIndexChanged(object sender, EventArgs e)
        {
            string malop = cbb_SinhVien_LopHoc.SelectedValue.ToString();

            LoadDSmalop(malop);

            SINHVIEN sv = db.SINHVIENs.Where(p => p.MALOP == malop).FirstOrDefault();

            if (sv != null)
            {
                if (dtgv_SinhVien_DS.RowCount >= 1)
                {
                    string masv = dtgv_SinhVien_DS.Rows[0].Cells[0].Value.ToString();
                    blinding(masv);
                }
            }
            else
            {
                resetText();
            }
        }
コード例 #4
0
 partial void DeleteSINHVIEN(SINHVIEN instance);
コード例 #5
0
 partial void UpdateSINHVIEN(SINHVIEN instance);
コード例 #6
0
 partial void InsertSINHVIEN(SINHVIEN instance);
コード例 #7
0
 private void detach_SINHVIENs(SINHVIEN entity)
 {
     this.SendPropertyChanging();
     entity.LOP = null;
 }
コード例 #8
0
 private void attach_SINHVIENs(SINHVIEN entity)
 {
     this.SendPropertyChanging();
     entity.LOP = this;
 }
コード例 #9
0
        private void btn_SinhVien_Luu_Click(object sender, EventArgs e)
        {
            if (txt_SinhVien_MaSV.Text == "" || txt_SinhVien_hoTen.Text == "" || txt_SinhVien_gioitinh.Text == "" || txt_SinhVien_diaChi.Text == "")
            {
                MessageBox.Show("Vui lòng điền đầy đủ thông tin !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                flag = false;
            }
            else
            {
                txt_SinhVien_MaSV.Enabled = true;
                if (nhanThem)
                {
                    SINHVIEN sv = new SINHVIEN();
                    sv.MASV     = txt_SinhVien_MaSV.Text;
                    sv.HOTEN    = txt_SinhVien_hoTen.Text;
                    sv.NGAYSINH = dtp_SinhVien_ngaySinh.Value;
                    sv.GIOITINH = txt_SinhVien_gioitinh.Text;
                    sv.DIACHI   = txt_SinhVien_diaChi.Text;
                    sv.MALOP    = cbb_SinhVien_LopHoc.SelectedValue.ToString();

                    if (db.SINHVIENs.Where(p => p.MASV == txt_SinhVien_MaSV.Text).SingleOrDefault() != null)
                    {
                        MessageBox.Show("Đã tồn tại sinh viên này", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        txt_SinhVien_MaSV.Focus();
                        txt_SinhVien_MaSV.SelectAll();
                    }
                    else
                    {
                        if (txt_SinhVien_gioitinh.Text == "Nam" || txt_SinhVien_gioitinh.Text == "Nữ")
                        {
                            db.SINHVIENs.InsertOnSubmit(sv);

                            MessageBox.Show("Thêm thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            db.SubmitChanges();
                            if (db.LOPs.Where(p => p.MAKHOA == cbb_SinhVien_Khoa.SelectedValue.ToString()).FirstOrDefault() != null)
                            {
                                LoadDS();
                            }
                            if (dtgv_SinhVien_DS.RowCount >= 1)
                            {
                                if (dtgv_SinhVien_DS.Rows[0].Cells[0].Value.ToString() != null)
                                {
                                    string MSSV = dtgv_SinhVien_DS.Rows[0].Cells[0].Value.ToString();
                                    blinding(MSSV);
                                }
                            }
                            cheDoXem();
                            nhanSua  = false;
                            nhanThem = false;
                        }
                        else
                        {
                            MessageBox.Show("Giới tính: \"Nam\" hoặc \"Nữ\"", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        }
                    }
                }
            }
            if (flag == true)
            {
                if (txt_SinhVien_MaSV.Text == "" || txt_SinhVien_hoTen.Text == "" || txt_SinhVien_gioitinh.Text == "" || txt_SinhVien_diaChi.Text == "")
                {
                    MessageBox.Show("Vui lòng điền đầy đủ thông tin !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                else
                {
                    if (nhanSua)
                    {
                        string   masv = txt_SinhVien_MaSV.Text;
                        SINHVIEN sv   = db.SINHVIENs.Where(p => p.MASV == masv).SingleOrDefault();
                        if (sv == null)
                        {
                            MessageBox.Show("Không tồn tại sinh viên này", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            txt_SinhVien_MaSV.Focus();
                            txt_SinhVien_MaSV.SelectAll();
                        }
                        else
                        {
                            if (txt_SinhVien_gioitinh.Text == "Nam" || txt_SinhVien_gioitinh.Text == "Nữ")
                            {
                                sv.MASV     = txt_SinhVien_MaSV.Text;
                                sv.HOTEN    = txt_SinhVien_hoTen.Text;
                                sv.NGAYSINH = dtp_SinhVien_ngaySinh.Value;
                                sv.GIOITINH = txt_SinhVien_gioitinh.Text;
                                sv.DIACHI   = txt_SinhVien_diaChi.Text;
                                db.SubmitChanges();
                                MessageBox.Show("Cập nhập thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                if (db.LOPs.Where(p => p.MAKHOA == cbb_SinhVien_Khoa.SelectedValue.ToString()).FirstOrDefault() != null)
                                {
                                    LoadDS();
                                }
                                if (dtgv_SinhVien_DS.RowCount >= 1)
                                {
                                    if (dtgv_SinhVien_DS.Rows[0].Cells[0].Value.ToString() != null)
                                    {
                                        string MSSV = dtgv_SinhVien_DS.Rows[0].Cells[0].Value.ToString();
                                        blinding(MSSV);
                                    }
                                }

                                cheDoXem();
                                nhanSua  = false;
                                nhanThem = false;

                                btn_SinhVien_Sua.Enabled = true;
                                btn_SinhVien_Xoa.Enabled = true;
                            }
                            else
                            {
                                MessageBox.Show("Giới tính: \"Nam\" hoặc \"Nữ\"", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            }
                        }
                    }
                }
            }
        }