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

            strSql.Append("update jmp_query set ");

            strSql.Append(" q_code = @q_code , ");
            strSql.Append(" q_time = @q_time  ");
            strSql.Append(" where q_id=@q_id ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@q_id",   SqlDbType.Int,       4),
                new SqlParameter("@q_code", SqlDbType.NVarChar, 50),
                new SqlParameter("@q_time", SqlDbType.Int, 4)
            };

            parameters[0].Value = model.q_id;
            parameters[1].Value = model.q_code;
            parameters[2].Value = model.q_time;
            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

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

            strSql.Append("insert into jmp_query(");
            strSql.Append("q_code,q_time");
            strSql.Append(") values (");
            strSql.Append("@q_code,@q_time");
            strSql.Append(") ");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@q_code", SqlDbType.NVarChar, 50),
                new SqlParameter("@q_time", SqlDbType.Int, 4)
            };

            parameters[0].Value = model.q_code;
            parameters[1].Value = model.q_time;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Example #3
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List <JMP.MDL.jmp_query> DataTableToList(DataTable dt)
        {
            List <JMP.MDL.jmp_query> modelList = new List <JMP.MDL.jmp_query>();
            int rowsCount = dt.Rows.Count;

            if (rowsCount > 0)
            {
                JMP.MDL.jmp_query model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new JMP.MDL.jmp_query();
                    if (dt.Rows[n]["q_id"].ToString() != "")
                    {
                        model.q_id = int.Parse(dt.Rows[n]["q_id"].ToString());
                    }
                    model.q_code = dt.Rows[n]["q_code"].ToString();
                    if (dt.Rows[n]["q_time"].ToString() != "")
                    {
                        model.q_time = int.Parse(dt.Rows[n]["q_time"].ToString());
                    }


                    modelList.Add(model);
                }
            }
            return(modelList);
        }
Example #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public JMP.MDL.jmp_query GetModel(int q_id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select q_id, q_code, q_time  ");
            strSql.Append("  from jmp_query ");
            strSql.Append(" where q_id=@q_id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@q_id", SqlDbType.Int, 4)
            };
            parameters[0].Value = q_id;


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

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["q_id"].ToString() != "")
                {
                    model.q_id = int.Parse(ds.Tables[0].Rows[0]["q_id"].ToString());
                }
                model.q_code = ds.Tables[0].Rows[0]["q_code"].ToString();
                if (ds.Tables[0].Rows[0]["q_time"].ToString() != "")
                {
                    model.q_time = int.Parse(ds.Tables[0].Rows[0]["q_time"].ToString());
                }

                return(model);
            }
            else
            {
                return(null);
            }
        }
Example #5
0
        /// <summary>
        /// 根据订单查询判断是否符合查询条件
        /// </summary>
        /// <param name="jmcode">订单好</param>
        /// <returns></returns>
        public static string QuerySelect(string jmcode)
        {
            string str = "";

            try
            {
                JMP.BLL.jmp_query bll  = new JMP.BLL.jmp_query();
                JMP.MDL.jmp_query mo   = new JMP.MDL.jmp_query();
                JMP.MDL.jmp_query mode = new JMP.MDL.jmp_query();
                if (JMP.TOOL.CacheHelper.IsCache(jmcode))                           //判读是否存在缓存
                {
                    mo = JMP.TOOL.CacheHelper.GetCaChe <JMP.MDL.jmp_query>(jmcode); //获取缓存
                }
                else
                {
                    mo = bll.SelectCode(jmcode);
                }
                if (mo != null && mo.q_id > 0)
                {
                    mode.q_time = mo.q_time + 1;
                    mode.q_code = mo.q_code;
                    mode.q_id   = mo.q_id;
                    if (mode.q_time > 5)
                    {
                        str = "{\"message\":\"fail\"}";
                    }
                    else
                    {
                        if (bll.Update(mode))
                        {
                            str = jxjson(SelectOrder(jmcode));
                            JMP.TOOL.CacheHelper.CacheObjectLocak <JMP.MDL.jmp_query>(mode, jmcode, 60);//存入缓存
                        }
                        else
                        {
                            str = "{\"message\":\"fail\"}";
                        }
                    }
                }
                else
                {
                    mode.q_code = jmcode;
                    mode.q_time = 1;
                    int cg = bll.Add(mode);
                    if (cg > 0)
                    {
                        str = jxjson(SelectOrder(jmcode));
                        JMP.TOOL.CacheHelper.CacheObjectLocak <JMP.MDL.jmp_query>(mode, jmcode, 60);//存入缓存
                    }
                    else
                    {
                        str = "{\"message\":\"fail\"}";
                    }
                }
            }
            catch (Exception ex)
            {
                AddLocLog.AddLog(1, 4, HttpContext.Current.Request.UserHostAddress, "查询接口判断订单出错", "报错信息:" + ex.ToString() + ",查询参数:" + jmcode);//写入报错日志
                return(str = "{\"message\":\"fail\"}");
            }
            return(str);
        }
Example #6
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(JMP.MDL.jmp_query model)
 {
     return(dal.Update(model));
 }
Example #7
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(JMP.MDL.jmp_query model)
 {
     return(dal.Add(model));
 }