Пример #1
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            this.Initiate();

            //接收參數
            this.getParameter();

            //找出此Case有哪一個問卷,取出其PaperID。
            strPaperID = mySQL.getPaperIDFromCase(strCaseID, strClinicNum, strSectionName);

            if (Session["PaperID"] != null)
            {
                strPaperID = Session["PaperID"].ToString();
            }

            //取得此問卷是使用者自行編輯或是系統在呈現題目時才亂數選題
            string  strSQL   = mySQL.getPaperHeader(strPaperID);
            DataSet dsHeader = sqldb.getDataSet(strSQL);

            try
            {
                strGenerationMethod = dsHeader.Tables[0].Rows[0]["cGenerationMethod"].ToString();
            }
            catch
            {
            }
            dsHeader.Dispose();

            //取得該組別的總問題數(依照PresentMethod有不同)
            if (strGenerationMethod == "Edit")
            {
                //取得此General組別尚未被選取的問題數量
                intQuestionNum = myReceiver.getGroupSelectionQuestionCountLevel1NotSelect(strGroupID, strPaperID);
            }
            else
            {
                intQuestionNum = myReceiver.getRandomSelectionQuestionCountLevel1NotSelect(strGroupID, strPaperID);
            }

            if (intQuestionNum <= 0)
            {
                //txtNumber.Disabled = true;
            }
            else
            {
                //txtNumber.Disabled = false;
            }

            //設定Title
            spanMax.InnerText = intQuestionNum.ToString();

            //設定問題難易度的顯示數量
            DataTable dtQuestionLevel = new DataTable();

            dtQuestionLevel = AuthoringTool.QuestionEditLevel.QuestionLevel.QuestionLevelName();
            foreach (DataRow drQuestionLevel in dtQuestionLevel.Rows)
            {
                DataTable dtQuestionLevelNum = new DataTable();
                dtQuestionLevelNum = PaperSystem.DataReceiver.GetQuestionLevelNum(strGroupID);
                string strQuestionLevelName = drQuestionLevel["cLevelName"].ToString();
                int    iQuestionLevel       = AuthoringTool.QuestionEditLevel.QuestionLevel.QuestionLevelName_SELECT_QuestionLevel(strQuestionLevelName);
                Label  lbQuestionLevelName  = new Label();
                lbQuestionLevelName.Text = "&nbsp;" + strQuestionLevelName;
                phQuestionLevel.Controls.Add(lbQuestionLevelName);
                int iQuestionLevelNum = 0;
                foreach (DataRow drQuestionLevelNum in dtQuestionLevelNum.Rows)
                {
                    if (Convert.ToInt16(drQuestionLevelNum["cQuestionLevel"].ToString()) == iQuestionLevel)
                    {
                        iQuestionLevelNum = Convert.ToInt16(drQuestionLevelNum["QuestionLevelNum"].ToString());
                    }
                }
                DropDownList ddlQuestionLevelNum = new DropDownList();
                for (int i = 0; i <= iQuestionLevelNum; i++)
                {
                    ddlQuestionLevelNum.Items.Add(i.ToString());
                }
                ddlQuestionLevelNum.ID = "ddlQuestionLevelNum_" + iQuestionLevel;
                phQuestionLevel.Controls.Add(ddlQuestionLevelNum);
            }


            //設定Finish button的事件
            btnSubmit.ServerClick += new ImageClickEventHandler(btnSubmit_ServerClick);
        }
        /// <summary>
        /// 接收參數
        /// </summary>
        private void getParametor()
        {
            //UserID
            if (Session["UserID"] != null)
            {
                strUserID = Session["UserID"].ToString();
            }
            //strUserID = "swakevin";

            //CaseID
            if (Session["CaseID"] != null)
            {
                strCaseID = Session["CaseID"].ToString();
            }

            //Division
            if (Session["DivisionID"] != null)
            {
                strDivisionID = Session["DivisionID"].ToString();
            }

            //ClinicNum
            if (Session["ClinicNum"] != null)
            {
                strClinicNum = Session["ClinicNum"].ToString();
            }

            //SectionName
            if (Session["SectionName"] != null)
            {
                strSectionName = Session["SectionName"].ToString();
            }

            hfPaperID.Value = "";
            //PaperID
            if (Session["PaperID"] != null)
            {
                strPaperID      = Session["PaperID"].ToString();
                hfPaperID.Value = strPaperID;
            }
            else
            {
                SQLString mySQL = new SQLString();
                strPaperID      = mySQL.getPaperIDFromCase(strCaseID, strClinicNum.ToString(), strSectionName);
                hfPaperID.Value = strPaperID;
            }
            //strPaperID = "wyt20060510150619";

            //Opener
            if (Request.QueryString["Opener"] != null)
            {
                hiddenOpener.Value = Request.QueryString["Opener"].ToString();
            }

            //QuestionMode
            if (Session["QuestionMode"] != null)
            {
                hiddenQuestionMode.Value = Session["QuestionMode"].ToString();
            }
            //hiddenQuestionMode.Value = "General";

            //PresentType
            if (Session["PresentType"] != null)
            {
                hiddenPresentType.Value = Session["PresentType"].ToString();
            }

            //Edit method
            if (Session["EditMode"] != null)
            {
                hiddenEditMode.Value = Session["EditMode"].ToString();
            }

            //bModify
            if (Session["bModify"] != null)
            {
                bModify = Convert.ToBoolean(Session["bModify"]);
            }

            //QID
            if (Request.QueryString["QID"] != null)
            {
                strQID = Request.QueryString["QID"].ToString();

                //把QID的題目內容寫入txtData , txtEdit中
                string strQuestionAnswer = DataReceiver.getTextQuestionContentByQID(strQID);
                if (this.IsPostBack == false)
                {
                    txtQuestionData.Text = strQuestionAnswer.Split('$')[0];
                    txtAnswerData.Text   = strQuestionAnswer.Split('$')[1];
                }
            }
            else
            {
                //建立QID
                DataReceiver myReceiver = new DataReceiver();
                strQID = strUserID + "_" + myReceiver.getNowTime();
            }

            //GroupID
            if (Request.QueryString["GroupID"] != null)
            {
                strGroupID = Request.QueryString["GroupID"].ToString();

                if (Session["GroupID"] != null)
                {
                    Session["GroupID"] = strGroupID;
                }
                else
                {
                    Session.Add("GroupID", strGroupID);
                }
            }


            //GroupDivisionID
            if (strGroupID != null)
            {
                if (strGroupID.Trim().Length > 0)
                {
                    DataReceiver myReceiver = new DataReceiver();
                    strGroupDivisionID = myReceiver.getGroupDivisionID(strGroupID);

                    if (Session["GroupDivisionID"] != null)
                    {
                        Session["GroupDivisionID"] = strGroupDivisionID;
                    }
                    else
                    {
                        Session.Add("GroupDivisionID", strGroupDivisionID);
                    }
                }
            }
        }
        /// <summary>
        /// 接收參數
        /// </summary>
        private void getParametor()
        {
            //UserID
            if (Session["UserID"] != null)
            {
                strUserID = Session["UserID"].ToString();
            }
            //strUserID = "swakevin";

            //CaseID
            if (Session["CaseID"] != null)
            {
                strCaseID          = Session["CaseID"].ToString();
                hiddenCaseID.Value = Session["CaseID"].ToString();
            }

            //Division
            if (Session["DivisionID"] != null)
            {
                strDivisionID = Session["DivisionID"].ToString();
            }

            //ClinicNum
            if (Session["ClinicNum"] != null)
            {
                strClinicNum = Session["ClinicNum"].ToString();
            }

            //SectionName
            if (Session["SectionName"] != null)
            {
                strSectionName = Session["SectionName"].ToString();
            }

            hfPaperID.Value = "";
            //PaperID
            if (Session["PaperID"] != null)
            {
                strPaperID      = Session["PaperID"].ToString();
                hfPaperID.Value = strPaperID;
            }
            else
            {
                SQLString mySQL = new SQLString();
                strPaperID      = mySQL.getPaperIDFromCase(strCaseID, strClinicNum.ToString(), strSectionName);
                hfPaperID.Value = strPaperID;
            }
            //strPaperID = "wyt20060510150619";

            //Opener
            if (Request.QueryString["Opener"] != null)
            {
                hiddenOpener.Value = Request.QueryString["Opener"].ToString();
            }

            //QuestionMode
            if (Session["QuestionMode"] != null)
            {
                hiddenQuestionMode.Value = Session["QuestionMode"].ToString();
            }
            //hiddenQuestionMode.Value = "General";

            //PresentType
            if (Session["PresentType"] != null)
            {
                hiddenPresentType.Value = Session["PresentType"].ToString();
            }

            //Edit method
            if (Session["EditMode"] != null)
            {
                hiddenEditMode.Value = Session["EditMode"].ToString();
            }

            //ModifyType
            if (Session["ModifyType"] != null)
            {
                hiddenModifyType.Value = Session["ModifyType"].ToString();
            }

            //bModify
            if (Session["bModify"] != null)
            {
                bModify = Convert.ToBoolean(Session["bModify"]);
            }

            //PreOpener
            if (Session["PreOpener"] != null)
            {
                if (Request.QueryString["Opener"] != null)
                {
                    if (Request.QueryString["Opener"].ToString() == "Paper_MainPage")
                    {
                        hiddenPreOpener.Value = Session["PreOpener"].ToString();
                    }
                    else
                    {
                        hiddenPreOpener.Value = "";
                    }
                }
            }

            //QID
            if (!IsPostBack)
            {
                Session["TextQuestionQID"] = null;
            }
            if (Request.QueryString["QID"] != null)
            {
                strQID = Request.QueryString["QID"].ToString();
                //把QID的題目內容寫入txtData中
                string strQuestion       = DataReceiver.QuestionAnswer_Question_SELECT_Question(strQID);
                string strQuestionAnswer = DataReceiver.getTextQuestionContentByQID(strQID);
                if (this.IsPostBack == false)
                {
                    txtQuestionData.Text = strQuestion;
                    txtAnswerData.Text   = strQuestionAnswer.Split('$')[1];
                }
            }
            else
            {
                //若不用session把strQID暫存,則postback後會有第二個strQID產生,則特徵listbox會被自動刷新,讀取不到使用者所選的特徵值
                //朱君 2012/12/18
                if (Session["TextQuestionQID"] != null)
                {
                    strQID = Session["TextQuestionQID"].ToString();
                }
                else
                {
                    //建立QID
                    DataReceiver myReceiver = new DataReceiver();
                    strQID = strUserID + "_Q_" + myReceiver.getNowTime();
                    Session["TextQuestionQID"] = strQID;
                }
            }


            //AID
            if (Request.QueryString["AID"] != null)
            {
                //暫存AID以防止PostBack後AID會改變         老詹 2013/09/09
                if (ViewState["TextQuestionAID"] == null)
                {
                    strAID = Request.QueryString["AID"].ToString();
                }
                else
                {
                    strAID = ViewState["TextQuestionAID"].ToString();
                }

                //把QID的題目答案寫入txtEdit中
                string strAnswer = DataReceiver.QuestionAnswer_Answer_SELECT_Answer(strQID, strAID);
                if (this.IsPostBack == false)
                {
                    txtAnswerData.Text = strAnswer;
                }
            }
            else
            {
                //建立AID
                DataReceiver myReceiver = new DataReceiver();
                System.Threading.Thread.Sleep(1000);
                strAID = strUserID + "_A_" + myReceiver.getNowTime();
            }

            //GroupID
            if (Request.QueryString["GroupID"] != null)
            {
                strGroupID             = Request.QueryString["GroupID"].ToString();
                hfGroupID.Value        = strGroupID;
                hfGroupSerialNum.Value = DataReceiver.getQuestionGroupSerialNumByQuestionGroupID(strGroupID).ToString();

                if (Session["GroupID"] != null)
                {
                    Session["GroupID"] = strGroupID;
                }
                else
                {
                    Session.Add("GroupID", strGroupID);
                }
            }
            else
            {
                SQLString sqlstring = new SQLString();
                strGroupID             = sqlstring.GetQuestionGroupIDByQID(strQID);
                hfGroupID.Value        = strGroupID;
                hfGroupSerialNum.Value = DataReceiver.getQuestionGroupSerialNumByQuestionGroupID(strGroupID).ToString();

                if (Session["GroupID"] != null)
                {
                    Session["GroupID"] = strGroupID;
                }
                else
                {
                    Session.Add("GroupID", strGroupID);
                }
            }


            //GroupDivisionID
            if (strGroupID != null)
            {
                if (strGroupID.Trim().Length > 0)
                {
                    DataReceiver myReceiver = new DataReceiver();
                    strGroupDivisionID = myReceiver.getGroupDivisionID(strGroupID);

                    if (Session["GroupDivisionID"] != null)
                    {
                        Session["GroupDivisionID"] = strGroupDivisionID;
                    }
                    else
                    {
                        Session.Add("GroupDivisionID", strGroupDivisionID);
                    }
                }
            }
        }