/// <summary> /// 对象实体绑定数据 /// </summary> public NoName.NetShop.Vote.Model.VoteRemark ReaderBind(IDataReader dataReader) { NoName.NetShop.Vote.Model.VoteRemark model = new NoName.NetShop.Vote.Model.VoteRemark(); object ojb; ojb = dataReader["VoteId"]; if (ojb != null && ojb != DBNull.Value) { model.VoteId = (int)ojb; } model.UserId = dataReader["UserId"].ToString(); model.Remark = dataReader["Remark"].ToString(); ojb = dataReader["VoteTime"]; if (ojb != null && ojb != DBNull.Value) { model.VoteTime = (DateTime)ojb; } model.VoteIP = dataReader["VoteIP"].ToString(); ojb = dataReader["LogId"]; if (ojb != null && ojb != DBNull.Value) { model.LogId = (int)ojb; } model.ItemIds = dataReader["itemids"].ToString(); return(model); }
protected void Page_Load(object sender, EventArgs e) { NoName.NetShop.Vote.BLL.VoteTopic vbll = new NoName.NetShop.Vote.BLL.VoteTopic(); NoName.NetShop.Vote.BLL.VoteRemark rbll = new NoName.NetShop.Vote.BLL.VoteRemark(); NoName.NetShop.Vote.Model.VoteRemark rmodel = new NoName.NetShop.Vote.Model.VoteRemark(); int voteId = int.Parse(ReqParas["voteId"]); NoName.NetShop.Vote.Model.VoteTopic vmodel = vbll.GetModel(voteId); string voteIp = Request.UserHostAddress; string remark = ReqParas["remark"]; List <string> itemIds = new List <string>(); foreach (string key in ReqParas.Keys) { if (Regex.IsMatch(key, @"^gid\d+$")) { if (!String.IsNullOrEmpty(ReqParas[key])) { itemIds.Add(ReqParas[key]); } } } string items = String.Join(",", itemIds.ToArray()); string userId = String.Empty; if (vmodel.IsRegUser) { if (!this.User.Identity.IsAuthenticated) { Response.Write("请先登陆,然后再投票!"); Response.End(); } else { userId = this.User.Identity.Name; } } rmodel.VoteId = voteId; rmodel.ItemIds = items; rmodel.LogId = 0; rmodel.Remark = remark; rmodel.UserId = userId; rmodel.VoteIP = voteIp; rbll.Add(rmodel); Response.Redirect("VoteResult.aspx?voteId=" + voteId); }
protected void Page_Load(object sender, EventArgs e) { NoName.NetShop.Vote.BLL.VoteTopic vbll = new NoName.NetShop.Vote.BLL.VoteTopic(); NoName.NetShop.Vote.BLL.VoteRemark rbll = new NoName.NetShop.Vote.BLL.VoteRemark(); NoName.NetShop.Vote.Model.VoteRemark rmodel = new NoName.NetShop.Vote.Model.VoteRemark(); int voteId = int.Parse(ReqParas["voteId"]); NoName.NetShop.Vote.Model.VoteTopic vmodel = vbll.GetModel(voteId); string voteIp = Request.UserHostAddress; string remark = ReqParas["remark"]; List<string> itemIds = new List<string>(); foreach (string key in ReqParas.Keys) { if (Regex.IsMatch(key, @"^gid\d+$")) { if (!String.IsNullOrEmpty(ReqParas[key])) { itemIds.Add(ReqParas[key]); } } } string items = String.Join(",", itemIds.ToArray()); string userId = String.Empty; if (vmodel.IsRegUser) { if (!this.User.Identity.IsAuthenticated) { Response.Write("请先登陆,然后再投票!"); Response.End(); } else { userId = this.User.Identity.Name; } } rmodel.VoteId = voteId; rmodel.ItemIds = items; rmodel.LogId =0; rmodel.Remark = remark; rmodel.UserId = userId; rmodel.VoteIP = voteIp; rbll.Add(rmodel); Response.Redirect("VoteResult.aspx?voteId="+voteId); }
/// <summary> /// 得到一个对象实体 /// </summary> public NoName.NetShop.Vote.Model.VoteRemark GetModel(int LogId) { Database db = CommDataAccess.DbReader; DbCommand dbCommand = db.GetStoredProcCommand("UP_voVoteRemark_GetModel"); db.AddInParameter(dbCommand, "LogId", DbType.Int32, LogId); NoName.NetShop.Vote.Model.VoteRemark model = null; using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { if (dataReader.Read()) { model = ReaderBind(dataReader); } } return(model); }
/// <summary> /// 增加一条数据 /// </summary> public void Add(NoName.NetShop.Vote.Model.VoteRemark model) { if (model.LogId == 0) { model.LogId = NoName.NetShop.Common.CommDataHelper.GetNewSerialNum(AppType.Other); } Database db = CommDataAccess.DbWriter; DbCommand dbCommand = db.GetStoredProcCommand("UP_voVoteRemark_ADD"); db.AddInParameter(dbCommand, "VoteId", DbType.Int32, model.VoteId); db.AddInParameter(dbCommand, "UserId", DbType.String, model.UserId); db.AddInParameter(dbCommand, "Remark", DbType.AnsiString, model.Remark); db.AddInParameter(dbCommand, "VoteIP", DbType.AnsiString, model.VoteIP); db.AddInParameter(dbCommand, "LogId", DbType.Int32, model.LogId); db.AddInParameter(dbCommand, "ItemIds", DbType.AnsiString, model.ItemIds); db.ExecuteNonQuery(dbCommand); }
/// <summary> /// ����ʵ������� /// </summary> public NoName.NetShop.Vote.Model.VoteRemark ReaderBind(IDataReader dataReader) { NoName.NetShop.Vote.Model.VoteRemark model=new NoName.NetShop.Vote.Model.VoteRemark(); object ojb; ojb = dataReader["VoteId"]; if(ojb != null && ojb != DBNull.Value) { model.VoteId=(int)ojb; } model.UserId = dataReader["UserId"].ToString(); model.Remark=dataReader["Remark"].ToString(); ojb = dataReader["VoteTime"]; if(ojb != null && ojb != DBNull.Value) { model.VoteTime=(DateTime)ojb; } model.VoteIP=dataReader["VoteIP"].ToString(); ojb = dataReader["LogId"]; if(ojb != null && ojb != DBNull.Value) { model.LogId=(int)ojb; } model.ItemIds = dataReader["itemids"].ToString(); return model; }