예제 #1
0
 /// <summary>
 ///  根据ID查询
 /// </summary>
 /// <param name="id">id</param>
 /// Author  : Napoleon
 /// Created : 2015-01-27 16:24:30
 public SystemRule GetRule(string id)
 {
     SystemRule rule = new SystemRule();
     try
     {
         string sql = "SELECT  ProjectId ,Id ,Name ,ParentId,Person,Address,TelPhone ,Sort ,Remark ,Operator FROM dbo.System_Rule WHERE Id=@Id";
         rule = DbHelper.GetEnumerable<SystemRule>(sql, new { @Id = id });
     }
     catch (Exception exception)
     {
         Log4Dao.InsertLog4(exception.Message);
     }
     return rule;
 }
예제 #2
0
 /// <summary>
 ///  更新
 /// </summary>
 /// <param name="rule">The rule.</param>
 /// Author  : Napoleon
 /// Created : 2015-01-27 16:28:34
 public int UpdateRule(SystemRule rule)
 {
     return _ruleDao.UpdateRule(rule);
 }
예제 #3
0
 /// <summary>
 ///  新增角色
 /// </summary>
 /// <param name="rule">The rule.</param>
 /// Author  : Napoleon
 /// Created : 2015-01-27 15:29:05
 public int InsertRule(SystemRule rule)
 {
     return _ruleDao.InsertRule(rule);
 }
예제 #4
0
 /// <summary>
 ///  更新角色
 /// </summary>
 /// <param name="projectId">The project identifier.</param>
 /// <param name="id">The identifier.</param>
 /// <param name="parentId">The parent identifier.</param>
 /// <param name="name">The name.</param>
 /// <param name="sort">The sort.</param>
 /// <param name="remark">The remark.</param>
 /// Author  : Napoleon
 /// Created : 2015-01-27 16:27:19
 public ActionResult UpdateRule(string projectId, string id, string parentId, string name, decimal sort, string remark)
 {
     SystemRule rule = new SystemRule();
     rule.ProjectId = projectId;
     rule.Id = id;
     rule.ParentId = string.IsNullOrWhiteSpace(parentId) ? "0" : parentId;
     rule.Name = name;
     rule.Sort = sort;
     rule.Remark = remark;
     rule.Operator = PublicFields.UserCookie.ReadCookie<SystemUser>().UserName;
     int count = _ruleService.UpdateRule(rule);
     string status = "failue", msg, json;
     switch (count)
     {
         case -1:
             msg = "更新失败,角色名称重复!";
             break;
         case 1:
             status = "success";
             msg = "更新成功!";
             break;
         default:
             msg = "更新失败!";
             break;
     }
     json = PublicFunc.ModelToJson(status, msg);
     return Content(json);
 }
예제 #5
0
 /// <summary>
 ///  更新
 /// </summary>
 /// <param name="rule">The rule.</param>
 /// Author  : Napoleon
 /// Created : 2015-01-27 16:28:34
 public int UpdateRule(SystemRule rule)
 {
     int count;
     try
     {
         string sql = "SELECT Id FROM dbo.System_Rule WHERE ProjectId=@ProjectId AND Name=@Name";
         SqlParameter[] parameters =
         {
             new SqlParameter("@ProjectId",rule.ProjectId),
             new SqlParameter("@Name",rule.Name)
         };
         DataTable dt = DbHelper.GetDataTable(sql, parameters);
         if (dt.Rows.Count == 0 || dt.Rows[0][0].ToString().Equals(rule.Id))
         {
             sql = "UPDATE dbo.System_Rule SET Name=@Name,ParentId=@ParentId,Sort=@Sort,Remark=@Remark,Operator=@Operator WHERE Id=@Id";
             count = DbHelper.ExecuteSql(sql, rule);
         }
         else
         {
             count = -1;
         }
     }
     catch (Exception exception)
     {
         count = 0;
         Log4Dao.InsertLog4(exception.Message);
     }
     return count;
 }
예제 #6
0
 /// <summary>
 ///  新增角色
 /// </summary>
 /// <param name="rule">rule</param>
 /// Author  : Napoleon
 /// Created : 2015-01-27 15:29:05
 public int InsertRule(SystemRule rule)
 {
     int count;
     try
     {
         string sql = "SELECT Id FROM dbo.System_Rule WHERE ProjectId=@ProjectId AND Name=@Name";
         SqlParameter[] parameters =
         {
             new SqlParameter("@ProjectId",rule.ProjectId),
             new SqlParameter("@Name", rule.Name)
         };
         DataTable dt = DbHelper.GetDataTable(sql, parameters);
         if (dt.Rows.Count > 0)
         {
             count = -1;
         }
         else
         {
             sql = "INSERT INTO dbo.System_Rule (ProjectId,Id,Name,ParentId,Sort,Remark,Operator) VALUES (@ProjectId,@Id,@Name,@ParentId,@Sort,@Remark,@Operator)";
             count = DbHelper.ExecuteSql(sql, rule);
         }
     }
     catch (Exception exception)
     {
         count = 0;
         Log4Dao.InsertLog4(exception.Message);
     }
     return count;
 }