Esempio n. 1
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (txtMaLop.Text.Trim() == "")
     {
         MessageBox.Show("Chưa nhập mã lớp", "Thông báo");
     }
     else
     {
         if (context.tblLOPs.Find(txtMaLop.Text.Trim()) != null)
         {
             MessageBox.Show("Mã lớp đã tồn tại", "Thông báo");
         }
         else
         {
             tblLOP g = new tblLOP();
             g.MaLop  = txtMaLop.Text;
             g.MaKhoa = cboKhoa.Text;
             g.TenLop = txtTenlop.Text;
             var result = new LOPF().Insert(g);
             dgrLop.DataSource = context.tblLOPs.ToList();
             txtMaLop.Clear();
             txtTenlop.Clear();
             cboKhoa.Text = "";
         }
     }
 }
Esempio n. 2
0
        public bool Delete(tblLOP model)
        {
            tblLOP dbEntry = context.tblLOPs.Find(model.MaLop);

            if (dbEntry == null)
            {
                return(false);
            }
            context.tblLOPs.Remove(dbEntry);
            context.SaveChanges();
            return(true);
        }
Esempio n. 3
0
        public bool Insert(tblLOP model)
        {
            tblLOP dbEntry = context.tblLOPs.Find(model.MaLop);

            if (dbEntry != null)
            {
                return(false);
            }
            context.tblLOPs.Add(model);
            context.SaveChanges();
            return(true);
        }
Esempio n. 4
0
        private void button2_Click(object sender, EventArgs e)
        {
            string id = txtMaLop.Text.Trim();

            if (MessageBox.Show(string.Format("Sửa lớp có mã '{0}'?", id), "", MessageBoxButtons.OKCancel) == DialogResult.OK)
            {
                tblLOP g = new tblLOP();
                g.MaLop  = txtMaLop.Text;
                g.MaKhoa = cboKhoa.Text;
                g.TenLop = txtTenlop.Text;
                var result = new LOPF().Update(g);
                dgrLop.DataSource = context.tblLOPs.ToList();
            }
        }
Esempio n. 5
0
        public bool Update(tblLOP model)
        {
            tblLOP dbEntry = context.tblLOPs.Find(model.MaLop);

            if (dbEntry == null)
            {
                return(false);
            }
            dbEntry.MaLop  = model.MaLop;
            dbEntry.TenLop = model.TenLop;

            dbEntry.MaKhoa = model.MaKhoa;

            context.SaveChanges();
            return(true);
        }
Esempio n. 6
0
        public tblLOP FindEntity(string ID)
        {
            tblLOP dbEntry = context.tblLOPs.Find(ID);

            return(dbEntry);
        }