MY_DEPART_KKB_XG.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="MY_DEPART_KKB_XG.aspx.cs" Inherits="GSAO.JKGL.MY_DEPART_KKB_XG" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <link href="../css/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <form id="form1" runat="server">
     <table class="tbDefault mt5 mb5" width="900">
        <caption>选课管理_开课班</caption>
       
       
        <tr>
            <td class="tdRight bgEFEFEF" width="100">学年:</td>
            <td class="tdLeft" width="280">
                 <asp:DropDownList ID="ddl_XNM" runat="server" CssClass="dll">
                 </asp:DropDownList>
            </td>
            <td class="tdRight bgEFEFEF" width="100">学期:</td>
            <td class="tdLeft" width="280">
                <asp:DropDownList ID="ddl_XQM" runat="server" CssClass="dll">
                  
                 </asp:DropDownList>
            </td>
        </tr>
         <tr>
            <td class="tdRight bgEFEFEF" width="100">单位:</td>
            <td class="tdLeft" width="280">
                 <asp:DropDownList ID="ddl_YXSM" runat="server" CssClass="ddl" 
                     AutoPostBack="True" onselectedindexchanged="ddl_YXSM_SelectedIndexChanged"   Enabled="false"
                   >
                 </asp:DropDownList>
            </td>
           <td class="tdRight bgEFEFEF" width="100"><font color="red">*</font>课程:</td>
            <td class="tdLeft" width="280">
                <asp:DropDownList ID="ddl_KCKEY" runat="server" CssClass="dll" 
                    AutoPostBack="True" onselectedindexchanged="ddl_KCKEY_SelectedIndexChanged">
                  
                 </asp:DropDownList>
            </td>
        </tr>
        
         <tr>
            <td class="tdRight bgEFEFEF" width="100">课程号:</td>
            <td class="tdLeft" width="280">
                <asp:TextBox ID="tb_KCH" runat="server" CssClass="txt" Width="280"></asp:TextBox>  
            </td>
            <td class="tdRight bgEFEFEF" width="100"><font color="red">*</font>课程名称:</td>
            <td class="tdLeft" width="280">
               <asp:TextBox ID="tb_KCMC" runat="server" CssClass="txt" Width="280"></asp:TextBox>  
            </td>
        </tr>
        
        <tr>
            <td class="tdRight bgEFEFEF" width="100">开课班号:</td>
            <td class="tdLeft" width="280">
                <asp:TextBox ID="tb_KXH" runat="server" CssClass="txt" Width="280"></asp:TextBox>  
            </td>
            <td class="tdRight bgEFEFEF" width="100">授课学时:</td>
            <td class="tdLeft" width="280">
               <asp:TextBox ID="tb_SKXS" runat="server" CssClass="txt" Width="280"></asp:TextBox>  
            </td>
        </tr>
        
         <tr>
            <td class="tdRight bgEFEFEF" width="100">授课对象:</td>
            <td class="tdLeft" width="280">
                <asp:TextBox ID="tb_ZYH" runat="server" CssClass="txt" Width="280"></asp:TextBox>  
            </td>
           <td class="tdRight bgEFEFEF" width="100">实验学时:</td>
            <td class="tdLeft" width="280">
                <asp:TextBox ID="tb_SYXS" runat="server" CssClass="txt" Width="280"></asp:TextBox>  
            </td>
        </tr>
        
        <tr>
            <td class="tdRight bgEFEFEF" width="100">限定人数:</td>
            <td class="tdLeft" width="280">
                <asp:TextBox ID="tb_RSXD" runat="server" CssClass="txt" Width="280"></asp:TextBox>  
            </td>
           <td class="tdRight bgEFEFEF" width="100">上机学时:</td>
            <td class="tdLeft" width="280">
                <asp:TextBox ID="tb_SJXS" runat="server" CssClass="txt" Width="280"></asp:TextBox>  
            </td>
        </tr>
         <tr>
            <td class="tdRight bgEFEFEF" width="100">培养层次:</td>
            <td class="tdLeft" width="280">
                <asp:DropDownList ID="ddl_PYCC" runat="server" CssClass="ddl">
                  
                    <asp:ListItem Value="13">硕士生</asp:ListItem>
                    <asp:ListItem Value="15">博士生</asp:ListItem>
                </asp:DropDownList>
            </td>
           <td class="tdRight bgEFEFEF" width="100">授课方式:</td>
            <td class="tdLeft" width="280">
                <asp:TextBox ID="tb_SKFS" runat="server" CssClass="txt" Width="280"></asp:TextBox>  
            </td>
        </tr>
        <tr>
          
           <td class="tdRight bgEFEFEF" width="100"> 授课教师:</td>
            <td class="tdLeft" width="280">
                <%--<asp:TextBox ID="tb_SKJGH" runat="server" CssClass="txt" Width="280"></asp:TextBox>--%>
                <asp:GridView ID="gv_SZ_DWJHGW_JG" runat="server" CssClass="tbGvw" Width="99%"  
                AutoGenerateColumns="false"     BorderStyle="Solid"  BorderWidth="1" 
                BorderColor="Silver" onrowcommand="gv_SZ_DWJHGW_JG_RowCommand" onrowdatabound="gv_SZ_DWJHGW_JG_RowDataBound">
                    <RowStyle HorizontalAlign="Center" Wrap="False" Height="25px" ></RowStyle>
                    <HeaderStyle Font-Bold="True" HorizontalAlign="Center" Height="23px" ForeColor="Black" BackColor="White" Wrap="False" ></HeaderStyle>
                    <Columns>
                        <asp:BoundField DataField="SZ_DWJHGW_JG_KEY"  HeaderText="SZ_DWJHGW_JG_KEY" />
                        <asp:BoundField DataField="DS_KEY" HeaderText="DS_KEY"  />
                        <asp:TemplateField HeaderText="删除" ItemStyle-Width="40px">
                        <ItemTemplate>
                            <asp:ImageButton id="btn_select" CommandArgument ="<%#  gv_SZ_DWJHGW_JG.Rows.Count %>" CommandName="delete1" runat="server" ImageUrl="../images/icon_delete.gif"
                            ImageAlign="Baseline" AlternateText="选择"></asp:ImageButton>
                        </ItemTemplate>
                        </asp:TemplateField>                                                
                        <asp:BoundField DataField="VID" HeaderText="VID" ItemStyle-Width="60px" />
                        <asp:BoundField DataField="XM" HeaderText="授课教师" ItemStyle-Width="100px" />
                    </Columns>                                                
                </asp:GridView>   
            </td>
            <td class="tdLeft" colspan="2">
                <asp:Button ID="btn_kkb_show" runat="server" Text="选择授课教师" CssClass="btnStyle" onclick="btn_kkb_show_Click" />

                <div  class="div_main" id="div_kkb_select" visible="false"  style="width:600px;left:30%;  position: absolute; top: 20%;z-index:999;" runat="server">
                    <table class="tbDefault" width="600" >
                    <tr>
                        <td class="tdRight bgEFEFEF" width="120">姓名:</td>
                        <td class="tdLeft">
                            <asp:TextBox ID="tb_ds_name" runat="server" CssClass="txt mr10"  ></asp:TextBox>
                            <asp:Button ID="btn_search_stuaa" runat="server" Text="查询授课教师" CssClass="btnStyle mr10" onclick="btn_search_stuaa_Click" />
                            <asp:button id="btn_exit" runat="server" Width="60px" Text="退 出" CssClass="btnStyle" onclick="btn_exit_Click"   ></asp:button>
                        </td>
                    </tr>
                    </table>
                    <div style="width:600px;height:300px;overflow:auto; float:left; text-align:left"> 
                        <asp:GridView ID="gv_ds" runat="server" CssClass="tbGvw" Width="100%"  HorizontalAlign="Left" AutoGenerateColumns="false"     BorderStyle="Solid"  BorderWidth="1" BorderColor="Silver" onrowcommand="gv_ds_RowCommand" onrowdatabound="gv_ds_RowDataBound" >
                            <RowStyle HorizontalAlign="Center" Wrap="False" Height="25px" ></RowStyle>
                            <HeaderStyle Font-Bold="True" HorizontalAlign="Center" Height="23px" ForeColor="Black" BackColor="White" Wrap="False" ></HeaderStyle>
                            <Columns>
                                <asp:TemplateField HeaderText="选择" ItemStyle-Width="60px">
                                    <ItemTemplate>
                                        <asp:ImageButton id="btn_select" CommandArgument ="<%#  gv_ds.Rows.Count %>" CommandName="select1" runat="server" ImageUrl="../images/icon_check.gif" ImageAlign="Baseline" AlternateText="选择"></asp:ImageButton>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:BoundField DataField="DS_KEY" HeaderText="DS_KEY" />                                                
                                <asp:BoundField DataField="JGH" HeaderText="VID" />
                                <asp:BoundField DataField="XM" HeaderText="授课教师" />
                            </Columns>                                                
                        </asp:GridView>
                    </div>     
                </div>     
            </td>
        </tr>
       
         <tr>
            <td class="tdRight bgEFEFEF" width="100" >培养目标:</td>
            <td class="tdLeft"   colspan="3">
                <asp:TextBox ID="tb_PYMB" runat="server" CssClass="textarea f12"  Width="680" Height="100"  TextMode="MultiLine" ></asp:TextBox>
            </td>
          
        </tr>
        
         <tr>
            <td class="tdRight bgEFEFEF" width="100" >课程教学基本要求:</td>
            <td class="tdLeft"   colspan="3">
                <asp:TextBox ID="tb_KCJXJBYQ" runat="server" CssClass="textarea f12"  Width="680" Height="100"  TextMode="MultiLine" ></asp:TextBox>
            </td>
          
        </tr>
        
         <tr>
            <td class="tdRight bgEFEFEF" width="100" >课程教学大纲:</td>
            <td class="tdLeft"   colspan="3">
                <asp:TextBox ID="tb_KCJXDG" runat="server" CssClass="textarea f12"  Width="680" Height="100"  TextMode="MultiLine" ></asp:TextBox>
            </td>
          
        </tr>
         <tr>
            <td class="tdRight bgEFEFEF" width="100" >当前状态:</td>
            <td class="tdLeft"   colspan="3">
                 <asp:DropDownList ID="ddl_YXBZ" runat="server" CssClass="ddl">
                    <asp:ListItem Value="1">已保存</asp:ListItem>
                    <asp:ListItem Value="2">开始选课</asp:ListItem>
                     <asp:ListItem Value="3">结束选课</asp:ListItem>
                </asp:DropDownList>
            </td>
          
        </tr>
        
         <tr>
            <td class="tdRight bgEFEFEF" width="100" >选修学生:</td>
            <td class="tdLeft"   colspan="3">
                <asp:GridView ID="GridView1" runat="server" CssClass="tbGvw" Width="500"  
          AutoGenerateColumns="false"     BorderStyle="Solid"  BorderWidth="1" 
           BorderColor="Silver"      
           onrowdatabound="GridView1_RowDataBound" 
         
           >
          
        <HeaderStyle CssClass="tbHeader" />
        <RowStyle HorizontalAlign="Center" Wrap="False" Height="25px" ></RowStyle>
        <Columns>
         <asp:BoundField DataField="XK_KEY" HeaderText="ID不显示" />
               
         <asp:BoundField HeaderText="学号"  ItemStyle-Width="100px" ItemStyle-HorizontalAlign="Center" DataField="XH"/>
         <asp:BoundField HeaderText="学生姓名"  ItemStyle-Width="100px" ItemStyle-HorizontalAlign="Center" DataField="XM"/>
            </Columns>
          
      </asp:GridView>
            </td>
          
        </tr>
        
         <tr>
            <td colspan="4">
                <asp:Button ID="btn_save" runat="server" Text="保存" CssClass="btnStyle mr10" 
                    onclick="btn_save_Click" />
               
                <input id="btn_back" type="button" value="返回" class="btnStyle" onclick="javascript:history.back();" /></td>
        </tr>
      </table>
    </form>
