Exemplo n.º 1
0
        private void setupCase(string strMethod)
        {
            //清除內容
            dlCase.Items.Clear();

            //建立Case的DropDownList
            string strSQL = "";

            if (strMethod == "Case")
            {
                //By Case
                strSQL = mySQL.getCasePaperList(strPaperID);
            }
            else
            {
                //By Author
                strSQL = mySQL.getAuthorCasePaperList(strPaperID, hiddenAuthor.Value);
            }

            DataSet dsCase = sqldb.getDataSet(strSQL);

            if (dsCase.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < dsCase.Tables[0].Rows.Count; i++)
                {
                    //有資料就把資料加入DropDownList
                    string strText = "";
                    try
                    {
                        strText = dsCase.Tables[0].Rows[i]["cCaseName"].ToString();
                    }
                    catch
                    {
                    }
                    string strValue = "";
                    try
                    {
                        strValue = dsCase.Tables[0].Rows[i]["cCaseID"].ToString();
                    }
                    catch
                    {
                    }
                    ListItem liCase = new ListItem(strText, strValue);
                    dlCase.Items.Add(liCase);
                }

                //加入None
                ListItem liNone = new ListItem("None", "None");
                dlCase.Items.Add(liNone);
            }
            else
            {
                //沒有資料的情形
                ListItem liCase = new ListItem("None", "None");
                dlCase.Items.Add(liCase);
            }
            //設定hiddenCase
            string Value = "";

            if (dsCase.Tables[0].Rows.Count > 0)
            {
                Value = dsCase.Tables[0].Rows[0]["cCaseID"].ToString();
            }
            else
            {
                Value = "None";
            }
            hiddenCase.Value = Value;
            if (Session["CaseID"] != null)
            {
                Session["CaseID"] = Value;
            }
            else
            {
                Session.Add("CaseID", Value);
            }
            dsCase.Dispose();
        }