示例#1
0
        private void xoaToolStripMenuItem_Click(object sender, EventArgs e)
        {
            MonHoc mh = new MonHoc();

            string mamh = dataGridView1.CurrentRow.Cells[0].Value.ToString();

            mh = db.MonHocs.Where(t => t.MaMonHoc == mamh).FirstOrDefault();

            db.MonHocs.DeleteOnSubmit(mh);

            db.SubmitChanges();

            var monhocss = from mh1 in db.MonHocs select mh1;

            dataGridView1.DataSource = monhocss;
        }
示例#2
0
        private void themToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (txtMaMonHoc.Text == "" || txtTenMonHoc.Text == "")
            {
                MessageBox.Show("Bạn chua nhạp đủ");
            }
            MonHoc mh = new MonHoc();

            mh.MaMonHoc  = txtMaMonHoc.Text;
            mh.TenMonHoc = txtTenMonHoc.Text;

            db.MonHocs.InsertOnSubmit(mh);
            db.SubmitChanges();
            var monhocss = from mh1 in db.MonHocs select mh1;

            dataGridView1.DataSource = monhocss;
        }
示例#3
0
        private void suaToolStripMenuItem_Click(object sender, EventArgs e)
        {
            MonHoc mh = new MonHoc();

            string mamh = dataGridView1.CurrentRow.Cells[0].Value.ToString();

            mh = db.MonHocs.Where(t => t.MaMonHoc == mamh).FirstOrDefault();
            if (mh != null)
            {
                mh.MaMonHoc  = txtMaMonHoc.Text;
                mh.TenMonHoc = txtTenMonHoc.Text;

                db.SubmitChanges();
            }
            else
            {
                MessageBox.Show("Khong ton tai");
            }


            var monhocss = from mh1 in db.MonHocs select mh1;

            dataGridView1.DataSource = monhocss;
        }
 partial void DeleteMonHoc(MonHoc instance);
 partial void UpdateMonHoc(MonHoc instance);
 partial void InsertMonHoc(MonHoc instance);