コード例 #1
0
        /// <summary>
        /// 根本登陆用户ID和文件ID查找权限
        /// 作者:章建国
        /// </summary>
        /// <param name="_fileid"></param>
        /// <returns></returns>
        public JsonResult GetLimitByUserIDandFileID(string _fileid)
        {
            try
            {
                tb_Limit         _limit       = null;
                E_tb_InPersonnel _inpersonnel = Session["UserInfo"] as Model.PersonnelManage.E_tb_InPersonnel;

                tb_LimitBLL _limitBLL = new tb_LimitBLL();
                string where = string.Format(" limitId = {0} and fileId = {1} and limitType = '用户'", _inpersonnel.PersonnelID, _fileid);
                var limitList = _limitbll.GetModelList(where);
                if (limitList != null && limitList.Count > 0)
                {
                    _limit = limitList[0];
                }
                else
                {
                    where     = string.Format(" limitId = {0} and fileId = {1} and limitType = '用户组'", _inpersonnel.AreaID, _fileid);
                    limitList = _limitbll.GetModelList(where);
                    if (limitList != null && limitList.Count > 0)
                    {
                        _limit = limitList[0];
                    }
                }
                return(Json(_limit, JsonRequestBehavior.AllowGet));
            }
            catch
            {
                return(Json("", JsonRequestBehavior.AllowGet));
            }
        }
コード例 #2
0
        /// <summary>
        /// 给权限加入
        /// </summary>
        /// <param name="_limitid"></param>
        /// <param name="_limittype"></param>
        /// <param name="_isCheck"></param>
        /// <returns></returns>
        public JsonResult updateLimitToFile(string _limitid, string _limittype, bool _isCheck)
        {
            string _message = "修改权限失败!";

            try
            {
                if (!string.IsNullOrEmpty(_limitid) && !string.IsNullOrEmpty(_limittype))
                {
                    tb_LimitBLL limitbll   = new tb_LimitBLL();
                    tb_Limit    limitmodel = limitbll.GetModel(Convert.ToInt32(_limitid));
                    switch (_limittype)
                    {
                    case "read":
                        limitmodel.limitRead = _isCheck;
                        break;

                    case "write":
                        limitmodel.limitWrite = _isCheck;
                        break;

                    case "delete":
                        limitmodel.limitDelete = _isCheck;
                        break;
                    }
                    if (limitbll.Update(limitmodel))
                    {
                        _message = "修改权限成功!";
                    }
                }
            }
            catch { }
            return(Json(_message, JsonRequestBehavior.AllowGet));
        }
コード例 #3
0
ファイル: tb_LimitDAL.cs プロジェクト: oakop01/lims
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public tb_Limit DataRowToModel(DataRow row)
        {
            tb_Limit model = new tb_Limit();

            if (row != null)
            {
                if (row["id"] != null && row["id"].ToString() != "")
                {
                    model.id = int.Parse(row["id"].ToString());
                }
                if (row["limitType"] != null)
                {
                    model.limitType = row["limitType"].ToString();
                }
                if (row["limitId"] != null && row["limitId"].ToString() != "")
                {
                    model.limitId = int.Parse(row["limitId"].ToString());
                }
                if (row["limitRead"] != null && row["limitRead"].ToString() != "")
                {
                    if ((row["limitRead"].ToString() == "1") || (row["limitRead"].ToString().ToLower() == "true"))
                    {
                        model.limitRead = true;
                    }
                    else
                    {
                        model.limitRead = false;
                    }
                }
                if (row["limitWrite"] != null && row["limitWrite"].ToString() != "")
                {
                    if ((row["limitWrite"].ToString() == "1") || (row["limitWrite"].ToString().ToLower() == "true"))
                    {
                        model.limitWrite = true;
                    }
                    else
                    {
                        model.limitWrite = false;
                    }
                }
                if (row["limitDelete"] != null && row["limitDelete"].ToString() != "")
                {
                    if ((row["limitDelete"].ToString() == "1") || (row["limitDelete"].ToString().ToLower() == "true"))
                    {
                        model.limitDelete = true;
                    }
                    else
                    {
                        model.limitDelete = false;
                    }
                }
                if (row["fileId"] != null && row["fileId"].ToString() != "")
                {
                    model.fileId = int.Parse(row["fileId"].ToString());
                }
            }
            return(model);
        }
