/// <summary> /// 增加一条数据 /// </summary> public void Add(AuctionLogModel model) { DbCommand dbCommand = dbw.GetStoredProcCommand("UP_mwAuctionLog_ADD"); dbw.AddInParameter(dbCommand, "logid", DbType.Int32, model.LogID); dbw.AddInParameter(dbCommand, "AuctionId", DbType.Int32, model.AuctionID); dbw.AddInParameter(dbCommand, "UserName", DbType.AnsiString, model.UserName); dbw.AddInParameter(dbCommand, "AuctionTime", DbType.DateTime, model.AuctionTime); dbw.AddInParameter(dbCommand, "AutionPrice", DbType.Decimal, model.AutionPrice); dbw.ExecuteNonQuery(dbCommand); }
protected void Repeater_AddPrices_ItemCommand(object sender, RepeaterCommandEventArgs e) { if (e.CommandName == "b") { if (CurrentUser != null) { AuctionLogModel LastAuction = LogBll.GetLastAuction(AuctionID); if (LastAuction != null && LastAuction.UserName == CurrentUser.UserId) { MessageBox.Show(this, "尚无竞拍者的出价高于您"); return; } decimal BidPrice = Convert.ToInt32(e.CommandArgument); AuctionProductModel model = bll.GetModel(AuctionID); decimal CurrentPrice = model.CurPrice + BidPrice; AuctionLogModel LogModel = new AuctionLogModel(); LogModel.LogID = CommDataHelper.GetNewSerialNum(AppType.MagicWorld); LogModel.AuctionID = AuctionID; LogModel.AuctionTime = DateTime.Now; LogModel.AutionPrice = CurrentPrice; LogModel.UserName = GetUserName(); LogBll.Add(LogModel); model.CurPrice = CurrentPrice; bll.Update(model); Response.Redirect(Request.RawUrl); } else { Response.Redirect("/Login.aspx?returnurl=" + Server.UrlPathEncode(Request.RawUrl)); } } }
public AuctionLogModel GetLastAuction(int AuctionID) { string sql = "select top 1 * from mwauctionlog where auctionid = @auctionid order by auctiontime desc"; DbCommand Command = dbr.GetSqlStringCommand(sql); dbr.AddInParameter(Command, "@auctionid", DbType.Int32, AuctionID); DataTable dt = dbr.ExecuteDataSet(Command).Tables[0]; AuctionLogModel model = null; if (dt.Rows.Count > 0) { DataRow row = dt.Rows[0]; model = new AuctionLogModel() { AuctionID = Convert.ToInt32(row["auctionid"]), AuctionTime = Convert.ToDateTime(row["AuctionTime"]), AutionPrice = Convert.ToDecimal(row["AutionPrice"]), LogID = Convert.ToInt32(row["logid"]), UserName = row["username"].ToString() }; } return model; }
/// <summary> /// 对象实体绑定数据 /// </summary> public AuctionLogModel ReaderBind(IDataReader dataReader) { AuctionLogModel model=new AuctionLogModel(); object ojb; ojb = dataReader["logid"]; if (ojb != null && ojb != DBNull.Value) { model.LogID = (int)ojb; } ojb = dataReader["AuctionId"]; if(ojb != null && ojb != DBNull.Value) { model.AuctionID=(int)ojb; } model.UserName=dataReader["UserName"].ToString(); ojb = dataReader["AuctionTime"]; if(ojb != null && ojb != DBNull.Value) { model.AuctionTime=(DateTime)ojb; } ojb = dataReader["AutionPrice"]; if(ojb != null && ojb != DBNull.Value) { model.AutionPrice=(decimal)ojb; } return model; }
/// <summary> /// 获得数据列表 /// </summary> public List<AuctionLogModel> GetModelList(string strWhere) { DataSet ds = dal.GetList(strWhere); List<AuctionLogModel> modelList = new List<AuctionLogModel>(); int rowsCount = ds.Tables[0].Rows.Count; if (rowsCount > 0) { AuctionLogModel model; for (int n = 0; n < rowsCount; n++) { model = new AuctionLogModel(); if(ds.Tables[0].Rows[n]["AuctionId"].ToString()!="") { model.AuctionID=int.Parse(ds.Tables[0].Rows[n]["AuctionId"].ToString()); } model.UserName=ds.Tables[0].Rows[n]["UserName"].ToString(); if(ds.Tables[0].Rows[n]["AuctionTime"].ToString()!="") { model.AuctionTime=DateTime.Parse(ds.Tables[0].Rows[n]["AuctionTime"].ToString()); } if(ds.Tables[0].Rows[n]["AutionPrice"].ToString()!="") { model.AutionPrice=decimal.Parse(ds.Tables[0].Rows[n]["AutionPrice"].ToString()); } modelList.Add(model); } } return modelList; }
/// <summary> /// 增加一条数据 /// </summary> public void Add(AuctionLogModel model) { dal.Add(model); }
/// <summary> /// 更新一条数据 /// </summary> public void Update(AuctionLogModel model) { dal.Update(model); }