public bool chuyen_trang_thai(int id, int trangthai, string time) { try { using (sql_NCKHContext db = new sql_NCKHContext()) { Tbldetai dt = db.Tbldetais.SingleOrDefault(x => x.Id == id); if (string.IsNullOrEmpty(dt.ToString())) { return(false); } switch (trangthai) { case 2: dt.Tinhtrang = 2; //duyệt dt.Thoigianbd = DateTime.Now; dt.Thoigiannt = tinhthoigiannt(dt, Convert.ToDateTime(dt.Thoigianbd)); break; case 3: dt.Tinhtrang = 3; //Hoan thanh break; case 4: dt.Thoigiangiahan = giahan(time); dt.Tinhtrang = 4; //Xin them thoi gian break; case 5: dt.Tinhtrang = 5; //áp dụng thực tế break; case -1: dt.Tinhtrang = -1; //huỷ break; } db.SaveChanges(); return(true); } } catch (Exception) { return(false); } }
public bool delete_detai(int id) { try { using (sql_NCKHContext db = new sql_NCKHContext()) { Tbldetai d = db.Tbldetais.SingleOrDefault(x => x.Id == id); if (string.IsNullOrEmpty(d.ToString())) { return(true); } db.Tbldetais.Remove(d); db.SaveChanges(); return(true); } } catch (Exception) { return(false); } }