예제 #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(JMP.MDL.jmp_appsdk model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update jmp_appsdk set ");

            strSql.Append(" appid = @appid , ");
            strSql.Append(" appurl = @appurl , ");
            strSql.Append(" uptimes = @uptimes  ");
            strSql.Append(" where id=@id ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@id",      SqlDbType.Int,       4),
                new SqlParameter("@appid",   SqlDbType.Int,       4),
                new SqlParameter("@appurl",  SqlDbType.NVarChar, -1),
                new SqlParameter("@uptimes", SqlDbType.DateTime)
            };

            parameters[0].Value = model.id;
            parameters[1].Value = model.appid;
            parameters[2].Value = model.appurl;
            parameters[3].Value = model.uptimes;
            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(JMP.MDL.jmp_appsdk model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into jmp_appsdk(");
            strSql.Append("appid,appurl,uptimes");
            strSql.Append(") values (");
            strSql.Append("@appid,@appurl,@uptimes");
            strSql.Append(") ");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@appid",   SqlDbType.Int,       4),
                new SqlParameter("@appurl",  SqlDbType.NVarChar, -1),
                new SqlParameter("@uptimes", SqlDbType.DateTime)
            };

            parameters[0].Value = model.appid;
            parameters[1].Value = model.appurl;
            parameters[2].Value = model.uptimes;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
예제 #3
0
        public ActionResult Upload()
        {
            int appid = string.IsNullOrEmpty(Request["appid"]) ? 0 : Int32.Parse(Request["appid"]);

            ViewBag.appid = appid;
            JMP.BLL.jmp_appsdk bll    = new JMP.BLL.jmp_appsdk();
            JMP.MDL.jmp_appsdk model  = new JMP.MDL.jmp_appsdk();
            JMP.BLL.jmp_app    bllapp = new JMP.BLL.jmp_app();
            JMP.MDL.jmp_app    mo     = new JMP.MDL.jmp_app();
            if (appid > 0)
            {
                model = bll.SelectModel(appid);
                mo    = bllapp.GetModel(appid);
            }
            ViewBag.model = model == null ? new JMP.MDL.jmp_appsdk() : model;
            ViewBag.mo    = mo == null ? new JMP.MDL.jmp_app() : mo;
            return(View());
        }
예제 #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public JMP.MDL.jmp_appsdk GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select id, appid, appurl, uptimes  ");
            strSql.Append("  from jmp_appsdk ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;


            JMP.MDL.jmp_appsdk model = new JMP.MDL.jmp_appsdk();
            DataSet            ds    = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["id"].ToString() != "")
                {
                    model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["appid"].ToString() != "")
                {
                    model.appid = int.Parse(ds.Tables[0].Rows[0]["appid"].ToString());
                }
                model.appurl = ds.Tables[0].Rows[0]["appurl"].ToString();
                if (ds.Tables[0].Rows[0]["uptimes"].ToString() != "")
                {
                    model.uptimes = DateTime.Parse(ds.Tables[0].Rows[0]["uptimes"].ToString());
                }

                return(model);
            }
            else
            {
                return(null);
            }
        }
예제 #5
0
        public JsonResult InsertOrUpdate(JMP.MDL.jmp_appsdk mo)
        {
            object retJson = new { success = 0, msg = "操作失败" };

            if (mo.appid > 0)
            {
                JMP.BLL.jmp_appsdk bll = new JMP.BLL.jmp_appsdk();

                DataTable dt = bll.GetList(" appid='" + mo.appid + "' ").Tables[0];
                if (dt.Rows.Count > 0)
                {
                    mo.id      = Int32.Parse(dt.Rows[0]["id"].ToString());
                    mo.uptimes = DateTime.Now;
                    if (bll.Update(mo))
                    {
                        retJson = new { success = 1, msg = "上传成功!" };
                        AddLocLog.AddUserLog(UserInfo.UserId, 3, Request.UserHostAddress, "修改上传应用asdk", "文件名:" + mo.appurl + ",应用id编号:" + mo.appid);
                    }
                    else
                    {
                        retJson = new { success = 0, msg = "上传失败!" };
                    }
                }
                else
                {
                    mo.uptimes = DateTime.Now;
                    int cg = bll.Add(mo);
                    if (cg > 0)
                    {
                        retJson = new { success = 1, msg = "上传成功!" };
                        AddLocLog.AddUserLog(UserInfo.UserId, 3, Request.UserHostAddress, "上传应用asdk", "文件名:" + mo.appurl + ",应用id编号:" + mo.appid);
                    }
                    else
                    {
                        retJson = new { success = 0, msg = "上传失败!" };
                    }
                }
            }
            return(Json(retJson));
        }