</body>
</html>
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace GSAO.JKGL
{
    public partial class MY_DEPART_KKB_XG : System.Web.UI.Page
    {
        protected System.Data.DataTable dt_SZ_DWJHGW_JG = new DataTable("SZ_DWJHGW_JG");
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.IsPostBack)
            {
                Bind_ddl_XNM();
                Bind_ddl_XQM();
                Bind_ddl_YXSM();
                Init_Data();
                Bind_gv();
                try
                {
                    if (this.Request.QueryString["showonly"].ToString() == "true")
                    {
                        Readonly_All();
                    }
                }
                catch
                { }
            }
        }

        #region 选择导师
        /// <summary>
        /// 选择导师(弹出层)
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btn_kkb_show_Click(object sender, EventArgs e)
        {
            this.div_kkb_select.Visible = true;
        }

        /// <summary>
        /// 查询
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btn_search_stuaa_Click(object sender, EventArgs e)
        {
            DataSet ds_JW_XSXJXX = DAL_GSAO_SZGW.DbHelperSQL_GSAO.Query("select DS_KEY,JGH,XM from JW_DSXX where XM like '%" + tb_ds_name.Text + "%'");
            gv_ds.DataSource = ds_JW_XSXJXX;
            gv_ds.DataBind();
        }

        /// <summary>
        /// 退出
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btn_exit_Click(object sender, EventArgs e)
        {
            this.div_kkb_select.Visible = false;
        }


        protected void gv_ds_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                e.Row.Attributes.Add("onmouseover", "if(this.style.backgroundColor!='#ffffd0'){this.oldcolor=this.style.backgroundColor;this.style.backgroundColor='#c4e4ff';}");
                e.Row.Attributes.Add("onmouseout", "if(this.style.backgroundColor!='#ffffd0')this.style.backgroundColor=this.oldcolor;");
                e.Row.Attributes.Add("onmousedown", "if(this.style.backgroundColor=='#ffffd0')this.style.backgroundColor='white';else this.style.backgroundColor='#ffffd0';");
            }
            if ((e.Row.RowType == DataControlRowType.DataRow) || (e.Row.RowType == DataControlRowType.Header) || (e.Row.RowType == DataControlRowType.Footer))
            {
                e.Row.Cells[1].Visible = false;
            }
        }

        /// <summary>
        ///选择导师
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void gv_ds_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "select1")
            {
                int nIdx = Convert.ToInt32(e.CommandArgument.ToString());
                GridViewRow row = gv_ds.Rows[nIdx];
                this.dt_SZ_DWJHGW_JG = (System.Data.DataTable)ViewState["SZ_DWJHGW_JG"];
                this.dt_SZ_DWJHGW_JG.Rows.Add(dt_SZ_DWJHGW_JG.NewRow());
                this.dt_SZ_DWJHGW_JG.Rows[this.dt_SZ_DWJHGW_JG.Rows.Count - 1]["SZ_DWJHGW_JG_KEY"] = dt_SZ_DWJHGW_JG.Rows.Count.ToString();
                this.dt_SZ_DWJHGW_JG.Rows[this.dt_SZ_DWJHGW_JG.Rows.Count - 1]["DS_KEY"] = row.Cells[1].Text; ;
                this.dt_SZ_DWJHGW_JG.Rows[this.dt_SZ_DWJHGW_JG.Rows.Count - 1]["VID"] = row.Cells[2].Text;
                this.dt_SZ_DWJHGW_JG.Rows[this.dt_SZ_DWJHGW_JG.Rows.Count - 1]["XM"] = row.Cells[3].Text;

                ViewState["SZ_DWJHGW_JG"] = dt_SZ_DWJHGW_JG;

                Bind_gv_SZ_DWJHGW_JG();

                this.div_kkb_select.Visible = false;
            }
        }
        #endregion

        #region 绑定授课老师
        protected void InitDataTable_SZ_DWJHGW_JG()
        {
            this.dt_SZ_DWJHGW_JG.Columns.Add("SZ_DWJHGW_JG_KEY");
            this.dt_SZ_DWJHGW_JG.Columns.Add("DS_KEY");
            this.dt_SZ_DWJHGW_JG.Columns.Add("VID");
            this.dt_SZ_DWJHGW_JG.Columns.Add("XM");
            ViewState["SZ_DWJHGW_JG"] = dt_SZ_DWJHGW_JG;
        }

        private void Bind_gv_SZ_DWJHGW_JG()
        {
            this.dt_SZ_DWJHGW_JG = (System.Data.DataTable)ViewState["SZ_DWJHGW_JG"];
            this.gv_SZ_DWJHGW_JG.DataSource = dt_SZ_DWJHGW_JG;
            this.gv_SZ_DWJHGW_JG.DataBind();
        }

        protected void gv_SZ_DWJHGW_JG_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                e.Row.Attributes.Add("onmouseover", "if(this.style.backgroundColor!='#ffffd0'){this.oldcolor=this.style.backgroundColor;this.style.backgroundColor='#c4e4ff';}");
                e.Row.Attributes.Add("onmouseout", "if(this.style.backgroundColor!='#ffffd0')this.style.backgroundColor=this.oldcolor;");
                e.Row.Attributes.Add("onmousedown", "if(this.style.backgroundColor=='#ffffd0')this.style.backgroundColor='white';else this.style.backgroundColor='#ffffd0';");
            }
            if ((e.Row.RowType == DataControlRowType.DataRow) || (e.Row.RowType == DataControlRowType.Header) || (e.Row.RowType == DataControlRowType.Footer))
            {
                e.Row.Cells[0].Visible = false;
                e.Row.Cells[1].Visible = false;
            }
        }

        protected void gv_SZ_DWJHGW_JG_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "delete1")
            {
                int nIdx = Convert.ToInt32(e.CommandArgument.ToString());
                GridViewRow row = this.gv_SZ_DWJHGW_JG.Rows[nIdx];
                string id = row.Cells[0].Text;
                dt_SZ_DWJHGW_JG = new DataTable("SZ_DWJHGW_JG");
                this.dt_SZ_DWJHGW_JG.Columns.Add("SZ_DWJHGW_JG_KEY");
                this.dt_SZ_DWJHGW_JG.Columns.Add("DS_KEY");
                this.dt_SZ_DWJHGW_JG.Columns.Add("VID");
                this.dt_SZ_DWJHGW_JG.Columns.Add("XM");
                for (int i = 0; i < this.gv_SZ_DWJHGW_JG.Rows.Count; i++)
                {
                    if (gv_SZ_DWJHGW_JG.Rows[i].Cells[0].Text != id)
                    {
                        this.dt_SZ_DWJHGW_JG.Rows.Add(dt_SZ_DWJHGW_JG.NewRow());
                        int add_one = 1 + i;
                        this.dt_SZ_DWJHGW_JG.Rows[this.dt_SZ_DWJHGW_JG.Rows.Count - 1]["SZ_DWJHGW_JG_KEY"] = add_one.ToString();
                        this.dt_SZ_DWJHGW_JG.Rows[this.dt_SZ_DWJHGW_JG.Rows.Count - 1]["DS_KEY"] = gv_SZ_DWJHGW_JG.Rows[i].Cells[1].Text;
                        this.dt_SZ_DWJHGW_JG.Rows[this.dt_SZ_DWJHGW_JG.Rows.Count - 1]["VID"] = gv_SZ_DWJHGW_JG.Rows[i].Cells[3].Text;
                        this.dt_SZ_DWJHGW_JG.Rows[this.dt_SZ_DWJHGW_JG.Rows.Count - 1]["XM"] = gv_SZ_DWJHGW_JG.Rows[i].Cells[4].Text;
                    }
                }
                ViewState["SZ_DWJHGW_JG"] = dt_SZ_DWJHGW_JG;
                Bind_gv_SZ_DWJHGW_JG();
            }
        }
        #endregion

        protected void Readonly_All()
        {
            this.ddl_KCKEY.Enabled = false;
            this.ddl_PYCC.Enabled = false;
            this.ddl_XNM.Enabled = false;
            this.ddl_XQM.Enabled = false;
            this.ddl_YXBZ.Enabled = false;
            this.ddl_YXSM.Enabled = false;
            this.tb_KCH.Enabled = false;
            this.tb_KCJXDG.Enabled = false;
            this.tb_KCJXJBYQ.Enabled = false;
            this.tb_KCMC.Enabled = false;
            this.tb_KXH.Enabled = false;
            this.tb_PYMB.Enabled = false;
            this.tb_RSXD.Enabled = false;
            this.tb_SJXS.Enabled = false;
            this.tb_SKFS.Enabled = false;
            //this.tb_SKJGH.Enabled = false;
            this.tb_SKXS.Enabled = false;
            this.tb_SYXS.Enabled = false;
            this.tb_ZYH.Enabled = false;
            this.btn_save.Visible = false;

            btn_kkb_show.Visible = false;
            gv_SZ_DWJHGW_JG.Columns[2].Visible = false;
        }
        private void Bind_gv()
        {
            string KKXX_KEY = this.Request.QueryString["KKXX_KEY"].ToString();
            string where = "  KSKCKEY=" + KKXX_KEY+" order by XH";
            DAL_GSAO_JW.Controller.JX_XSXK C_JX_XSXK = new DAL_GSAO_JW.Controller.JX_XSXK();
            DataSet ds = C_JX_XSXK.GetList(where);
            this.GridView1.DataSource = ds.Tables[0];
            this.GridView1.DataBind();
        }
        protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                e.Row.Attributes.Add("onmouseover", "if(this.style.backgroundColor!='#ffffd0'){this.oldcolor=this.style.backgroundColor;this.style.backgroundColor='#c4e4ff';}");
                e.Row.Attributes.Add("onmouseout", "if(this.style.backgroundColor!='#ffffd0')this.style.backgroundColor=this.oldcolor;");
                e.Row.Attributes.Add("onmousedown", "if(this.style.backgroundColor=='#ffffd0')this.style.backgroundColor='white';else this.style.backgroundColor='#ffffd0';");
            }
            if ((e.Row.RowType == DataControlRowType.DataRow) || (e.Row.RowType == DataControlRowType.Header) || (e.Row.RowType == DataControlRowType.Footer))
            {
                e.Row.Cells[0].Visible = false;
            }

        }
        protected void Init_Data()
        {
            string KKXX_KEY = this.Request.QueryString["KKXX_KEY"].ToString();
            DAL_GSAO_JW.Controller.JX_KKXX C_JX_KKXX = new DAL_GSAO_JW.Controller.JX_KKXX();
            DAL_GSAO_JW.Entities.JX_KKXX E_JX_KKXX = C_JX_KKXX.GetModel(int.Parse(KKXX_KEY));
            this.ddl_PYCC.SelectedIndex = -1;
            this.ddl_PYCC.Items.FindByValue(E_JX_KKXX.PYCCM.ToString()).Selected = true;

            this.ddl_XNM.SelectedIndex = -1;
            this.ddl_XNM.Items.FindByValue(E_JX_KKXX.XNM.ToString()).Selected = true;

            this.ddl_XQM.SelectedIndex = -1;
            this.ddl_XQM.Items.FindByValue(E_JX_KKXX.XQM.ToString()).Selected = true;

            this.ddl_YXBZ.SelectedIndex = -1;
            this.ddl_YXBZ.Items.FindByValue(E_JX_KKXX.YXBZ.ToString()).Selected = true;

            this.ddl_YXSM.SelectedIndex = -1;
            this.ddl_YXSM.Items.FindByValue(E_JX_KKXX.JXDWH).Selected = true;

            Bind_ddl_KCKEY();

            this.ddl_KCKEY.SelectedIndex = -1;
            this.ddl_KCKEY.Items.FindByValue(E_JX_KKXX.KCKEY.ToString()).Selected = true;

            this.tb_KCH.Text = E_JX_KKXX.KCH;
            this.tb_KCJXDG.Text = E_JX_KKXX.KCJXDG;
            this.tb_KCJXJBYQ.Text = E_JX_KKXX.KCJXJBYQ;
            this.tb_KCMC.Text = E_JX_KKXX.KCMC;
            this.tb_KXH.Text = E_JX_KKXX.KXH;
            this.tb_PYMB.Text = E_JX_KKXX.PYMB;
            this.tb_RSXD.Text = E_JX_KKXX.RSXD.ToString();
            this.tb_SJXS.Text = E_JX_KKXX.SJXS.ToString();
            this.tb_SKFS.Text = E_JX_KKXX.SKFS;
            //this.tb_SKJGH.Text = E_JX_KKXX.SKJGH;
            this.tb_SKXS.Text = E_JX_KKXX.SKXS.ToString();
            this.tb_SYXS.Text = E_JX_KKXX.SYXS.ToString();
            this.tb_ZYH.Text = E_JX_KKXX.ZYH;

            //授课教师
            InitDataTable_SZ_DWJHGW_JG();
            DAL_GSAO_JW.Controller.JX_KKXX_JS C_JX_KKXX_JS = new DAL_GSAO_JW.Controller.JX_KKXX_JS();
            DataTable dt_JX_KKXX_JS = C_JX_KKXX_JS.GetList("KKXX_KEY=" + KKXX_KEY).Tables[0];
            if (dt_JX_KKXX_JS.Rows.Count>0)
            {
                this.dt_SZ_DWJHGW_JG = (System.Data.DataTable)ViewState["SZ_DWJHGW_JG"];
                for (int i = 0; i < dt_JX_KKXX_JS.Rows.Count; i++)
                {
                    this.dt_SZ_DWJHGW_JG.Rows.Add(dt_SZ_DWJHGW_JG.NewRow());
                    this.dt_SZ_DWJHGW_JG.Rows[this.dt_SZ_DWJHGW_JG.Rows.Count - 1]["SZ_DWJHGW_JG_KEY"] = i+1;
                    this.dt_SZ_DWJHGW_JG.Rows[this.dt_SZ_DWJHGW_JG.Rows.Count - 1]["DS_KEY"] = dt_JX_KKXX_JS.Rows[i]["DS_KEY"].ToString(); ;
                    this.dt_SZ_DWJHGW_JG.Rows[this.dt_SZ_DWJHGW_JG.Rows.Count - 1]["VID"] = dt_JX_KKXX_JS.Rows[i]["JGH"].ToString(); ;
                    this.dt_SZ_DWJHGW_JG.Rows[this.dt_SZ_DWJHGW_JG.Rows.Count - 1]["XM"] = dt_JX_KKXX_JS.Rows[i]["XM"].ToString(); ;
                }
                ViewState["SZ_DWJHGW_JG"] = dt_SZ_DWJHGW_JG;
                Bind_gv_SZ_DWJHGW_JG();
            }
        }
        protected void Bind_ddl_XNM()
        {
            this.ddl_XNM.DataSource = DAL_GSAO_SZGW.DbHelperSQL_GSAO.Query("select * from TB_XN order by ZT_FLG desc").Tables[0];
            this.ddl_XNM.DataTextField = "XNMC";
            this.ddl_XNM.DataValueField = "XNM";
            this.ddl_XNM.DataBind();
        }

        protected void Bind_ddl_XQM()
        {
            this.ddl_XQM.DataSource = DAL_GSAO_SZGW.DbHelperSQL_GSAO.Query("select * from TB_XQ order by ZT_FLG desc").Tables[0];
            this.ddl_XQM.DataTextField = "XQMC";
            this.ddl_XQM.DataValueField = "XQM";
            this.ddl_XQM.DataBind();
        }

        protected void Bind_ddl_YXSM()
        {
            string ldap_account = Session["ldap_account"].ToString();
            if (ldap_account == "zjcai" || ldap_account == "linyq")
                this.ddl_YXSM.DataSource = DAL_GSAO_SZGW.DbHelperSQL_GSAO.Query("select * from TB_YXS   order by YXSMC asc").Tables[0];
            else
                this.ddl_YXSM.DataSource = DAL_GSAO_SZGW.DbHelperSQL_GSAO.Query("select * from TB_YXS where YXSM in (select YXSM from XTB_YHDYYXS where vid=" + Session["vid"].ToString() + ") order by YXSMC asc").Tables[0];
            this.ddl_YXSM.DataTextField = "YXSMC";
            this.ddl_YXSM.DataValueField = "YXSM";
            this.ddl_YXSM.DataBind();
        }
        protected void Bind_ddl_KCKEY()
        {
            this.ddl_KCKEY.DataSource = DAL_GSAO_SZGW.DbHelperSQL_GSAO.Query("select * from JW_KCXX where YXSM=" + ddl_YXSM.SelectedValue).Tables[0];
            this.ddl_KCKEY.DataTextField = "KCMC";
            this.ddl_KCKEY.DataValueField = "KC_KEY";
            this.ddl_KCKEY.DataBind();
        }
        protected void Bind_KCKEY_Info()
        {
            DAL_GSAO_JW.Controller.JW_KCXX C_JW_KCXX = new DAL_GSAO_JW.Controller.JW_KCXX();
            DAL_GSAO_JW.Entities.JW_KCXX E_JW_KCXX = C_JW_KCXX.GetModel(int.Parse(ddl_KCKEY.SelectedValue));
            this.tb_KCH.Text = E_JW_KCXX.KCH;
            this.tb_KCMC.Text = E_JW_KCXX.KCMC;
            this.tb_SKXS.Text = E_JW_KCXX.ZXS.ToString();
        }
        protected void btn_save_Click(object sender, EventArgs e)
        {
            string from = " MY_DEPART_KKB.aspx";
            try
            {
                from = this.Request.QueryString["from"].ToString();
            }
            catch
            { }
            if (this.tb_KCMC.Text == "")
            {
                Common_GSAO.Tools.ShowAlert("-*-不能为空!");
                return;
            }

            //授课教师
            string XM_All = "";
            if (gv_SZ_DWJHGW_JG.Rows.Count > 0)
            {
                for (int i = 0; i < this.gv_SZ_DWJHGW_JG.Rows.Count; i++)
                {
                    if (XM_All != "")
                        XM_All += "," + gv_SZ_DWJHGW_JG.Rows[i].Cells[4].Text;
                    else
                        XM_All += gv_SZ_DWJHGW_JG.Rows[i].Cells[4].Text;
                }
            }
            else
            {
                Common_GSAO.Tools.ShowAlert("授课教师不能为空!");
                return;
            }

            string KKXX_KEY = this.Request.QueryString["KKXX_KEY"].ToString();
            DAL_GSAO_JW.Controller.JX_KKXX C_JX_KKXX = new DAL_GSAO_JW.Controller.JX_KKXX();
            DAL_GSAO_JW.Entities.JX_KKXX E_JX_KKXX = C_JX_KKXX.GetModel(int.Parse(KKXX_KEY));
            E_JX_KKXX.JXDWH = this.ddl_YXSM.SelectedValue;
            E_JX_KKXX.JXDWMC = this.ddl_YXSM.SelectedItem.Text;
            E_JX_KKXX.KCH = this.tb_KCH.Text;
            E_JX_KKXX.KCJXDG = this.tb_KCJXDG.Text;
            E_JX_KKXX.KCJXJBYQ = this.tb_KCJXJBYQ.Text;
            E_JX_KKXX.KCKEY = int.Parse(this.ddl_KCKEY.SelectedValue);
            E_JX_KKXX.KCMC = this.tb_KCMC.Text;
            E_JX_KKXX.KXH = this.tb_KXH.Text;
            E_JX_KKXX.PYCCM = int.Parse(this.ddl_PYCC.SelectedValue);
            E_JX_KKXX.PYMB = this.tb_PYMB.Text;
            try
            {
                E_JX_KKXX.RSXD = int.Parse(this.tb_RSXD.Text);
            }
            catch
            {
                E_JX_KKXX.RSXD = 0;
            }
            try
            {
                E_JX_KKXX.SJXS = int.Parse(this.tb_SJXS.Text);
            }
            catch
            {
                E_JX_KKXX.SJXS = 0;
            }
            E_JX_KKXX.SKFS = this.tb_SKFS.Text;

            //授课教师教工号
            //E_JX_KKXX.SKJGH = this.tb_SKJGH.Text;
            E_JX_KKXX.SKJGH = XM_All;

            try
            {
                E_JX_KKXX.SKXS = int.Parse(this.tb_SKXS.Text);
            }
            catch
            {
                E_JX_KKXX.SKXS = 0;
            }
            try
            {
                E_JX_KKXX.SYXS = int.Parse(this.tb_SYXS.Text);
            }
            catch
            {
                E_JX_KKXX.SYXS = 0;
            }
            E_JX_KKXX.XNM = int.Parse(this.ddl_XNM.SelectedValue);
            E_JX_KKXX.XQM = int.Parse(this.ddl_XQM.SelectedValue);
            E_JX_KKXX.XXKCH = "";
            E_JX_KKXX.XZLX = 1;//限制到人
            E_JX_KKXX.YXBZ = int.Parse(this.ddl_YXBZ.SelectedValue);
            E_JX_KKXX.ZYH = this.tb_ZYH.Text;
            C_JX_KKXX.Update(E_JX_KKXX);

            //添加授课教师
            DAL_GSAO_JW.Entities.JX_KKXX_JS E_JX_KKXX_JS = new DAL_GSAO_JW.Entities.JX_KKXX_JS();
            DAL_GSAO_JW.Controller.JX_KKXX_JS C_JX_KKXX_JS = new DAL_GSAO_JW.Controller.JX_KKXX_JS();
            //删除授课教师原数据
            C_JX_KKXX_JS.Delete_KKXX_KEY(int.Parse(KKXX_KEY));
            for (int i = 0; i < this.gv_SZ_DWJHGW_JG.Rows.Count; i++)
            {
                E_JX_KKXX_JS.KKXX_KEY = int.Parse(KKXX_KEY);
                E_JX_KKXX_JS.DS_KEY = int.Parse(gv_SZ_DWJHGW_JG.Rows[i].Cells[1].Text);
                E_JX_KKXX_JS.JGH = int.Parse(gv_SZ_DWJHGW_JG.Rows[i].Cells[3].Text);
                E_JX_KKXX_JS.XM = gv_SZ_DWJHGW_JG.Rows[i].Cells[4].Text;
                C_JX_KKXX_JS.Add(E_JX_KKXX_JS);
            }

            Common_GSAO.Tools.ShowAlertAndRedirect("成功保存-" + this.tb_KCMC.Text + "-!", from);
        }

        protected void ddl_YXSM_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                Bind_ddl_KCKEY();
                Bind_KCKEY_Info();
            }
            catch
            { }
        }

        protected void ddl_KCKEY_SelectedIndexChanged(object sender, EventArgs e)
        {
            Bind_KCKEY_Info();
        }
    }
}

 

posted @ 2014-06-09 16:34  linyongqin  阅读(189)  评论(0编辑  收藏  举报