<%@ Control Language="C#" %>
<%@ Import Namespace="Kesion.Publics" %>
<%@ Import Namespace="Kesion.BLL" %>
<%@ Import Namespace="Kesion.Cache" %>
<%@ Import Namespace="Kesion.HtmlTags" %>
<%@ Import Namespace="Kesion.APPCode" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="Kesion.Course" %>
<script runat="server" type="text/C#">
	dynamic __user = HttpContext.Current.Items["user"];                //初始化用户信息，
	private static dynamic __info = new System.Dynamic.ExpandoObject();   //初始化当前页信息
	bool isLoadPage = true;  //定义页面是否加载
	private int typeId = 0;
	public int tmType = 0;
	protected void Page_Load(object sender, EventArgs e)
	{
		
		typeId = Utils.StrToInt(KSCMS.S("typeid"));
			__info.TxtOrderID = Convert.ToString(Convert.ToInt16(DataFactory.GetOnlyValue("select max(orderid) from [KS_SJType]")) + 1);
			initial();
			if (KSCMS.S("action").Equals("save"))
			{
				SaveChange();
			}
			if (KSCMS.S("do").Equals("modify"))
			{
				initialModify();
			}
			
	}
	private void initialModify()
	{
        string sql = "Select top 1 title as typename, * From KS_SJRndZJ Where id=" + typeId;
        if (KSCMS.S("dtfs") != "3")
        {
            sql = "Select top 1 * From KS_SJTMType Where TypeId=" + typeId;
        }
        using (DataTable dt = DataFactory.GetDataTable(sql))
		{
			if (dt.Rows.Count > 0)
			{
				DataRow dr = dt.Rows[0];
				tmType = Utils.StrToInt(dr["tmType"].ToString());
				__info.TxtTypeName = dr["typename"].ToString();
				__info.TxtIntro = dr["intro"].ToString();
				__info.TxtOrderID = dr["orderid"].ToString();
			}

		}
	}
	protected void SaveChange()
	{
        Utils.TipsDisabled();  //检查是否演示状态
	
		Hashtable ht = new Hashtable();
        if (KSCMS.S("dtfs") == "3")
        {
            ht.Add("title", __info.TxtTypeName);
            ht.Add("intro", __info.TxtIntro);
            ht.Add("orderid", Utils.StrToInt(__info.TxtOrderID));
            CommonData.Update("KS_SJRndZJ", ht, " where id=" + typeId);
        }
        else
        {
            ht.Add("typename", __info.TxtTypeName);
            ht.Add("intro", __info.TxtIntro);
            ht.Add("orderid", Utils.StrToInt(__info.TxtOrderID));
            CommonData.Update("KS_SJTMType", ht, " where typeid=" + typeId);
        }
		Msg.AlertDoFun("恭喜，大题修改成功!","top.location.reload();");
		isLoadPage = false;
		return;
	}
	public void initial()
	{
		__info.TxtTypeName = KSCMS.S("TxtTypeName");
		__info.TxtIntro = KSCMS.S("TxtIntro");
		__info.TxtOrderID = KSCMS.S("TxtOrderID");
		__info.TxtTypeName = KSCMS.S("TxtTypeName");
	}

</script>
<%
    if (!isLoadPage) return;
%>
<div class="t_tybox" style="padding-right: 10px;border: 0;border-bottom: none;box-shadow: none;">
    <form name="myform" action="<%=BasicField.GetUserUrl("SJ/TcSjEditDT","do-"+KSCMS.S("do")) %>" method="post" id="Form1" >
 <input type="hidden" value="save" name="action" />
         <input type="hidden" value="save" name="frame" />
         <input type="hidden" value="<%=KSCMS.S("dtfs") %>" name="dtfs" />
  <input type="hidden" value="<%=KSCMS.S("typeid") %>" name="typeid" />
    <table width="100%" align="center" border="0" cellpadding="0" cellspacing="0" class="border"> 
          
     <tr>
            <td class="lefttd" nowrap>类型名称：</td>
            <td class="tag_left">
              <input name="TxtTypeName" type="text" value="<%=__info.TxtTypeName %>" id="TxtTypeName" class="textbox" />

        </tr>
        <%if (tmType!=6 && tmType!=7){ %>
        <tr>
            <td class="lefttd" nowrap>题目简介：</td>
			<td>
			 <textarea name="TxtIntro" rows="2" cols="20" id="TxtIntro" style="width:100%;height:400px;"><%=__info.TxtIntro %></textarea>          
                    <%Kesion.APPCode.EditorAPI.EchoHead(); %>
               <% Kesion.APPCode.EditorAPI.EchoEditor("editor", "TxtIntro", "Basic");%>               
            </td>
        </tr>
        <%} %>
       
        <tr>
            <td class="lefttd" nowrap>题目序号：</td>
            <td class="tag_left">
			  <input name="TxtOrderID" type="text" value="<%=__info.TxtOrderID %>" id="Text1" class="textbox" style="width:60px;text-align:center" />&nbsp;&nbsp;序号越小排在越前面</td>
        </tr>
      </table>
      <br />
      <div class="cz_btn nofloat" style="width: 280px;margin: auto; padding-top:0; background:none; border-top:0;">
        <span><input type="submit" name="Button1" value="确定修改(O)" id="Button1" accesskey="O" class="button" /></span>
        <span><input type="button" class="button" value="取消关闭(C)" accesskey="C" onclick="closed()" /></span>
      <br />
      </div>
    </form>
    <script>
    	function closed() {
    		//alert(1);
    		//  box.close();
    		top.location.reload();
    	}
        </script>
</div>