Exemplo n.º 1
0
        // 递归树形
        public string Recursion(E_tb_Action model, List <E_tb_RoleAction> RoleActionList)
        {
            string res_s = "";
            //你想要在视图中得到的值
            string strChecked = this.ActionIsChecked(RoleActionList, model.ActionID);

            if (RoleActionList.Where(p => p.ActionID == model.ActionID).Count() > 0)
            {
                strChecked = "true";
            }

            res_s += "{\"id\":\"" + model.ActionID + "\",\"text\":\"" + model.ActionName + "(" + model.ActionCode + ")" + "\",\"checked\":" + strChecked;

            IList <E_tb_Action> list = tAction.GetModelList("ParentID=" + model.ActionID).ToList();

            if (list != null)
            {
                res_s += "," + "\"children\":[";
                for (int i = 0; i < list.Count; i++)
                {
                    if (i > 0)
                    {
                        res_s += ",";
                    }
                    res_s += Recursion(list[i], RoleActionList);
                }
                res_s += "]";
            }
            ;
            res_s += "}";
            return(res_s);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List <E_tb_Action> DataTableToList(DataTable dt)
        {
            List <E_tb_Action> modelList = new List <E_tb_Action>();
            int rowsCount = dt.Rows.Count;

            if (rowsCount > 0)
            {
                E_tb_Action model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new E_tb_Action();
                    if (dt.Rows[n]["ActionID"].ToString() != "")
                    {
                        model.ActionID = int.Parse(dt.Rows[n]["ActionID"].ToString());
                    }
                    if (dt.Rows[n]["ParentID"].ToString() != "")
                    {
                        model.ParentID = int.Parse(dt.Rows[n]["ParentID"].ToString());
                    }
                    model.ActionName  = dt.Rows[n]["ActionName"].ToString();
                    model.ActionCode  = dt.Rows[n]["ActionCode"].ToString();
                    model.RequestType = dt.Rows[n]["RequestType"].ToString();
                    model.RequestURL  = dt.Rows[n]["RequestURL"].ToString();
                    if (dt.Rows[n]["ActionType"].ToString() != "")
                    {
                        model.ActionType = int.Parse(dt.Rows[n]["ActionType"].ToString());
                    }
                    modelList.Add(model);
                }
            }
            return(modelList);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 保存信息
        /// 作者:小朱
        /// </summary>
        /// <param name="eAction">要处理的对象</param>
        /// <returns>返回是否处理成功</returns>
        public string Save(E_tb_Action eAction)
        {
            string msg = "0";

            if (string.IsNullOrEmpty(eAction.ActionCode))
            {
                eAction.ActionCode = Guid.NewGuid().ToString().Substring(0, 8);
            }
            if (eAction.EditType == "Add")
            {
                if (eAction.ParentID == null)
                {
                    eAction.ActionType = 1;
                    eAction.ParentID   = 0;
                }
                tAction.Add(eAction);
                msg = "1";
            }
            else
            {
                tAction.Update(eAction);
                msg = "1";
            }
            return(msg);
        }
Exemplo n.º 4
0
 /// <summary>
 /// 显示详情页  模块
 /// </summary>
 /// <param name="EditType">编辑类型</param>
 /// <returns>返回编辑结果</returns>
 public ActionResult ActionEdit(E_tb_Action eAction, string EditType, int?InfoID)
 {
     if (EditType == "Edit")
     {
         eAction = tAction.GetModel(Convert.ToInt32(InfoID));
     }
     eAction.EditType = EditType;
     return(View(eAction));
 }
Exemplo n.º 5
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public E_tb_Action GetModel(int ActionID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 ActionID,ParentID,ActionName,ActionCode,RequestType,RequestURL,ActionType from tb_Action ");
            strSql.Append(" where ActionID=@ActionID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ActionID", SqlDbType.Int, 4)
            };
            parameters[0].Value = ActionID;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["ActionID"].ToString() != "")
                {
                    model.ActionID = int.Parse(ds.Tables[0].Rows[0]["ActionID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ParentID"].ToString() != "")
                {
                    model.ParentID = int.Parse(ds.Tables[0].Rows[0]["ParentID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ActionName"] != null)
                {
                    model.ActionName = ds.Tables[0].Rows[0]["ActionName"].ToString();
                }
                if (ds.Tables[0].Rows[0]["ActionCode"] != null)
                {
                    model.ActionCode = ds.Tables[0].Rows[0]["ActionCode"].ToString();
                }
                if (ds.Tables[0].Rows[0]["RequestType"] != null)
                {
                    model.RequestType = ds.Tables[0].Rows[0]["RequestType"].ToString();
                }
                if (ds.Tables[0].Rows[0]["RequestURL"] != null)
                {
                    model.RequestURL = ds.Tables[0].Rows[0]["RequestURL"].ToString();
                }
                if (ds.Tables[0].Rows[0]["ActionType"].ToString() != "")
                {
                    model.ActionType = int.Parse(ds.Tables[0].Rows[0]["ActionType"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 6
0
 /// <summary>
 /// 显示详情页 页面、操作
 /// </summary>
 /// <param name="EditType">编辑类型</param>
 /// <returns>返回编辑结果</returns>
 public ActionResult ActionPageEdit(E_tb_Action eAction, string EditType, int?ParentID, int?InfoID)
 {
     if (EditType == "Edit")
     {
         eAction            = tAction.GetModel(Convert.ToInt32(InfoID));
         eAction.ParentName = tAction.GetModel(Convert.ToInt32(eAction.ParentID)).ActionName;
     }
     else
     {
         E_tb_Action TempAction = tAction.GetModel(int.Parse(ParentID.ToString()));
         eAction.ParentID   = ParentID;
         eAction.ActionType = TempAction.ActionType + 1;
         eAction.ParentName = TempAction.ActionName;
     }
     eAction.EditType = EditType;
     return(View(eAction));
 }
Exemplo n.º 7
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(E_tb_Action model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update tb_Action set ");
            strSql.Append("ParentID=@ParentID,");
            strSql.Append("ActionName=@ActionName,");
            strSql.Append("ActionCode=@ActionCode,");
            strSql.Append("RequestType=@RequestType,");
            strSql.Append("RequestURL=@RequestURL,");
            strSql.Append("ActionType=@ActionType");
            strSql.Append(" where ActionID=@ActionID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ParentID",    SqlDbType.Int,       4),
                new SqlParameter("@ActionName",  SqlDbType.NVarChar, 50),
                new SqlParameter("@ActionCode",  SqlDbType.NVarChar, 50),
                new SqlParameter("@RequestType", SqlDbType.NVarChar, 50),
                new SqlParameter("@RequestURL",  SqlDbType.NVarChar, 50),
                new SqlParameter("@ActionType",  SqlDbType.Int,       4),
                new SqlParameter("@ActionID",    SqlDbType.Int, 4)
            };
            parameters[0].Value = model.ParentID;
            parameters[1].Value = model.ActionName;
            parameters[2].Value = model.ActionCode;
            parameters[3].Value = model.RequestType;
            parameters[4].Value = model.RequestURL;
            parameters[5].Value = model.ActionType;
            parameters[6].Value = model.ActionID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(E_tb_Action model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into tb_Action(");
            strSql.Append("ParentID,ActionName,ActionCode,RequestType,RequestURL,ActionType)");
            strSql.Append(" values (");
            strSql.Append("@ParentID,@ActionName,@ActionCode,@RequestType,@RequestURL,@ActionType)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ParentID",    SqlDbType.Int,       4),
                new SqlParameter("@ActionName",  SqlDbType.NVarChar, 50),
                new SqlParameter("@ActionCode",  SqlDbType.NVarChar, 50),
                new SqlParameter("@RequestType", SqlDbType.NVarChar, 50),
                new SqlParameter("@RequestURL",  SqlDbType.NVarChar, 50),
                new SqlParameter("@ActionType",  SqlDbType.Int, 4)
            };
            parameters[0].Value = model.ParentID;
            parameters[1].Value = model.ActionName;
            parameters[2].Value = model.ActionCode;
            parameters[3].Value = model.RequestType;
            parameters[4].Value = model.RequestURL;
            parameters[5].Value = model.ActionType;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Exemplo n.º 9
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(E_tb_Action model)
 {
     return(dal.Update(model));
 }
Exemplo n.º 10
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(E_tb_Action model)
 {
     return(dal.Add(model));
 }