JXJ_XX.aspx (序号,多选框)
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="JXJ_XX.aspx.cs" Inherits="GSAO.JZXJ.JXJ_XX" %> <!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"> <title>研究生国家奖学金申请_学校审核</title> <link href="../css/style.css" rel="stylesheet" type="text/css" /> <script src="../js/jquery-1.7.2.min.js" type="text/javascript"></script> <script type="text/javascript"> $(function() { //全选 $("#CheckAll").live("click", function() { $("input[id$='cb_select']").attr("checked", this.checked); }); //CheckBoxXS是否全选 $("input[id$='cb_select']").live("click", function() { var $tmp = $("input[id$='cb_select']"); $('#CheckAll').attr('checked', $tmp.length == $tmp.filter(':checked').length); }); //打印申请表,成绩单 $("input[id$='btnSQB'],input[id$='btnCJD']").live("click", function() { if ($("input[id$='cb_select']").filter(':checked').length <= 0) { alert("请勾选学生信息"); return false; } }); }); </script> </head> <body> <form id="form1" runat="server"> <table width="99%" class="tbDefault mb5 mt5"> <tr> <td class="tdRight bgEFEFEF" width="80"> 排序方式: </td> <td class="tdLeft"> <asp:DropDownList ID="ddl_orderBy" runat="server" CssClass="ddl"> <asp:ListItem Value="提交时间">提交时间</asp:ListItem> <asp:ListItem Value="姓名">姓名</asp:ListItem> <asp:ListItem Value="学号">学号</asp:ListItem> </asp:DropDownList> </td> <td class="tdRight bgEFEFEF" width="80"> 奖学金: </td> <td class="tdLeft"> <asp:DropDownList ID="ddl_JXJ_ITEM" runat="server" CssClass="ddl"> </asp:DropDownList> </td> <td class="tdRight bgEFEFEF" width="80"> 申请年份: </td> <td class="tdLeft"> <asp:DropDownList ID="ddl_SQNF" runat="server" CssClass="ddl"> </asp:DropDownList> </td> <td class="tdRight bgEFEFEF" width="80"> 院系: </td> <td class="tdLeft"> <asp:DropDownList ID="ddl_YXSM" runat="server" CssClass="ddl"> </asp:DropDownList> </td> </tr> <tr> <td class="tdRight bgEFEFEF" width="80"> 学号: </td> <td class="tdLeft"> <asp:TextBox ID="txt_XH" runat="server" CssClass="txt"></asp:TextBox> </td> <td class="tdRight bgEFEFEF" width="80"> 姓 名: </td> <td class="tdLeft"> <asp:TextBox ID="txt_XM" runat="server" CssClass="txt"></asp:TextBox> </td> <td class="tdRight bgEFEFEF" width="80"> 状 态: </td> <td class="tdLeft" colspan="3"> <asp:DropDownList ID="ddl_ztFlg" runat="server" CssClass="ddl mr10"> <asp:ListItem Value="">全部</asp:ListItem> <asp:ListItem Value="-1">未提交</asp:ListItem> <asp:ListItem Value="0">提交申请</asp:ListItem> <asp:ListItem Value="1">审核不通过</asp:ListItem> <asp:ListItem Value="2">审核通过</asp:ListItem> <asp:ListItem Value="3">入围</asp:ListItem> <asp:ListItem Value="4">获奖者</asp:ListItem> </asp:DropDownList> <asp:Button ID="btnSearch" runat="server" Text=" 查 询 " CssClass="btnStyle mr10" OnClick="btnSearch_Click" /> <asp:Label ID="lb_total" runat="server" Text="" CssClass="lbl mr10"></asp:Label> <asp:Button ID="btnExport" runat="server" Text="导出Excel" CssClass="btnStyle mr10" OnClick="btnExport_Click" /> <asp:Label ID="lbl_select_total" runat="server" Text="0" Visible="false"></asp:Label> <asp:Button ID="btn_print" runat="server" Text="打印" CssClass="btnStyle" OnClick="btn_print_Click" /> </td> </tr> <tr> <td colspan="8" class="colorRed f14"> 批量更改状态:1.勾选项目 -> 2.选择状态 <asp:DropDownList ID="ddl_ztFlg_all" runat="server" CssClass="ddl"> <asp:ListItem Value="4">获奖者</asp:ListItem> </asp:DropDownList> -> 3.更改状态 <asp:Button ID="btn_update_ztFlg" runat="server" Text="确认更改" CssClass="btnStyle" onclick="btn_update_ztFlg_Click" OnClientClick="return confirm('确定要批量更改状态?')"/> </td> </tr> </table> <asp:GridView ID="GridView1" runat="server" CssClass="tbGvw" Width="99%" AllowPaging="false" AutoGenerateColumns="false" OnRowDataBound="GridView1_RowDataBound" OnRowCommand="GridView1_RowCommand"> <Columns> <asp:BoundField DataField="JXJ_SQ_KEY" HeaderText="JXJ_SQ_KEY不显示" /> <asp:TemplateField> <HeaderTemplate> <input id="CheckAll" type="checkbox" /> </HeaderTemplate> <ItemTemplate> <asp:CheckBox ID="cb_select" runat="server" Text='' /> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="序号"> <ItemTemplate> <%# Container.DataItemIndex+1 %> </ItemTemplate> </asp:TemplateField> <asp:BoundField HeaderText="姓名" DataField="XM" /> <asp:BoundField HeaderText="学号" DataField="XH" /> <asp:BoundField HeaderText="专业学院" DataField="YXSMC" /> <asp:BoundField HeaderText="专业" DataField="ZY" /> <asp:BoundField HeaderText="奖学金" DataField="JXJ_ITEM_NAME" /> <asp:BoundField HeaderText="申请年度" DataField="APPLY_YEAR" /> <asp:BoundField HeaderText="提交时间" DataField="APPLY_TIME" DataFormatString="{0:yyyy-MM-dd}" /> <asp:BoundField HeaderText="状态" DataField="ZT_FLG_NAME" /> <asp:TemplateField HeaderText="审核/查看/删除" ItemStyle-Width="100" ItemStyle-HorizontalAlign="Center"> <ItemTemplate> <asp:Image ID="img_modify" runat="server" ImageUrl="../images/icon_edit.gif" ToolTip="修改" CssClass="cursorPointer" /> <asp:Image ID="img_show" runat="server" ImageUrl="../images/icon_view.gif" ToolTip="查看" CssClass="cursorPointer" /> <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> </Columns> </asp:GridView> </form> </body> </html>
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; namespace GSAO.JZXJ { public partial class JXJ_XX : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Common_GSAO.Tools.Verlify_menu(Request.QueryString["menu_id"]); BindData(); Bind_gv(); } } private void BindData() { //奖学金 ddl_JXJ_ITEM.DataSource = DAL_GSAO_SZGW.DbHelperSQL_GSAO.Query("select * from JXJ_ITEM").Tables[0]; ddl_JXJ_ITEM.DataTextField = "JXJ_ITEM_NAME"; ddl_JXJ_ITEM.DataValueField = "JXJ_ITEM_KEY"; ddl_JXJ_ITEM.DataBind(); ddl_JXJ_ITEM.Items.Insert(0, "全部"); ddl_JXJ_ITEM.Items[0].Value = "0"; ddl_JXJ_ITEM.SelectedValue = "1"; //院系 ddl_YXSM.DataSource = DAL_GSAO_SZGW.DbHelperSQL_GSAO.Query("select * from TB_YXS order by YXSMC asc").Tables[0]; ddl_YXSM.DataTextField = "YXSMC"; ddl_YXSM.DataValueField = "YXSM"; ddl_YXSM.DataBind(); ddl_YXSM.Items.Insert(0, "全部"); ddl_YXSM.Items[0].Value = "0"; //申请年份 for (int i = DateTime.Now.Year; i >= 2013; i--) { ddl_SQNF.Items.Add(new ListItem(i.ToString(), i.ToString())); } ddl_SQNF.Items.Insert(0, "全部"); ddl_SQNF.Items[0].Value = "0"; ddl_SQNF.SelectedValue = DateTime.Now.Year.ToString(); ddl_ztFlg.SelectedValue = "3"; } private void Bind_gv() { string where = "1=1"; if (ddl_JXJ_ITEM.SelectedValue != "0") { where += " and JXJ_SQ.JXJ_ITEM_KEY=" + ddl_JXJ_ITEM.SelectedValue; } if (ddl_SQNF.SelectedValue != "0") { where += " and year(JXJ_SQ.APPLY_TIME)=" + ddl_SQNF.SelectedValue; } if (ddl_YXSM.SelectedValue != "0") { where += " and JXJ_SQ.YXSM=" + ddl_YXSM.SelectedValue; } if (txt_XH.Text != "") { where += " and JXJ_SQ.XH like '%" + txt_XH.Text + "%' "; } if (txt_XM.Text != "") { where += " and JXJ_SQ.XM like '%" + txt_XM.Text + "%' "; } if (ddl_ztFlg.SelectedValue != "") { where += " and JXJ_SQ.ZT_FLG='" + ddl_ztFlg.SelectedValue + "'"; } if (ddl_orderBy.SelectedValue == "姓名") { where += " order by JXJ_SQ.XM asc"; } else if (ddl_orderBy.SelectedValue == "学号") { where += " order by JXJ_SQ.XH asc"; } else if (ddl_orderBy.SelectedValue == "提交时间") { where += " order by JXJ_SQ.APPLY_TIME asc"; } else { where += " order by JXJ_SQ.APPLY_TIME asc"; } DAL_GSAO_JXJ.Controller.JXJ_SQ C_JXJ_SQ = new DAL_GSAO_JXJ.Controller.JXJ_SQ(); DataSet ds = C_JXJ_SQ.GetListJoinAll(where); GridView1.DataSource = ds.Tables[0]; GridView1.DataBind(); lb_total.Text = "总计-" + ds.Tables[0].Rows.Count.ToString() + "-项"; for (int i = 0; i < GridView1.Rows.Count; i++) { System.Web.UI.WebControls.Image img_modify = (System.Web.UI.WebControls.Image)GridView1.Rows[i].FindControl("img_modify"); img_modify.Attributes.Add("onclick", "location.href='JXJ_XX_VIEW.aspx?menu_id=" + Request.QueryString["menu_id"] + "&type=xx&JXJ_SQ_KEY=" + GridView1.Rows[i].Cells[0].Text.Trim() + "'"); System.Web.UI.WebControls.Image img_show = (System.Web.UI.WebControls.Image)GridView1.Rows[i].FindControl("img_show"); img_show.Attributes.Add("onclick", "location.href='JXJ_XX_VIEW.aspx?showonly=true&menu_id=" + Request.QueryString["menu_id"] + "&type=xx&JXJ_SQ_KEY=" + 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[3].Text.Trim() + "-" + this.GridView1.Rows[i].Cells[8].Text.Trim() + "年的奖学金申请-吗?');"); if (GridView1.Rows[i].Cells[10].Text == "获奖者") { img_modify.Visible = false; btn_delete.Visible = false; } } } 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_JXJ.Controller.JXJ_SQ C_JXJ_SQ = new DAL_GSAO_JXJ.Controller.JXJ_SQ(); C_JXJ_SQ.Delete(int.Parse(id)); Bind_gv(); } } protected void btnSearch_Click(object sender, EventArgs e) { Bind_gv(); } /// <summary> /// 导出需要 /// </summary> /// <param name="control"></param> public override void VerifyRenderingInServerForm(Control control) { //base.VerifyRenderingInServerForm(control); } /// <summary> /// 导出Excel /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnExport_Click(object sender, EventArgs e) { try { int select = 0; for (int i = 0; i < GridView1.Rows.Count; i++) { System.Web.UI.WebControls.CheckBox cb_select = (System.Web.UI.WebControls.CheckBox)GridView1.Rows[i].FindControl("cb_select"); if (cb_select.Checked == true) { select++; //C_dkb_dksqb.InsterTempDksqb(ReportValue, int.Parse(GridView1.Rows[i].Cells[0].Text.Trim())); // str_dksq_key += "," + GridView1.Rows[i].Cells[0].Text.Trim(); GridView1.Rows[i].Cells[3].Text = select.ToString(); } else { GridView1.Rows[i].Visible = false; } } if (select <= 0) { Common_GSAO.Tools.ShowAlert("请选择需要导出的学生信息!"); return; } //统计选中项 lbl_select_total.Text = "总计-" + select.ToString() + "-项"; lbl_select_total.Visible = true; string ExcelFile = "YJSGJJXJ_" + System.DateTime.Now.ToString("yyyyMMddHHmmss"); string header = @"<table><tr><td colspan=9><center><b><u><font size='3'>研究生国家奖学金申请表</font></u></b></center></td></tr>" + "<tr><td colspan=7></td><td colspan=2>导出时间:" + DateTime.Now.ToShortDateString() + "</td></tr></table>"; string bottomer = ""; GridView1.Columns[0].Visible = false; GridView1.Columns[1].Visible = false; GridView1.Columns[2].Visible = false; Common_GSAO.Tools.OutputExcel(GridView1, ExcelFile, header, bottomer, lbl_select_total); lbl_select_total.Visible = false; } catch { Common_GSAO.Tools.ShowAlert("导出Excel出错!"); return; } } /// <summary> /// 打印 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btn_print_Click(object sender, EventArgs e) { int select = 0; string str_JXJ_SQ_KEY = "-1"; for (int i = 0; i < GridView1.Rows.Count; i++) { System.Web.UI.WebControls.CheckBox cb_select = (System.Web.UI.WebControls.CheckBox)GridView1.Rows[i].FindControl("cb_select"); if (cb_select.Checked == true) { select++; str_JXJ_SQ_KEY += "," + GridView1.Rows[i].Cells[0].Text.Trim(); } } if (select <= 0) { Common_GSAO.Tools.ShowAlert("请选择需要打印的学生信息!"); return; } else { string ReportUrl = "http://gridreport.stu.edu.cn/GSAO/JZXJ_GJJXJ_YJS.aspx"; Common_GSAO.Tools.ShowScript("window.open('" + ReportUrl + "?JXJ_SQ_KEYs=" + str_JXJ_SQ_KEY + "','_blank','width=900,height=640;help:no;resizable;status:no;scroll')"); } #warning 打印功能 } /// <summary> /// 确认更改状态 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btn_update_ztFlg_Click(object sender, EventArgs e) { int select = 0; string str_JXJ_SQ_KEY = "-1"; for (int i = 0; i < GridView1.Rows.Count; i++) { System.Web.UI.WebControls.CheckBox cb_select = (System.Web.UI.WebControls.CheckBox)GridView1.Rows[i].FindControl("cb_select"); if (cb_select.Checked == true) { select++; str_JXJ_SQ_KEY += "," + GridView1.Rows[i].Cells[0].Text.Trim(); } } if (select <= 0) { Common_GSAO.Tools.ShowAlert("请勾选需要批量更改状态的项目!"); return; } DAL_GSAO_JXJ.Controller.JXJ_SQ C_JXJ_SQ = new DAL_GSAO_JXJ.Controller.JXJ_SQ(); C_JXJ_SQ.UpdateZtflg(Convert.ToInt32(ddl_ztFlg_all.SelectedValue), str_JXJ_SQ_KEY); Bind_gv(); } } }