//保存
        protected void Button_Click(object sender, EventArgs e)
        {
            M_Question    qinfo  = new M_Question();
            M_QuestOption option = new M_QuestOption();

            option.FillByForm(Request);
            if (Qid > 0)
            {
                qinfo = B_Survey.GetQuestion(Qid);
            }
            qinfo.QuestionTitle   = this.TxtQTitle.Text.Trim();
            qinfo.TypeID          = Convert.ToInt32(Request.Form["type_rad"]);
            qinfo.IsNull          = Convert.ToBoolean(Convert.ToInt32(NotNull.SelectedValue));
            qinfo.QuestionContent = Content_T.Text;
            qinfo.Qoption         = JsonConvert.SerializeObject(option);
            if (Qid > 0)
            {
                B_Survey.UpdateQuestion(qinfo);
            }
            else
            {
                qinfo.SurveyID = Sid;
                qinfo.OrderID  = B_Survey.GetMaxOrderID(Sid) + 1;
                int qid = B_Survey.AddQuestion(qinfo);
            }
            function.WriteSuccessMsg("操作成功", "SurveyItemList.aspx?SID=" + Sid);
        }
Exemple #2
0
        public string GetScore(string qid, string qtypeid)
        {
            string result = "";

            if (Convert.ToInt32(qtypeid) != 1)
            {
                result = "";
            }
            else
            {
                M_Question QueMod = new M_Question();
                QueMod = B_Survey.GetQuestion(Convert.ToInt32(qid));
                B_Survey surBll = new B_Survey();
                if (!CheckScore(QueMod.QuestionContent))
                {
                    result = "";
                }
                else
                {
                    //result = "<td colspan='3'>";
                    //result += surBll.GetScore(Convert.ToInt32(qid), Convert.ToInt32(qtypeid)) + "<div><iframe width='400' height='350' id='TbLocation' src='/Plugins/Chart/pie-basic.aspx?Bases=400|400||";
                    //result += "%u4F4D&Datas=" + Server.UrlEncode(surBll.CreateIframe(Convert.ToInt32(qid))) + "' frameborder='0' scrolling='no'></iframe><div><td>";
                }
            }
            return(result);
        }
Exemple #3
0
        public bool AddQuestiony(M_Question m_Question)
        {
            string strSql = "PR_Questiony_Add";

            SqlParameter[] parameter = GetParameters(m_Question);
            return(SqlHelper.ExecuteProc(strSql, parameter));
        }
        // 获取验证文本的具体类型
        public string GetVType(int qid)
        {
            string[]   types   = { "邮箱", "手机号码", "固定电话", "身份证号", "准考证号" };
            M_Question info    = B_Survey.GetQuestion(qid);
            string     tpIndex = info.QuestionContent.Split('|')[1];

            return(types[DataConverter.CLng(tpIndex)]);
        }
Exemple #5
0
        protected void rptResult_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem)
            {
                return;
            }
            M_Question rowv = (M_Question)e.Item.DataItem;

            if (rowv.TypeID >= 3)
            {
                ((HtmlGenericControl)e.Item.FindControl("divTable")).Style["display"] = "none";
                (e.Item.FindControl("ltlTitle") as Literal).Text = rowv.QuestionTitle;
                return;
            }
            GridView      gview   = e.Item.FindControl("gviewOption") as GridView;
            string        options = rowv.QuestionContent;//内容
            List <string> lstopts = new List <string>();

            for (int i = 0; i < options.Split('|').Length; i++)
            {
                lstopts.Add(options.Split('|')[i].Split(':')[0]);
            }

            int    sum    = 0;
            string ratios = "";
            string names  = "";

            gview.RowDataBound += delegate(object s, GridViewRowEventArgs ex)
            {
                int    total  = 0;
                string rate   = "";
                int    papers = B_Survey.GetUsersCnt(rowv.SurveyID);
                if (ex.Row.RowType == DataControlRowType.DataRow)
                {
                    total = B_Survey.GetAnsOptionCount(rowv.QuestionID, ex.Row.DataItem.ToString());
                    (ex.Row.FindControl("ltlTotal") as Literal).Text = total.ToString();
                    sum += total;
                    if (papers == 0)
                    {
                        rate = "未填写";
                    }
                    else
                    {
                        rate = ((float)total / papers).ToString("P");
                    }
                    (ex.Row.FindControl("ltlRate") as Literal).Text = rate;
                    names  += CutContent(ex.Row.DataItem.ToString(), 4) + ",";
                    ratios += total + ",";
                }
                if (ex.Row.RowType == DataControlRowType.Footer)
                {
                    (ex.Row.FindControl("ltlSum") as Literal).Text = papers.ToString();
                }
            };
            gview.DataSource = lstopts;
            gview.DataBind();
        }
