private void button2_Click(object sender, EventArgs e)
        {
            string mk = mkcombo.SelectedItem.ToString();

            MessageBox.Show(mk);
            char[] ar   = mk.ToCharArray();
            string test = ar[1].ToString() + ar[2].ToString();

            if (txtml.Text != "" && txtlop.Text != "" && txtss.Text != "" && checkMaL1.ErrorMessage == null && checkTenL1.ErrorMessage == null)
            {
                char[] ar2   = txtlop.Text.ToCharArray();
                string test2 = ar2[0].ToString() + ar2[1].ToString();

                if (test != test2)
                {
                    MessageBox.Show("vui lòng nhập tên lớp phù hợp với  khối");
                }
                else
                {
                    clasDTO lopp = new clasDTO(txtml.Text, txtlop.Text, int.Parse(txtss.Text), mk);
                    HSB.InsertL(lopp);
                    HSB.Loadkl();
                    MessageBox.Show("successfull");
                }
            }
            else
            {
                MessageBox.Show("vui lòng nhập đầy đủ ");
            }
        }
Exemple #2
0
        public void GetKL()
        {
            HocSinhDBDataContext hdb = new HocSinhDBDataContext();

            try
            {
                HocKi.HK.Clear();
                var hocki = from hk in hdb.HOCKIs select hk;
                if (hocki != null)
                {
                    foreach (var hki in hocki)
                    {
                        HocKi lst = new HocKi(hki.MaHocKi, hki.TenHocKi);
                        HocKi.HK.Add(lst);
                    }
                }
                CTMonHoc.ctmh.Clear();
                var ct = from mh in hdb.MONHOCs select mh;
                if (ct != null)
                {
                    foreach (var b in ct)
                    {
                        CTMonHoc lst = new CTMonHoc(b.MaMonHoc, b.TenMonHoc);
                        CTMonHoc.ctmh.Add(lst);
                    }
                }



                ClassDTO.khoilop.Clear();
                clasDTO.lop.Clear();
                var kk = from l in hdb.DANHSACHLOPs select l;
                var q  = from kq in hdb.KHOILOPs select kq;
                if (q == null || kk == null)
                {
                    clasDTO.TonTail = false;
                    ClassDTO.TonTai = false;
                }
                else
                {
                    ClassDTO.TonTai = true;
                    clasDTO.TonTail = true;
                    foreach (var x in q)
                    {
                        ClassDTO kl = new ClassDTO(x.MaKhoiLop, x.TenKhoiLop);
                        ClassDTO.khoilop.Add(kl);
                    }
                    foreach (var n in kk)
                    {
                        clasDTO lop = new clasDTO(n.MaLop, n.TenLop, 0, n.MaKhoiLop);
                        clasDTO.lop.Add(lop);
                    }
                }
            }
            catch
            {
            }
        }
Exemple #3
0
        public bool InsertL(clasDTO l)
        {
            try
            {
                HocSinhDBDataContext hdb = new HocSinhDBDataContext();
                DANHSACHLOP          L   = new DANHSACHLOP {
                    MaLop = l.MaL1, TenLop = l.TenL1, SiSo = l.SiSo1, MaKhoiLop = l.MaK1
                };

                hdb.DANHSACHLOPs.InsertOnSubmit(L);
                hdb.SubmitChanges();

                return(true);
            }
            catch
            {
                return(false);
            }
        }
 public bool InsertL(clasDTO KL)
 {
     return(HS.InsertL(KL));
 }