Exemplo n.º 1
0
        private List <ITC_Roles_M> DsToList(DataSet ds)
        {
            List <ITC_Roles_M> list = new List <ITC_Roles_M>();

            if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                ITC_Roles_M model = null;
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    model             = new ITC_Roles_M();
                    model.Role_ID     = ds.Tables[0].Rows[i]["Role_ID"].ToString().Trim();
                    model.Role_Name   = ds.Tables[0].Rows[i]["Role_Name"].ToString();
                    model.Role_Remark = ds.Tables[0].Rows[i]["Role_Remark"].ToString();
                    if (ds.Tables[0].Rows[i]["Role_Status"].ToString() != "")
                    {
                        model.Role_Status = int.Parse(ds.Tables[0].Rows[i]["Role_Status"].ToString());
                    }
                    if (ds.Tables[0].Rows[0]["Role_createdtime"].ToString() != "")
                    {
                        model.Role_createdtime = DateTime.Parse(ds.Tables[0].Rows[i]["Role_createdtime"].ToString());
                    }
                    model.Role_oprt = ds.Tables[0].Rows[i]["Role_oprt"].ToString();

                    list.Add(model);
                }
            }
            return(list);
        }
Exemplo n.º 2
0
 //编辑保存
 public ActionResult SaveEdit(ITC_Roles_M model)
 {
     if (uifo.Exists(model.Role_ID))
     {
         model.Role_createdtime = DateTime.Now;
         model.Role_oprt        = UserContext.UserName;
         if (uifo.Update(model))
         {
             EventContext.Add(MenuID, string.Format("修改:{0}", model.Role_ID));
             return(Content("保存成功!"));
         }
         else
         {
             return(Content("保存失败!"));
         }
     }
     else
     {
         return(Content("保存失败! 编码[" + model.Role_ID + "]不存在!"));
     }
 }
Exemplo n.º 3
0
        //设置权限
        public ActionResult SaveRight(FormCollection collection)
        {
            string roleid = Request["roleid"];

            if (!string.IsNullOrEmpty(roleid))
            {
                //删除菜单权限 操作权限
                uifo.DeleteRoleRights(roleid);
                uifo.DeleteRoleOperator(roleid);
                if (collection.Count > 0)
                {
                    string menuid   = "";
                    string buttonid = "";
                    for (int i = 0; i < collection.Count; i++)
                    {
                        string key   = collection.Keys[i];
                        string value = collection[i];
                        menuid   = key.Split('|')[0];
                        buttonid = key.Split('|')[1];
                        //添加菜单权限 操作权限
                        if (value == "on")
                        {
                            uifo.AddRoleRights(roleid, menuid);
                            uifo.AddRoleOperator(roleid, menuid, buttonid);
                        }
                    }
                }
                ITC_Roles_M model = uifo.GetModel(roleid);
                model.Role_oprt        = UserContext.UserName;
                model.Role_createdtime = DateTime.Now;
                uifo.Update(model);
                EventContext.Add(MenuID, string.Format("设置权限:{0}", roleid));
                return(Content("保存成功!"));
            }
            else
            {
                return(Content("参数错误!"));
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(ITC_Roles_M model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update ITC_Roles set ");
            strSql.Append(" Role_Name = @Role_Name , ");
            strSql.Append(" Role_Remark = @Role_Remark , ");
            strSql.Append(" Role_Status = @Role_Status , ");
            strSql.Append(" Role_createdtime = @Role_createdtime , ");
            strSql.Append(" Role_oprt = @Role_oprt  ");
            strSql.Append(" where Role_ID=@Role_ID  ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@Role_ID",          SqlDbType.Char,       10),
                new SqlParameter("@Role_Name",        SqlDbType.VarChar,    50),
                new SqlParameter("@Role_Remark",      SqlDbType.VarChar,   500),
                new SqlParameter("@Role_Status",      SqlDbType.Int,         4),
                new SqlParameter("@Role_createdtime", SqlDbType.DateTime),
                new SqlParameter("@Role_oprt",        SqlDbType.VarChar, 10)
            };

            parameters[0].Value = model.Role_ID;
            parameters[1].Value = model.Role_Name;
            parameters[2].Value = model.Role_Remark;
            parameters[3].Value = model.Role_Status;
            parameters[4].Value = model.Role_createdtime;
            parameters[5].Value = model.Role_oprt;
            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

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

            strSql.Append("insert into ITC_Roles(");
            strSql.Append("Role_ID,Role_Name,Role_Remark,Role_Status,Role_createdtime,Role_oprt");
            strSql.Append(") values (");
            strSql.Append("@Role_ID,@Role_Name,@Role_Remark,@Role_Status,@Role_createdtime,@Role_oprt");
            strSql.Append(") ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@Role_ID",          SqlDbType.Char,       10),
                new SqlParameter("@Role_Name",        SqlDbType.VarChar,    50),
                new SqlParameter("@Role_Remark",      SqlDbType.VarChar,   500),
                new SqlParameter("@Role_Status",      SqlDbType.Int,         4),
                new SqlParameter("@Role_createdtime", SqlDbType.DateTime),
                new SqlParameter("@Role_oprt",        SqlDbType.VarChar, 10)
            };

            parameters[0].Value = model.Role_ID;
            parameters[1].Value = model.Role_Name;
            parameters[2].Value = model.Role_Remark;
            parameters[3].Value = model.Role_Status;
            parameters[4].Value = model.Role_createdtime;
            parameters[5].Value = model.Role_oprt;
            int result = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (result > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 6
0
        //获取模型
        public ActionResult GetModel(string id)
        {
            ITC_Roles_M mo = uifo.GetModel(id);

            return(Json(mo, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 7
0
        public string GetRoleName(string roleid)
        {
            ITC_Roles_M model = GetModel(roleid);

            return(model != null ? model.Role_Name : "");
        }
Exemplo n.º 8
0
 /// <summary>
 /// 修改
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public bool Update(ITC_Roles_M model)
 {
     return(dal.Update(model));
 }
Exemplo n.º 9
0
 /// <summary>
 /// 添加
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public bool Add(ITC_Roles_M model)
 {
     return(dal.Add(model));
 }