/// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(DNSABC.Model.DNSABC_Transaction model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update DNSABC_Transaction set ");
            strSql.Append("UserId=@UserId,");
            strSql.Append("TradeType=@TradeType,");
            strSql.Append("Price=@Price,");
            strSql.Append("AccountBalance=@AccountBalance,");
            strSql.Append("PayentMethord=@PayentMethord,");
            strSql.Append("TradeExplaining=@TradeExplaining,");
            strSql.Append("PaymentLogo=@PaymentLogo,");
            strSql.Append("Remark=@Remark,");
            strSql.Append("CreateTime=@CreateTime");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@UserId",          SqlDbType.Int,         4),
                new SqlParameter("@TradeType",       SqlDbType.Int,         4),
                new SqlParameter("@Price",           SqlDbType.Int,         4),
                new SqlParameter("@AccountBalance",  SqlDbType.Int,         4),
                new SqlParameter("@PayentMethord",   SqlDbType.VarChar,    50),
                new SqlParameter("@TradeExplaining", SqlDbType.VarChar,   500),
                new SqlParameter("@PaymentLogo",     SqlDbType.VarChar,   100),
                new SqlParameter("@Remark",          SqlDbType.VarChar,   500),
                new SqlParameter("@CreateTime",      SqlDbType.DateTime),
                new SqlParameter("@Id",              SqlDbType.Int, 4)
            };
            parameters[0].Value = model.UserId;
            parameters[1].Value = model.TradeType;
            parameters[2].Value = model.Price;
            parameters[3].Value = model.AccountBalance;
            parameters[4].Value = model.PayentMethord;
            parameters[5].Value = model.TradeExplaining;
            parameters[6].Value = model.PaymentLogo;
            parameters[7].Value = model.Remark;
            parameters[8].Value = model.CreateTime;
            parameters[9].Value = model.Id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 2
