Exemplo n.º 1
0
        /// <summary>
        /// �����û���
        /// </summary>
        /// <param name="dto">�������û�����Ϣ��</param>
        /// <returns>�����Ƿ�ɹ��ı�ʾ����1���ɹ���-2����¼Id�ظ�����</returns>
        public static string InsertUser(UserDTO dto)
        {
            //�жϵ�¼Id�Ƿ��ظ���
            string hql = "select count(*) from User u where u.LoginId = :loginId";
            IQuery q = Db.Session.CreateQuery(hql);
            q.SetString("loginId", dto.LoginId);
            object o = q.UniqueResult();
            if (int.Parse(o.ToString()) > 0) { return "-2"; }

            Db.SessionFactory.EvictQueries("User");

            User u = new User();
            u.LoginId = dto.LoginId;
            u.Password = StringSecurity.StringToSHA1Hash(dto.Password);
            u.Name = dto.Name;
            u.Disabled = dto.Disabled;
            u.IdCard = dto.IdCard;
            u.Sex = dto.Sex;
            u.Birthday = dto.Birthday;
            u.OfficePhone = dto.OfficePhone;
            u.CellPhone = dto.CellPhone;
            u.FamilyPhone = dto.FamilyPhone;
            u.Email = dto.Email;
            u.ZipCode = dto.ZipCode;
            u.Remark = dto.Remark;
            u.Address = dto.Address;
            u.RegisterDate = DateTime.Now;

            Db.TransInsert(u);
            return "1";
        }
Exemplo n.º 2
0
        /// <summary>
        /// �����û���
        /// </summary>
        /// <param name="dto">�������û�����Ϣ��</param>
        public static void UpdateUser(UserDTO dto)
        {
            Db.SessionFactory.EvictQueries("User");

            User u = Db.Session.Load(typeof(User), dto.LoginId) as User;
            u.Name = dto.Name;
            u.Disabled = dto.Disabled;
            u.IdCard = dto.IdCard;
            u.Sex = dto.Sex;
            u.Birthday = dto.Birthday;
            u.OfficePhone = dto.OfficePhone;
            u.CellPhone = dto.CellPhone;
            u.FamilyPhone = dto.FamilyPhone;
            u.Email = dto.Email;
            u.ZipCode = dto.ZipCode;
            u.Remark = dto.Remark;
            u.Address = dto.Address;

            Db.TransUpdate(u);
        }