Exemple #6
0
        public ActionResult GetQuestion(int quesIndex)
        {
            List <M_Question> ql = QuestionHelper.Questions;

            M_Question q = ql.FirstOrDefault(a => a.Num == quesIndex);

            ViewBag.QuesIndex = quesIndex;
            ViewBag.QuesCount = ql.Count;
            return(View(q));
        }
        protected void Order_B_Click(object sender, EventArgs e)
        {
            DataTable dt = JsonConvert.DeserializeObject <DataTable>(Order_Hid.Value);

            foreach (DataRow dr in dt.Rows)
            {
                M_Question surmod = B_Survey.GetQuestion(DataConverter.CLng(dr["id"]));
                surmod.OrderID = DataConverter.CLng(dr["oid"]);
                B_Survey.UpdateQuestion(surmod);
            }
            MyBind();
        }
        protected void MyBind()
        {
            M_Question qinfo = B_Survey.GetQuestion(Qid);

            if (qinfo != null)
            {
                NotNull.SelectedValue = qinfo.IsNull ? "1" : "0";
                TxtQTitle.Text        = qinfo.QuestionTitle;
                Content_T.Text        = qinfo.QuestionContent;
                Option_Hid.Value      = qinfo.Qoption;
                function.Script(this, "SetRadVal('type_rad'," + qinfo.TypeID + ");");
            }
        }
Exemple #9
0
        private M_Question GetQuestionInfoFromReader(SqlDataReader reader)
        {
            M_Question info = new M_Question();

            info.QuestionID         = DataConverter.CLng(reader["QuestionID"].ToString());
            info.SurveryID          = DataConverter.CLng(reader["SurveryID"].ToString());
            info.TypeID             = DataConverter.CLng(reader["TypeID"].ToString());
            info.QuestionTitle      = reader["QuestionTitle"].ToString();
            info.QuestionContent    = reader["QuestionContent"].ToString();
            info.QuestionCreateTime = DataConverter.CDate(reader["QuestionCreateTime"]);
            info.ManagerID          = DataConverter.CLng(reader["ManagerID"]);
            return(info);
        }
Exemple #10
0
        public static M_Question GetQuestion(int QID)
        {
            string sql = "SELECT * FROM ZL_Question WHERE QID=" + QID;

            using (SqlDataReader rdr = SqlHelper.ExecuteReader(CommandType.Text, sql))
            {
                if (rdr.Read())
                {
                    M_Question info = new M_Question();
                    info = info.GetQuestionFromReader(rdr);
                    return(info);
                }
                else
                {
                    return(null);
                }
            }
        }
Exemple #11
0
 private SqlParameter[] GetParameters(M_Question m_Question)
 {
     SqlParameter[] parameter = new SqlParameter[] {
         new SqlParameter("@QuestionID", SqlDbType.Int, 4),
         new SqlParameter("@SurveryID", SqlDbType.Int, 4),
         new SqlParameter("@TypeID", SqlDbType.Int, 4),
         new SqlParameter("@QuestionTitle", SqlDbType.NVarChar, 255),
         new SqlParameter("@QuestionContent", SqlDbType.Text),
         new SqlParameter("@QuestionCreateTime", SqlDbType.DateTime, 8),
         new SqlParameter("@ManagerID", SqlDbType.Int, 4)
     };
     parameter[0].Value = m_Question.QuestionID;
     parameter[1].Value = m_Question.SurveryID;
     parameter[2].Value = m_Question.TypeID;
     parameter[3].Value = m_Question.QuestionTitle;
     parameter[4].Value = m_Question.QuestionContent;
     parameter[5].Value = m_Question.QuestionCreateTime;
     parameter[6].Value = m_Question.ManagerID;
     return(parameter);
 }
