private void LayDsLoaiDoChoi() { DoChoiEntities db = new DoChoiEntities(); var query = from l in db.LoaiDoChois select l; var ds = query.ToList(); dgvKind.DataSource = ds; }
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; }
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(); }
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(); }
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(); } }