Beispiel #1
0
    protected void Btn_next_Click(object sender, EventArgs e)
    {
        SqlDB myDB = new SqlDB(System.Configuration.ConfigurationSettings.AppSettings["connstr"]);

        string strQuestionMode       = "General";
        string strQuestionGroupID    = Session["GroupID"].ToString();
        string strQuestionDivisionID = "";
        string strPaperID            = "";

        //title update
        hf_Title.Value = TB_SimulatorTitle.Text;
        //update questionIndex and QMode
        clsTextQuestion myText = new clsTextQuestion();

        myText.saveSimulatorQuestion(hf_QID.Value, TB_SimulatorTitle.Text, strPaperID, strQuestionDivisionID, strQuestionGroupID, strQuestionMode);
        //update Question_simulator
        //string strSQL = "SELECT * FROM Question_Simulator WHERE cQID LIKE '" + hf_QID.Value + "'";
        //DataTable dt_update = sqlDB.getDataSet(strSQL).Tables[0];
        //for (int i = 0; i < dt_update.Rows.Count; i++)
        //{
        string strSQL = "UPDATE Question_Simulator SET cContent = @cContent " +
                        "WHERE cQID = '" + hf_QID.Value + "'";

        object[] pList = { hf_Title.Value };
        myDB.ExecuteNonQuery(strSQL, pList);
        //}
        Response.Redirect("Paper_SimulatorQuestionEditor3.aspx?cImg=" + hf_img.Value + "&Title=" + hf_Title.Value + "&QID=" + hf_QID.Value + "");
    }
    protected void Btn_new_Click(object sender, EventArgs e)
    {
        SqlDB myDB = new SqlDB(System.Configuration.ConfigurationSettings.AppSettings["connstr"]);

        //string str_elementtype = "button";
        clsHintsDB sqlDB     = new clsHintsDB();
        string     strSQL    = "SELECT * FROM Question_Simulator_ans WHERE cQuestion_simulator_ID LIKE '" + hf_QID.Value + "'";
        DataTable  dt_Update = sqlDB.getDataSet(strSQL).Tables[0];

        //將此時的ANNOTATION ORDER更新回simulator_ans
        for (int idata = 0; idata < dt_Update.Rows.Count; idata++)
        {
            Label AnsBuff = (Label)this.FindControl("Form1").FindControl("lb_" + idata.ToString());
            for (int i = 0; i < dt_Update.Rows.Count; i++)
            {
                if (dt_Update.Rows[i]["cName"].ToString() == AnsBuff.Text)
                {   //Update order
                    TextBox OrderBuff = (TextBox)this.FindControl("Form1").FindControl("Order_" + idata.ToString());

                    strSQL = "UPDATE Question_Simulator_ans SET cOrder=@cOrder WHERE cQuestion_simulator_ID LIKE @cQuestion_simulator_ID  AND cName LIKE '" + AnsBuff.Text + "'";
                    object[] pList = { OrderBuff.Text, hf_QID.Value };
                    myDB.ExecuteNonQuery(strSQL, pList);
                    //找到就跳開
                    i = dt_Update.Rows.Count;
                }
            }
        }
        //重新讀取新數據(order)
        strSQL = "SELECT * FROM Question_Simulator_ans WHERE cQuestion_simulator_ID LIKE '" + hf_QID.Value + "'";
        DataTable dtbackground = sqlDB.getDataSet(strSQL).Tables[0];
        //建立QID
        DataReceiver myReceiver            = new DataReceiver();
        string       strUserID             = usi.UserID.ToString();
        string       strAnsID              = "Ans_" + myReceiver.getNowTime();
        string       strQuestionMode       = "General";
        string       strQuestionGroupID    = Session["GroupID"].ToString();
        string       strQuestionDivisionID = "";
        string       strPaperID            = "";
        string       strQuestion           = hf_Title.Value;
        string       strOrder              = "";
        string       strSimulatorID        = "";

        //因為hf_img很長 所以只取VM ID的部分
        //if (hf_img.Value == "1111|Internal Medicine|General|1")
        //{
        //    strSimulatorID = "alivsCase201007111917095468750|Internal Medicine|General|1";
        //}
        //else if (hf_img.Value == "2222|Internal Medicine|General|2")
        //{
        //    strSimulatorID = "jeffCase201108171058121942541|Internal Medicine|General|2";
        //}
        //else
        //{
        //}
        //都會走這
        strSimulatorID = hf_img.Value;
        string          strAnswer = "";
        clsTextQuestion myText    = new clsTextQuestion();

        //如果是第一次存要多存一個其他(答錯)
        //換讀取VM Annotation cFindingNum
        strSQL = "SELECT * FROM Question_Simulator WHERE cQID LIKE '" + hf_QID.Value + "'";
        DataTable dt_firstTime = sqlDB.getDataSet(strSQL).Tables[0];

        if (dt_firstTime.Rows.Count == 0)
        {
            string strRAnsID = "RAns_" + myReceiver.getNowTime();
            //VM ID
            myText.saveIntoQuestionSimulator(hf_QID.Value, "其他(答錯)|", "1|", strSimulatorID, strQuestion, strRAnsID);
        }
        //拼出答案和順序
        string[] arr_Delete = hf_Delte.Value.Split('|');
        for (int x = 0; x < dtbackground.Rows.Count; x++)
        {
            strAnswer += dtbackground.Rows[x]["cName"].ToString() + "|";
            if (RB1.Checked == true)
            {
                //有順序
                strOrder += dtbackground.Rows[x]["cOrder"].ToString() + "|";
            }
            else if (RB2.Checked == true)
            {
                strOrder += "1|";
            }
        }

        //save Question

        strSQL = "SELECT * FROM QuestionMode WHERE cQID = '" + hf_QID.Value + "' ";
        // SqlDB myDB = new SqlDB(System.Configuration.ConfigurationSettings.AppSettings["connstr"]);
        DataSet dsCheck = myDB.getDataSet(strSQL);

        if (dsCheck.Tables[0].Rows.Count == 0)
        {//問題只存一次
            myText.saveSimulatorQuestion(hf_QID.Value, strQuestion, strPaperID, strQuestionDivisionID, strQuestionGroupID, strQuestionMode);
        }
        //savE 正確答案 ANS
        //VM ID
        myText.saveIntoQuestionSimulator(hf_QID.Value, strAnswer, strOrder, strSimulatorID, strQuestion, strAnsID);
        //draw the answer table
        pl_ans.Controls.Clear();
        Ansdisplay();
        //刪除記錄中的記錄
        strSQL = "DELETE Question_Simulator_ans WHERE cQuestion_simulator_ID LIKE '" + hf_QID.Value + "'";
        clsHintsDB MLASDB = new clsHintsDB();

        MLASDB.ExecuteNonQuery(strSQL);
        //重新放進原始資料
        //換VM ANNOTATION
        string str_Annotation = "";

        //if (hf_img.Value == "1111|Internal Medicine|General|1")
        //{
        //    str_Annotation = "alivsCase201007111917095468750|Simulation|Simulation|1";
        //}
        //else if (hf_img.Value.Contains("Internal Medicine|General|2"))
        //{
        //    str_Annotation = "jeffCase201108171058121942541|Simulation|Simulation|2";
        //}
        //else
        //{//都會走這
        //    //str_Annotation = hf_img.Value;
        //    str_Annotation = hf_img.Value.Replace("Internal Medicine|General","Simulation|Simulation");
        //}
        str_Annotation = hf_img.Value.Replace("Internal Medicine|General", "Simulation|Simulation");
        string[] str_VMID_O_D_S = str_Annotation.ToString().Split('|');
        strSQL = "SELECT * FROM ItemForVMAnnotations WHERE cCaseID LIKE '" + str_VMID_O_D_S[0].ToString() + "' AND cOrgan LIKE '" + str_VMID_O_D_S[1].ToString() + "' AND cDisease LIKE '" + str_VMID_O_D_S[2].ToString() + "' AND cSlideNum LIKE '" + str_VMID_O_D_S[3].ToString() + "'";
        DataTable dt_load = sqlDB.getDataSet(strSQL).Tables[0];

        //計算出所有的場景ID

        //將所有的場景ID以 同一個QID 各自的ANNOTATION 屬於哪個場景 點擊順序  記錄起來
        for (int i = 0; i < dt_load.Rows.Count; i++)
        {
            //insert
            //SqlDB myDB = new SqlDB(System.Configuration.ConfigurationSettings.AppSettings["connstr"]);
            strSQL = "INSERT INTO Question_Simulator_ans (cQuestion_simulator_ID, cName, cOrder) " +
                     "VALUES ('" + hf_QID.Value + "' , @cName , @cOrder) ";
            object[] pList = { dt_load.Rows[i]["cAnnotationTitle"].ToString(), i + 1 };
            myDB.ExecuteNonQuery(strSQL, pList);
        }
        //init
        hf_Delte.Value = "";
        //draw the edit table
        DataTable dtredraw = new DataTable();

        dtredraw.Columns.Add("name", typeof(string));
        dtredraw.Columns.Add("order", typeof(string));
        //重新讀取資料
        strSQL = "SELECT * FROM Question_Simulator_ans WHERE cQuestion_simulator_ID LIKE '" + hf_QID.Value + "' ";
        DataTable dt_data_temp = sqlDB.getDataSet(strSQL).Tables[0];

        for (int n = 0; n < dt_data_temp.Rows.Count; n++)
        {
            DataRow dr_in = dtredraw.NewRow();
            dr_in["name"]  = dt_data_temp.Rows[n]["cName"].ToString();
            dr_in["order"] = dt_data_temp.Rows[n]["cOrder"].ToString();

            dtredraw.Rows.Add(dr_in);
        }
        PL_table.Controls.Clear();
        if (RB1.Checked == true)
        {
            table_O_display(dtredraw);
        }
        else if (RB2.Checked == true)
        {
            noorderdisplay(dtredraw);
        }
    }