コード例 #4
0
ファイル: tb_LimitDAL.cs プロジェクト: oakop01/lims
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(tb_Limit model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update tb_Limit set ");
            strSql.Append("limitType=@limitType,");
            strSql.Append("limitId=@limitId,");
            strSql.Append("limitRead=@limitRead,");
            strSql.Append("limitWrite=@limitWrite,");
            strSql.Append("limitDelete=@limitDelete,");
            strSql.Append("fileId=@fileId");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@limitType",   SqlDbType.NVarChar, 50),
                new SqlParameter("@limitId",     SqlDbType.Int,       4),
                new SqlParameter("@limitRead",   SqlDbType.Bit,       1),
                new SqlParameter("@limitWrite",  SqlDbType.Bit,       1),
                new SqlParameter("@limitDelete", SqlDbType.Bit,       1),
                new SqlParameter("@fileId",      SqlDbType.Int,       4),
                new SqlParameter("@id",          SqlDbType.Int, 4)
            };
            parameters[0].Value = model.limitType;
            parameters[1].Value = model.limitId;
            parameters[2].Value = model.limitRead;
            parameters[3].Value = model.limitWrite;
            parameters[4].Value = model.limitDelete;
            parameters[5].Value = model.fileId;
            parameters[6].Value = model.id;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #5
0
        /// <summary>
        /// 给文件加入新的权限
        /// 作者:章建国
        /// </summary>
        /// <param name="_fileid">文件ID</param>
        /// <param name="_limitid">用户或者用户组ID</param>
        /// <param name="_limittype">类型(用户或用户组)</param>
        /// <returns></returns>
        public JsonResult addLimitToFile(string _fileid, string _limitid, string _limittype)
        {
            string flag = "false";

            if (!string.IsNullOrEmpty(_fileid) && !string.IsNullOrEmpty(_limitid) && !string.IsNullOrEmpty(_limittype))
            {
                try
                {
                    _limittype = _limittype.Equals("0") ? "用户" : _limittype.Equals("00") ? "用户组" : "";
                    tb_Limit limitmodel = new tb_Limit()
                    {
                        fileId = Convert.ToInt32(_fileid), limitDelete = false, limitRead = false, limitWrite = false, limitId = Convert.ToInt32(_limitid), limitType = _limittype
                    };
                    if (new tb_LimitBLL().Add(limitmodel) > 0)
                    {
                        flag = "true";
                    }
                }
                catch { }
            }
            return(Json(flag, JsonRequestBehavior.AllowGet));
        }
コード例 #6
0
ファイル: tb_LimitDAL.cs プロジェクト: oakop01/lims
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(tb_Limit model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into tb_Limit(");
            strSql.Append("limitType,limitId,limitRead,limitWrite,limitDelete,fileId)");
            strSql.Append(" values (");
            strSql.Append("@limitType,@limitId,@limitRead,@limitWrite,@limitDelete,@fileId)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@limitType",   SqlDbType.NVarChar, 50),
                new SqlParameter("@limitId",     SqlDbType.Int,       4),
                new SqlParameter("@limitRead",   SqlDbType.Bit,       1),
                new SqlParameter("@limitWrite",  SqlDbType.Bit,       1),
                new SqlParameter("@limitDelete", SqlDbType.Bit,       1),
                new SqlParameter("@fileId",      SqlDbType.Int, 4)
            };
            parameters[0].Value = model.limitType;
            parameters[1].Value = model.limitId;
            parameters[2].Value = model.limitRead;
            parameters[3].Value = model.limitWrite;
            parameters[4].Value = model.limitDelete;
            parameters[5].Value = model.fileId;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
コード例 #7
0
ファイル: tb_LimitDAL.cs プロジェクト: oakop01/lims
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public tb_Limit GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,limitType,limitId,limitRead,limitWrite,limitDelete,fileId from tb_Limit ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

            tb_Limit model = new tb_Limit();
            DataSet  ds    = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
コード例 #8
0
ファイル: tb_LimitBLL.cs プロジェクト: jangocheng/lims
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(tb_Limit model)
 {
     return(dal.Update(model));
 }
コード例 #9
0
ファイル: tb_LimitBLL.cs プロジェクト: jangocheng/lims
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(tb_Limit model)
 {
     return(dal.Add(model));
 }