Exemple #12
0
        /// <summary>
        /// 获取问题总分和平均分
        /// </summary>
        /// <param name="qid">问题ID</param>
        /// <param name="qtypeid">问题类型ID</param>
        /// <returns></returns>
        public string GetScore(int qid, int qtypeid)
        {
            double     score = 0;
            M_Question QMod  = new M_Question();

            QMod = B_Survey.GetQuestion(Convert.ToInt32(qid));
            string[]  qConte = QMod.QuestionContent.Split('|');
            string    str    = "select * from ZL_Answer where qid=" + qid;
            DataTable dt     = SqlHelper.ExecuteTable(CommandType.Text, str);

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                for (int j = 0; j < qConte.Length; j++)
                {
                    if (!string.IsNullOrEmpty(qConte[j].Split(':').ToString()) && dt.Rows[i]["AnswerContent"].ToString() == qConte[j].Split(':')[0])
                    {
                        score += Convert.ToDouble(qConte[j].Split(':')[1]);
                    }
                }
            }
            return("总分:" + score.ToString() + " 平均分:" + score / dt.Rows.Count);
        }
Exemple #13
0
        public string CreateIframe(int qid)
        {
            M_Question QMod = new M_Question();

            QMod = B_Survey.GetQuestion(Convert.ToInt32(qid));
            string[]  qConte = QMod.QuestionContent.Split('|');
            string    str    = "select * from ZL_Answer where qid=" + qid;
            DataTable dt     = SqlHelper.ExecuteTable(CommandType.Text, str);
            string    num    = "";
            string    text   = "";

            for (int i = 0; i < qConte.Length; i++)
            {
                DataTable dt1;
                dt.DefaultView.RowFilter = "AnswerContent='" + qConte[i].Split(':')[0] + "'";
                dt1   = dt.DefaultView.ToTable();
                num  += dt1.Rows.Count.ToString() + ",";
                text += qConte[i].Split(':')[0] + ",";
            }
            num  = num.Trim(',');
            text = text.Trim(',');
            return(num + "|" + text);
        }
        protected void Lnk_Click(object sender, GridViewCommandEventArgs e)
        {
            int Id = DataConverter.CLng(e.CommandArgument);

            if (e.CommandName == "Edit")
            {
                Response.Redirect("SurveyItem.aspx?SID=" + Sid + "&QID=" + Id);
            }
            if (e.CommandName == "MovePre")
            {
                M_Question info = B_Survey.GetQuestion(Id);
                if (info.OrderID != B_Survey.GetMinOrderID(info.SurveyID))
                {
                    M_Question Pre       = B_Survey.GetQuestion(B_Survey.PreQusID(info.SurveyID, info.OrderID));
                    int        CurrOrder = info.OrderID;
                    info.OrderID = Pre.OrderID;
                    Pre.OrderID  = CurrOrder;
                    B_Survey.UpdateQuestion(info);
                    B_Survey.UpdateQuestion(Pre);
                }
            }
            if (e.CommandName == "MoveNext")
            {
                M_Question info = B_Survey.GetQuestion(Id);
                if (info.OrderID != B_Survey.GetMaxOrderID(info.SurveyID))
                {
                    M_Question Pre       = B_Survey.GetQuestion(B_Survey.NexQusID(info.SurveyID, info.OrderID));
                    int        CurrOrder = info.OrderID;
                    info.OrderID = Pre.OrderID;
                    Pre.OrderID  = CurrOrder;
                    B_Survey.UpdateQuestion(info);
                    B_Survey.UpdateQuestion(Pre);
                }
            }
            MyBind();
        }
