<%@ Page language="c#" Codebehind="PAYMENTDETAILReport.aspx.cs" AutoEventWireup="true" Inherits="Benq.Flower.Form.BQYFORMPAYMENT.PAYMENTDETAILReport" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" > <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> </HEAD> <body MS_POSITIONING="GridLayout"> <form id="Form1" method="post" runat="server"> <table id="titleTable" width="80%"> <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" AutoPostBack="True"></asp:dropdownlist> 收款单位 <asp:dropdownlist id="DropDownListRec" Runat="server" 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"></asp:label></td> </tr> <tr> <td align="center" width="30%">部门名称 </td> <td><asp:label id="Label_Dept" Runat="server" ></asp:label></td> </tr> <tr> <td align="center" width="30%">收款单位 </td> <td><asp:Label ID="Label_RecDept" Runat="server" ></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> <td colspan="6" align="center">应 付 款 明 细</td> </tr> <tr> <td align="center">序号</td> <td align="center">发生时间</td> <td align="center">单据编号</td> <td align="center">应付金额</td> <td align="center">付款金额</td> <td align="center">应付款余额</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 Benq.Flower.Web.Forms.Help; namespace Benq.Flower.Form.BQYFORMPAYMENT { /// <summary> /// AnnualTrainingPlanReport 的摘要说明。 /// </summary> public class PAYMENTDETAILReport : System.Web.UI.Page { protected System.Web.UI.WebControls.DropDownList DropDownListYear; protected System.Web.UI.WebControls.DropDownList DropDownListDept; protected System.Web.UI.WebControls.DropDownList DropDownListRec; 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.Label Label_RecDept; protected System.Web.UI.WebControls.Literal Literal1; private void Page_Load(object sender, System.EventArgs e) { // 在此处放置用户代码以初始化页面 if(!IsPostBack) { //this.DropDownListDept.Items.FindByValue(Request.QueryString["dept"]).Selected; //Console.WriteLine(Request.QueryString["recp"]); //初始化年度下拉列表 string CurrentYear = DateTime.Now.Year.ToString(); int YearStartWith = int.Parse(CurrentYear); //DropDownListYear.Items.Clear(); 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("--请选择部门--","")); //初始化收款单位下拉列表 DataSet DeptSet2 = new Facade.BQYFORMPAYMENT().GetRelatedCompany(); DropDownListRec.DataSource = DeptSet2.Tables[0]; DropDownListRec.DataTextField = "PAYMENT_COMPANY"; DropDownListRec.DataValueField = "PAYMENT_COMPANY"; DropDownListRec.DataBind(); DropDownListRec.Items.Insert(0,new ListItem("--请选择收款单位--","")); //初始化日期label Label_Date.Text = DateTime.Now.ToString("yyyy年MM月dd日"); this.DropDownListYear.SelectedValue = Request.QueryString["year"]; this.DropDownListDept.SelectedValue=Request.QueryString["dept"]; this.DropDownListRec.SelectedValue=Request.QueryString["recp"]; if(this.DropDownListDept.SelectedValue!=string.Empty) { this.Label_Dept.Text = this.DropDownListDept.SelectedItem.Text; } else { this.Label_Dept.Text = ""; } //this.Label_Dept.Text = this.DropDownListDept.Items.FindByValue(this.DropDownListDept.SelectedValue).Text; this.Label_RecDept.Text = Request.QueryString["recp"]; SearchAnnualPlan(); } } #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.DropDownListRec.SelectedIndexChanged += new System.EventHandler(this.DropDownListRec_SelectedIndexChanged); this.ButtonSearch.Click += new System.EventHandler(this.ButtonSearch_Click); } #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; string SelectedRecp = this.DropDownListRec.SelectedValue; DataSet dstTemp = null; try { dstTemp = new Facade.BQYFORMPAYMENT().LoadDetailTableList(SelectedYear,SelectedDept,SelectedRecp); } 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]; string content = @"<tr> <td><span>{0}</span></td> <td><span>{1}</span></td> <td><span>{2}</span></td> <td><span>{3}</span></td> <td><span>{4}</span></td> <td><span>{5}</span></td> </tr>"; html = html + content; string _strDate = ""; DateTime date = new DateTime(); if(row[0]!=null && row[0].ToString().Trim()!=string.Empty) _strDate = row[0].ToString().Trim(); else return; try { _strDate = DateTime.Parse(_strDate).ToString("yyyy年MM月dd日"); /*或者 date = DateTime.Parse(_strDate); _strDate = date。Year + "年" + date。MOnth + "月" + date.Day; */ } catch { throw new Exception("数据错误"); } html = string.Format(html,(i+1).ToString(),_strDate,row[1].ToString(),row[2].ToString(),row[3].ToString(),row[4].ToString()); } this.Literal1.Text = html; } } private void DropDownListDept_SelectedIndexChanged(object sender, System.EventArgs e) { if(this.DropDownListDept.SelectedValue!=string.Empty) { this.Label_Dept.Text = this.DropDownListDept.SelectedItem.Text; } else { this.Label_Dept.Text = ""; } } private void DropDownListRec_SelectedIndexChanged(object sender, System.EventArgs e) { this.Label_RecDept.Text = this.DropDownListRec.SelectedValue; } } }