private void ShowInfo(int OperID) { WebDemo.BLL.WebDemo.PaymentList bll = new WebDemo.BLL.WebDemo.PaymentList(); WebDemo.Model.WebDemo.PaymentList model = bll.GetModel(OperID); this.lblOperID.Text = model.OperID.ToString(); this.lblUsersID.Text = model.UsersID.ToString(); this.lblMeterID.Text = model.MeterID.ToString(); this.lblInvoiceNum.Text = model.InvoiceNum; this.lblLastbalance.Text = model.Lastbalance.ToString(); this.lblThisMoney.Text = model.ThisMoney.ToString(); this.lblFactMoney.Text = model.FactMoney.ToString(); this.lblThisBalance.Text = model.ThisBalance.ToString(); this.lblPayDate.Text = model.PayDate.ToString(); this.lblOperatorID.Text = model.OperatorID.ToString(); this.lblPayMode.Text = model.PayMode.ToString(); this.lblFlag.Text = model.Flag.ToString(); this.lblSiteID.Text = model.SiteID.ToString(); this.lblOperInt.Text = model.OperInt.ToString(); this.lblPrice.Text = model.Price.ToString(); this.lblInvoiceID.Text = model.InvoiceID.ToString(); this.lblInvoiceType.Text = model.InvoiceType.ToString(); this.lblPayType.Text = model.PayType.ToString(); this.lblPayWay.Text = model.PayWay.ToString(); this.lblTransactionId.Text = model.TransactionId; this.lblOutTradeNo.Text = model.OutTradeNo; }
/// <summary> /// 得到一个对象实体 /// </summary> public WebDemo.Model.WebDemo.PaymentList GetModel(int OperID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 OperID,UsersID,MeterID,InvoiceNum,Lastbalance,ThisMoney,FactMoney,ThisBalance,PayDate,OperatorID,PayMode,Flag,SiteID,OperInt,Price,InvoiceID,InvoiceType,PayType,PayWay,TransactionId,OutTradeNo from PaymentList "); strSql.Append(" where OperID=@OperID "); SqlParameter[] parameters = { new SqlParameter("@OperID", SqlDbType.Int, 4) }; parameters[0].Value = OperID; WebDemo.Model.WebDemo.PaymentList model = new WebDemo.Model.WebDemo.PaymentList(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
protected void btnSave_Click(object sender, EventArgs e) { string strErr = ""; if (!PageValidate.IsNumber(txtOperID.Text)) { strErr += "业务编号格式错误!\\n"; } if (!PageValidate.IsNumber(txtUsersID.Text)) { strErr += "UsersID格式错误!\\n"; } if (!PageValidate.IsNumber(txtMeterID.Text)) { strErr += "MeterID格式错误!\\n"; } if (this.txtInvoiceNum.Text.Trim().Length == 0) { strErr += "发票号码不能为空!\\n"; } if (!PageValidate.IsDecimal(txtLastbalance.Text)) { strErr += "上次余额格式错误!\\n"; } if (!PageValidate.IsDecimal(txtThisMoney.Text)) { strErr += "本次应交格式错误!\\n"; } if (!PageValidate.IsDecimal(txtFactMoney.Text)) { strErr += "本次实交格式错误!\\n"; } if (!PageValidate.IsDecimal(txtThisBalance.Text)) { strErr += "本次余额格式错误!\\n"; } if (!PageValidate.IsDateTime(txtPayDate.Text)) { strErr += "业务日期格式错误!\\n"; } if (!PageValidate.IsNumber(txtOperatorID.Text)) { strErr += "操作员编号格式错误!\\n"; } if (!PageValidate.IsNumber(txtPayMode.Text)) { strErr += "PayMode格式错误!\\n"; } if (!PageValidate.IsNumber(txtFlag.Text)) { strErr += "误收费恢复后格式错误!\\n"; } if (!PageValidate.IsNumber(txtSiteID.Text)) { strErr += "SiteID格式错误!\\n"; } if (!PageValidate.IsNumber(txtOperInt.Text)) { strErr += "OperInt格式错误!\\n"; } if (!PageValidate.IsDecimal(txtPrice.Text)) { strErr += "Price格式错误!\\n"; } if (!PageValidate.IsNumber(txtInvoiceID.Text)) { strErr += "InvoiceID格式错误!\\n"; } if (!PageValidate.IsNumber(txtInvoiceType.Text)) { strErr += "InvoiceType格式错误!\\n"; } if (!PageValidate.IsNumber(txtPayType.Text)) { strErr += "PayType格式错误!\\n"; } if (!PageValidate.IsNumber(txtPayWay.Text)) { strErr += "PayWay格式错误!\\n"; } if (this.txtTransactionId.Text.Trim().Length == 0) { strErr += "TransactionId不能为空!\\n"; } if (this.txtOutTradeNo.Text.Trim().Length == 0) { strErr += "OutTradeNo不能为空!\\n"; } if (strErr != "") { MessageBox.Show(this, strErr); return; } int OperID = int.Parse(this.txtOperID.Text); int UsersID = int.Parse(this.txtUsersID.Text); int MeterID = int.Parse(this.txtMeterID.Text); string InvoiceNum = this.txtInvoiceNum.Text; decimal Lastbalance = decimal.Parse(this.txtLastbalance.Text); decimal ThisMoney = decimal.Parse(this.txtThisMoney.Text); decimal FactMoney = decimal.Parse(this.txtFactMoney.Text); decimal ThisBalance = decimal.Parse(this.txtThisBalance.Text); DateTime PayDate = DateTime.Parse(this.txtPayDate.Text); int OperatorID = int.Parse(this.txtOperatorID.Text); int PayMode = int.Parse(this.txtPayMode.Text); int Flag = int.Parse(this.txtFlag.Text); int SiteID = int.Parse(this.txtSiteID.Text); int OperInt = int.Parse(this.txtOperInt.Text); decimal Price = decimal.Parse(this.txtPrice.Text); int InvoiceID = int.Parse(this.txtInvoiceID.Text); int InvoiceType = int.Parse(this.txtInvoiceType.Text); int PayType = int.Parse(this.txtPayType.Text); int PayWay = int.Parse(this.txtPayWay.Text); string TransactionId = this.txtTransactionId.Text; string OutTradeNo = this.txtOutTradeNo.Text; WebDemo.Model.WebDemo.PaymentList model = new WebDemo.Model.WebDemo.PaymentList(); model.OperID = OperID; model.UsersID = UsersID; model.MeterID = MeterID; model.InvoiceNum = InvoiceNum; model.Lastbalance = Lastbalance; model.ThisMoney = ThisMoney; model.FactMoney = FactMoney; model.ThisBalance = ThisBalance; model.PayDate = PayDate; model.OperatorID = OperatorID; model.PayMode = PayMode; model.Flag = Flag; model.SiteID = SiteID; model.OperInt = OperInt; model.Price = Price; model.InvoiceID = InvoiceID; model.InvoiceType = InvoiceType; model.PayType = PayType; model.PayWay = PayWay; model.TransactionId = TransactionId; model.OutTradeNo = OutTradeNo; WebDemo.BLL.WebDemo.PaymentList bll = new WebDemo.BLL.WebDemo.PaymentList(); bll.Add(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "add.aspx"); }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(WebDemo.Model.WebDemo.PaymentList model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into PaymentList("); strSql.Append("OperID,UsersID,MeterID,InvoiceNum,Lastbalance,ThisMoney,FactMoney,ThisBalance,PayDate,OperatorID,PayMode,Flag,SiteID,OperInt,Price,InvoiceID,InvoiceType,PayType,PayWay,TransactionId,OutTradeNo)"); strSql.Append(" values ("); strSql.Append("@OperID,@UsersID,@MeterID,@InvoiceNum,@Lastbalance,@ThisMoney,@FactMoney,@ThisBalance,@PayDate,@OperatorID,@PayMode,@Flag,@SiteID,@OperInt,@Price,@InvoiceID,@InvoiceType,@PayType,@PayWay,@TransactionId,@OutTradeNo)"); SqlParameter[] parameters = { new SqlParameter("@OperID", SqlDbType.Int, 4), new SqlParameter("@UsersID", SqlDbType.Int, 4), new SqlParameter("@MeterID", SqlDbType.Int, 4), new SqlParameter("@InvoiceNum", SqlDbType.VarChar, 50), new SqlParameter("@Lastbalance", SqlDbType.Decimal, 9), new SqlParameter("@ThisMoney", SqlDbType.Decimal, 9), new SqlParameter("@FactMoney", SqlDbType.Decimal, 9), new SqlParameter("@ThisBalance", SqlDbType.Decimal, 9), new SqlParameter("@PayDate", SqlDbType.DateTime), new SqlParameter("@OperatorID", SqlDbType.Int, 4), new SqlParameter("@PayMode", SqlDbType.Int, 4), new SqlParameter("@Flag", SqlDbType.Int, 4), new SqlParameter("@SiteID", SqlDbType.Int, 4), new SqlParameter("@OperInt", SqlDbType.Int, 4), new SqlParameter("@Price", SqlDbType.Decimal, 9), new SqlParameter("@InvoiceID", SqlDbType.Int, 4), new SqlParameter("@InvoiceType", SqlDbType.Int, 4), new SqlParameter("@PayType", SqlDbType.Int, 4), new SqlParameter("@PayWay", SqlDbType.Int, 4), new SqlParameter("@TransactionId", SqlDbType.VarChar, 100), new SqlParameter("@OutTradeNo", SqlDbType.VarChar, 100) }; parameters[0].Value = model.OperID; parameters[1].Value = model.UsersID; parameters[2].Value = model.MeterID; parameters[3].Value = model.InvoiceNum; parameters[4].Value = model.Lastbalance; parameters[5].Value = model.ThisMoney; parameters[6].Value = model.FactMoney; parameters[7].Value = model.ThisBalance; parameters[8].Value = model.PayDate; parameters[9].Value = model.OperatorID; parameters[10].Value = model.PayMode; parameters[11].Value = model.Flag; parameters[12].Value = model.SiteID; parameters[13].Value = model.OperInt; parameters[14].Value = model.Price; parameters[15].Value = model.InvoiceID; parameters[16].Value = model.InvoiceType; parameters[17].Value = model.PayType; parameters[18].Value = model.PayWay; parameters[19].Value = model.TransactionId; parameters[20].Value = model.OutTradeNo; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public WebDemo.Model.WebDemo.PaymentList DataRowToModel(DataRow row) { WebDemo.Model.WebDemo.PaymentList model = new WebDemo.Model.WebDemo.PaymentList(); if (row != null) { if (row["OperID"] != null && row["OperID"].ToString() != "") { model.OperID = int.Parse(row["OperID"].ToString()); } if (row["UsersID"] != null && row["UsersID"].ToString() != "") { model.UsersID = int.Parse(row["UsersID"].ToString()); } if (row["MeterID"] != null && row["MeterID"].ToString() != "") { model.MeterID = int.Parse(row["MeterID"].ToString()); } if (row["InvoiceNum"] != null) { model.InvoiceNum = row["InvoiceNum"].ToString(); } if (row["Lastbalance"] != null && row["Lastbalance"].ToString() != "") { model.Lastbalance = decimal.Parse(row["Lastbalance"].ToString()); } if (row["ThisMoney"] != null && row["ThisMoney"].ToString() != "") { model.ThisMoney = decimal.Parse(row["ThisMoney"].ToString()); } if (row["FactMoney"] != null && row["FactMoney"].ToString() != "") { model.FactMoney = decimal.Parse(row["FactMoney"].ToString()); } if (row["ThisBalance"] != null && row["ThisBalance"].ToString() != "") { model.ThisBalance = decimal.Parse(row["ThisBalance"].ToString()); } if (row["PayDate"] != null && row["PayDate"].ToString() != "") { model.PayDate = DateTime.Parse(row["PayDate"].ToString()); } if (row["OperatorID"] != null && row["OperatorID"].ToString() != "") { model.OperatorID = int.Parse(row["OperatorID"].ToString()); } if (row["PayMode"] != null && row["PayMode"].ToString() != "") { model.PayMode = int.Parse(row["PayMode"].ToString()); } if (row["Flag"] != null && row["Flag"].ToString() != "") { model.Flag = int.Parse(row["Flag"].ToString()); } if (row["SiteID"] != null && row["SiteID"].ToString() != "") { model.SiteID = int.Parse(row["SiteID"].ToString()); } if (row["OperInt"] != null && row["OperInt"].ToString() != "") { model.OperInt = int.Parse(row["OperInt"].ToString()); } if (row["Price"] != null && row["Price"].ToString() != "") { model.Price = decimal.Parse(row["Price"].ToString()); } if (row["InvoiceID"] != null && row["InvoiceID"].ToString() != "") { model.InvoiceID = int.Parse(row["InvoiceID"].ToString()); } if (row["InvoiceType"] != null && row["InvoiceType"].ToString() != "") { model.InvoiceType = int.Parse(row["InvoiceType"].ToString()); } if (row["PayType"] != null && row["PayType"].ToString() != "") { model.PayType = int.Parse(row["PayType"].ToString()); } if (row["PayWay"] != null && row["PayWay"].ToString() != "") { model.PayWay = int.Parse(row["PayWay"].ToString()); } if (row["TransactionId"] != null) { model.TransactionId = row["TransactionId"].ToString(); } if (row["OutTradeNo"] != null) { model.OutTradeNo = row["OutTradeNo"].ToString(); } } return(model); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(WebDemo.Model.WebDemo.PaymentList model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update PaymentList set "); strSql.Append("UsersID=@UsersID,"); strSql.Append("MeterID=@MeterID,"); strSql.Append("InvoiceNum=@InvoiceNum,"); strSql.Append("Lastbalance=@Lastbalance,"); strSql.Append("ThisMoney=@ThisMoney,"); strSql.Append("FactMoney=@FactMoney,"); strSql.Append("ThisBalance=@ThisBalance,"); strSql.Append("PayDate=@PayDate,"); strSql.Append("OperatorID=@OperatorID,"); strSql.Append("PayMode=@PayMode,"); strSql.Append("Flag=@Flag,"); strSql.Append("SiteID=@SiteID,"); strSql.Append("OperInt=@OperInt,"); strSql.Append("Price=@Price,"); strSql.Append("InvoiceID=@InvoiceID,"); strSql.Append("InvoiceType=@InvoiceType,"); strSql.Append("PayType=@PayType,"); strSql.Append("PayWay=@PayWay,"); strSql.Append("TransactionId=@TransactionId,"); strSql.Append("OutTradeNo=@OutTradeNo"); strSql.Append(" where OperID=@OperID "); SqlParameter[] parameters = { new SqlParameter("@UsersID", SqlDbType.Int, 4), new SqlParameter("@MeterID", SqlDbType.Int, 4), new SqlParameter("@InvoiceNum", SqlDbType.VarChar, 50), new SqlParameter("@Lastbalance", SqlDbType.Decimal, 9), new SqlParameter("@ThisMoney", SqlDbType.Decimal, 9), new SqlParameter("@FactMoney", SqlDbType.Decimal, 9), new SqlParameter("@ThisBalance", SqlDbType.Decimal, 9), new SqlParameter("@PayDate", SqlDbType.DateTime), new SqlParameter("@OperatorID", SqlDbType.Int, 4), new SqlParameter("@PayMode", SqlDbType.Int, 4), new SqlParameter("@Flag", SqlDbType.Int, 4), new SqlParameter("@SiteID", SqlDbType.Int, 4), new SqlParameter("@OperInt", SqlDbType.Int, 4), new SqlParameter("@Price", SqlDbType.Decimal, 9), new SqlParameter("@InvoiceID", SqlDbType.Int, 4), new SqlParameter("@InvoiceType", SqlDbType.Int, 4), new SqlParameter("@PayType", SqlDbType.Int, 4), new SqlParameter("@PayWay", SqlDbType.Int, 4), new SqlParameter("@TransactionId", SqlDbType.VarChar, 100), new SqlParameter("@OutTradeNo", SqlDbType.VarChar, 100), new SqlParameter("@OperID", SqlDbType.Int, 4) }; parameters[0].Value = model.UsersID; parameters[1].Value = model.MeterID; parameters[2].Value = model.InvoiceNum; parameters[3].Value = model.Lastbalance; parameters[4].Value = model.ThisMoney; parameters[5].Value = model.FactMoney; parameters[6].Value = model.ThisBalance; parameters[7].Value = model.PayDate; parameters[8].Value = model.OperatorID; parameters[9].Value = model.PayMode; parameters[10].Value = model.Flag; parameters[11].Value = model.SiteID; parameters[12].Value = model.OperInt; parameters[13].Value = model.Price; parameters[14].Value = model.InvoiceID; parameters[15].Value = model.InvoiceType; parameters[16].Value = model.PayType; parameters[17].Value = model.PayWay; parameters[18].Value = model.TransactionId; parameters[19].Value = model.OutTradeNo; parameters[20].Value = model.OperID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }