MY_ZZCG.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="MY_ZZCG.aspx.cs" Inherits="GSAO.CGGL.MY_ZZCG" %> <!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" /> </head> <body> <form id="form1" runat="server"> <asp:Label ID="lb_function_desc" runat="server" Visible="false" > 功能说明:显示我的成果,按状态确定可执行操作,已提交审批或学院不通过的可以修改删除,已通过的只可查看!<br/> 操作表为:CGGL_ZZCG </asp:Label> <table width="99%" class="tbDefault mb5 mt5"> <tr> <td class="tdRight bgEFEFEF" width="80">成果名称:</td> <td class="tdLeft"> <asp:TextBox ID="tb_CGGL_ZZCG_MC" runat="server" CssClass="txt" Width="200"></asp:TextBox> <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_ZZCG_TJ.aspx">提交著作成果</asp:hyperlink> </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="CGGL_ZZCG_KEY" HeaderText="ID不显示" /> <asp:BoundField DataField="ZT_FLG" HeaderText="ZT_FLG不显示" /> <asp:TemplateField HeaderText="修改/查看/删除" ItemStyle-Width="100" > <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> <asp:BoundField HeaderText="学号" ItemStyle-Width="80px" DataField="CGGL_XH"/> <asp:BoundField HeaderText="姓名" ItemStyle-Width="80px" DataField="CGGL_XM"/> <asp:BoundField HeaderText="单位名称" ItemStyle-Width="150px" DataField="CGGL_YXSM_MC"/> <asp:BoundField HeaderText="成果类型" ItemStyle-Width="120px" DataField="CGGL_ZZCG_LX"/> <asp:BoundField HeaderText="成果名称" ItemStyle-Width="300px" ItemStyle-CssClass="wordBreak" DataField="CGGL_ZZCG_MC"/> <asp:BoundField HeaderText="出版社" ItemStyle-Width="150px" DataField="CGGL_ZZCG_CBS"/> <asp:BoundField HeaderText="书号" ItemStyle-Width="80px" DataField="CGGL_ZZCG_SH"/> <asp:BoundField HeaderText="出版日期" DataFormatString="{0:yyyy-MM-dd}" ItemStyle-Width="100px" DataField="CGGL_ZZCG_CBRQ"/> <asp:BoundField HeaderText="当前状态" ItemStyle-Width="100px" DataField="ZT_FLG"/> </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.CGGL { public partial class MY_ZZCG : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!this.IsPostBack) { Bind_gv(); } } private void Bind_gv() { string where = " CGGL_VID=" + Session["vid"].ToString() + " and CGGL_ZZCG_MC like '%" + this.tb_CGGL_ZZCG_MC.Text + "%' "; where += " order by CGGL_ZZCG_CBRQ desc"; DAL_GSAO_KYGL.Controller.CGGL_ZZCG C_CGGL_ZZCG = new DAL_GSAO_KYGL.Controller.CGGL_ZZCG(); DataSet ds = C_CGGL_ZZCG.GetList(where); this.GridView1.DataSource = ds.Tables[0]; this.GridView1.DataBind(); this.lb_total.Text = "总计-" + ds.Tables[0].Rows.Count.ToString() + "-项"; for (int i = 0; i < this.GridView1.Rows.Count; i++) { 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_ZZCG_XG.aspx?CGGL_ZZCG_KEY=" + this.GridView1.Rows[i].Cells[0].Text.Trim() + "';"); 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_ZZCG_XG.aspx?showonly=true&CGGL_ZZCG_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[7].Text.Trim() + "-吗?');"); if (this.GridView1.Rows[i].Cells[1].Text == "1") { this.GridView1.Rows[i].Cells[11].Text = "已提交审批"; img_modify.Visible = true; btn_delete.Visible = true; } if (this.GridView1.Rows[i].Cells[1].Text == "2") { this.GridView1.Rows[i].Cells[11].Text = "学院审批通过"; img_modify.Visible = false; btn_delete.Visible = false; } if (this.GridView1.Rows[i].Cells[1].Text == "3") { this.GridView1.Rows[i].Cells[11].Text = "学院审批不通过"; img_modify.Visible = true; btn_delete.Visible = true; } if (this.GridView1.Rows[i].Cells[1].Text == "4") { this.GridView1.Rows[i].Cells[11].Text = "学校审批通过"; img_modify.Visible = false; btn_delete.Visible = false; } if (this.GridView1.Rows[i].Cells[1].Text == "5") { this.GridView1.Rows[i].Cells[11].Text = "学校审批不通过"; img_modify.Visible = true; btn_delete.Visible = true; } } } 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; e.Row.Cells[1].Visible = false; } } protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e) { try { GridView1.PageIndex = e.NewPageIndex; } catch { GridView1.PageIndex = 0; } } 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_KYGL.Controller.CGGL_ZZCG C_CGGL_ZZCG = new DAL_GSAO_KYGL.Controller.CGGL_ZZCG(); C_CGGL_ZZCG.Delete(int.Parse(id)); Bind_gv(); } } protected void btn_search_Click(object sender, EventArgs e) { Bind_gv(); } public override void VerifyRenderingInServerForm(Control control) { //base.VerifyRenderingInServerForm(control); } } }