Beispiel #1
0
        /// <summary>
        /// 生成明细
        /// </summary>
        private void LoadDataGrid(bool IsScreenToTable)
        {
            try
            {
                //按单位工程
                this.txtPBSType.Value = "";
                this.txtPBSCode.Value = "";
                this.lblPBSName.Text  = "";
                if (this.sltPBS.Value.Trim() != "")
                {
                    this.lblPBSName.Text = "[" + this.sltPBS.Items[this.sltPBS.SelectedIndex].Text + "]";

                    if (this.sltPBS.Value.ToUpper() == "P") //项目
                    {
                        this.txtPBSType.Value = "P";
                    }
                    else //楼栋
                    {
                        this.txtPBSType.Value = "B";
                        this.txtPBSCode.Value = this.sltPBS.Value;
                    }
                }

                BLL.ContractPaySchedule sch = new RmsPM.BLL.ContractPaySchedule(this.txtProjectCode.Value);
                sch.PBSType = this.txtPBSType.Value;
                sch.PBSCode = this.txtPBSCode.Value;
                sch.StartYm = BLL.ConvertRule.ToString(ViewState["StartYm"]);
                sch.EndYm   = BLL.ConvertRule.ToString(ViewState["EndYm"]);

                sch.Generate();

                //暂存一览表
//				m_sch = sch;

                BindDataGrid(sch, IsScreenToTable);
            }
            catch (Exception ex)
            {
                ApplicationLog.WriteLog(this.ToString(), ex, "");
                Response.Write(Rms.Web.JavaScript.Alert(true, "显示付款一览表出错:" + ex.Message));
            }
        }
Beispiel #2
0
        /// <summary>
        /// 导出Excel
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Excel(bool CloseWindow)
        {
            try
            {
                string ProjectCode = this.txtProjectCode.Value;
                string StartYm     = "" + Request.QueryString["StartYm"];
                string EndYm       = "" + Request.QueryString["EndYm"];
                string PBSType     = "" + Request.QueryString["PBSType"];
                string PBSCode     = "" + Request.QueryString["PBSCode"];

                BLL.ContractPaySchedule sch = new RmsPM.BLL.ContractPaySchedule(ProjectCode);
                sch.PBSType = this.txtPBSType.Value;
                sch.PBSCode = this.txtPBSCode.Value;
                sch.StartYm = StartYm;
                sch.EndYm   = EndYm;
                sch.Generate();

                TExcel excel = new TExcel(Response, Request, Server, Session);
                try
                {
                    excel.StartRow      = 10;
                    excel.ColumnHeadRow = 9;

                    //去掉1级合计

                    /*
                     * DataView dv;
                     * if (dyn.NeedApport) //有分摊时,多了一级总计
                     * {
                     *  dv = new DataView(dyn.tb, "Deep=3", "SortID", DataViewRowState.CurrentRows);
                     * }
                     * else
                     * {
                     *  dv = new DataView(dyn.tb, "Deep=2", "SortID", DataViewRowState.CurrentRows);
                     * }
                     */

                    //新建工作簿
                    excel.TemplateFileName  = "付款一览表.xls";
                    excel.TemplateSheetName = "";
                    excel.AddWorkbook();

                    //表头信息
                    string ProjectName = BLL.ProjectRule.GetProjectName(sch.ProjectCode);
                    if (PBSType != "")
                    {
                        ProjectName += "[" + this.sltPBS.Items[this.sltPBS.SelectedIndex].Text + "]";
                    }
                    excel.SetCellValue(1, 1, ProjectName);

                    //报表日期
                    excel.SetCellValue(1, 3, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));

                    //最后两列是年月明细
                    int colYm = excel.Sheet.UsedRange.Columns.Count - 1;

                    if ((StartYm != "") && (EndYm != ""))  //有年月明细
                    {
                        int MonthCount = BLL.StringRule.GetMonthsBetween(StartYm, EndYm);

                        //插空列
                        TExcel.InsertBlankColumn(excel.Sheet, colYm, 1, 2, MonthCount);

                        int col = colYm - 1;
                        for (int i = 0; i < MonthCount; i++)
                        {
                            col++;
                            string ym = BLL.StringRule.YmAddMonths(StartYm, i);

                            //写excel的明细字段定义
                            excel.SetCellValue(excel.ColumnHeadRow, col, "PayoutMoneyYm_" + ym);
                        }
                    }
                    else  //无年月明细
                    {
                        //隐藏最后两列(年月明细)
                        TExcel.HideColumn(excel.Sheet, colYm);
                        TExcel.HideColumn(excel.Sheet, colYm + 1);
                    }

                    excel.DataSource = sch.tb;
                    excel.DataToSheet();

                    //保存
                    excel.SaveWorkbook();
                    excel.ShowClient();
                }
                finally
                {
                    excel.Dispose();
                }

                if (CloseWindow)
                {
                    Response.Write(Rms.Web.JavaScript.WinClose(true));
                }
            }
            catch (Exception ex)
            {
                ApplicationLog.WriteLog(this.ToString(), ex, "");
                Response.Write(Rms.Web.JavaScript.Alert(true, "导出Excel出错:" + ex.Message));
            }
        }