Beispiel #1
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                if (validation() == false)
                {
                    return;
                }
                IQCareUtils theUtils = new IQCareUtils();


                if ((ddQuarter.SelectedValue.ToString() != "0") && (txtyears.Text.Trim() != ""))
                {
                    IReports ReportDetails = (IReports)ObjectFactory.CreateInstance("BusinessProcess.Reports.BReports,BusinessProcess.Reports");
                    theRepQuarterDS = (DataSet)ReportDetails.GetNACPQuarterlyReportData(Convert.ToInt32(ddQuarter.SelectedValue.ToString()), Convert.ToInt32(txtyears.Text.Trim()), Convert.ToInt32(Session["AppLocationId"]));

                    #region "TableNames"
                    theRepQuarterDS.Tables[0].TableName = "FacilityInfo1";
                    theRepQuarterDS.Tables[1].TableName = "Table1Data1";
                    theRepQuarterDS.Tables[2].TableName = "Table2Data1";

                    #endregion
                    Excel.Spreadsheet theApp      = new Microsoft.Office.Interop.Owc11.Spreadsheet();
                    string            theFilePath = Server.MapPath("..\\ExcelFiles\\Templates\\TZNACPQuarterlyReport.xml");
                    theApp.XMLURL = theFilePath;
                    writeCellWiseInExcel(theApp);

                    //theApp.Export(Server.MapPath("..\\ExcelFiles\\TZNACPQuarterlyReport.xls"), Microsoft.Office.Interop.Owc11.SheetExportActionEnum.ssExportActionOpenInExcel, Microsoft.Office.Interop.Owc11.SheetExportFormat.ssExportXMLSpreadsheet);
                    theApp.Export(Server.MapPath("..\\ExcelFiles\\TZNACPQuarterlyReport.xls"), Microsoft.Office.Interop.Owc11.SheetExportActionEnum.ssExportActionNone, Microsoft.Office.Interop.Owc11.SheetExportFormat.ssExportXMLSpreadsheet);
                    //theUtils.OpenExcelFile(Server.MapPath("..\\ExcelFiles\\TZNACPQuarterlyReport.xls"),Response);
                    IQWebUtils theUtl = new IQWebUtils();
                    theUtl.ShowExcelFile(Server.MapPath("..\\ExcelFiles\\TZNACPQuarterlyReport.xls"), Response);
                }
                else if ((ddMonth.SelectedValue.ToString() != "0") && (txtYear.Text.Trim() != ""))
                {
                    int years  = Convert.ToInt32(txtYear.Text);
                    int Months = Convert.ToInt32(ddMonth.SelectedItem.Value);

                    IReports ReportDetails = (IReports)ObjectFactory.CreateInstance("BusinessProcess.Reports.BReports,BusinessProcess.Reports");
                    theRepDS = (DataSet)ReportDetails.GetNACPMonthlyReportData(Months, years, Convert.ToInt32(Session["AppLocationId"]));

                    #region "TableNames"
                    theRepDS.Tables[0].TableName = "FacilityInfo";
                    theRepDS.Tables[1].TableName = "Table1Data";
                    theRepDS.Tables[2].TableName = "Table2Data";
                    #endregion


                    //Response.Redirect("..\\ExcelFiles\\TZNACPMonthlyReport.xls");
                    Excel.Spreadsheet theApp      = new Microsoft.Office.Interop.Owc11.Spreadsheet();
                    string            theFilePath = Server.MapPath("..\\ExcelFiles\\Templates\\TanzaniaNACPMonthlyreport.xml");
                    theApp.XMLURL = theFilePath;
                    writeCellWiseInExcel(theApp);

                    // theApp.Export(Server.MapPath("..\\ExcelFiles\\TZNACPMonthlyReport.xls"), Microsoft.Office.Interop.Owc11.SheetExportActionEnum.ssExportActionOpenInExcel, Microsoft.Office.Interop.Owc11.SheetExportFormat.ssExportAsAppropriate);
                    theApp.Export(Server.MapPath("..\\ExcelFiles\\TZNACPMonthlyReport.xls"), Microsoft.Office.Interop.Owc11.SheetExportActionEnum.ssExportActionNone, Microsoft.Office.Interop.Owc11.SheetExportFormat.ssExportXMLSpreadsheet);
                    //theUtils.OpenExcelFile(Server.MapPath("..\\ExcelFiles\\TZNACPMonthlyReport.xls"), Response);
                    IQWebUtils theUtl = new IQWebUtils();
                    theUtl.ShowExcelFile(Server.MapPath("..\\ExcelFiles\\TZNACPMonthlyReport.xls"), Response);
                }
            }
            catch (Exception err)
            {
                MsgBuilder theBuilder = new MsgBuilder();
                theBuilder.DataElements["MessageText"] = err.Message.ToString();
                IQCareMsgBox.Show("#C1", theBuilder, this);
                return;
            }
        }