Esempio n. 1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(JMP.MDL.jmp_logtype model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into jmp_logtype(");
            strSql.Append("l_name,l_value");
            strSql.Append(") values (");
            strSql.Append("@l_name,@l_value");
            strSql.Append(") ");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@l_name",  SqlDbType.NVarChar, -1),
                new SqlParameter("@l_value", SqlDbType.NVarChar, -1)
            };

            parameters[0].Value = model.l_name;
            parameters[1].Value = model.l_value;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(JMP.MDL.jmp_logtype model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update jmp_logtype set ");

            strSql.Append(" l_name = @l_name , ");
            strSql.Append(" l_value = @l_value  ");
            strSql.Append(" where l_id=@l_id ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@l_id",    SqlDbType.Int,       4),
                new SqlParameter("@l_name",  SqlDbType.NVarChar, -1),
                new SqlParameter("@l_value", SqlDbType.NVarChar, -1)
            };

            parameters[0].Value = model.l_id;
            parameters[1].Value = model.l_name;
            parameters[2].Value = model.l_value;
            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public JMP.MDL.jmp_logtype GetModel(int l_id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select l_id, l_name, l_value  ");
            strSql.Append("  from jmp_logtype ");
            strSql.Append(" where l_id=@l_id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@l_id", SqlDbType.Int, 4)
            };
            parameters[0].Value = l_id;


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

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["l_id"].ToString() != "")
                {
                    model.l_id = int.Parse(ds.Tables[0].Rows[0]["l_id"].ToString());
                }
                model.l_name  = ds.Tables[0].Rows[0]["l_name"].ToString();
                model.l_value = ds.Tables[0].Rows[0]["l_value"].ToString();

                return(model);
            }
            else
            {
                return(null);
            }
        }