<%@ Page language="c#" Codebehind="PAYMENTReport.aspx.cs" AutoEventWireup="true" Inherits="Benq.Flower.Form.BQYFORMPAYMENT.PAYMENTReport"%> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <HTML> <HEAD> <title>付款余额表查询页面</title> <meta http-equiv="content-Type" content="text/html; charset=gb2312"> <meta content="Microsoft Visual Studio 7.0" name="GENERATOR"> <meta content="C#" name="CODE_LANGUAGE"> <meta content="JavaScript" name="vs_defaultClientScript"> <meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema"> <meta content="FlowER Forms Group" name="Author"> <LINK href="../ShangAn/Public/CSS/FormPublic.css" mce_href="ShangAn/Public/CSS/FormPublic.css" rel="stylesheet"> <mce:script language="javascript" src="../../javascript/Const.js" mce_src="javascript/Const.js" type="text/javascript"></mce:script> <mce:script language="javascript" src="../../javascript/Function.js" mce_src="javascript/Function.js" type="text/javascript"></mce:script> <mce:script language="javascript" src="../ShangAn/Public/Utility/FormPublic.js" mce_src="ShangAn/Public/Utility/FormPublic.js" type="text/javascript"></mce:script> <mce:script type="text/javascript" language="javascript"><!-- function rowDbClick() { var ddlYear=document.getElementById("DropDownListYear"); var ddlYearValue=ddlYear.options[ddlYear.selectedIndex].value; var ddlDept=document.getElementById("DropDownListDept"); var ddlDeptValue=ddlDept.options[ddlDept.selectedIndex].value; var receiveComapny=event.srcElement.parentNode.childNodes[1].childNodes[0].innerHTML; var url="PAYMENTDETAILReport.aspx?year="+ddlYearValue+"&dept="+ddlDeptValue+"&recp="+receiveComapny; //alert(url); //window.showModalDialog(url,"",""); location.href=url; } // --></mce:script> </HEAD> <body MS_POSITIONING="GridLayout"> <form id="form1" method="post" runat="server"> <table width="80%" id="titleTable"> <tr> <td align="center" colSpan="2" height="30"><span style="FONT-WEIGHT: bold; FONT-SIZE: 16pt; COLOR: black" mce_style="FONT-WEIGHT: bold; FONT-SIZE: 16pt; COLOR: black">上海市安装工程有限公司</span></td> </tr> <tr> <td align="center" colSpan="2"><span style="FONT-WEIGHT: bold; FONT-SIZE: 16pt; COLOR: black" mce_style="FONT-WEIGHT: bold; FONT-SIZE: 16pt; COLOR: black">应付款余额表</span></td> </tr> <tr> </tr> <tr> <td align="center" colSpan="2"> 年度 <asp:dropdownlist id="DropDownListYear" runat="server" > <asp:ListItem Value="" Selected="True">--请选择年度--</asp:ListItem> </asp:dropdownlist> 部门 <asp:dropdownlist id="DropDownListDept" Runat="server" OnSelectedIndexChanged="DropDownListDept_SelectedIndexChanged" AutoPostBack="True"> </asp:dropdownlist> <asp:button id="ButtonSearch" Runat="server" Width="80px" Text="查询"></asp:button></td> </tr> <tr> <td align="center" colSpan="2"> 日期: <asp:label id="Label_Date" runat="server" Enabled="false"></asp:label></td> </tr> <tr> <td align="center" width="30%">部门名称 </td> <td><asp:label id="Label_Dept" Runat="server" Enabled="False" CssClass="liLeft"></asp:label></td> </tr> </table> <br> <table style="BORDER-COLLAPSE: collapse" mce_style="BORDER-COLLAPSE: collapse" borderColor="#e5e5fa" cellSpacing="2" cellPadding="4" width="80%" align="center" border="1"> <tr align="center"> <td>序号</td> <td >收款单位</td> <td>应付款余额</td> </tr> <asp:literal id="Literal1" Runat="server"></asp:literal></table> </form> </body> </HTML> 后台代码: using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Drawing; using System.Web; using System.Web.SessionState; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; using System.Globalization; using Benq.Flower.Common.Config; using System.Configuration; using System.Web.Security; //using System.Web.UI.WebControls.WebParts; using Benq.Flower.Form.FormFoundation; using Benq.Flower.Common.Util; using System.Text; //using Benq.Flower.Web.Forms.Help; namespace Benq.Flower.Form.BQYFORMPAYMENT { /// <summary> /// PAYMENTReport 的摘要说明。 /// </summary> public class PAYMENTReport : System.Web.UI.Page { protected System.Web.UI.HtmlControls.HtmlForm form1; protected System.Web.UI.WebControls.DropDownList DropDownListYear; protected System.Web.UI.WebControls.DropDownList DropDownListDept; protected System.Web.UI.WebControls.Button ButtonSearch; protected System.Web.UI.WebControls.Label Label_Date; protected System.Web.UI.WebControls.Label Label_Dept; protected System.Web.UI.WebControls.Literal Literal1; private void Page_Load(object sender, System.EventArgs e) { if(!IsPostBack) { // 第一次加载时初始化页面 SearchAnnualPlan(); //初始化年度下拉列表 string CurrentYear = DateTime.Now.Year.ToString(); int YearStartWith = int.Parse(CurrentYear); for(int i=YearStartWith;i>YearStartWith-10;i--) { DropDownListYear.Items.Add(new ListItem(i.ToString(),i.ToString())); } //初始化部门下拉列表 DataSet DeptSet = new Facade.BQYFORMPAYMENT().GetRelatedDepartment(); DropDownListDept.DataSource = DeptSet.Tables[0]; DropDownListDept.DataTextField = "DEPT_NAME"; DropDownListDept.DataValueField = "APPLICANT_DEPARTMENT_CODE"; DropDownListDept.DataBind(); DropDownListDept.Items.Insert(0,new ListItem("--请选择部门--","")); //初始化日期label Label_Date.Text = DateTime.Now.ToString("yyyy年MM月dd日"); Label_Dept.Text = ""; } } #region Web 窗体设计器生成的代码 override protected void OnInit(EventArgs e) { // // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。 // InitializeComponent(); base.OnInit(e); } /// <summary> /// 设计器支持所需的方法 - 不要使用代码编辑器修改 /// 此方法的内容。 /// </summary> private void InitializeComponent() { this.DropDownListDept.SelectedIndexChanged += new System.EventHandler(this.DropDownListDept_SelectedIndexChanged); this.ButtonSearch.Click += new System.EventHandler(this.ButtonSearch_Click); //this.Load += new System.EventHandler(this.Page_Load); } #endregion private void ButtonSearch_Click(object sender, System.EventArgs e) { Literal1.Text = string.Empty; SearchAnnualPlan(); } protected void SearchAnnualPlan() { string SelectedYear = this.DropDownListYear.SelectedValue; string SelectedDept = this.DropDownListDept.SelectedValue; DataSet dstTemp = null; try { dstTemp = new Facade.BQYFORMPAYMENT().LoadTableList(SelectedYear,SelectedDept); } catch { return; } if (dstTemp != null && dstTemp.Tables.Count > 0 && dstTemp.Tables[0].Rows.Count>0) { string html = string.Empty; for(int i=0;i<dstTemp.Tables[0].Rows.Count;i++) { DataRow row = dstTemp.Tables[0].Rows[i]; html = html + "<tr ondblclick='return rowDbClick();'><td><span>{0}</span></td><td><span>{1}</span></td><td><span>{2}</span></td></tr>"; html = string.Format(html,(i+1).ToString(),row[0].ToString(),row[1].ToString()); } this.Literal1.Text = html; } } public void DropDownListDept_SelectedIndexChanged(object sender, System.EventArgs e) { if(this.DropDownListDept.SelectedValue!="") { this.Label_Dept.Text = this.DropDownListDept.SelectedItem.Text; } else { this.Label_Dept.Text = ""; } } } }