Ejemplo n.º 1
0
        /// <summary>
        /// Thêm một record vào table THOIKHOABIEU
        /// thêm thành công trả về 1 và ngược lại
        /// </summary>
        public int Them(int MaLop, String MaGiaoVien, int Tiet)
        {
            int result = DB.usp_InsertThoiKhoaBieu(MaLop, MaGiaoVien, Tiet);

            DB.SubmitChanges();
            return(result);
        }
        private void btnDeleteClass_Click(object sender, EventArgs e)
        {
            QLHSDataContext context = new QLHSDataContext();
            var             Class   = (from LopHoc in context.LOPHOCs
                                       where LopHoc.MaLop == Int32.Parse(txtClass.Text)
                                       select LopHoc).FirstOrDefault();
            var students = (from student in context.HOCSINHs
                            where student.MaLop == Int32.Parse(txtClass.Text)
                            select student).ToList();

            if (students.Count > 0)
            {
                context.HOCSINHs.DeleteAllOnSubmit(students);
                context.SubmitChanges();
            }
            if (Class != null)
            {
                context.LOPHOCs.DeleteOnSubmit(Class);
                context.SubmitChanges();
                clearListClass();
                showListClass();
                txtClass.Text = "";
                if (txtClass.Text != string.Empty)
                {
                    var Class1 = context.LOPHOCs.Where(lh => lh.MaLop == Int32.Parse(txtClass.Text)).ToList();
                    if (Class1.Count == 0)
                    {
                        lbError.Show();
                        btnDeleteClass.Enabled     = false;
                        btnUpdateClass.Enabled     = false;
                        btnShowListStudent.Enabled = false;
                    }
                }
                else
                {
                    lbError.Hide();
                }
            }
            context.Dispose();
        }
Ejemplo n.º 3
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            HOCSINH hocsinh = new HOCSINH
            {
                MaHocSinh  = Int32.Parse(txtIDStudent.Text),
                TenHocSinh = txtFullName.Text,
                NgaySinh   = Convert.ToDateTime(dtNgaySinh.Text),
                GioiTinh   = txtSex.Text,
                MaLop      = Int32.Parse(txtIDClass.Text)
            };
            QLHSDataContext context = new QLHSDataContext();

            context.HOCSINHs.InsertOnSubmit(hocsinh);
            context.SubmitChanges();
            context.Dispose();
            this.Close();
        }
Ejemplo n.º 4
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            LOPHOC lophoc = new LOPHOC
            {
                MaLop      = Int32.Parse(txtIDClass.Text),
                SiSo       = Int32.Parse(txtNumberOfStudent.Text),
                LopTruong  = Int32.Parse(txtClassPresident.Text),
                GVQuanLy   = Int32.Parse(txtIDTeacher.Text),
                NamBatDau  = Convert.ToDateTime(dateTimePicker1.Text),
                NamKetThuc = Convert.ToDateTime(dateTimePicker2.Text)
            };
            QLHSDataContext context = new QLHSDataContext();

            context.LOPHOCs.InsertOnSubmit(lophoc);
            context.SubmitChanges();
            context.Dispose();
            this.Close();
        }
Ejemplo n.º 5
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            QLHSDataContext context = new QLHSDataContext();
            var             student = (from HocSinh in context.HOCSINHs
                                       where HocSinh.MaHocSinh == Int32.Parse(txtIDStudent.Text)
                                       select HocSinh).FirstOrDefault();

            if (student != null)
            {
                student.MaLop      = Int32.Parse(txtIDClass.Text);
                student.NgaySinh   = Convert.ToDateTime(dateTimePicker1.Text);
                student.TenHocSinh = txtFullName.Text;
                student.GioiTinh   = txtSex.Text;
                context.SubmitChanges();
            }
            context.Dispose();
            this.Close();
        }
Ejemplo n.º 6
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            QLHSDataContext context = new QLHSDataContext();
            var             Class   = (from LopHoc in context.LOPHOCs
                                       where LopHoc.MaLop.ToString() == txtIDClass.Text
                                       select LopHoc).FirstOrDefault();

            if (Class != null)
            {
                Class.SiSo       = Int32.Parse(txtNumberOfStudent.Text);
                Class.LopTruong  = Int32.Parse(txtClassPresident.Text);
                Class.GVQuanLy   = Int32.Parse(txtIDTeacher.Text);
                Class.NamBatDau  = Convert.ToDateTime(dateTimePicker1.Text);
                Class.NamKetThuc = Convert.ToDateTime(dateTimePicker2.Text);
                context.SubmitChanges();
            }
            context.Dispose();
            this.Close();
        }
Ejemplo n.º 7
0
        private void btnDeleteStudent_Click(object sender, EventArgs e)
        {
            if (context == null)
            {
                context = new QLHSDataContext();
            }
            var Student = (from HocSinh in context.HOCSINHs
                           where HocSinh.MaHocSinh == Int32.Parse(txtStudent.Text)
                           select HocSinh).FirstOrDefault();

            if (Student != null)
            {
                context.HOCSINHs.DeleteOnSubmit(Student);
                context.SubmitChanges();
                clearListStudent();
                showListStudent();
                txtStudent.Text = "";
                if (txtStudent.Text != string.Empty)
                {
                    var Student1 = context.HOCSINHs.Where(hs => hs.MaHocSinh.ToString() == txtStudent.Text);
                    if (Student1.Count() == 0)
                    {
                        btnDeleteStudent.Enabled = false;
                        btnUpdateStudent.Enabled = false;
                        lbError.Hide();
                    }
                    else
                    {
                        lbError.Show();
                    }
                }
                else
                {
                    lbError.Hide();
                }
            }
            context.Dispose();
        }
Ejemplo n.º 8
0
 /// <summary>
 /// thêm một học sinh vào bảng
 /// </summary>
 /// <param name="_HoTen"></param>
 /// <param name="_DiaChi"></param>
 /// <param name="_NgaySinh"></param>
 /// <param name="_Email"></param>
 /// <param name="_GioiTinh"></param>
 public void Them(String _HoTen, String _DiaChi, DateTime _NgaySinh, String _Email, String _GioiTinh)
 {
     DB.usp_InsertHosohocsinh(LayMaHocSinhCuoi() + 1, _HoTen, _DiaChi, _NgaySinh, _Email, _GioiTinh);
     DB.SubmitChanges();
 }
Ejemplo n.º 9
0
 public void Delete(String MaGiaoVien)
 {
     DB.usp_DeleteGiaoVien(MaGiaoVien);
     DB.SubmitChanges();
 }
Ejemplo n.º 10
0
 //Lưu thay đổi
 public void SAVE()
 {
     qlhs.GetChangeSet();
     qlhs.SubmitChanges();
 }