Esempio n. 1
0
        /// <summary>
        /// 添加用户
        /// </summary>
        /// <param name="name">用户名称</param>
        /// <param name="description">用户描述</param>
        /// <param name="state">状态</param>
        /// <returns>True-操作成功|False-操作失败</returns>
        public bool AddUserInfo(Contacts contactsInfo)
        {
            using (_session = _sessionfactory.Session)
            {
                _session.Save(contactsInfo);
                _session.Flush();

            }
            return true;
        }
Esempio n. 2
0
 /// <summary>
 /// 更新用户信息
 /// </summary>
 /// <param name="name">用户名称</param>
 /// <param name="description">用户描述</param>
 /// <param name="state">状态</param>
 /// <returns>True-操作成功|False-操作失败</returns>
 public bool UpdateUserInfo(Contacts contactsInfo)
 {
     bool result = false;
     if (ExistUserInfo(contactsInfo.FirstName))
     {
         string hql = "update Contacts set FirstName=:FirstName where LastName=:LastName";
         using (_session = _sessionfactory.Session)
         {
             IQuery query = _session.CreateQuery(hql);
             query.SetString("FirstName", contactsInfo.FirstName);
             query.SetString("LastName", contactsInfo.LastName);
             result = (query.ExecuteUpdate() > 0) ? true : false;
         }
     }
     else
     {
         result = false;
     }
     return result;
 }