Esempio n. 1
0
        private void DeleteUserRelation(string syskey)
        {
            Plat_RoleOfUser ruser = new Plat_RoleOfUser();

            ruser.RoleId     = Convert.ToInt32(HttpContext.Current.Request["roleid"]);
            ruser.UserIDCard = HttpContext.Current.Request["deluseridcard"];
            jsonModel        = new Plat_RoleOfUserService().DeleteUserRelation(ruser);
        }
Esempio n. 2
0
        /// <summary>
        /// 设置角色成员
        /// </summary>
        /// <param name="roleid">角色id</param>
        /// <param name="idCardStr">身份证号字符串,以逗号连接</param>
        /// <returns>返回 JsonModel</returns>
        public JsonModel SetRoleMember(string roleid, string idCardStr)
        {
            //定义JSON标准格式实体中
            JsonModel jsonModel = new JsonModel();

            try
            {
                //事务
                using (SqlTransaction trans = dal.GetTran())
                {
                    try
                    {
                        string[] idcardArray = idCardStr.Split(',');
                        int      count       = 0;
                        foreach (string idcard in idcardArray)
                        {
                            Plat_RoleOfUser ru = new Plat_RoleOfUser();
                            ru.RoleId     = Convert.ToInt32(roleid);
                            ru.UserIDCard = idcard;
                            int result = new Plat_RoleOfUserDal().Add(ru, trans);
                            if (result > 0)
                            {
                                count++;
                            }
                        }
                        if (idcardArray.Length != count)
                        {
                            trans.Rollback();//回滚
                            jsonModel = new JsonModel()
                            {
                                errNum  = 1,
                                errMsg  = "fial",
                                retData = "操作失败"
                            };
                            return(jsonModel);
                        }
                        else
                        {
                            trans.Commit();//提交
                        }
                    }
                    catch (Exception)
                    {
                        trans.Rollback();//回滚
                        throw;
                    }
                }
                jsonModel = new JsonModel()
                {
                    errNum  = 0,
                    errMsg  = "success",
                    retData = "操作成功"
                };
                return(jsonModel);
            }
            catch (Exception ex)
            {
                jsonModel = new JsonModel()
                {
                    errNum  = 400,
                    errMsg  = ex.Message,
                    retData = ""
                };
                return(jsonModel);
            }
        }