Exemplo n.º 1
0
        public bool ChangeAccount(int username, NHANVIEN after)    //NHANVIEN before
        {
            db = new PBL3_QLTraSuaEntities();
            var s = db.NHANVIENs.Where(p => p.ID_NV == username).FirstOrDefault();

            s.Ten_NV   = after.Ten_NV;
            s.password = after.password;
            try
            {
                db.SaveChanges();
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Exemplo n.º 2
0
 public bool Delete(NHANVIEN temp)
 {
     try
     {
         using (var newStaff = new PBL3_QLTraSuaEntities())
         {
             newStaff.Entry(temp).State = System.Data.Entity.EntityState.Deleted;
             newStaff.SaveChanges();
             MessageBox.Show("Thành Công");
             return(true);
         }
     }
     catch (Exception)
     {
         MessageBox.Show("Lỗi");
         return(false);
     }
 }
Exemplo n.º 3
0
        public bool Update(NHANVIEN before, NHANVIEN after)    //NHANVIEN before
        {
            try
            {
                using (PBL3_QLTraSuaEntities db = new PBL3_QLTraSuaEntities())  //var newStaff = new PBL3_QLTraSuaEntities()
                {
                    before             = db.NHANVIENs.Where(p => p.ID_NV.Equals(before.ID_NV)).SingleOrDefault();
                    before.Ten_NV      = after.Ten_NV;
                    before.PhoneNumber = after.PhoneNumber;
                    before.Gender      = after.Gender;
                    db.SaveChanges();

                    MessageBox.Show("Thành Công");
                    return(true);
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Lỗi ");
                return(false);
            }
        }
Exemplo n.º 4
0
        public bool ResetPassword_DAL(string username, string newpassword)
        {
            db = new PBL3_QLTraSuaEntities();
            var s = db.NHANVIENs.Where(p => p.PhoneNumber == username).FirstOrDefault();

            s.password = newpassword;
            try
            {
                db.SaveChanges();
                return(true);
            }
            catch (DbEntityValidationException ex)
            {
                foreach (var entityValidationErrors in ex.EntityValidationErrors)
                {
                    foreach (var validationError in entityValidationErrors.ValidationErrors)
                    {
                        Console.Write("Property: " + validationError.PropertyName + " Error: " + validationError.ErrorMessage);
                    }
                }
                return(false);
            }
        }
Exemplo n.º 5
0
 public void Sync()
 {
     db.SaveChanges();
 }