예제 #1
0
        private void LayDsLoaiDoChoi()
        {
            DoChoiEntities db    = new DoChoiEntities();
            var            query = from l in db.LoaiDoChois
                                   select l;
            var ds = query.ToList();

            dgvKind.DataSource = ds;
        }
예제 #2
0
 private bool DangNhap()
 {
     string TenDangNhap = txtUsername.Text;
     string MatKhau = txtPassword.Text;
     if (TenDangNhap != null && MatKhau != null)
     {
         using (var db = new DoChoiEntities())
         {
             return db.DangNhaps.Where(x => x.TenDangNhap == TenDangNhap && x.MatKhau == MatKhau).Count() > 0;
         }
     }
     return false;
 }
예제 #3
0
        private void btnXoakind_Click(object sender, EventArgs e)
        {
            var            maloai = txtKindID.Text;
            DoChoiEntities db     = new DoChoiEntities();
            var            ketqua = db.LoaiDoChois.SingleOrDefault(l => l.MaLoai == maloai);

            if (ketqua != null)
            {
                db.LoaiDoChois.Remove(ketqua);
                db.SaveChanges();
            }
            LayDsLoaiDoChoi();
            ThemDataBinding();
        }
예제 #4
0
        private void btnThemkind_Click(object sender, EventArgs e)
        {
            var            maloai  = txtKindID.Text;
            var            tenloai = txtTenLoaiDC.Text;
            DoChoiEntities db      = new DoChoiEntities();

            db.LoaiDoChois.Add(new LoaiDoChoi()
            {
                MaLoai = maloai, TenLoai = tenloai
            });
            db.SaveChanges();
            LayDsLoaiDoChoi();
            ThemDataBinding();
        }
예제 #5
0
        private void btnUpdatek_Click(object sender, EventArgs e)
        {
            var            maloai  = txtKindID.Text;
            var            tenloai = txtTenLoaiDC.Text;
            DoChoiEntities db      = new DoChoiEntities();
            var            ketqua  = db.LoaiDoChois.SingleOrDefault(l => l.MaLoai == maloai);

            if (ketqua != null)
            {
                ketqua.TenLoai = tenloai;
                db.SaveChanges();
                LayDsLoaiDoChoi();
                ThemDataBinding();
            }
        }