Exemple #15
0
        private static void SetQuestionsByXML()
        {
            List <M_Question> ql = new List <M_Question>();

            XDocument file = XDocument.Load(GetMapPath(QuestionXMLPath));

            // 获取xml文件的根节点
            XElement xmlRoot = file.Root;
            // 获取根节点下的第一级子节点
            IEnumerable <XElement> nodeFirst = xmlRoot.Elements();

            M_Question   q  = null;
            M_QuesOption qo = null;

            foreach (var item in nodeFirst)
            {
                q         = new M_Question();
                q.Num     = int.Parse(item.Element("num").Value);
                q.Content = item.Element("content").Value;
                q.Pic     = item.Element("pic").Value;
                q.Point   = string.IsNullOrEmpty(item.Element("point").Value) ? 0 : int.Parse(item.Element("point").Value);
                q.Options = new List <M_QuesOption>();
                foreach (var node in item.Element("options").Elements())
                {
                    qo         = new M_QuesOption();
                    qo.Num     = node.Element("num").Value;
                    qo.Content = node.Element("content").Value;
                    qo.Point   = int.Parse(node.Element("point").Value);
                    qo.Point   = string.IsNullOrEmpty(node.Element("point").Value) ? 0 : int.Parse(node.Element("point").Value);
                    q.Options.Add(qo);
                }
                ql.Add(q);
            }

            Questions = ql;
        }
Exemple #16
0
        protected void rptReuslt_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem)
            {
                return;
            }
            Repeater   rep  = e.Item.FindControl("rptOption") as Repeater;
            Label      lbl  = e.Item.FindControl("lblTip") as Label;
            M_Question rowv = (M_Question)e.Item.DataItem;

            if (rowv.TypeID > 2)
            {
                rep.Visible = false;
                lbl.Visible = true;
                return;
            }
            lbl.Visible = false;
            string options = rowv.QuestionContent;

            if (options.Length <= 0)
            {
                options = " 暂时没有添加选项内容。。。";
            }
            List <string> lstopts = new List <string>();

            lstopts.AddRange(options.Split('|'));
            int qid = rowv.QuestionID;
            int sid = rowv.SurveyID;

            rep.ItemDataBound += delegate(object obj, RepeaterItemEventArgs ex)
            {
                if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem)
                {
                    return;
                }
                if (ex.Item.DataItem != null)
                {
                    string item     = ex.Item.DataItem.ToString().Split(':')[0];
                    int    count    = surBll.SelectNum(sid, qid, item);
                    int    papers   = surBll.GetQuCount(qid);
                    string strPcent = "";
                    if (papers == 0)
                    {
                        strPcent = "未填写";
                    }
                    else
                    {
                        strPcent = ((float)count / papers).ToString("P");
                    }
                    Image img = ex.Item.FindControl("imgBar") as Image;
                    if (count == 0)
                    {
                        img.Style["Width"] = "0.2%";
                        (ex.Item.FindControl("lblPercent") as Label).Text = "0票/" + strPcent + "<span style='color:green;'>(0分)</span>";
                    }
                    else
                    {
                        img.Style["width"] = strPcent;
                        (ex.Item.FindControl("lblPercent") as Label).Text = count + "票/" + strPcent + "<span style='color:green;'>(分)</span>";//" + (count * score) + "
                    }
                }
            };
            rep.DataSource = lstopts;
            rep.DataBind();
        }
Exemple #17
0
 /*-------------------------问答-------------------------------*/
 public static int AddQuestion(M_Question info)
 {
     return(Sql.insertID(info.TbName, info.GetParameters(), BLLCommon.GetParas(info), BLLCommon.GetFields(info)));
 }
Exemple #18
0
 public bool UpdateQuestion(M_Question m_Question)
 {
     return(dal.UpdateQuestion(m_Question));
 }
Exemple #19
0
 public bool AddQuestiony(M_Question m_Question)
 {
     return(dal.AddQuestiony(m_Question));
 }
Exemple #20
0
 public bool UpdateQuestion(M_Question m_Question)
 {
     SqlParameter[] cmdParams = GetParameters(m_Question);;
     return(SqlHelper.ExecuteProc("PR_Questiony_Update", cmdParams));
 }
Exemple #21
0
 public static bool UpdateQuestion(M_Question info)
 {
     return(Sql.UpdateByIDs(info.TbName, info.PK, info.QuestionID.ToString(), BLLCommon.GetFieldAndPara(info), info.GetParameters()));
 }