protected void btnAdd_Click(object sender, EventArgs e) { NoName.NetShop.Vote.BLL.VoteTopic bll = new NoName.NetShop.Vote.BLL.VoteTopic(); int voteId = int.Parse(this.lblVoteId.Text); NoName.NetShop.Vote.Model.VoteTopic model = null; if (voteId != 0) { model = bll.GetModel(voteId); } if (model == null) { model = new NoName.NetShop.Vote.Model.VoteTopic(); } model.Topic = txtTopic.Text.Trim(); model.Remark = txtRemark.Text.Trim(); try { model.StartTime = DateTime.Parse(txtStartDate.Text); } catch { } try { model.EndTime = DateTime.Parse(txtEndDate.Text); } catch { } model.IsRegUser = chkIsRegUser.Checked; model.IsMulti = chkIsMulti.Checked; model.Status = chkStatus.Checked; bll.Save(model); Response.Redirect("ShowVoteInfo.aspx?voteId=" + model.VoteId); }
protected void btnAdd_Click(object sender, EventArgs e) { NoName.NetShop.Vote.BLL.VoteTopic bll = new NoName.NetShop.Vote.BLL.VoteTopic(); int voteId = int.Parse(this.lblVoteId.Text); NoName.NetShop.Vote.Model.VoteTopic model = null; if (voteId != 0) model = bll.GetModel(voteId); if (model == null) model = new NoName.NetShop.Vote.Model.VoteTopic(); model.Topic = txtTopic.Text.Trim(); model.Remark = txtRemark.Text.Trim(); try { model.StartTime = DateTime.Parse(txtStartDate.Text); } catch { } try { model.EndTime = DateTime.Parse(txtEndDate.Text); } catch { } model.IsRegUser = chkIsRegUser.Checked; model.IsMulti = chkIsMulti.Checked; model.Status = chkStatus.Checked; bll.Save(model); Response.Redirect("ShowVoteInfo.aspx?voteId=" + model.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.VoteTopic GetModel(int VoteId) { Database db = CommDataAccess.DbReader; DbCommand dbCommand = db.GetStoredProcCommand("UP_voVoteTopic_GetModel"); db.AddInParameter(dbCommand, "VoteId", DbType.Int32, VoteId); NoName.NetShop.Vote.Model.VoteTopic model = null; using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { if (dataReader.Read()) { model = ReaderBind(dataReader); } } return(model); }
/// <summary> /// 对象实体绑定数据 /// </summary> public NoName.NetShop.Vote.Model.VoteTopic ReaderBind(IDataReader dataReader) { NoName.NetShop.Vote.Model.VoteTopic model = new NoName.NetShop.Vote.Model.VoteTopic(); object ojb; ojb = dataReader["VoteId"]; if (ojb != null && ojb != DBNull.Value) { model.VoteId = (int)ojb; } model.Topic = dataReader["Topic"].ToString(); model.Remark = dataReader["Remark"].ToString(); ojb = dataReader["StartTime"]; if (ojb != null && ojb != DBNull.Value) { model.StartTime = (DateTime)ojb; } ojb = dataReader["EndTime"]; if (ojb != null && ojb != DBNull.Value) { model.EndTime = (DateTime)ojb; } ojb = dataReader["VoteUserNum"]; if (ojb != null && ojb != DBNull.Value) { model.VoteUserNum = (int)ojb; } ojb = dataReader["IsRegUser"]; if (ojb != null && ojb != DBNull.Value) { model.IsRegUser = (bool)ojb; } ojb = dataReader["status"]; if (ojb != null && ojb != DBNull.Value) { model.Status = (bool)ojb; } ojb = dataReader["IsMulti"]; if (ojb != null && ojb != DBNull.Value) { model.IsMulti = (bool)ojb; } return(model); }
/// <summary> /// 增加一条数据 /// </summary> public void Save(NoName.NetShop.Vote.Model.VoteTopic model) { if (model.VoteId == 0) { model.VoteId = NetShop.Common.CommDataHelper.GetNewSerialNum(AppType.Other); } Database db = CommDataAccess.DbWriter; DbCommand dbCommand = db.GetStoredProcCommand("UP_voVoteTopic_Save"); db.AddInParameter(dbCommand, "VoteId", DbType.Int32, model.VoteId); db.AddInParameter(dbCommand, "Topic", DbType.AnsiString, model.Topic); db.AddInParameter(dbCommand, "Remark", DbType.AnsiString, model.Remark); db.AddInParameter(dbCommand, "StartTime", DbType.DateTime, model.StartTime); db.AddInParameter(dbCommand, "EndTime", DbType.DateTime, model.EndTime); db.AddInParameter(dbCommand, "IsRegUser", DbType.Boolean, model.IsRegUser); db.AddInParameter(dbCommand, "Status", DbType.Boolean, model.Status); db.AddInParameter(dbCommand, "IsMulti", DbType.Boolean, model.IsMulti); db.ExecuteNonQuery(dbCommand); }
private void ShowVoteTopicInfo(int voteId) { NoName.NetShop.Vote.BLL.VoteTopic bll = new NoName.NetShop.Vote.BLL.VoteTopic(); NoName.NetShop.Vote.Model.VoteTopic model = bll.GetModel(voteId); if (model != null) { this.txtStartDate.Text = model.StartTime == null ? "" : (model.StartTime ?? DateTime.MinValue).ToShortDateString(); this.txtEndDate.Text = model.EndTime == null ? "" : (model.EndTime ?? DateTime.MinValue).ToShortDateString(); this.lblVoteUserNum.Text = model.VoteUserNum.ToString(); this.txtTopic.Text = model.Topic; this.txtRemark.Text = model.Remark; this.chkIsMulti.Checked = model.IsMulti; this.chkIsRegUser.Checked = model.IsRegUser; this.chkStatus.Checked = model.Status; this.lblVoteId.Text = model.VoteId.ToString(); } else { this.lblVoteId.Text = "0"; } }