Esempio n. 1
0
        /// <summary>
        /// ����ְԱ��
        /// </summary>
        /// <param name="dto">������ְԱ����Ϣ��</param>
        /// <returns>�����Ƿ�ɹ��ı�ʾ����1���ɹ���-2����¼Id�ظ���</returns>
        public static string InsertStaff(StaffDTO dto)
        {
            //�жϵ�¼Id�Ƿ��ظ���
            string hql = "select count(*) from Staff s where s.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"; }

            //ְԱ������Ϣ��
            Staff s = new Staff();
            s.LoginId = dto.LoginId;
            s.Password = StringSecurity.StringToSHA1Hash(dto.Password);
            s.Name = dto.Name;
            s.Disabled = dto.Disabled;
            s.OrderId = dto.OrderId;
            s.IdCard = dto.IdCard;
            s.Code = dto.Code;
            s.OfficePhone = dto.OfficePhone;
            s.ExtNumber = dto.ExtNumber;
            s.CellPhone = dto.CellPhone;
            s.FamilyPhone = dto.FamilyPhone;
            s.Email = dto.Email;
            s.ZipCode = dto.ZipCode;
            s.Remark = dto.Remark;
            s.Address = dto.Address;
            s.DegreeTag = dto.DegreeTag;
            s.Sex = dto.Sex;
            s.PoliticalAppearanceTag = dto.PoliticalAppearanceTag;
            s.Married = dto.Married;
            s.Birthday = dto.Birthday;
            s.CountryTag = dto.CountryTag;
            s.EntersDay = dto.EntersDay;
            s.NationTag = dto.NationTag;
            s.LeavesDay = dto.LeavesDay;
            s.PositionTag = dto.PositionTag;
            s.TitleTag = dto.TitleTag;

            //����ͨ����������ְԱ�������ڲ��û���
            s.IsInnerUser = 0;

            //������š�
            Department d = Db.Session.Load(typeof(Department), dto.DepartmentId) as Department;
            d.AddStaff(s);

            Db.TransInsert(s);
            return "1";
        }
Esempio n. 2
0
        /// <summary>
        /// ����ְԱ��
        /// </summary>
        /// <param name="dto">������ְԱ����Ϣ��</param>
        public static void UpdateStaff(StaffDTO dto)
        {
            Staff s = Db.Session.Load(typeof(Staff), dto.LoginId) as Staff;
            s.Name = dto.Name;
            s.Disabled = dto.Disabled;
            s.OrderId = dto.OrderId;
            s.IdCard = dto.IdCard;
            s.Code = dto.Code;
            s.OfficePhone = dto.OfficePhone;
            s.ExtNumber = dto.ExtNumber;
            s.CellPhone = dto.CellPhone;
            s.FamilyPhone = dto.FamilyPhone;
            s.Email = dto.Email;
            s.ZipCode = dto.ZipCode;
            s.Remark = dto.Remark;
            s.Address = dto.Address;
            s.DegreeTag = dto.DegreeTag;
            s.Sex = dto.Sex;
            s.PoliticalAppearanceTag = dto.PoliticalAppearanceTag;
            s.Married = dto.Married;
            s.Birthday = dto.Birthday;
            s.CountryTag = dto.CountryTag;
            s.EntersDay = dto.EntersDay;
            s.NationTag = dto.NationTag;
            s.LeavesDay = dto.LeavesDay;
            s.PositionTag = dto.PositionTag;
            s.TitleTag = dto.TitleTag;

            Db.TransUpdate(s);
        }