/// <summary> /// 页面数据绑定 /// </summary> public void PageBind() { allCount = 0f; tvv = tv.GetModel(voteId); if (tvv != null) { tviiList = tvi.GetModelList("ivote_voteId = " + voteId + ""); if (tviiList.Count > 0) { foreach (Tunnel.Model.Tunnel_Votei item in tviiList) { allCount += Convert.ToInt32(item.ivote_Count.ToString()); } Repeater1.DataSource = tviiList; Repeater1.DataBind(); } } PageBase pb = new PageBase(); pb.TblName = "Tunnel_VoteRe"; pb.FldName = "vote_Id"; pb.ProcedureName = "pagination"; pb.PageSize = pageSize; if (cuttentPage == 0) { cuttentPage = pb.PageIndex; } pb.PageIndex = cuttentPage; pb.StrWhere = "vate_voteId=" + voteId + ""; pb.OrderName = "vate_Date"; pb.OrderType = 1; int count = 0; List <Tunnel.Model.Tunnel_VoteRe> modelList = new List <Tunnel.Model.Tunnel_VoteRe>(); modelList = tbll.GetList(pb, ref count); //获取分页结果 pb.DoCount = 1; tbll.GetList(pb, ref count); //获取总条数 //数据绑定 Repeater2.DataSource = modelList; Repeater2.DataBind(); //数据分页 MTCPager1.PageSize = pageSize; MTCPager1.RecordCount = count; MTCPager1.PageIndex = cuttentPage; if (count <= pb.PageSize) { MTCPager1.Visible = false; } else { MTCPager1.Visible = true; } }
public List <Tunnel.Model.Tunnel_Vote> GetList(PageBase pb, ref int count) { DataTable dt = dal.GetList(pb, ref count).Tables[0]; List <Tunnel.Model.Tunnel_Vote> modelList = new List <Tunnel.Model.Tunnel_Vote>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0 && pb.DoCount == 0) { Tunnel.Model.Tunnel_Vote model; for (int n = 0; n < rowsCount; n++) { model = new Tunnel.Model.Tunnel_Vote(); if (dt.Rows[n]["vote_Id"].ToString() != "") { model.vote_Id = int.Parse(dt.Rows[n]["vote_Id"].ToString()); } if (dt.Rows[n]["vote_userId"].ToString() != "") { model.vote_userId = int.Parse(dt.Rows[n]["vote_userId"].ToString()); } model.vote_userGroup = dt.Rows[n]["vote_userGroup"].ToString(); model.vote_bumGroup = dt.Rows[n]["vote_bumGroup"].ToString(); model.vote_jsGroup = dt.Rows[n]["vote_jsGroup"].ToString(); model.vote_Title = dt.Rows[n]["vote_Title"].ToString(); model.vote_mark = dt.Rows[n]["vote_mark"].ToString(); if (dt.Rows[n]["vote_Type"].ToString() != "") { model.vote_Type = int.Parse(dt.Rows[n]["vote_Type"].ToString()); } if (dt.Rows[n]["vote_startDate"].ToString() != "") { model.vote_startDate = DateTime.Parse(dt.Rows[n]["vote_startDate"].ToString()); } if (dt.Rows[n]["vote_endDate"].ToString() != "") { model.vote_endDate = DateTime.Parse(dt.Rows[n]["vote_endDate"].ToString()); } if (dt.Rows[n]["vote_seeType"].ToString() != "") { model.vote_seeType = int.Parse(dt.Rows[n]["vote_seeType"].ToString()); } if (dt.Rows[n]["vote_state"].ToString() != "") { model.vote_state = int.Parse(dt.Rows[n]["vote_state"].ToString()); } if (dt.Rows[n]["vote_max"].ToString() != "") { model.vote_max = int.Parse(dt.Rows[n]["vote_max"].ToString()); } if (dt.Rows[n]["vote_top"].ToString() != "") { model.vote_top = int.Parse(dt.Rows[n]["vote_top"].ToString()); } modelList.Add(model); } } return(modelList); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (!string.IsNullOrEmpty(Request.QueryString["id"])) { id = Convert.ToInt32(Request.QueryString["id"].ToString()); Tunnel.BLL.Tunnel_Vote t = new Tunnel.BLL.Tunnel_Vote(); Tunnel.Model.Tunnel_Vote tt = new Tunnel.Model.Tunnel_Vote(); Tunnel.BLL.Tunnel_menber tm = new Tunnel.BLL.Tunnel_menber(); tt = t.GetModel(id); voteTitle = tt.vote_Title; voteUserName = tm.GetModel(Convert.ToInt32(tt.vote_userId)).m_name; voteDate = Convert.ToDateTime(tt.vote_startDate).ToShortDateString(); voteMark = tt.vote_mark; voteMax = tt.vote_max.ToString(); voteType = tt.vote_Type.ToString(); max.Value = voteMax; tvList = tv.GetModelList("ivote_voteId=" + id + ""); Repeater1.DataSource = tvList; Repeater1.DataBind(); if (voteType == "0") { foreach (RepeaterItem item in Repeater1.Items) { ((CheckBox)item.FindControl("CheckBox1")).Visible = false; } } else { foreach (RepeaterItem item in Repeater1.Items) { ((RadioButton)item.FindControl("RadioButton1")).Visible = false; } } Tunnel.BLL.UserLogin ul = new Tunnel.BLL.UserLogin(); bool b = false; foreach (Tunnel.Model.Tunnel_Votei item in tvList) { string[] temp = item.ivote_yesUserId.Split(','); foreach (string item1 in temp) { if (ul.LoginID.ToString() == item1) { b = true; } } } if (b) { //Button1.Text = "查看结果"; Response.Redirect("VoteShow.aspx?id=" + Request.QueryString["id"].ToString()); } } } }
/// <summary> /// 获得数据列表 /// </summary> public List <Tunnel.Model.Tunnel_Vote> DataTableToList(DataTable dt) { List <Tunnel.Model.Tunnel_Vote> modelList = new List <Tunnel.Model.Tunnel_Vote>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { Tunnel.Model.Tunnel_Vote model; for (int n = 0; n < rowsCount; n++) { model = new Tunnel.Model.Tunnel_Vote(); if (dt.Rows[n]["vote_Id"].ToString() != "") { model.vote_Id = int.Parse(dt.Rows[n]["vote_Id"].ToString()); } if (dt.Rows[n]["vote_userId"].ToString() != "") { model.vote_userId = int.Parse(dt.Rows[n]["vote_userId"].ToString()); } model.vote_userGroup = dt.Rows[n]["vote_userGroup"].ToString(); model.vote_bumGroup = dt.Rows[n]["vote_bumGroup"].ToString(); model.vote_jsGroup = dt.Rows[n]["vote_jsGroup"].ToString(); model.vote_Title = dt.Rows[n]["vote_Title"].ToString(); model.vote_mark = dt.Rows[n]["vote_mark"].ToString(); if (dt.Rows[n]["vote_Type"].ToString() != "") { model.vote_Type = int.Parse(dt.Rows[n]["vote_Type"].ToString()); } if (dt.Rows[n]["vote_startDate"].ToString() != "") { model.vote_startDate = DateTime.Parse(dt.Rows[n]["vote_startDate"].ToString()); } if (dt.Rows[n]["vote_endDate"].ToString() != "") { model.vote_endDate = DateTime.Parse(dt.Rows[n]["vote_endDate"].ToString()); } if (dt.Rows[n]["vote_seeType"].ToString() != "") { model.vote_seeType = int.Parse(dt.Rows[n]["vote_seeType"].ToString()); } if (dt.Rows[n]["vote_state"].ToString() != "") { model.vote_state = int.Parse(dt.Rows[n]["vote_state"].ToString()); } if (dt.Rows[n]["vote_max"].ToString() != "") { model.vote_max = int.Parse(dt.Rows[n]["vote_max"].ToString()); } if (dt.Rows[n]["vote_top"].ToString() != "") { model.vote_top = int.Parse(dt.Rows[n]["vote_top"].ToString()); } modelList.Add(model); } } return(modelList); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (!string.IsNullOrEmpty(Request.QueryString["id"])) { voteId = Convert.ToInt32(Request.QueryString["id"].ToString()); Tunnel.BLL.Tunnel_Vote t = new Tunnel.BLL.Tunnel_Vote(); Tunnel.Model.Tunnel_Vote tt = new Tunnel.Model.Tunnel_Vote(); Tunnel.BLL.Tunnel_menber tm = new Tunnel.BLL.Tunnel_menber(); tt = t.GetModel(voteId); voteTitle = tt.vote_Title; voteMark = tt.vote_mark; PageBind(); } } }
public void Pagebind() { tvv = tv.GetModel(tempId); if (tvv != null) { if (!string.IsNullOrEmpty(tvv.vote_bumGroup) && tvv.vote_bumGroup != "|") { TextbumName.Value = tvv.vote_bumGroup.Split('|')[1]; } else { TextbumName.Value = tvv.vote_bumGroup; } TextbumId.Value = tvv.vote_bumGroup; txtTitle.Text = tvv.vote_Title; txtText.Text = tvv.vote_mark; TextBox3.Text = tvv.vote_max.ToString(); DropDownList1.SelectedIndex = Convert.ToInt32(tvv.vote_Type.ToString()); TextBox1.Text = Convert.ToDateTime(tvv.vote_startDate).ToShortDateString(); TextBox2.Text = Convert.ToDateTime(tvv.vote_endDate).ToShortDateString(); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Tunnel.Model.Tunnel_Vote model) { int rowsAffected; SqlParameter[] parameters = { new SqlParameter("@vote_Id", SqlDbType.Int, 4), new SqlParameter("@vote_userId", SqlDbType.Int, 4), new SqlParameter("@vote_userGroup", SqlDbType.VarChar, 3000), new SqlParameter("@vote_bumGroup", SqlDbType.VarChar, 3000), new SqlParameter("@vote_jsGroup", SqlDbType.VarChar, 3000), new SqlParameter("@vote_Title", SqlDbType.VarChar, 3000), new SqlParameter("@vote_mark", SqlDbType.VarChar, 3000), new SqlParameter("@vote_Type", SqlDbType.Int, 4), new SqlParameter("@vote_startDate", SqlDbType.DateTime), new SqlParameter("@vote_endDate", SqlDbType.DateTime), new SqlParameter("@vote_seeType", SqlDbType.Int, 4), new SqlParameter("@vote_state", SqlDbType.Int, 4), new SqlParameter("@vote_max", SqlDbType.Int, 4), new SqlParameter("@vote_top", SqlDbType.Int, 4) }; parameters[0].Direction = ParameterDirection.Output; parameters[1].Value = model.vote_userId; parameters[2].Value = model.vote_userGroup; parameters[3].Value = model.vote_bumGroup; parameters[4].Value = model.vote_jsGroup; parameters[5].Value = model.vote_Title; parameters[6].Value = model.vote_mark; parameters[7].Value = model.vote_Type; parameters[8].Value = model.vote_startDate; parameters[9].Value = model.vote_endDate; parameters[10].Value = model.vote_seeType; parameters[11].Value = model.vote_state; parameters[12].Value = model.vote_max; parameters[13].Value = model.vote_top; DbHelperSQL.RunProcedure("UP_Tunnel_Vote_ADD", parameters, out rowsAffected); return((int)parameters[0].Value); }
protected void btnSave_Click(object sender, EventArgs e) { Tunnel.BLL.Tunnel_Vote tv = new Tunnel.BLL.Tunnel_Vote(); Tunnel.Model.Tunnel_Vote tvv = new Tunnel.Model.Tunnel_Vote(); Tunnel.BLL.UserLogin ul = new Tunnel.BLL.UserLogin(); tvv.vote_userId = Convert.ToInt32(ul.LoginID.ToString()); tvv.vote_bumGroup = TextbumId.Value; tvv.vote_startDate = TextBox1.Text.Trim().Length > 0 ? Convert.ToDateTime(TextBox1.Text) : DateTime.Now; tvv.vote_endDate = TextBox2.Text.Trim().Length > 0 ? Convert.ToDateTime(TextBox2.Text) : Convert.ToDateTime(tvv.vote_startDate).AddYears(1); tvv.vote_mark = txtText.Text; tvv.vote_state = 0; tvv.vote_Title = txtTitle.Text; tvv.vote_top = 0; tvv.vote_Type = Convert.ToInt32(DropDownList1.SelectedValue); tvv.vote_max = 1; if (tvv.vote_Type == 1) { if (TextBox3.Text.Length > 0) { tvv.vote_max = Convert.ToInt32(TextBox3.Text.Trim()); } else { tvv.vote_max = 1; } } int relf = tv.Add(tvv); if (relf > 0) { if (CheckBox1.Checked) { #region 发消息给大家////////////////////////////////////// //获得所需参数 string strToIds = tvv.vote_bumGroup; string strTitle = "投票:" + tvv.vote_Title; //写入数据库 if (strToIds != "" && strToIds != "|") { strToIds = strToIds.Split('|')[0].ToString(); if (strToIds.LastIndexOf(',') > 0) { strToIds = strToIds.Remove(strToIds.LastIndexOf(','), 1); } string[] arr = strToIds.Split(','); List <Tunnel.Model.Tunnel_menber> tmList = new List <Tunnel.Model.Tunnel_menber>(); foreach (string item in arr) { Tunnel.BLL.Tunnel_menber tm = new Tunnel.BLL.Tunnel_menber(); tmList = new List <Tunnel.Model.Tunnel_menber>(); tmList = tm.GetModelList("m_bum=" + item + ""); for (int j = 0; j < tmList.Count; j++) { call(strTitle, relf.ToString(), DateTime.Now, tmList[j].m_id); } } } else { List <Tunnel.Model.Tunnel_menber> tmList = new List <Tunnel.Model.Tunnel_menber>(); Tunnel.BLL.Tunnel_menber tm = new Tunnel.BLL.Tunnel_menber(); tmList = tm.GetModelList(""); foreach (Tunnel.Model.Tunnel_menber item in tmList) { call(strTitle, relf.ToString(), DateTime.Now, item.m_id); } } #endregion } Tunnel.Common.Message.Show("添加成功!", "VoteItemsAdd.aspx?id=" + relf + ""); } else { Tunnel.Common.Message.Show("添加失败!"); } }
/// <summary> /// 更新一条数据 /// </summary> public void Update(Tunnel.Model.Tunnel_Vote model) { dal.Update(model); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Tunnel.Model.Tunnel_Vote model) { return(dal.Add(model)); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (!string.IsNullOrEmpty(Request.QueryString["id"])) { id = Convert.ToInt32(Request.QueryString["id"].ToString()); Tunnel.BLL.Tunnel_Vote t = new Tunnel.BLL.Tunnel_Vote(); Tunnel.Model.Tunnel_Vote tt = new Tunnel.Model.Tunnel_Vote(); Tunnel.BLL.Tunnel_menber tm = new Tunnel.BLL.Tunnel_menber(); tt = t.GetModel(id); voteTitle = tt.vote_Title; voteUserName = tm.GetModel(Convert.ToInt32(tt.vote_userId)).m_name; voteDate = Convert.ToDateTime(tt.vote_startDate).ToShortDateString(); if (!string.IsNullOrEmpty(tt.vote_mark)) { voteMark = "<img src=../image/info.png width=20px />" + tt.vote_mark; } voteMax = tt.vote_max.ToString(); voteType = tt.vote_Type.ToString(); max.Value = voteMax; tvList = tv.GetModelList("ivote_voteId=" + id + ""); Repeater1.DataSource = tvList; Repeater1.DataBind(); if (voteType == "0") { for (int i = 0; i < Repeater1.Items.Count; i++) { ((CheckBox)Repeater1.Items[i].FindControl("CheckBox1")).Visible = false; } } else { for (int i = 0; i < Repeater1.Items.Count; i++) { ((RadioButton)Repeater1.Items[i].FindControl("RadioButton1")).Visible = false; } } Tunnel.BLL.UserLogin ul = new Tunnel.BLL.UserLogin(); bool b = false; for (int i = 0; i < tvList.Count; i++) { string[] temp = tvList[i].ivote_yesUserId.Split(','); for (int j = 0; j < temp.Length; j++) { if (ul.LoginID.ToString() == temp[j]) { b = true; } } } if (b) { Button1.Text = "查看结果"; } } else { Tunnel.BLL.Tunnel_Vote tv = new Tunnel.BLL.Tunnel_Vote(); List <Tunnel.Model.Tunnel_Vote> tvList = new List <Tunnel.Model.Tunnel_Vote>(); tvList = tv.GetModelList("(getdate()>vote_startDate and getdate()<vote_endDate) and vote_state=0 and vote_top =1 order by vote_startDate desc"); if (tvList.Count > 0) { Response.Redirect("indexvote.aspx?id=" + tvList[0].vote_Id + ""); } } } }
/// <summary> /// 得到一个对象实体 /// </summary> public Tunnel.Model.Tunnel_Vote GetModel(int vote_Id) { SqlParameter[] parameters = { new SqlParameter("@vote_Id", SqlDbType.Int, 4) }; parameters[0].Value = vote_Id; Tunnel.Model.Tunnel_Vote model = new Tunnel.Model.Tunnel_Vote(); DataSet ds = DbHelperSQL.RunProcedure("UP_Tunnel_Vote_GetModel", parameters, "ds"); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["vote_Id"].ToString() != "") { model.vote_Id = int.Parse(ds.Tables[0].Rows[0]["vote_Id"].ToString()); } if (ds.Tables[0].Rows[0]["vote_userId"].ToString() != "") { model.vote_userId = int.Parse(ds.Tables[0].Rows[0]["vote_userId"].ToString()); } model.vote_userGroup = ds.Tables[0].Rows[0]["vote_userGroup"].ToString(); model.vote_bumGroup = ds.Tables[0].Rows[0]["vote_bumGroup"].ToString(); model.vote_jsGroup = ds.Tables[0].Rows[0]["vote_jsGroup"].ToString(); model.vote_Title = ds.Tables[0].Rows[0]["vote_Title"].ToString(); model.vote_mark = ds.Tables[0].Rows[0]["vote_mark"].ToString(); if (ds.Tables[0].Rows[0]["vote_Type"].ToString() != "") { model.vote_Type = int.Parse(ds.Tables[0].Rows[0]["vote_Type"].ToString()); } if (ds.Tables[0].Rows[0]["vote_startDate"].ToString() != "") { model.vote_startDate = DateTime.Parse(ds.Tables[0].Rows[0]["vote_startDate"].ToString()); } if (ds.Tables[0].Rows[0]["vote_endDate"].ToString() != "") { model.vote_endDate = DateTime.Parse(ds.Tables[0].Rows[0]["vote_endDate"].ToString()); } if (ds.Tables[0].Rows[0]["vote_seeType"].ToString() != "") { model.vote_seeType = int.Parse(ds.Tables[0].Rows[0]["vote_seeType"].ToString()); } if (ds.Tables[0].Rows[0]["vote_state"].ToString() != "") { model.vote_state = int.Parse(ds.Tables[0].Rows[0]["vote_state"].ToString()); } if (ds.Tables[0].Rows[0]["vote_max"].ToString() != "") { model.vote_max = int.Parse(ds.Tables[0].Rows[0]["vote_max"].ToString()); } if (ds.Tables[0].Rows[0]["vote_top"].ToString() != "") { model.vote_top = int.Parse(ds.Tables[0].Rows[0]["vote_top"].ToString()); } return(model); } else { return(null); } }