示例#1
0
        /// <summary>
        /// 获取投票信息
        /// </summary>
        /// <param name="context"></param>
        /// <param name="msg"></param>
        /// <param name="P1">ID</param>
        /// <param name="P2"></param>
        /// <param name="strUserName"></param>
        public void GETQYTPMODEL(HttpContext context, Msg_Result msg, string P1, string P2, JH_Auth_UserB.UserInfo UserInfo)
        {
            int Id = 0;

            int.TryParse(P1, out Id);
            SZHL_QYHDN qyhd     = new SZHL_QYHDNB().GetEntity(d => d.ID == Id);
            string     UserISTP = "N";

            //判断当前人是否已投票
            UserISTP = new SZHL_QYHD_ResultB().GetEntities(d => d.HDID == qyhd.ID && d.OptionUser == UserInfo.User.UserName && d.ComId == UserInfo.User.ComId).Count() > 0 ? "Y" : "N";

            if (P2 == "isuser")
            {
                UserISTP = "";
            }

            //选项详细
            DataTable dt = new SZHL_QYHD_ResultB().GetDTByCommand(@"SELECT ID,OptionText FROM SZHL_QYHD_Option  WHERE HDId='" + P1 + @"'");

            msg.Result  = qyhd;
            msg.Result2 = new SZHL_QYHD_ResultB().GetDTByCommand("SELECT COUNT(0),OptionUser FROM SZHL_QYHD_Result WHERE HDId='" + P1 + "' GROUP BY OptionUser,ComId").Rows.Count;
            if (UserISTP == "N")//未投票返回企业投票信息
            {
                msg.Result1 = dt;
            }
            else
            {  //已投票返回投票信息
                dt.Columns.Add("tpr", Type.GetType("System.Object"));
                dt.Columns.Add("num", Type.GetType("System.Object"));
                List <SZHL_QYHD_Result> resultList = new SZHL_QYHD_ResultB().GetEntities(d => d.HDID == Id).ToList();
                foreach (DataRow row in dt.Rows)
                {
                    int opId = 0;
                    int.TryParse(row["ID"].ToString(), out opId);
                    List <string> optionUser = resultList.Where(d => d.OptionID == opId).Select(d => d.OptionUser).ToList();
                    row["tpr"] = optionUser;
                    row["num"] = optionUser.Count;
                }
                msg.Result1 = dt;
                msg.Result3 = resultList.Count;
            }
            msg.Result4 = UserISTP;
            if (qyhd != null && qyhd.EndTime < DateTime.Now)
            {
                qyhd.Status = 1;
            }
        }
示例#2
0
        /// <summary>
        /// 获取投票信息
        /// </summary>
        /// <param name="context"></param>
        /// <param name="msg"></param>
        /// <param name="P1"></param>
        /// <param name="P2"></param>
        /// <param name="strUserName"></param>
        public void TPCOUNTLIST(HttpContext context, Msg_Result msg, string P1, string P2, JH_Auth_UserB.UserInfo UserInfo)
        {
            int Id = 0;

            int.TryParse(P1, out Id);
            DataTable dt = new SZHL_QYHD_ResultB().GetDTByCommand(@"SELECT ID,OptionText FROM SZHL_QYHD_Option  WHERE HDId='" + P1 + @"'");

            dt.Columns.Add("num", Type.GetType("System.Object"));
            dt.Columns.Add("tpr", Type.GetType("System.Object"));
            List <SZHL_QYHD_Result> resultList = new SZHL_QYHD_ResultB().GetEntities(d => d.HDID == Id).ToList();

            foreach (DataRow row in dt.Rows)
            {
                int opId = 0;
                int.TryParse(row["ID"].ToString(), out opId);
                List <string> optionUser = resultList.Where(d => d.OptionID == opId).Select(d => d.OptionUser).ToList();
                row["num"] = optionUser.Count;
                row["tpr"] = optionUser;
            }
            msg.Result  = dt;
            msg.Result1 = resultList.Count;
        }