private void GetCastVote() { POLLONLINEREQ req = new POLLONLINEREQ(); req.dwPollID = ToUInt(Request["id"]); POLLONLINE[] rlt; if (m_Request.Admin.GetPollOnLine(req, out rlt) == REQUESTCODE.EXECUTE_SUCCESS) { if (rlt.Length > 0) { POLLONLINE vote = rlt[0]; voteHeader = "<h1 class='h_title'>投票信息</h1><div class='line'></div><h3 class='text-center'>" + vote.szPollSubject + "</h3>"; uint done = (uint)POLLONLINE.DWVOTESTAT.VOTESTAT_DONE | (uint)POLLONLINE.DWVOTESTAT.VOTESTAT_CLOSED | (uint)POLLONLINE.DWVOTESTAT.VOTESTAT_UNOPEN; bool isDone = (vote.dwVoteStat & done) > 0; voteItems = "<a class='click' onclick='castVote(" + vote.dwPollID + ")'>" + (isDone ? "查看" : "投票") + "</a>"; POLLITEM[] list = vote.PollItems; if (list != null && list.Length > 0) { voteItems = "<div id='vote_" + vote.dwPollID + "'><div class='vote_items'>" + "<p class='grey'>" + vote.szMemo + "</p><ul vote='" + vote.dwPollID + "'>"; for (int i = 0; i < list.Length; i++) { POLLITEM item = list[i]; uint? max = vote.dwTotalUsers * item.dwMaxTickItems; double rate = (double)item.dwVotes / (double)max * 100; voteItems += "<li><label class='" + (isDone ? "grey" : "avail") + "'><input name='vote_" + vote.dwPollID + "' class='vote_item' type='radio' value='" + item.dwItemID + "' style='display:" + (isDone ? "none" : "") + "'/>" + item.szItemName + "</label><div class='progress'><div class='progress-bar progress-bar-success' role='progressbar' aria-valuenow='" + item.dwVotes + "' aria-valuemin='0' aria-valuemax='" + max + "' style='width: " + rate + "%;'>" + item.dwVotes + "</div></div></li>"; } string dt = ToDate(vote.dwBeginDate) + " - " + ToDate(vote.dwEndDate); voteItems += "</ul><div class='grey text-right'>投票日期:" + dt + "</div><div class='text-center'>" + (isDone ? "" : "<input type='button'' class='btn btn-info' value='提交' onclick='castVote(" + vote.dwPollID + ")'/>") + "</div></div></div>"; } } } else { MsgBoxH(m_Request.szErrMsg); } }
//暂未用 private string ToAct(POLLONLINE vote) { string ret = ""; uint open = (uint)POLLONLINE.DWVOTESTAT.VOTESTAT_OPENING; uint done = (uint)POLLONLINE.DWVOTESTAT.VOTESTAT_DONE; if ((vote.dwVoteStat & (open | done)) > 0) { bool isDone = (vote.dwVoteStat & done) > 0; ret += "<a class='click' onclick='castVote(" + vote.dwPollID + ")'>" + (isDone?"查看":"投票") + "</a>"; POLLITEM[] list = vote.PollItems; if (list != null && list.Length > 0) { ret += "<div class='hidden' id='vote_" + vote.dwPollID + "'><div class='vote_items'>" + "<h3>" + vote.szPollSubject + "</h3>" + "<p class='grey'>" + vote.szMemo + "</p>" + "<ul vote='" + vote.dwPollID + "'>"; for (int i = 0; i < list.Length; i++) { POLLITEM item = list[i]; uint? max = vote.dwTotalUsers * item.dwMaxTickItems; double rate = (double)item.dwVotes / (double)max * 100; ret += "<li><label class='" + (isDone?"grey":"avail") + "'><input name='vote_" + vote.dwPollID + "' class='vote_item' type='radio' value='" + item.dwItemID + "' style='display:" + (isDone?"none":"") + "'/>" + item.szItemName + "</label><div class='progress'><div class='progress-bar progress-bar-success' role='progressbar' aria-valuenow='" + item.dwVotes + "' aria-valuemin='0' aria-valuemax='" + max + "' style='width: " + rate + "%;'>" + item.dwVotes + "</div></div></li>"; } string dt = ToDate(vote.dwBeginDate) + " - " + ToDate(vote.dwEndDate); ret += "</ul><div class='grey text-right'>投票日期:" + dt + "</div><div class='text-center'>" + (isDone?"":"<input type='button'' class='btn btn-info cast' value='提交'/>") + "</div></div></div>"; } } else { ret = "<span class='grey'>不能投票</span>"; } return(ret); }
protected void Page_Load(object sender, EventArgs e) { string szName = Request["name"]; string szID = Request["id"]; uint uID = Parse(szID); string szOP = Request["op"]; Response.CacheControl = "no-cache"; if (szOP == null || szOP.ToLower() != "get") { POLLITEM[] itemList = (POLLITEM[])Session["POLLITEM"]; if (itemList == null) { POLLITEM[] ListTemp = new POLLITEM[1]; ListTemp[0] = new POLLITEM(); ListTemp[0].szItemName = szName; Session["POLLITEM"] = ListTemp; } else { POLLITEM temp = new POLLITEM(); temp.szItemName = szName; int len = itemList.Length; bool bAdd = true; ArrayList list = new ArrayList(); for (int i = 0; i < len; i++) { if (szOP == "del") { if (!((szName == itemList[i].szItemName) || (itemList[i].dwItemID != null && uID != 0 && uID == (uint)itemList[i].dwItemID))) { list.Add(itemList[i]); } } else if (itemList[i].szItemName == szName) { bAdd = false; } } if (szOP == "del") { POLLITEM[] itemListNew = new POLLITEM[list.Count]; for (int i = 0; i < list.Count; i++) { itemListNew[i] = new POLLITEM(); POLLITEM tempDel = (POLLITEM)list[i]; itemListNew[i].dwItemID = tempDel.dwItemID; itemListNew[i].szItemName = tempDel.szItemName; } Session["POLLITEM"] = itemListNew; } else { if (bAdd) { POLLITEM[] itemListNew = new POLLITEM[len + 1]; for (int i = 0; i < len; i++) { itemListNew[i] = new POLLITEM(); itemListNew[i] = itemList[i]; } itemListNew[len] = new POLLITEM(); itemListNew[len] = temp; Session["POLLITEM"] = itemListNew; } else { Session["POLLITEM"] = itemList; } } } } POLLITEM[] vtRes = (POLLITEM[])Session["POLLITEM"]; MyString szOut = new MyString(); szOut += "["; for (int i = 0; vtRes != null && i < vtRes.Length; i++) { if (vtRes[i].szItemName != null) { uint uTestItemID = 0; if (vtRes[i].dwItemID != null) { uTestItemID = (uint)vtRes[i].dwItemID; } szOut += "{\"id\":\"" + uTestItemID.ToString() + "\",\"label\": \"" + vtRes[i].szItemName + "\"}"; if (i < vtRes.Length - 1) { szOut += ","; } } } szOut += "]"; Response.Write(szOut); }