Example #1
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public JMP.MDL.jmp_paychannel GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select id, payname, payid, money, datetimes,paytype  ");
            strSql.Append("  from jmp_paychannel ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;


            JMP.MDL.jmp_paychannel model = new JMP.MDL.jmp_paychannel();
            DataSet ds = DbHelperSQLTotal.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());
                }
                model.payname = ds.Tables[0].Rows[0]["payname"].ToString();
                model.paytype = ds.Tables[0].Rows[0]["paytype"].ToString();
                if (ds.Tables[0].Rows[0]["payid"].ToString() != "")
                {
                    model.payid = int.Parse(ds.Tables[0].Rows[0]["payid"].ToString());
                }
                if (ds.Tables[0].Rows[0]["money"].ToString() != "")
                {
                    model.money = decimal.Parse(ds.Tables[0].Rows[0]["money"].ToString());
                }
                if (ds.Tables[0].Rows[0]["datetimes"].ToString() != "")
                {
                    model.datetimes = DateTime.Parse(ds.Tables[0].Rows[0]["datetimes"].ToString());
                }
                if (ds.Tables[0].Rows[0]["success"].ToString() != "")
                {
                    model.success = int.Parse(ds.Tables[0].Rows[0]["success"].ToString());
                }
                if (ds.Tables[0].Rows[0]["successratio"].ToString() != "")
                {
                    model.successratio = decimal.Parse(ds.Tables[0].Rows[0]["successratio"].ToString());
                }
                if (ds.Tables[0].Rows[0]["notpay"].ToString() != "")
                {
                    model.notpay = int.Parse(ds.Tables[0].Rows[0]["notpay"].ToString());
                }


                return(model);
            }
            else
            {
                return(null);
            }
        }
Example #2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(JMP.MDL.jmp_paychannel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update jmp_paychannel set ");

            strSql.Append(" payname = @payname , ");
            strSql.Append(" payid = @payid , ");
            strSql.Append(" money = @money , ");
            strSql.Append(" datetimes = @datetimes,  ");
            strSql.Append(" paytype = @paytype,  ");
            strSql.Append(" success=@success, successratio=@successratio, notpay=@notpay ");
            strSql.Append(" where id=@id ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id",           SqlDbType.Int,        4),
                new SqlParameter("@payname",      SqlDbType.NVarChar,  -1),
                new SqlParameter("@payid",        SqlDbType.Int,        4),
                new SqlParameter("@money",        SqlDbType.Decimal,    9),
                new SqlParameter("@datetimes",    SqlDbType.DateTime),
                new SqlParameter("@paytype",      SqlDbType.NVarChar,  -1),
                new SqlParameter("@success",      model.success),
                new SqlParameter("@successratio", model.successratio),
                new SqlParameter("@notpay",       model.notpay)
            };

            parameters[0].Value = model.id;
            parameters[1].Value = model.payname;
            parameters[2].Value = model.payid;
            parameters[3].Value = model.money;
            parameters[4].Value = model.datetimes;
            parameters[5].Value = model.paytype;
            int rows = DbHelperSQLTotal.ExecuteSql(strSql.ToString(), parameters);

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

            strSql.Append("insert into jmp_paychannel(");
            strSql.Append("payname,payid,money,datetimes,paytype,success,successratio,notpay");
            strSql.Append(") values (");
            strSql.Append("@payname,@payid,@money,@datetimes,@paytype");
            strSql.Append(") ");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@payname",      SqlDbType.NVarChar,  -1),
                new SqlParameter("@payid",        SqlDbType.Int,        4),
                new SqlParameter("@money",        SqlDbType.Decimal,    9),
                new SqlParameter("@datetimes",    SqlDbType.DateTime),
                new SqlParameter("@paytype",      SqlDbType.NVarChar,  -1),
                new SqlParameter("@success",      model.success),
                new SqlParameter("@successratio", model.successratio),
                new SqlParameter("@notpay",       model.notpay)
            };

            parameters[0].Value = model.payname;
            parameters[1].Value = model.payid;
            parameters[2].Value = model.money;
            parameters[3].Value = model.datetimes;
            parameters[4].Value = model.paytype;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }