protected void btnSave_Click(object sender, EventArgs e) { string strErr = ""; if (!PageValidate.IsNumber(txtUserID.Text)) { strErr += "用户ID格式错误!\\n"; } if (this.txtPaymentType.Text.Trim().Length == 0) { strErr += "支付接口不能为空!\\n"; } if (this.txtPaymentName.Text.Trim().Length == 0) { strErr += "支付接口名称不能为空!\\n"; } if (!PageValidate.IsNumber(txtPaymentAmount.Text)) { strErr += "支付金额格式错误!\\n"; } if (this.txtPaymentNum.Text.Trim().Length == 0) { strErr += "支付号不能为空!\\n"; } if (!PageValidate.IsDateTime(txtUpdateTime.Text)) { strErr += "更新时间格式错误!\\n"; } if (!PageValidate.IsDateTime(txtCreateTime.Text)) { strErr += "创建时间格式错误!\\n"; } if (strErr != "") { MessageBox.Show(this, strErr); return; } int UserID = int.Parse(this.txtUserID.Text); string PaymentType = this.txtPaymentType.Text; string PaymentName = this.txtPaymentName.Text; int PaymentAmount = int.Parse(this.txtPaymentAmount.Text); string PaymentNum = this.txtPaymentNum.Text; DateTime UpdateTime = DateTime.Parse(this.txtUpdateTime.Text); DateTime CreateTime = DateTime.Parse(this.txtCreateTime.Text); DNSABC.Model.DNSABC_Payment model = new DNSABC.Model.DNSABC_Payment(); model.UserID = UserID; model.PaymentType = PaymentType; model.PaymentName = PaymentName; model.PaymentAmount = PaymentAmount; model.PaymentNum = PaymentNum; model.UpdateTime = UpdateTime; model.CreateTime = CreateTime; DNSABC.BLL.DNSABC_Payment bll = new DNSABC.BLL.DNSABC_Payment(); bll.Add(model); ROYcms.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "add.aspx"); }
/// <summary> /// 得到一个对象实体 /// </summary> public DNSABC.Model.DNSABC_Payment GetModel(int Id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 Id,UserID,PaymentType,PaymentName,PaymentAmount,PaymentNum,UpdateTime,CreateTime from DNSABC_Payment "); strSql.Append(" where Id=@Id"); SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.Int, 4) }; parameters[0].Value = Id; DNSABC.Model.DNSABC_Payment model = new DNSABC.Model.DNSABC_Payment(); 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]["PaymentType"] != null && ds.Tables[0].Rows[0]["PaymentType"].ToString() != "") { model.PaymentType = ds.Tables[0].Rows[0]["PaymentType"].ToString(); } if (ds.Tables[0].Rows[0]["PaymentName"] != null && ds.Tables[0].Rows[0]["PaymentName"].ToString() != "") { model.PaymentName = ds.Tables[0].Rows[0]["PaymentName"].ToString(); } if (ds.Tables[0].Rows[0]["PaymentAmount"] != null && ds.Tables[0].Rows[0]["PaymentAmount"].ToString() != "") { model.PaymentAmount = int.Parse(ds.Tables[0].Rows[0]["PaymentAmount"].ToString()); } if (ds.Tables[0].Rows[0]["PaymentNum"] != null && ds.Tables[0].Rows[0]["PaymentNum"].ToString() != "") { model.PaymentNum = ds.Tables[0].Rows[0]["PaymentNum"].ToString(); } if (ds.Tables[0].Rows[0]["UpdateTime"] != null && ds.Tables[0].Rows[0]["UpdateTime"].ToString() != "") { model.UpdateTime = DateTime.Parse(ds.Tables[0].Rows[0]["UpdateTime"].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); } }
private void ShowInfo(int Id) { DNSABC.BLL.DNSABC_Payment bll = new DNSABC.BLL.DNSABC_Payment(); DNSABC.Model.DNSABC_Payment model = bll.GetModel(Id); this.lblId.Text = model.Id.ToString(); this.lblUserID.Text = model.UserID.ToString(); this.lblPaymentType.Text = model.PaymentType; this.lblPaymentName.Text = model.PaymentName; this.lblPaymentAmount.Text = model.PaymentAmount.ToString(); this.lblPaymentNum.Text = model.PaymentNum; this.lblUpdateTime.Text = model.UpdateTime.ToString(); this.lblCreateTime.Text = model.CreateTime.ToString(); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(DNSABC.Model.DNSABC_Payment model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update DNSABC_Payment set "); strSql.Append("UserID=@UserID,"); strSql.Append("PaymentType=@PaymentType,"); strSql.Append("PaymentName=@PaymentName,"); strSql.Append("PaymentAmount=@PaymentAmount,"); strSql.Append("PaymentNum=@PaymentNum,"); strSql.Append("UpdateTime=@UpdateTime,"); strSql.Append("CreateTime=@CreateTime"); strSql.Append(" where Id=@Id"); SqlParameter[] parameters = { new SqlParameter("@UserID", SqlDbType.Int, 4), new SqlParameter("@PaymentType", SqlDbType.VarChar, 50), new SqlParameter("@PaymentName", SqlDbType.VarChar, 4000), new SqlParameter("@PaymentAmount", SqlDbType.Int, 4), new SqlParameter("@PaymentNum", SqlDbType.VarChar, 100), new SqlParameter("@UpdateTime", SqlDbType.DateTime), new SqlParameter("@CreateTime", SqlDbType.DateTime), new SqlParameter("@Id", SqlDbType.Int, 4) }; parameters[0].Value = model.UserID; parameters[1].Value = model.PaymentType; parameters[2].Value = model.PaymentName; parameters[3].Value = model.PaymentAmount; parameters[4].Value = model.PaymentNum; parameters[5].Value = model.UpdateTime; parameters[6].Value = model.CreateTime; parameters[7].Value = model.Id; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(DNSABC.Model.DNSABC_Payment model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into DNSABC_Payment("); strSql.Append("UserID,PaymentType,PaymentName,PaymentAmount,PaymentNum,UpdateTime,CreateTime)"); strSql.Append(" values ("); strSql.Append("@UserID,@PaymentType,@PaymentName,@PaymentAmount,@PaymentNum,@UpdateTime,@CreateTime)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@UserID", SqlDbType.Int, 4), new SqlParameter("@PaymentType", SqlDbType.VarChar, 50), new SqlParameter("@PaymentName", SqlDbType.VarChar, 4000), new SqlParameter("@PaymentAmount", SqlDbType.Int, 4), new SqlParameter("@PaymentNum", SqlDbType.VarChar, 100), new SqlParameter("@UpdateTime", SqlDbType.DateTime), new SqlParameter("@CreateTime", SqlDbType.DateTime) }; parameters[0].Value = model.UserID; parameters[1].Value = model.PaymentType; parameters[2].Value = model.PaymentName; parameters[3].Value = model.PaymentAmount; parameters[4].Value = model.PaymentNum; parameters[5].Value = model.UpdateTime; parameters[6].Value = model.CreateTime; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }