Esempio n. 1
0
 public static string Add(string id, string name, string desc)
 {
     RoleInfo model = new RoleInfo();
     model.Id = id;
     model.Name = name;
     model.Description = desc;
     bool successs = RoleBLL.Add(model);
     StringBuilder json = new StringBuilder();
     json.Append("[{");
     json.Append("\"success\":\"" + successs + "\"");
     json.Append("}]");
     return json.ToString();
 }
Esempio n. 2
0
 public bool Add(RoleInfo model)
 {
     StringBuilder sql = new StringBuilder();
     sql.Append("insert into BigDog_Admin_Role(Id,Name,Description) values(@id,@name,@desc)");
     SqlParameter[] parms = new SqlParameter[] {
         new SqlParameter("@id",SqlDbType.NVarChar,50),
         new SqlParameter("@name",SqlDbType.NVarChar,50),
         new SqlParameter("@desc",SqlDbType.NVarChar,200)
     };
     parms[0].Value = model.Id;
     parms[1].Value = model.Name;
     parms[2].Value = model.Description;
     return SQLHelper.ExecuteNonQuery(CommandType.Text, sql.ToString(), parms) > 0;
 }
Esempio n. 3
0
 public RoleInfo GetById(string id)
 {
     StringBuilder sql = new StringBuilder();
     sql.Append("select Id,Name,Description from BigDog_Admin_Role where Id=@id");
     SqlParameter[] parms = new SqlParameter[] {
         new SqlParameter("@Id",SqlDbType.Int)
     };
     parms[0].Value = id;
     RoleInfo model = new RoleInfo();
     DataTable dt = SQLHelper.GetDs(sql.ToString(), parms).Tables[0];
     if (dt.Rows.Count > 0)
     {
         model.Id = dt.Rows[0]["Id"].ToString();
         model.Name = dt.Rows[0]["Name"].ToString();
         model.Description = dt.Rows[0]["Description"].ToString();
         return model;
     }
     return null;
 }
Esempio n. 4
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string type = context.Request.Params["type"].ToString();
            StringBuilder sql = new StringBuilder();
            StringBuilder json = new StringBuilder();

            if (type == "read")  //检索数据
            {
                sql.Append("select Id,Name,Description,Created_Date from BigDog_Admin_Role");
                DataTable dt = SQLHelper.GetDs(sql.ToString()).Tables[0];
                if (dt.Rows.Count > 0)
                {
                    json.Append("[");
                    json.Append("\"result\":\"1\",\"data\":");
                    foreach (DataRow dr in dt.Rows)
                    {
                        json.Append("{\"Id\":\"" + dr["Id"].ToString() + "\"");
                        json.Append(",\"Name\":\"" + dr["Name"].ToString() + "\"");
                        json.Append(",\"Description\":\"" + dr["Description"].ToString() + "\"");
                        json.Append(",\"Created_Date\":\"" + dr["Created_Date"].ToString() + "\"");
                        json.Append("}");
                    }
                    json.Append("]");
                }
            }
            if (type == "add")
            {
                string name = context.Request.Params["name"].ToString();
                string desc = context.Request.Params["desc"].ToString();
                sql.Clear();
                sql.Append("insert into BigDog_Admin_Role(name,description)values(@name,@desc)");
                SqlParameter[] parms = new SqlParameter[]{
                new SqlParameter("@name",SqlDbType.NVarChar,50),
                new SqlParameter("@desc",SqlDbType.NVarChar,200)
            };
                parms[0].Value = name;
                parms[1].Value = desc;
                int val = SQLHelper.ExecuteNonQuery(CommandType.Text, sql.ToString(), parms);
                if (val > 0)
                {
                    json.Append("[");
                    json.Append("\"result\":\"1\",\"data\":\"\"");
                    json.Append("]");
                }
                else
                {
                    json.Append("[");
                    json.Append("\"result\":\"0\",\"data\":\"\"");
                    json.Append("]");

                }
            }

            if (type == "update")
            {
                string name = context.Request.Params["name"].ToString();
                string desc = context.Request.Params["desc"].ToString();
                RoleInfo model = new RoleInfo();
                model.Name = name;
                model.Description = desc;
                if (RoleBLL.Update(model))
                {
                    json.Append("[");
                    json.Append("\"result\":\"1\",\"data\":\"\"");
                    json.Append("]");
                }
                else
                {
                    json.Append("[");
                    json.Append("\"result\":\"0\",\"data\":\"\"");
                    json.Append("]");
                }
            }

            context.Response.Write(json.ToString());
        }
Esempio n. 5
0
 public static string Update(string u_id, string u_name, string u_desc)
 {
     RoleInfo model = new RoleInfo();
     model.Id = u_id;
     model.Name = u_name;
     model.Description = u_desc;
     bool success = RoleBLL.Update(model);
     StringBuilder json = new StringBuilder();
     json.Append("[{");
     json.Append("\"success\":\"" + success + "\"");
     json.Append("}]");
     return json.ToString();
 }
Esempio n. 6
0
 public static bool Update(RoleInfo model)
 {
     return Dal.Update(model);
 }
Esempio n. 7
0
 public static bool Add(RoleInfo model)
 {
     return Dal.Add(model);
 }
Esempio n. 8
0
 public bool Update(RoleInfo model)
 {
     StringBuilder sql = new StringBuilder();
     sql.Append("update BigDog_Admin_Role set Name=@name,Description=@desc where Id=@id");
     SqlParameter[] parms = new SqlParameter[] {
         new SqlParameter("@name",SqlDbType.NVarChar,50),
         new SqlParameter("@desc",SqlDbType.NVarChar,200),
         new SqlParameter("@id",SqlDbType.NVarChar,50)
     };
     parms[0].Value = model.Name;
     parms[1].Value = model.Description;
     parms[2].Value = model.Id;
     return SQLHelper.ExecuteNonQuery(CommandType.Text, sql.ToString(), parms) > 0;
 }