Example #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Cms.Model.C_payment model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into C_payment(");
            strSql.Append("title,img_url,remark,type,poundage_type,poundage_amount,sort_id,is_lock,api_path,p_name,p_account,p_merchant,p_secretkey)");
            strSql.Append(" values (");
            strSql.Append("@title,@img_url,@remark,@type,@poundage_type,@poundage_amount,@sort_id,@is_lock,@api_path,@p_name,@p_account,@p_merchant,@p_secretkey)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@title",           SqlDbType.NVarChar, 100),
                new SqlParameter("@img_url",         SqlDbType.NVarChar, 255),
                new SqlParameter("@remark",          SqlDbType.NVarChar, 500),
                new SqlParameter("@type",            SqlDbType.TinyInt,    1),
                new SqlParameter("@poundage_type",   SqlDbType.TinyInt,    1),
                new SqlParameter("@poundage_amount", SqlDbType.Decimal,    5),
                new SqlParameter("@sort_id",         SqlDbType.Int,        4),
                new SqlParameter("@is_lock",         SqlDbType.TinyInt,    1),
                new SqlParameter("@api_path",        SqlDbType.NVarChar, 100),
                new SqlParameter("@p_name",          SqlDbType.NVarChar, 100),
                new SqlParameter("@p_account",       SqlDbType.NVarChar, 100),
                new SqlParameter("@p_merchant",      SqlDbType.NVarChar, 100),
                new SqlParameter("@p_secretkey",     SqlDbType.NVarChar, 100)
            };
            parameters[0].Value  = model.title;
            parameters[1].Value  = model.img_url;
            parameters[2].Value  = model.remark;
            parameters[3].Value  = model.type;
            parameters[4].Value  = model.poundage_type;
            parameters[5].Value  = model.poundage_amount;
            parameters[6].Value  = model.sort_id;
            parameters[7].Value  = model.is_lock;
            parameters[8].Value  = model.api_path;
            parameters[9].Value  = model.p_name;
            parameters[10].Value = model.p_account;
            parameters[11].Value = model.p_merchant;
            parameters[12].Value = model.p_secretkey;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Example #2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Cms.Model.C_payment GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,title,img_url,remark,type,poundage_type,poundage_amount,sort_id,is_lock,api_path,p_name,p_account,p_merchant,p_secretkey from C_payment ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

            Cms.Model.C_payment model = new Cms.Model.C_payment();
            DataSet             ds    = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Example #3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Cms.Model.C_payment DataRowToModel(DataRow row)
 {
     Cms.Model.C_payment model = new Cms.Model.C_payment();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["title"] != null)
         {
             model.title = row["title"].ToString();
         }
         if (row["img_url"] != null)
         {
             model.img_url = row["img_url"].ToString();
         }
         if (row["remark"] != null)
         {
             model.remark = row["remark"].ToString();
         }
         if (row["type"] != null && row["type"].ToString() != "")
         {
             model.type = int.Parse(row["type"].ToString());
         }
         if (row["poundage_type"] != null && row["poundage_type"].ToString() != "")
         {
             model.poundage_type = int.Parse(row["poundage_type"].ToString());
         }
         if (row["poundage_amount"] != null && row["poundage_amount"].ToString() != "")
         {
             model.poundage_amount = decimal.Parse(row["poundage_amount"].ToString());
         }
         if (row["sort_id"] != null && row["sort_id"].ToString() != "")
         {
             model.sort_id = int.Parse(row["sort_id"].ToString());
         }
         if (row["is_lock"] != null && row["is_lock"].ToString() != "")
         {
             model.is_lock = int.Parse(row["is_lock"].ToString());
         }
         if (row["api_path"] != null)
         {
             model.api_path = row["api_path"].ToString();
         }
         if (row["p_name"] != null)
         {
             model.p_name = row["p_name"].ToString();
         }
         if (row["p_account"] != null)
         {
             model.p_account = row["p_account"].ToString();
         }
         if (row["p_merchant"] != null)
         {
             model.p_merchant = row["p_merchant"].ToString();
         }
         if (row["p_secretkey"] != null)
         {
             model.p_secretkey = row["p_secretkey"].ToString();
         }
     }
     return(model);
 }
Example #4
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Cms.Model.C_payment model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update C_payment set ");
            strSql.Append("title=@title,");
            strSql.Append("img_url=@img_url,");
            strSql.Append("remark=@remark,");
            strSql.Append("type=@type,");
            strSql.Append("poundage_type=@poundage_type,");
            strSql.Append("poundage_amount=@poundage_amount,");
            strSql.Append("sort_id=@sort_id,");
            strSql.Append("is_lock=@is_lock,");
            strSql.Append("api_path=@api_path,");
            strSql.Append("p_name=@p_name,");
            strSql.Append("p_account=@p_account,");
            strSql.Append("p_merchant=@p_merchant,");
            strSql.Append("p_secretkey=@p_secretkey");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@title",           SqlDbType.NVarChar, 100),
                new SqlParameter("@img_url",         SqlDbType.NVarChar, 255),
                new SqlParameter("@remark",          SqlDbType.NVarChar, 500),
                new SqlParameter("@type",            SqlDbType.TinyInt,    1),
                new SqlParameter("@poundage_type",   SqlDbType.TinyInt,    1),
                new SqlParameter("@poundage_amount", SqlDbType.Decimal,    5),
                new SqlParameter("@sort_id",         SqlDbType.Int,        4),
                new SqlParameter("@is_lock",         SqlDbType.TinyInt,    1),
                new SqlParameter("@api_path",        SqlDbType.NVarChar, 100),
                new SqlParameter("@p_name",          SqlDbType.NVarChar, 100),
                new SqlParameter("@p_account",       SqlDbType.NVarChar, 100),
                new SqlParameter("@p_merchant",      SqlDbType.NVarChar, 100),
                new SqlParameter("@p_secretkey",     SqlDbType.NVarChar, 100),
                new SqlParameter("@id",              SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.title;
            parameters[1].Value  = model.img_url;
            parameters[2].Value  = model.remark;
            parameters[3].Value  = model.type;
            parameters[4].Value  = model.poundage_type;
            parameters[5].Value  = model.poundage_amount;
            parameters[6].Value  = model.sort_id;
            parameters[7].Value  = model.is_lock;
            parameters[8].Value  = model.api_path;
            parameters[9].Value  = model.p_name;
            parameters[10].Value = model.p_account;
            parameters[11].Value = model.p_merchant;
            parameters[12].Value = model.p_secretkey;
            parameters[13].Value = model.id;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }