public void ExportToExcelDepartmentAverageMark(string departmentId, string reportType, string dateValue, Guid?parentId)
        {
            Guid?department;

            if (departmentId == "*")
            {
                department = null;
            }
            else
            {
                department = Guid.Parse(departmentId);
            }
            var dates = dateValue.Split(',').ToArray();

            DateTime[] dateValues = new DateTime[] {
                DateTime.ParseExact(dates[0], "MM/dd/yyyy", CultureInfo.InvariantCulture),
                DateTime.ParseExact(dates[1], "MM/dd/yyyy", CultureInfo.InvariantCulture)
            };

            XlsReport    report  = new XlsReport(unit, department, reportType, dateValues, parentId);
            ExcelPackage package = report.FormReport();

            Response.Clear();
            Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
            Response.AddHeader("content-disposition", "attachment: filename=ExcelReport.xlsx");
            Response.BinaryWrite(package.GetAsByteArray());
            Response.End();
        }
예제 #2
0
 public void ShouldReturnMinValueDateTimeWhenReadingStartTimeFromAnEmptyCell()
 {
     using (var report = new XlsReport(TestTimesheet))
     {
         var readTime = report.ReadStartTime(new DateTime(2012, 12, 19));
         Assert.That(readTime, Is.EqualTo(DateTime.MinValue));
     }
 }
예제 #3
0
        public void ShouldReturnTimeFromEndTimeCellWhenPassedARequestedEndTime()
        {
            var endTime = new DateTime(2012, 12, 20, 08, 15, 00);

            using (var report = new XlsReport(TestTimesheet))
            {
                report.WriteEndTime(endTime);
                var readTime = report.ReadEndTime(new DateTime(2012, 12, 20));
                Assert.That(readTime, Is.EqualTo(endTime));
            }
        }
예제 #4
0
        public void ShouldWritetimeToCorrectCellForTuesdayInCoupleOfWeeks()
        {
            using (var report = new XlsReport(TestTimesheet))
            {
                var nextMondayStartTime = new DateTime(2013, 01, 01, 08, 15, 00);
                report.WriteStartTime(nextMondayStartTime);
            }

            var date = GetValueFromCell(TestTimesheet, "January", "C40");

            Assert.That(ConvertToDateTime(date), Is.EqualTo(new TimeSpan(8, 15, 0)));
        }
예제 #5
0
        public void ShouldWriteTimeToCorrectCellForNextFridayStartTime()
        {
            using (var report = new XlsReport(TestTimesheet))
            {
                var nextMondayStartTime = new DateTime(2012, 12, 28, 08, 15, 00);
                report.WriteStartTime(nextMondayStartTime);
            }

            var date = GetValueFromCell(TestTimesheet, "January", "C27");

            Assert.That(ConvertToDateTime(date), Is.EqualTo(new TimeSpan(8, 15, 0)));
        }
예제 #6
0
        public void ShouldWriteTimeToCorrectCellForMondayStartTime()
        {
            using (var report = new XlsReport(TestTimesheet))
            {
                var mondayStartTime = new DateTime(2012, 12, 17, 9, 30, 0);
                report.WriteStartTime(mondayStartTime);
            }

            var date = GetValueFromCell(TestTimesheet, "January", "C7");

            Assert.That(ConvertToDateTime(date), Is.EqualTo(new TimeSpan(9, 30, 0)));
        }
예제 #7
0
        public void ShouldWriteEndTimeToCorrectCellForThursday()
        {
            using (var report = new XlsReport(TestTimesheet))
            {
                var thursdayEndTime = new DateTime(2012, 12, 20, 08, 15, 00);
                report.WriteEndTime(thursdayEndTime);
            }

            var date = GetValueFromCell(TestTimesheet, "January", "D10");

            Assert.That(ConvertToDateTime(date), Is.EqualTo(new TimeSpan(8, 15, 0)));
        }
        public void ExportToExcel(string departmentId, string reportType, DateTime dateValue, Guid?parentId)
        {
            Guid?department;

            if (departmentId == "*")
            {
                department = null;
            }
            else
            {
                department = Guid.Parse(departmentId);
            }
            XlsReport    report  = new XlsReport(unit, department, reportType, dateValue, parentId);
            ExcelPackage package = report.FormReport();

            Response.Clear();
            Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
            Response.AddHeader("content-disposition", "attachment: filename=ExcelReport.xlsx");
            Response.BinaryWrite(package.GetAsByteArray());
            Response.End();
        }
예제 #9
0
        private void btn_stampa_Click(object sender, System.Web.UI.ImageClickEventArgs e)
        {
            DocsPAWA.DocsPaWR.FileDocumento fileRep = new DocsPAWA.DocsPaWR.FileDocumento();
            try
            {
                string dataInizio = "";
                string dataFine   = "";

                #region controllo che i campi data non siano vuoti
                if (this.txt_initDataScadenza.Text.Equals("") || this.txt_fineDataScadenza.Text.Equals(""))
                {
                    Response.Write("<script>alert('Attenzione inserire il periodo di riferimento.');</script>");
                    string s = "<SCRIPT language='javascript'>document.getElementById('" + txt_initDataScadenza.ID + "').focus();</SCRIPT>";
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "focus", s);
                    do_openinRightFrame(this, "whitepage.htm");
                    return;
                }

                if (!this.txt_initDataScadenza.Text.Equals(""))
                {
                    //controllo validità di data iniziale
                    if (!DocsPAWA.Utils.isDate(this.txt_initDataScadenza.Text))
                    {
                        Response.Write("<script>alert('Il formato della data non è valido. \\nIl formato richiesto è gg/mm/aaaa');</script>");
                        string s = "<SCRIPT language='javascript'>document.getElementById('" + txt_initDataScadenza.ID + "').focus();</SCRIPT>";
                        Page.ClientScript.RegisterStartupScript(this.GetType(), "focus", s);
                        do_openinRightFrame(this, "whitepage.htm");
                        return;
                    }
                }
                if (!this.txt_fineDataScadenza.Text.Equals(""))
                {
                    //controllo validità di data finale
                    if (!DocsPAWA.Utils.isDate(this.txt_fineDataScadenza.Text))
                    {
                        Response.Write("<script>alert('Il formato della data non è valido. \\nIl formato richiesto è gg/mm/aaaa');</script>");
                        string s = "<SCRIPT language='javascript'>document.getElementById('" + txt_fineDataScadenza.ID + "').focus();</SCRIPT>";
                        Page.ClientScript.RegisterStartupScript(this.GetType(), "focus", s);
                        do_openinRightFrame(this, "whitepage.htm");
                        return;
                    }
                }
                if (DocsPAWA.Utils.verificaIntervalloDate(txt_initDataScadenza.Text, txt_fineDataScadenza.Text))
                {
                    //controllo periodo data
                    Response.Write("<script>alert('Verificare intervallo date !');</script>");
                    string s = "<SCRIPT language='javascript'>document.getElementById('" + txt_initDataScadenza.ID + "').focus();</SCRIPT>";
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "focus", s);
                    do_openinRightFrame(this, "whitepage.htm");
                    return;
                }
                #endregion

                dataInizio = this.txt_initDataScadenza.Text;
                dataFine   = this.txt_fineDataScadenza.Text;
                int id_reg = Convert.ToInt32(ddl_registro.SelectedValue);
                fileRep = XlsReport.CreaReportPianiRientro(this, id_reg, ddl_registro.SelectedItem.Text, dataInizio, dataFine);
                if (fileRep != null)
                {
                    DocsPAWA.exportDati.exportDatiSessionManager session = new DocsPAWA.exportDati.exportDatiSessionManager();
                    session.SetSessionExportFile(fileRep);
                }
            }
            catch (Exception ex)
            {
                DocsPAWA.ErrorManager.redirectToErrorPage(this, ex);
            }
            if (fileRep != null)
            {
                if (fileRep.content != null && fileRep.content.Length > 0)
                {
                    this.executeJS("<SCRIPT>OpenFile();</SCRIPT>");
                    do_openinRightFrame(this, "whitepage.htm");
                }
                else
                {
                    this.executeJS("<SCRIPT>alert('Impossibile generare il file xls');</SCRIPT>");
                }
            }
            else
            {
                do_alert(this, "Non ci sono dati per il Rapporto selezionato");
                do_openinRightFrame(this, "whitepage.htm");
            }
        }