Exemplo n.º 1
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public JMP.MDL.jmp_pay GetModel(int p_id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select p_id,p_tradeno,p_applytime,p_dealno,p_paytime,p_state,p_money,p_bill_id");
            strSql.Append("  from jmp_pay ");
            strSql.Append(" where p_id=@p_id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@p_id", SqlDbType.Int, 4)
            };
            parameters[0].Value = p_id;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["p_id"].ToString() != "")
                {
                    model.p_id = int.Parse(ds.Tables[0].Rows[0]["p_id"].ToString());
                }
                model.p_tradeno = ds.Tables[0].Rows[0]["p_tradeno"].ToString();
                if (ds.Tables[0].Rows[0]["p_applytime"].ToString() != "")
                {
                    model.p_applytime = DateTime.Parse(ds.Tables[0].Rows[0]["p_applytime"].ToString());
                }
                model.p_dealno = ds.Tables[0].Rows[0]["p_dealno"].ToString();
                if (ds.Tables[0].Rows[0]["p_paytime"].ToString() != "")
                {
                    model.p_paytime = DateTime.Parse(ds.Tables[0].Rows[0]["p_paytime"].ToString());
                }
                if (ds.Tables[0].Rows[0]["p_state"].ToString() != "")
                {
                    model.p_state = int.Parse(ds.Tables[0].Rows[0]["p_state"].ToString());
                }
                if (ds.Tables[0].Rows[0]["p_money"].ToString() != "")
                {
                    model.p_money = decimal.Parse(ds.Tables[0].Rows[0]["p_money"].ToString());
                }
                model.p_bill_id = ds.Tables[0].Rows[0]["p_bill_id"].ToString();

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

            strSql.Append("update jmp_pay set ");

            strSql.Append("p_tradeno=@p_tradeno,");
            strSql.Append("p_applytime=@p_applytime,");
            strSql.Append("p_dealno=@p_dealno,");
            strSql.Append("p_paytime=@p_paytime,");
            strSql.Append("p_state=@p_state,");
            strSql.Append("p_money=@p_money,");
            strSql.Append("p_bill_id=@p_bill_id");
            strSql.Append(" where p_id=@p_id ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@p_id",        SqlDbType.Int,        4),
                new SqlParameter("@p_tradeno",   SqlDbType.NVarChar,  -1),
                new SqlParameter("@p_applytime", SqlDbType.DateTime),
                new SqlParameter("@p_dealno",    SqlDbType.NVarChar,  -1),
                new SqlParameter("@p_paytime",   SqlDbType.DateTime),
                new SqlParameter("@p_state",     SqlDbType.Int,        4),
                new SqlParameter("@p_money",     SqlDbType.Money,      8),
                new SqlParameter("@p_bill_id",   SqlDbType.NVarChar, -1)
            };

            parameters[0].Value = model.p_id;
            parameters[1].Value = model.p_tradeno;
            parameters[2].Value = model.p_applytime;
            parameters[3].Value = model.p_dealno;
            parameters[4].Value = model.p_paytime;
            parameters[5].Value = model.p_state;
            parameters[6].Value = model.p_money;
            parameters[7].Value = model.p_bill_id;
            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

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

            strSql.Append("insert into jmp_pay(");
            strSql.Append("p_tradeno,p_applytime,p_dealno,p_paytime,p_state,p_money,p_bill_id");
            strSql.Append(") values (");
            strSql.Append("@p_tradeno,@p_applytime,@p_dealno,@p_paytime,@p_state,@p_money,@p_bill_id");
            strSql.Append(") ");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@p_tradeno",   SqlDbType.NVarChar,  -1),
                new SqlParameter("@p_applytime", SqlDbType.DateTime),
                new SqlParameter("@p_dealno",    SqlDbType.NVarChar,  -1),
                new SqlParameter("@p_paytime",   SqlDbType.DateTime),
                new SqlParameter("@p_state",     SqlDbType.Int,        4),
                new SqlParameter("@p_money",     SqlDbType.Money,      8),
                new SqlParameter("@p_bill_id",   SqlDbType.NVarChar, -1)
            };

            parameters[0].Value = model.p_tradeno;
            parameters[1].Value = model.p_applytime;
            parameters[2].Value = model.p_dealno;
            parameters[3].Value = model.p_paytime;
            parameters[4].Value = model.p_state;
            parameters[5].Value = model.p_money;
            parameters[6].Value = model.p_bill_id;

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

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