예제 #1
0
        /// <summary>
        /// 更新基本信息
        /// </summary>
        /// <returns></returns>
        public bool Update()
        {
            HIS.Model.BASE_EMPLOYEE_PROPERTY mdl_emp = BindEntity <Model.BASE_EMPLOYEE_PROPERTY> .CreateInstanceDAL(oleDb).GetModel(_employeeID);

            if (mdl_emp == null)
            {
                throw new Exception("获取人员基本信息对象失败");
            }
            HIS.Model.BASE_ROLE_DOCTOR   mdl_doc        = new HIS.Model.BASE_ROLE_DOCTOR( );
            HIS.Model.BASE_ROLE_NURSE    mdl_nurse      = new HIS.Model.BASE_ROLE_NURSE( );
            HIS.Model.BASE_USER          mdl_user       = new HIS.Model.BASE_USER( );
            HIS.Model.BASE_GROUP_USER    mdl_group_user = new HIS.Model.BASE_GROUP_USER( );
            HIS.Model.BASE_EMP_DEPT_ROLE mdl_emp_dept   = new HIS.Model.BASE_EMP_DEPT_ROLE( );

            mdl_emp.D_CODE     = _dgCode;
            mdl_emp.NAME       = _name;
            mdl_emp.PY_CODE    = _pyCode;
            mdl_emp.SEX        = _sex;
            mdl_emp.WB_CODE    = _wbCode;
            mdl_emp.DELETE_BIT = notUse;

            oleDb.BeginTransaction( );
            try
            {
                BindEntity <Model.BASE_EMPLOYEE_PROPERTY> .CreateInstanceDAL(oleDb).Update(mdl_emp);

                BindEntity <Model.BASE_ROLE_DOCTOR> .CreateInstanceDAL(oleDb).Delete(Tables.base_role_doctor.EMPLOYEE_ID + oleDb.EuqalTo() + _employeeID);

                if (Role == 1)
                {
                    if (DocCode.Trim() != "")
                    {
                        if (BindEntity <Model.BASE_ROLE_DOCTOR> .CreateInstanceDAL(oleDb).GetModel(Tables.base_role_doctor.YS_CODE + oleDb.EuqalTo() + "'" + DocCode + "'" + oleDb.And() + Tables.base_role_doctor.EMPLOYEE_ID + oleDb.NotEqualTo() + _employeeID) != null)
                        {
                            throw new Exception("医生代码已经在使用中");
                        }
                    }

                    mdl_doc.CF_RIGHT    = CFQ;
                    mdl_doc.DM_RIGHT    = DMQ;
                    mdl_doc.EMPLOYEE_ID = _employeeID;
                    mdl_doc.MZ_RIGHT    = MZQ;
                    mdl_doc.YS_CODE     = DocCode;
                    mdl_doc.YS_TYPEID   = doctor_typeId;
                    BindEntity <Model.BASE_ROLE_DOCTOR> .CreateInstanceDAL(oleDb).Add(mdl_doc);
                }
                BindEntity <Model.BASE_ROLE_NURSE> .CreateInstanceDAL(oleDb).Delete(Tables.base_role_nurse.EMPLOYEE_ID + oleDb.EuqalTo() + _employeeID);

                if (Role == 2)
                {
                    mdl_nurse.EMPLOYEE_ID = _employeeID;
                    BindEntity <Model.BASE_ROLE_NURSE> .CreateInstanceDAL(oleDb).Add(mdl_nurse);
                }
                //科室
                BindEntity <Model.BASE_EMP_DEPT_ROLE> .CreateInstanceDAL(oleDb).Delete(Tables.base_emp_dept_role.EMPLOYEE_ID + oleDb.EuqalTo() + _employeeID);

                for (int i = 0; i < DeptIds.Length; i++)
                {
                    mdl_emp_dept             = new HIS.Model.BASE_EMP_DEPT_ROLE( );
                    mdl_emp_dept.DEPT_ID     = DeptIds[i];
                    mdl_emp_dept.EMPLOYEE_ID = _employeeID;
                    BindEntity <Model.BASE_EMP_DEPT_ROLE> .CreateInstanceDAL(oleDb).Add(mdl_emp_dept);
                }
                //用户和组
                if (UserCode.Trim( ) != "")
                {
                    if (BindEntity <Model.BASE_USER> .CreateInstanceDAL(oleDb).GetModel(Tables.base_user.CODE + oleDb.EuqalTo() + "'" + UserCode + "'" + oleDb.And() + Tables.base_user.EMPLOYEE_ID + oleDb.NotEqualTo() + _employeeID) == null)
                    {
                        mdl_user = BindEntity <Model.BASE_USER> .CreateInstanceDAL(oleDb).GetModel(Tables.base_user.EMPLOYEE_ID + oleDb.EuqalTo() + _employeeID);

                        if (mdl_user == null)
                        {
                            mdl_user             = new HIS.Model.BASE_USER( );
                            mdl_user.PASSWORD    = "******";
                            mdl_user.EMPLOYEE_ID = _employeeID;
                            mdl_user.CODE        = UserCode;
                            mdl_user.USER_ID     = BindEntity <Model.BASE_USER> .CreateInstanceDAL(oleDb).Add(mdl_user);
                        }
                        else
                        {
                            mdl_user.CODE = UserCode;
                            BindEntity <Model.BASE_USER> .CreateInstanceDAL(oleDb).Update(mdl_user);
                        }

                        BindEntity <Model.BASE_GROUP_USER> .CreateInstanceDAL(oleDb).Delete(Tables.base_group_user.USER_ID + oleDb.EuqalTo() + mdl_user.USER_ID);

                        for (int i = 0; i < GroupIds.Length; i++)
                        {
                            mdl_group_user          = new HIS.Model.BASE_GROUP_USER( );
                            mdl_group_user.GROUP_ID = GroupIds[i];
                            mdl_group_user.USER_ID  = mdl_user.USER_ID;

                            BindEntity <Model.BASE_GROUP_USER> .CreateInstanceDAL(oleDb).Add(mdl_group_user);
                        }
                    }
                    else
                    {
                        throw new Exception("用户名存在");
                    }
                }
                else
                {
                    //mdl_user = BindEntity<Model.BASE_USER>.CreateInstanceDAL( oleDb ).GetModel( Tables.base_user.EMPLOYEE_ID + oleDb.EuqalTo() + _employeeID );
                    //if ( mdl_user != null )
                    //{
                    //    BindEntity<Model.BASE_USER>.CreateInstanceDAL( oleDb ).Delete( Tables.base_user.USER_ID + oleDb.EuqalTo( ) + mdl_user.USER_ID );
                    //    BindEntity<Model.BASE_GROUP_USER>.CreateInstanceDAL( oleDb ).Delete( Tables.base_group_user.USER_ID + oleDb.EuqalTo( ) + mdl_user.USER_ID );
                    //}
                }
                oleDb.CommitTransaction( );
                return(true);
            }
            catch (Exception err)
            {
                oleDb.RollbackTransaction( );
                throw err;
            }
        }
예제 #2
0
        /// <summary>
        /// 新增人员
        /// </summary>
        /// <returns></returns>
        public bool Add()
        {
            HIS.Model.BASE_EMPLOYEE_PROPERTY mdl_emp    = new HIS.Model.BASE_EMPLOYEE_PROPERTY( );
            HIS.Model.BASE_ROLE_DOCTOR       mdl_doc    = new HIS.Model.BASE_ROLE_DOCTOR( );
            HIS.Model.BASE_ROLE_NURSE        mdl_nurse  = new HIS.Model.BASE_ROLE_NURSE( );
            HIS.Model.BASE_USER          mdl_user       = new HIS.Model.BASE_USER( );
            HIS.Model.BASE_GROUP_USER    mdl_group_user = new HIS.Model.BASE_GROUP_USER( );
            HIS.Model.BASE_EMP_DEPT_ROLE mdl_emp_dept   = new HIS.Model.BASE_EMP_DEPT_ROLE( );

            mdl_emp.D_CODE     = _dgCode;
            mdl_emp.NAME       = _name;
            mdl_emp.PY_CODE    = _pyCode;
            mdl_emp.SEX        = _sex;
            mdl_emp.WB_CODE    = _wbCode;
            mdl_emp.DELETE_BIT = notUse;

            oleDb.BeginTransaction( );
            try
            {
                BindEntity <Model.BASE_EMPLOYEE_PROPERTY> .CreateInstanceDAL(oleDb).Add(mdl_emp);

                _employeeID = Convert.ToInt32(mdl_emp.EMPLOYEE_ID);
                if (_employeeID == 0)
                {
                    throw new Exception("保存人员基本信息异常!");
                }
                if (Role == 1)
                {
                    string strWhere = BLL.Tables.base_role_doctor.YS_CODE + oleDb.EuqalTo() + "'" + DocCode + "'";
                    if (BindEntity <Model.BASE_ROLE_DOCTOR> .CreateInstanceDAL(oleDb).GetModel(strWhere) == null)
                    {
                        mdl_doc.CF_RIGHT    = CFQ;
                        mdl_doc.DM_RIGHT    = DMQ;
                        mdl_doc.EMPLOYEE_ID = _employeeID;
                        mdl_doc.MZ_RIGHT    = MZQ;
                        mdl_doc.YS_CODE     = DocCode;
                        mdl_doc.YS_TYPEID   = doctor_typeId;
                        BindEntity <Model.BASE_ROLE_DOCTOR> .CreateInstanceDAL(oleDb).Add(mdl_doc);
                    }
                    else
                    {
                        throw new Exception("医生代码已经在使用中");
                    }
                }
                if (Role == 2)
                {
                    mdl_nurse.EMPLOYEE_ID = _employeeID;
                    BindEntity <Model.BASE_ROLE_NURSE> .CreateInstanceDAL(oleDb).Add(mdl_nurse);
                }
                //科室
                for (int i = 0; i < DeptIds.Length; i++)
                {
                    mdl_emp_dept             = new HIS.Model.BASE_EMP_DEPT_ROLE( );
                    mdl_emp_dept.DEPT_ID     = DeptIds[i];
                    mdl_emp_dept.EMPLOYEE_ID = _employeeID;
                    BindEntity <Model.BASE_EMP_DEPT_ROLE> .CreateInstanceDAL(oleDb).Add(mdl_emp_dept);
                }
                //用户和组
                if (UserCode.Trim( ) != "")
                {
                    mdl_user.EMPLOYEE_ID = _employeeID;
                    mdl_user.CODE        = UserCode;
                    mdl_user.PASSWORD    = "******";

                    mdl_user = null;
                    mdl_user = BindEntity <Model.BASE_USER> .CreateInstanceDAL(oleDb).GetModel(oleDb.UCASE(Tables.base_user.CODE) + oleDb.EuqalTo( ) + "'" + UserCode.ToUpper() + "'");

                    if (mdl_user != null)
                    {
                        throw new Exception("用户名" + UserCode + "已经在使用中!");
                    }
                    else
                    {
                        mdl_user = new HIS.Model.BASE_USER( );
                    }

                    mdl_user.PASSWORD    = "******";
                    mdl_user.EMPLOYEE_ID = _employeeID;
                    mdl_user.CODE        = UserCode;
                    BindEntity <Model.BASE_USER> .CreateInstanceDAL(oleDb).Add(mdl_user);

                    for (int i = 0; i < GroupIds.Length; i++)
                    {
                        mdl_group_user          = new HIS.Model.BASE_GROUP_USER( );
                        mdl_group_user.GROUP_ID = GroupIds[i];
                        mdl_group_user.USER_ID  = mdl_user.USER_ID;

                        BindEntity <Model.BASE_GROUP_USER> .CreateInstanceDAL(oleDb).Add(mdl_group_user);
                    }
                }
                oleDb.CommitTransaction( );
                return(true);
            }
            catch (Exception err)
            {
                oleDb.RollbackTransaction( );
                throw err;
            }
        }