예제 #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();
 }
예제 #2
0
파일: Role.cs 프로젝트: Carevel/BigDogShop
 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;
 }
예제 #3
0
파일: Role.cs 프로젝트: Carevel/BigDogShop
 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;
 }
예제 #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());
        }
예제 #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();
 }
예제 #6
0
 public static bool Update(RoleInfo model)
 {
     return Dal.Update(model);
 }
예제 #7
0
 public static bool Add(RoleInfo model)
 {
     return Dal.Add(model);
 }
예제 #8
0
파일: Role.cs 프로젝트: Carevel/BigDogShop
 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;
 }