0
 private void ShowInfo(int Id)
 {
     DNSABC.BLL.DNSABC_Transaction   bll   = new DNSABC.BLL.DNSABC_Transaction();
     DNSABC.Model.DNSABC_Transaction model = bll.GetModel(Id);
     this.lblId.Text              = model.Id.ToString();
     this.txtUserId.Text          = model.UserId.ToString();
     this.txtTradeType.Text       = model.TradeType.ToString();
     this.txtPrice.Text           = model.Price.ToString();
     this.txtAccountBalance.Text  = model.AccountBalance.ToString();
     this.txtPayentMethord.Text   = model.PayentMethord;
     this.txtTradeExplaining.Text = model.TradeExplaining;
     this.txtPaymentLogo.Text     = model.PaymentLogo;
     this.txtRemark.Text          = model.Remark;
     this.txtCreateTime.Text      = model.CreateTime.ToString();
 }
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(DNSABC.Model.DNSABC_Transaction model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into DNSABC_Transaction(");
            strSql.Append("UserId,TradeType,Price,AccountBalance,PayentMethord,TradeExplaining,PaymentLogo,Remark,CreateTime)");
            strSql.Append(" values (");
            strSql.Append("@UserId,@TradeType,@Price,@AccountBalance,@PayentMethord,@TradeExplaining,@PaymentLogo,@Remark,@CreateTime)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@UserId",          SqlDbType.Int,       4),
                new SqlParameter("@TradeType",       SqlDbType.Int,       4),
                new SqlParameter("@Price",           SqlDbType.Int,       4),
                new SqlParameter("@AccountBalance",  SqlDbType.Int,       4),
                new SqlParameter("@PayentMethord",   SqlDbType.VarChar,  50),
                new SqlParameter("@TradeExplaining", SqlDbType.VarChar, 500),
                new SqlParameter("@PaymentLogo",     SqlDbType.VarChar, 100),
                new SqlParameter("@Remark",          SqlDbType.VarChar, 500),
                new SqlParameter("@CreateTime",      SqlDbType.DateTime)
            };
            parameters[0].Value = model.UserId;
            parameters[1].Value = model.TradeType;
            parameters[2].Value = model.Price;
            parameters[3].Value = model.AccountBalance;
            parameters[4].Value = model.PayentMethord;
            parameters[5].Value = model.TradeExplaining;
            parameters[6].Value = model.PaymentLogo;
            parameters[7].Value = model.Remark;
            parameters[8].Value = model.CreateTime;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Exemplo n.º 4
0
        public void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (!PageValidate.IsNumber(txtUserId.Text))
            {
                strErr += "用户ID格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtTradeType.Text))
            {
                strErr += "交易类型 1为在线支付 2为银格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtPrice.Text))
            {
                strErr += "交易金额 正数为充值格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtAccountBalance.Text))
            {
                strErr += "账户余额格式错误!\\n";
            }
            if (this.txtPayentMethord.Text.Trim().Length == 0)
            {
                strErr += "支付方式不能为空!\\n";
            }
            if (this.txtTradeExplaining.Text.Trim().Length == 0)
            {
                strErr += "交易说明不能为空!\\n";
            }
            if (this.txtPaymentLogo.Text.Trim().Length == 0)
            {
                strErr += "付款标识不能为空!\\n";
            }
            if (this.txtRemark.Text.Trim().Length == 0)
            {
                strErr += "备注不能为空!\\n";
            }
            if (!PageValidate.IsDateTime(txtCreateTime.Text))
            {
                strErr += "交易时间格式错误!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int      Id              = int.Parse(this.lblId.Text);
            int      UserId          = int.Parse(this.txtUserId.Text);
            int      TradeType       = int.Parse(this.txtTradeType.Text);
            int      Price           = int.Parse(this.txtPrice.Text);
            int      AccountBalance  = int.Parse(this.txtAccountBalance.Text);
            string   PayentMethord   = this.txtPayentMethord.Text;
            string   TradeExplaining = this.txtTradeExplaining.Text;
            string   PaymentLogo     = this.txtPaymentLogo.Text;
            string   Remark          = this.txtRemark.Text;
            DateTime CreateTime      = DateTime.Parse(this.txtCreateTime.Text);


            DNSABC.Model.DNSABC_Transaction model = new DNSABC.Model.DNSABC_Transaction();
            model.Id              = Id;
            model.UserId          = UserId;
            model.TradeType       = TradeType;
            model.Price           = Price;
            model.AccountBalance  = AccountBalance;
            model.PayentMethord   = PayentMethord;
            model.TradeExplaining = TradeExplaining;
            model.PaymentLogo     = PaymentLogo;
            model.Remark          = Remark;
            model.CreateTime      = CreateTime;

            DNSABC.BLL.DNSABC_Transaction bll = new DNSABC.BLL.DNSABC_Transaction();
            bll.Update(model);
            ROYcms.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx");
        }
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public DNSABC.Model.DNSABC_Transaction GetModel(int Id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 Id,UserId,TradeType,Price,AccountBalance,PayentMethord,TradeExplaining,PaymentLogo,Remark,CreateTime from DNSABC_Transaction ");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Id", SqlDbType.Int, 4)
            };
            parameters[0].Value = Id;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["Id"] != null && ds.Tables[0].Rows[0]["Id"].ToString() != "")
                {
                    model.Id = int.Parse(ds.Tables[0].Rows[0]["Id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["UserId"] != null && ds.Tables[0].Rows[0]["UserId"].ToString() != "")
                {
                    model.UserId = int.Parse(ds.Tables[0].Rows[0]["UserId"].ToString());
                }
                if (ds.Tables[0].Rows[0]["TradeType"] != null && ds.Tables[0].Rows[0]["TradeType"].ToString() != "")
                {
                    model.TradeType = int.Parse(ds.Tables[0].Rows[0]["TradeType"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Price"] != null && ds.Tables[0].Rows[0]["Price"].ToString() != "")
                {
                    model.Price = int.Parse(ds.Tables[0].Rows[0]["Price"].ToString());
                }
                if (ds.Tables[0].Rows[0]["AccountBalance"] != null && ds.Tables[0].Rows[0]["AccountBalance"].ToString() != "")
                {
                    model.AccountBalance = int.Parse(ds.Tables[0].Rows[0]["AccountBalance"].ToString());
                }
                if (ds.Tables[0].Rows[0]["PayentMethord"] != null && ds.Tables[0].Rows[0]["PayentMethord"].ToString() != "")
                {
                    model.PayentMethord = ds.Tables[0].Rows[0]["PayentMethord"].ToString();
                }
                if (ds.Tables[0].Rows[0]["TradeExplaining"] != null && ds.Tables[0].Rows[0]["TradeExplaining"].ToString() != "")
                {
                    model.TradeExplaining = ds.Tables[0].Rows[0]["TradeExplaining"].ToString();
                }
                if (ds.Tables[0].Rows[0]["PaymentLogo"] != null && ds.Tables[0].Rows[0]["PaymentLogo"].ToString() != "")
                {
                    model.PaymentLogo = ds.Tables[0].Rows[0]["PaymentLogo"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Remark"] != null && ds.Tables[0].Rows[0]["Remark"].ToString() != "")
                {
                    model.Remark = ds.Tables[0].Rows[0]["Remark"].ToString();
                }
                if (ds.Tables[0].Rows[0]["CreateTime"] != null && ds.Tables[0].Rows[0]["CreateTime"].ToString() != "")
                {
                    model.CreateTime = DateTime.Parse(ds.Tables[0].Rows[0]["CreateTime"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }