public List <TAI_KHOAN> DoiTrangThai(int id, string trangthai) { var TK = (from d in db.TAI_KHOAN where d.ID == id select d).FirstOrDefault(); if (TK != null) { TK.TrangThai = trangthai; db.SaveChanges(); } return(GetTaiKhoan()); }
public static bool ThemDichVu(string ten, decimal dongia, string dvt, string tt) { DICH_VU dv = new DICH_VU() { TenDichVu = ten, DonGia = dongia, DonViTinh = dvt, TrangThai = tt }; db.DICH_VU.Add(dv); db.SaveChanges(); return(true); }
private void button2_Click(object sender, EventArgs e) { //try //{ // DichVuService.SuaDichVu(int.Parse(txt_id.Text),(txt_tdv.Text), decimal.Parse(txt_dongia.Text), (txt_dvt.Text), (txt_trangthai.Text)); // MessageBox.Show("Sửa thành công"); // C05_DICHVU_Load(sender, e); //} //catch //{ // MessageBox.Show("Sửa thất bại"); //} try { DB_QL_NN_KSEntities db = new DB_QL_NN_KSEntities(); int idd = Convert.ToInt32(dataGridView1.SelectedCells[0].OwningRow.Cells["Id"].Value.ToString()); DICH_VU edit = db.DICH_VU.Find(idd); edit.TenDichVu = txt_tdv.Text; edit.DonGia = decimal.Parse(txt_dongia.Text); edit.DonViTinh = txt_dvt.Text; edit.TrangThai = txt_trangthai.Text; db.SaveChanges(); MessageBox.Show("sửa thành công"); C05_DICHVU_Load(sender, e); } catch { MessageBox.Show("sửa thất bại"); } }