MY_DEPART_KKB.aspx (学年、学期、单位)

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

<!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">
     <asp:Label ID="lb_function_desc" runat="server" Visible="false" >
    功能说明:管理本学院开课班信息!<br/>
    操作表为:JX_KKXX
    </asp:Label>
    
     <table width="99%" class="tbDefault mb5 mt5">
        <tr>
         <td class="tdRight bgEFEFEF" width="50">学年:</td>
            <td class="tdLeft" width="60">
                <asp:DropDownList ID="ddl_XNM" runat="server" CssClass="ddl">
                 </asp:DropDownList>
            </td>
            <td class="tdRight bgEFEFEF" width="50">学期:</td>
             <td class="tdLeft" width="60">
                <asp:DropDownList ID="ddl_XQM" runat="server" CssClass="ddl">
                  
                 </asp:DropDownList>
            </td>
        <td class="tdRight bgEFEFEF" width="50">单位:</td>
             <td class="tdLeft" width="150">
                <asp:DropDownList ID="ddl_YXSM" runat="server" CssClass="ddl">
                 </asp:DropDownList>
            </td>
             <td class="tdRight bgEFEFEF" width="80">名称:</td>
             <td class="tdLeft">
               <asp:TextBox ID="tb_KCMC" runat="server" CssClass="txt"  Width="100"></asp:TextBox>
                &nbsp;&nbsp;
                <asp:Button ID="btn_search" runat="server" Text="查 询" CssClass="btnStyle" 
                     onclick="btn_search_Click" />
               <asp:Label ID="lb_total" runat="server"></asp:Label>
             
            </td>
           <td class="tdRight"> <img src="../images/icon_add.gif" /><asp:hyperlink id="btnAdd" runat="server" NavigateUrl="MY_DEPART_KKB_TJ.aspx">添加开课班</asp:hyperlink>&nbsp;&nbsp;&nbsp;&nbsp;</td>
        </tr>
      </table>
       <asp:GridView ID="GridView1" runat="server" CssClass="tbGvw" Width="99%"   AllowPaging="true"  
          AutoGenerateColumns="false"     BorderStyle="Solid"  BorderWidth="1" 
           BorderColor="Silver"       PageSize="20" onpageindexchanged="GridView1_PageIndexChanged" 
           onrowdatabound="GridView1_RowDataBound" 
           onpageindexchanging="GridView1_PageIndexChanging" 
           onrowcommand="GridView1_RowCommand">
            <PagerSettings PageButtonCount="20" FirstPageText="[ 首页 ]" LastPageText="[ 末页 ]" 
               Mode="NextPreviousFirstLast" NextPageText="[ 下一页 ]" Position="TopAndBottom" 
               PreviousPageText="[ 上一页 ]"   />
         <PagerTemplate>
            <table width="100%"> <tr> <td style="text-align:left; color:#996600;"><asp:Label id="lblPageIndex" runat="server" text='<%# ((GridView)Container.Parent.Parent).PageIndex + 1 %>' />页 共<asp:Label id="lblPageCount" runat="server" text='<%# ((GridView)Container.Parent.Parent).PageCount %>' />页 <asp:linkbutton id="btnFirst" runat="server" causesvalidation="False" commandargument="First" ForeColor="#996600" Font-Bold="true" commandname="Page" text="首页" /> <asp:linkbutton id="btnPrev" runat="server" causesvalidation="False" ForeColor="#996600" Font-Bold="true"  commandargument="Prev" commandname="Page" text="上一页" /> <asp:linkbutton id="btnNext" runat="server" ForeColor="#996600" Font-Bold="true"  causesvalidation="False" commandargument="Next" commandname="Page" text="下一页" /> <asp:linkbutton id="btnLast" runat="server" ForeColor="#996600" Font-Bold="true"  causesvalidation="False" commandargument="Last" commandname="Page" text="尾页" /></td> </tr> </table>
         </PagerTemplate>
        <HeaderStyle CssClass="tbHeader" />
        <RowStyle HorizontalAlign="Center" Wrap="False" Height="25px" ></RowStyle>
        <Columns>
         <asp:BoundField DataField="KKXX_KEY" HeaderText="ID不显示" />       
            <asp:TemplateField HeaderText="修改/取消" ItemStyle-Width="100" ItemStyle-HorizontalAlign="Center" >
            <ItemTemplate>
            <asp:Image id="img_show" runat="server" ImageUrl="../images/icon_view.gif" ToolTip="查看" CssClass="cursorPointer" />&nbsp;
                <asp:Image id="img_modify" runat="server" ImageUrl="../images/icon_edit.gif" ToolTip="修改" CssClass="cursorPointer" />&nbsp;
        
                <asp:ImageButton id="btn_delete" CommandArgument ="<%#  GridView1.Rows.Count %>" CommandName="delete1" runat="server" ImageUrl="../images/icon_delete.gif" ImageAlign="Baseline" AlternateText="删除"></asp:ImageButton>             
            </ItemTemplate>
            </asp:TemplateField> 
         
             <asp:BoundField HeaderText="学年"  ItemStyle-Width="100px" ItemStyle-HorizontalAlign="Center" DataField="XNMC"/>
            <asp:BoundField HeaderText="学期"  ItemStyle-Width="100px" ItemStyle-HorizontalAlign="Center" DataField="XQMC"/>
            <asp:BoundField HeaderText="开设学院"  ItemStyle-Width="120px" ItemStyle-HorizontalAlign="Center" DataField="YXSMC"/>
            <asp:BoundField HeaderText="课程号"  ItemStyle-Width="80px" ItemStyle-HorizontalAlign="Center" DataField="KCH"/>
            <asp:BoundField HeaderText="课程名称"  ItemStyle-Width="190px" ItemStyle-HorizontalAlign="Center" DataField="KCMC"/>
            <asp:BoundField HeaderText="授课对象"  ItemStyle-Width="120px" ItemStyle-HorizontalAlign="Center" DataField="ZYH"/> 
            <asp:BoundField HeaderText="授课老师"  ItemStyle-Width="120px" ItemStyle-HorizontalAlign="Center" DataField="SKJGH"/> 
             
              <asp:BoundField HeaderText="当前状态"  ItemStyle-Width="120px" ItemStyle-HorizontalAlign="Center" DataField="YXBZ"/>  
              <asp:BoundField HeaderText="选修人数"  ItemStyle-Width="80px" ItemStyle-HorizontalAlign="Center" /> 
            </Columns>
            <PagerStyle  Font-Size="10pt"  BorderColor="White" Font-Bold="False" ForeColor="#996600"></PagerStyle> 
      </asp:GridView>
    </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 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.IsPostBack)
            {
                Bind_ddl_XNM();
                Bind_ddl_XQM();
                Bind_ddl_YXSM();
                Bind_gv();
            }
        }
        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_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();
        }
        private void Bind_gv()
        {
            string where = " JX_KKXX.YXBZ not in (0) and JX_KKXX.KCMC like '%" + this.tb_KCMC.Text + "%' ";
            if (this.ddl_YXSM.SelectedValue != "0")
                where += " and JW_KCXX.YXSM=" + this.ddl_YXSM.SelectedValue;
            if (this.ddl_XNM.SelectedValue != "0")
                where += " and JX_KKXX.XNM=" + this.ddl_XNM.SelectedValue;
            if (this.ddl_XQM.SelectedValue != "0")
                where += " and JX_KKXX.XQM=" + this.ddl_XQM.SelectedValue;
            DAL_GSAO_JW.Controller.JX_KKXX C_JX_KKXX = new DAL_GSAO_JW.Controller.JX_KKXX();
            DAL_GSAO_JW.Controller.JX_XSXK C_JX_XSXK = new DAL_GSAO_JW.Controller.JX_XSXK();
            DataTable  dt = C_JX_KKXX.GetList_Join_All(where).Tables[0];
            this.GridView1.DataSource = dt;
            this.GridView1.DataBind();

            string KSKCKEY_In = "0";
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                KSKCKEY_In += "," + dt.Rows[i]["KKXX_KEY"].ToString();
            }
            DataTable dt_JX_XSXK = C_JX_XSXK.GetList(" KSKCKEY in (" + KSKCKEY_In + ")").Tables[0];
            this.lb_total.Text = "总计-" + dt.Rows.Count.ToString() + "-项";
            for (int i = 0; i < this.GridView1.Rows.Count; i++)
            {
                 System.Web.UI.WebControls.Image img_show = (System.Web.UI.WebControls.Image)this.GridView1.Rows[i].FindControl("img_show");
                 img_show.Attributes.Add("onclick", "location.href='MY_DEPART_KKB_XG.aspx?showonly=true&KKXX_KEY=" + this.GridView1.Rows[i].Cells[0].Text.Trim() + "';");

                System.Web.UI.WebControls.Image img_modify = (System.Web.UI.WebControls.Image)this.GridView1.Rows[i].FindControl("img_modify");
                img_modify.Attributes.Add("onclick", "location.href='MY_DEPART_KKB_XG.aspx?KKXX_KEY=" + this.GridView1.Rows[i].Cells[0].Text.Trim() + "';");

                System.Web.UI.WebControls.ImageButton btn_delete = (System.Web.UI.WebControls.ImageButton)this.GridView1.Rows[i].FindControl("btn_delete");
                btn_delete.Attributes.Add("onclick", "return confirm('确定要取消-" + this.GridView1.Rows[i].Cells[6].Text.Trim() + "-吗?');");

                if (this.GridView1.Rows[i].Cells[9].Text == "1")
                    this.GridView1.Rows[i].Cells[9].Text = "已保存";
                if (this.GridView1.Rows[i].Cells[9].Text == "2")
                    this.GridView1.Rows[i].Cells[9].Text = "开始选课";
                if (this.GridView1.Rows[i].Cells[9].Text == "3")
                    this.GridView1.Rows[i].Cells[9].Text = "结束选课";

                 DataRow[] row = dt_JX_XSXK.Select("KSKCKEY="+this.GridView1.Rows[i].Cells[0].Text);
                this.GridView1.Rows[i].Cells[10].Text="<a href='MY_DEPART_KKB_XG.aspx?showonly=true&KKXX_KEY=" + this.GridView1.Rows[i].Cells[0].Text.Trim()+"'>"+row.Length.ToString()+"</a>";
            }
        }
        protected void GridView1_PageIndexChanged(object sender, EventArgs e)
        {
            Bind_gv();
        }
        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 GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "delete1")
            {
                int nIdx = Convert.ToInt32(e.CommandArgument.ToString());
                GridViewRow row = this.GridView1.Rows[nIdx];
                string id = row.Cells[0].Text;

                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(id));
                E_JX_KKXX.YXBZ = 0;
                C_JX_KKXX.Update(E_JX_KKXX);
                Bind_gv();  
            }

        }
        protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            try
            {
                GridView1.PageIndex = e.NewPageIndex;
            }
            catch
            {
                GridView1.PageIndex = 0;
            }
        }

        protected void btn_search_Click(object sender, EventArgs e)
        {
            Bind_gv();
        }
        public override void VerifyRenderingInServerForm(Control control)
        {
            //base.VerifyRenderingInServerForm(control);
        }
    }
}

 

posted @ 2014-06-09 16:31  linyongqin  阅读(169)  评论(0)    收藏  举报