Ejemplo n.º 1
0
 /// <summary>
 /// 保存用户信息
 /// </summary>
 /// <param name="entity">用户实体</param>
 public void SaveUserInfo(GI_UserInfo entity)
 {
     if (!string.IsNullOrWhiteSpace(entity.UserID) && entity.UserID != "null")
     {
         entity.ModifyTime = DateTime.Now;
         entity.PassWord   = null;
         //user.PASSWORD = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(user.PASSWORD, "md5");
         entity.UpdateM("USERID");
     }
     else
     {
         entity.UserID    = this.GetPrimaryId(entity.OrganID) + "";
         entity.LoginTime = entity.ModifyTime = DateTime.Now;
         entity.SaveModelM();
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 增加和保存
        /// </summary>
        /// <param name="entity"></param>
        public void SaveInfo(GI_UserInfo entity)
        {
            string[] dpetlist      = new string[] { }; //科室
            string[] inpatientlist = new string[] { }; //病区
            string[] medicallist   = new string[] { }; //医疗组
            //科室
            if (!string.IsNullOrWhiteSpace(entity.DpetID))
            {
                dpetlist      = entity.DpetID.Split(',');
                entity.DpetID = dpetlist[0];//默认科室
            }
            //病区
            if (!string.IsNullOrWhiteSpace(entity.InpatientID))
            {
                inpatientlist      = entity.InpatientID.Split(',');
                entity.InpatientID = inpatientlist[0];//默认病区
            }
            //医疗组
            if (!string.IsNullOrWhiteSpace(entity.MedicalID))
            {
                medicallist      = entity.MedicalID.Split(',');
                entity.MedicalID = medicallist[0];//默认医疗组
            }
            //状态为正常
            entity.IsCance = 0;
            //保存或修改
            if (!string.IsNullOrWhiteSpace(entity.UserID) && entity.UserID != "null")
            {
                entity.UpdateM("UserID");
            }
            else
            {
                entity.UserID = CommonService.GetPrimaryId(new GI_SerialInfo()
                {
                    Name = "GI_UserInfo", ColumnName = "UserID", OrganID = entity.OrganID
                }) + "";
                entity.SaveModelM();
            }

            #region 科室,病区关联
            //删除用户关联科室,重新关联
            EntityOperate <AI_UserDept> .DeleteByFilter(" UserID='" + entity.UserID + "' ");

            //添加科室关联
            for (int i = 0; i < dpetlist.Length; i++)
            {
                AI_UserDept userdept = new AI_UserDept()
                {
                    UserID = entity.UserID, DeptID = dpetlist[i], TypeCode = 1, DisplaySort = i
                };
                userdept.SaveModelM();
            }
            //添加病区关联
            for (int i = 0; i < inpatientlist.Length; i++)
            {
                AI_UserDept userdept = new AI_UserDept()
                {
                    UserID = entity.UserID, DeptID = inpatientlist[i], TypeCode = 2, DisplaySort = i
                };
                userdept.SaveModelM();
            }
            #endregion
            #region 医疗组
            //获得该用户的医疗组
            DoctorGroupService    doctorgroupService  = new DoctorGroupService();
            List <AI_DoctorGroup> userDoctorGroupList = doctorgroupService.GetDoctorGroupByUserId(entity.UserID);
            string[] userDoctorGroup = (from u in userDoctorGroupList select u.DoctorGroupId).ToArray();
            foreach (var item in userDoctorGroup)
            {
                if (!((IList <string>)medicallist).Contains(item))
                {
                    //保存的医疗组中不包含该医疗组对照表中-删除对照表中的信息
                    EntityOperate <AI_GroupMember> .DeleteByFilter(" DoctorGroupId='" + item + "' and Member='" + entity.UserID + "' ");
                }
            }
            foreach (var item in medicallist)
            {
                if (!((IList <string>)userDoctorGroup).Contains(item))
                {
                    //数据库中的医疗组对照表不包含该医疗组id-添加对照
                    AI_GroupMember groupMember = new AI_GroupMember()
                    {
                        DoctorGroupId = item, Member = entity.UserID, MemberNum = entity.UserCode, MemberName = entity.UserName, Creator = entity.ModifyUserID, CreateTime = entity.ModifyTime, Updater = entity.ModifyUserID, UpdateTime = entity.ModifyTime
                    };
                    groupMember.MemberId = CommonService.GetPrimaryId(new GI_SerialInfo()
                    {
                        Name = "AI_GroupMember", ColumnName = "MemberId", OrganID = entity.OrganID
                    }) + "";
                    groupMember.SaveModelM();
                }
            }
            #endregion
        }