예제 #1
0
    public void CreateReport()
    {
        LocalReport report = new LocalReport();

        byte[] file;
        string mimeType, encoding, fileExtension;

        string[]  streams;
        Warning[] warnings;

        ReportDataSource rds = new ReportDataSource();

        rds.Name = "MostreFabrica";

        List <MostreFabrica> mostre = MostreFabrica.GetMostreFabrica(DropDownList1.SelectedValue, TextBox1.Text, TextBox2.Text);

        string datatestare  = TextBox1.Text;
        string datatestare2 = TextBox2.Text;

        rds.Value = mostre;

        report.DataSources.Clear();
        report.DataSources.Add(rds);

        report.ReportPath = "ReportFabricaIntre4.rdlc";

        report.Refresh();

        string deviceInfo =
            "<DeviceInfo>" +
            "  <OutputFormat>PDF</OutputFormat>" +
            "  <PageWidth>29.7cm</PageWidth>" +
            "  <PageHeight>21cm</PageHeight>" +
            "  <MarginTop>0.0cm</MarginTop>" +
            "  <MarginLeft>0.1cm</MarginLeft>" +
            "  <MarginRight>0.1cm</MarginRight>" +
            "  <MarginBottom>0.5cm</MarginBottom>" +
            "</DeviceInfo>";

        string deviceInfoXls =
            "<DeviceInfo>" +
            "  <OutputFormat>XLS</OutputFormat>" +
            "  <PageWidth>29.7cm</PageWidth>" +
            "  <PageHeight>21cm</PageHeight>" +
            "  <MarginTop>0.0cm</MarginTop>" +
            "  <MarginLeft>0.0cm</MarginLeft>" +
            "  <MarginRight>0.1cm</MarginRight>" +
            "  <MarginBottom>0.1cm</MarginBottom>" +
            "</DeviceInfo>";

        string fabricaid   = DropDownList1.SelectedValue;
        string fabricaname = DropDownList1.Items[DropDownList1.SelectedIndex].ToString();
        // read fabrica
        SqlConnection cnn = new SqlConnection(ConfigurationManager.ConnectionStrings["fccl2ConnectionString"].ConnectionString);
        SqlCommand    cmd = new SqlCommand();

        cmd.Connection = cnn;

        cmd.CommandText = "SELECT Fabrici.Strada,Fabrici.Numar,Fabrici.Oras,Judete.Denloc "
                          + "FROM Fabrici,Judete WHERE Fabrici.ID=" + fabricaid + " AND Fabrici.Judet=Judete.ID";
        cnn.Open();
        SqlDataReader reader = cmd.ExecuteReader();

        reader.Read();
        string fabricastrada = Convert.ToString(reader["Strada"]);
        string fabricanumar  = Convert.ToString(reader["Numar"]);
        string fabricaoras   = Convert.ToString(reader["Oras"]);
        string fabricajudet  = Convert.ToString(reader["Denloc"]);

        reader.Close();
        cnn.Close();

        //set report parameters
        string          laborator      = ddlLaborator.Items[ddlLaborator.SelectedIndex].ToString();
        string          responsabil    = ddlResponsabil.Items[ddlResponsabil.SelectedIndex].ToString();
        string          combi          = mostre[0].Combi;
        ReportParameter pDatatestare   = new ReportParameter("datatestare", datatestare);
        ReportParameter pDatatestare2  = new ReportParameter("datatestare2", datatestare2);
        ReportParameter pCombi         = new ReportParameter("combi", combi);
        ReportParameter pFabricanume   = new ReportParameter("fabricanume", fabricaname);
        ReportParameter pFabricastrada = new ReportParameter("fabricastrada", fabricastrada);
        ReportParameter pFabricanumar  = new ReportParameter("fabricanumar", fabricanumar);
        ReportParameter pFabricaoras   = new ReportParameter("fabricaoras", fabricaoras);
        ReportParameter pFabricajudet  = new ReportParameter("fabricajudet", fabricajudet);
        ReportParameter pLaborator     = new ReportParameter("laborator", laborator);
        ReportParameter pResponsabil   = new ReportParameter("responsabil", responsabil);
        ReportParameter pVersiune      = new ReportParameter("Versiune", new SettingManager(StaticDataHelper.FCCLDbContext).GetValueByName("ReportFabricaIntre4"));

        ReportParameter[] p = { pDatatestare, pDatatestare2, pCombi, pFabricanume, pFabricastrada, pFabricanumar, pFabricaoras, pFabricajudet, pLaborator, pResponsabil, pVersiune };
        report.SetParameters(p);

        file = report.Render("PDF", deviceInfo, out mimeType, out encoding, out fileExtension, out streams, out warnings);
        string httppath = StaticDataHelper.SettingsManager.CaleRapoarteHttp;
        string filepath = StaticDataHelper.SettingsManager.CaleRapoarte;

        fabricaname = replace_special_car_null(fabricaname);

        string raport_name  = "RaportFabrica" + datatestare.Replace("/", "_") + "_" + datatestare2.Replace("/", "_") + "_" + fabricaid + "-" + fabricaname + ".pdf";
        string raport_excel = "RaportFabrica" + datatestare.Replace("/", "_") + "_" + datatestare2.Replace("/", "_") + "_" + fabricaid + "-" + fabricaname + ".xls";

        string path_raport_http = "http://" + Request.ServerVariables.Get("HTTP_HOST") + "/" + httppath;
        string pdf_link         = path_raport_http + @"Fabrici/" + raport_name;
        string pdf_file         = filepath + @"Fabrici/" + raport_name;
        // writefile

        string excel_link = path_raport_http + @"Fabrici/" + raport_excel;
        string excel_file = filepath + @"Fabrici/" + raport_excel;

        report.SetParameters(new ReportParameter("BkImage", ""));
        File.WriteAllBytes(pdf_file, file);
        byte[] file_xls = report.Render("EXCEL", deviceInfoXls, out mimeType, out encoding, out fileExtension, out streams, out warnings);
        File.WriteAllBytes(excel_file, file_xls);

        pdflink.Visible     = true;
        pdflink.NavigateUrl = pdf_link;
        pdflink.Text        = raport_name;

        xlslink.Visible     = true;
        xlslink.NavigateUrl = excel_link;
        xlslink.Text        = raport_excel;
    }
예제 #2
0
    public void CreateReport()
    {
        LocalReport report = new LocalReport();

        byte[] file;
        string mimeType, encoding, fileExtension;

        string[]  streams;
        Warning[] warnings;

        long          reportNumber;
        ReportManager rManager  = new ReportManager(ctx);
        Report        dalReport = rManager.GetOrCreateReport(FCCLReportType.Fabrica, ObjectId
                                                             , DropDownList1.SelectedItem.Text, TestDate, PrintDate, long.TryParse(TextBox3.Text, out reportNumber) ? (long?)reportNumber : null);

        TextBox3.Text = dalReport.ReportNumber.ToString();

        ReportDataSource rds = new ReportDataSource();

        rds.Name = "MostreFabrica";

        List <MostreFabrica> mostre = MostreFabrica.GetMostreFabrica(DropDownList1.SelectedValue, TextBox1.Text);

        rds.Value = mostre;
        string datatestare = TextBox1.Text;

        string datatmin      = datatestare;
        string datatmax      = datatestare;
        string datatesttitlu = datatestare;

        string dataprimirii  = "";
        string datapmin      = dataprimirii;
        string datapmax      = dataprimirii;
        string dataprimtitlu = dataprimirii;

        string nrcomanda = "";
        string combi     = mostre[0].Combi;

        foreach (MostreFabrica mf in mostre)
        {
            string datamin = mf.DataTestare;
            string datamax = mf.DataTestareFinala;
            dataprimirii = mf.DataPrimirii;
            if (datapmin == "")
            {
                datapmin = dataprimirii;
            }
            if (datapmax == "")
            {
                datapmax = dataprimirii;
            }

            if (mf.NrComanda.Trim() != "")
            {
                nrcomanda = mf.NrComanda.Trim();
            }
            if (datamin != datatmin)
            {
                DateTime dt1 = new DateTime(Int32.Parse(datamin.Substring(6, 4)), Int32.Parse(datamin.Substring(3, 2)), Int32.Parse(datamin.Substring(0, 2)));
                DateTime dt2 = new DateTime(Int32.Parse(datatmin.Substring(6, 4)), Int32.Parse(datatmin.Substring(3, 2)), Int32.Parse(datatmin.Substring(0, 2)));
                if (DateTime.Compare(dt1, dt2) < 0)
                {
                    datatmin = datamin;
                }
            }
            if (datamax != datatmax)
            {
                DateTime dt1 = new DateTime(Int32.Parse(datamax.Substring(6, 4)), Int32.Parse(datamax.Substring(3, 2)), Int32.Parse(datamax.Substring(0, 2)));
                DateTime dt2 = new DateTime(Int32.Parse(datatmax.Substring(6, 4)), Int32.Parse(datatmax.Substring(3, 2)), Int32.Parse(datatmax.Substring(0, 2)));
                if (DateTime.Compare(dt1, dt2) > 0)
                {
                    datatmax = datamax;
                }
            }
            // data primirii
            if (dataprimirii != datapmin)
            {
                DateTime dt1 = new DateTime(Int32.Parse(dataprimirii.Substring(6, 4)), Int32.Parse(dataprimirii.Substring(3, 2)), Int32.Parse(dataprimirii.Substring(0, 2)));
                DateTime dt2 = new DateTime(Int32.Parse(datapmin.Substring(6, 4)), Int32.Parse(datapmin.Substring(3, 2)), Int32.Parse(datapmin.Substring(0, 2)));
                if (DateTime.Compare(dt1, dt2) < 0)
                {
                    datapmin = dataprimirii;
                }
            }
            if (dataprimirii != datapmax)
            {
                DateTime dt1 = new DateTime(Int32.Parse(dataprimirii.Substring(6, 4)), Int32.Parse(dataprimirii.Substring(3, 2)), Int32.Parse(dataprimirii.Substring(0, 2)));
                DateTime dt2 = new DateTime(Int32.Parse(datapmax.Substring(6, 4)), Int32.Parse(datapmax.Substring(3, 2)), Int32.Parse(datapmax.Substring(0, 2)));
                if (DateTime.Compare(dt1, dt2) > 0)
                {
                    datapmax = dataprimirii;
                }
            }
        }
        if (datatmin != datatmax)
        {
            datatesttitlu = datatmin + " - " + datatmax;
        }
        if (datapmin != datapmax)
        {
            dataprimtitlu = datapmin + " si " + datapmax;
        }
        else
        {
            dataprimtitlu = datapmin;
        }

        rds.Value = mostre;

        report.DataSources.Clear();
        report.DataSources.Add(rds);

        report.ReportPath = "ReportFabrica4.rdlc";
        report.Refresh();

        string fabricaid   = DropDownList1.SelectedValue;
        string fabricaname = DropDownList1.Items[DropDownList1.SelectedIndex].ToString();
        // read fabrica
        SqlConnection cnn = new SqlConnection(ConfigurationManager.ConnectionStrings["fccl2ConnectionString"].ConnectionString);
        SqlCommand    cmd = new SqlCommand();

        cmd.Connection = cnn;

        cmd.CommandText = "SELECT Fabrici.Strada,Fabrici.Numar,Fabrici.Oras,Judete.Denloc " + "FROM Fabrici,Judete WHERE Fabrici.ID=" + fabricaid + " AND Fabrici.Judet=Judete.ID";
        cnn.Open();
        SqlDataReader reader = cmd.ExecuteReader();

        reader.Read();
        string fabricastrada = Convert.ToString(reader["Strada"]);
        string fabricanumar  = Convert.ToString(reader["Numar"]);
        string fabricaoras   = Convert.ToString(reader["Oras"]);
        string fabricajudet  = Convert.ToString(reader["Denloc"]);

        reader.Close();
        cnn.Close();
        string nrb = dalReport.ReportNumber.ToString();
        //set report parameters
        string laborator   = ddlLaborator.Items[ddlLaborator.SelectedIndex].ToString();
        string responsabil = ddlResponsabil.Items[ddlResponsabil.SelectedIndex].ToString();

        ReportParameter pNrcomanda     = new ReportParameter("nrcomanda", nrcomanda);
        ReportParameter pDatatestare   = new ReportParameter("datatestare", datatesttitlu);
        ReportParameter pDataprimirii  = new ReportParameter("dataprimirii", dataprimtitlu);
        ReportParameter pCombi         = new ReportParameter("combi", combi);
        ReportParameter pDatab         = new ReportParameter("datab", TextBox2.Text);
        ReportParameter pNrb           = new ReportParameter("nrb", nrb);
        ReportParameter pFabricanume   = new ReportParameter("fabricanume", fabricaname);
        ReportParameter pFabricastrada = new ReportParameter("fabricastrada", fabricastrada);
        ReportParameter pFabricanumar  = new ReportParameter("fabricanumar", fabricanumar);
        ReportParameter pFabricaoras   = new ReportParameter("fabricaoras", fabricaoras);
        ReportParameter pFabricajudet  = new ReportParameter("fabricajudet", fabricajudet);
        ReportParameter pLaborator     = new ReportParameter("laborator", laborator);
        ReportParameter pResponsabil   = new ReportParameter("responsabil", responsabil);
        ReportParameter pVersiune      = new ReportParameter("Versiune", new SettingManager(StaticDataHelper.FCCLDbContext).GetValueByName("ReportFabrica4"));

        ReportParameter[] p = { pDatatestare,  pDataprimirii, pCombi,       pNrcomanda, pDatab, pNrb, pFabricanume, pFabricastrada, pFabricanumar, pFabricaoras,
                                pFabricajudet, pLaborator,    pResponsabil, pVersiune };
        report.SetParameters(p);

        file = report.Render("PDF", StaticData.DEVICE_INFO_PDF, out mimeType, out encoding, out fileExtension, out streams, out warnings);

        string httppath = StaticDataHelper.SettingsManager.CaleRapoarteHttp;
        string filepath = StaticDataHelper.SettingsManager.CaleRapoarte;

        fabricaname = replace_special_car_null(fabricaname);
        string raport_name      = "RaportFabrica" + datatestare.Replace("/", "_") + "_" + fabricaid + "-" + fabricaname + ".pdf";
        string raport_excel     = "RaportFabrica" + datatestare.Replace("/", "_") + "_" + fabricaid + "-" + fabricaname + ".xls";
        string path_raport_http = "http://" + Request.ServerVariables.Get("HTTP_HOST") + "/" + httppath;
        string pdf_link         = path_raport_http + @"Fabrici/" + raport_name;
        string pdf_file         = filepath + @"Fabrici/" + raport_name;
        // writefile

        string excel_link = path_raport_http + @"Fabrici/" + raport_excel;
        string excel_file = filepath + @"Fabrici/" + raport_excel;

        File.WriteAllBytes(pdf_file, file);
        File.WriteAllBytes(pdf_file, file);
        dalReport.SampleCount = mostre.Count;
        dalReport.PageCount   = PDFHelper.GetNumberOfPdfPages(pdf_file);
        rManager.Save(dalReport);
        ctx.SaveChanges();

        // raport excel
        LocalReport rapexcel = new LocalReport();

        ReportDataSource rdse = new ReportDataSource();

        rdse.Name  = "MostreFabrica";
        rdse.Value = mostre;
        rapexcel.DataSources.Clear();
        rapexcel.DataSources.Add(rdse);
        rapexcel.ReportPath = "ReportFabricaExcel4.rdlc";
        rapexcel.SetParameters(p);
        rapexcel.Refresh();

        byte[] file_xls = rapexcel.Render("EXCEL", StaticData.DEVICE_INFO_XLS, out mimeType, out encoding, out fileExtension, out streams, out warnings);
        // end raport excel
        File.WriteAllBytes(excel_file, file_xls);

        pdflink.Visible     = true;
        pdflink.NavigateUrl = pdf_link;
        pdflink.Text        = raport_name;

        xlslink.Visible     = true;
        xlslink.NavigateUrl = excel_link;
        xlslink.Text        = raport_excel;
    }
예제 #3
0
    public void CreateReport()
    {
        ReportManager rManager = new ReportManager(ctx);
        DateTime      testDate;
        int           farmId;

        DateTime.TryParse(TextBox1.Text, out testDate);
        Int32.TryParse(DropDownList1.SelectedValue, out farmId);

        Report b     = rManager.GetByDateAndId(testDate, farmId);
        string nrb   = b.ReportNumber.ToString();
        string datab = b.TestDate.ToShortDateString();
        int    pos   = 0;

        LocalReport report = new LocalReport();

        byte[] file;
        string mimeType, encoding, fileExtension;

        string[]  streams;
        Warning[] warnings;

        string fabricaid   = DropDownList1.SelectedValue;
        string fabricaname = DropDownList1.Items[DropDownList1.SelectedIndex].ToString();
        // read fabrica
        SqlConnection cnn = new SqlConnection(ConfigurationManager.ConnectionStrings["fccl2ConnectionString"].ConnectionString);
        SqlCommand    cmd = new SqlCommand();

        cmd.Connection = cnn;

        cmd.CommandText = "SELECT Fabrici.Strada,Fabrici.Numar,Fabrici.Oras,Judete.Denloc "
                          + "FROM Fabrici,Judete WHERE Fabrici.ID=" + fabricaid + " AND Fabrici.Judet=Judete.ID";
        cnn.Open();
        SqlDataReader reader = cmd.ExecuteReader();

        reader.Read();
        string fabricastrada = Convert.ToString(reader["Strada"]);
        string fabricanumar  = Convert.ToString(reader["Numar"]);
        string fabricaoras   = Convert.ToString(reader["Oras"]);
        string fabricajudet  = Convert.ToString(reader["Denloc"]);

        reader.Close();
        cnn.Close();
        string datatestare = TextBox1.Text;
        // date fabrica

        //deviceinfo

        string deviceInfo =
            "<DeviceInfo>" +
            "  <OutputFormat>PDF</OutputFormat>" +
            "  <PageWidth>29.7cm</PageWidth>" +
            "  <PageHeight>21cm</PageHeight>" +
            "  <MarginTop>0.0cm</MarginTop>" +
            "  <MarginLeft>0.5cm</MarginLeft>" +
            "  <MarginRight>0.5cm</MarginRight>" +
            "  <MarginBottom>0.5cm</MarginBottom>" +
            "</DeviceInfo>";

        string httppath = StaticDataHelper.SettingsManager.CaleRapoarteHttp;
        string filepath = StaticDataHelper.SettingsManager.CaleRapoarte;

        cmd.CommandTimeout = 300;
        cmd.CommandText    = "SELECT DISTINCT Ferme_CCL.Nume,Ferme_CCL.ID, MostreTancuri.FermaID,  Ferme_CCL.Cod, "
                             + "Ferme_CCL.Strada,Ferme_CCL.Numar, Ferme_CCL.Oras, Ferme_CCL.Judet,Ferme_CCL.PersonaDeContact,Ferme_CCL.TelPersoanaContact,Ferme_CCL.Ferme_CCL,Ferme_CCL.FermierID,Judete.Denloc "
                             + " FROM MostreTancuri, Ferme_CCL INNER JOIN JUDETE ON  Convert(int,Ferme_CCL.Judet,2)=Judete.ID WHERE"
                             + " CONVERT(datetime, MostreTancuri.DataTestareFinala, 103) = CONVERT(datetime, '" + datatestare + "', 103) "
                             + " AND MostreTancuri.CodFerma = Ferme_CCL.Cod " + " AND Ferme_CCL.FabricaID = " + fabricaid
                             + " AND MostreTancuri.Validat = 1 ORDER BY Ferme_CCL.Nume";

        cnn.Open();
        SqlDataReader drferme = cmd.ExecuteReader();
        //prepare report parameters
        string laborator   = ddlLaborator.Items[ddlLaborator.SelectedIndex].ToString();
        string responsabil = ddlResponsabil.Items[ddlResponsabil.SelectedIndex].ToString();
        string semnlab     = ddlLaborator.SelectedValue;
        string semnresp    = ddlResponsabil.SelectedValue;

        semnresp = semnresp.Substring(0, semnresp.LastIndexOf("."));
        semnlab  = semnlab.Substring(0, semnlab.LastIndexOf("."));
        semnresp = semnresp.ToLower();
        semnlab  = semnlab.ToLower();

        ReportParameter pDatatestare   = new ReportParameter("datatestare", datatestare);
        ReportParameter pDatab         = new ReportParameter("datab", datab);
        ReportParameter pNrb           = new ReportParameter("nrb", nrb);
        ReportParameter pFabricanume   = new ReportParameter("fabricanume", fabricaname);
        ReportParameter pFabricastrada = new ReportParameter("fabricastrada", fabricastrada);
        ReportParameter pFabricanumar  = new ReportParameter("fabricanumar", fabricanumar);
        ReportParameter pFabricaoras   = new ReportParameter("fabricaoras", fabricaoras);
        ReportParameter pFabricajudet  = new ReportParameter("fabricajudet", fabricajudet);
        ReportParameter pLaborator     = new ReportParameter("laborator", laborator);
        ReportParameter pResponsabil   = new ReportParameter("responsabil", responsabil);

        List <FileLinks> list = new List <FileLinks>();

        while (drferme.Read())
        {
            FileLinks filelink         = new FileLinks();
            string    fermacod         = Convert.ToString(drferme["Cod"]);
            string    fermanume        = Convert.ToString(drferme["Nume"]);
            string    fermastrada      = Convert.ToString(drferme["Strada"]);
            string    fermanumar       = Convert.ToString(drferme["Numar"]);
            string    fermaoras        = Convert.ToString(drferme["Oras"]);
            string    judet            = Convert.ToString(drferme["Denloc"]);
            string    codferma         = Convert.ToString(drferme["Cod"]);
            string    fermaadresa      = "Str. " + fermastrada + " nr. " + fermanumar + ", " + fermaoras;
            string    fermatelcontact  = Convert.ToString(drferme["TelPersoanaContact"]);
            string    fermaperscontact = Convert.ToString(drferme["PersonaDeContact"]);

            ReportDataSource rds = new ReportDataSource();
            rds.Name = "MostreFabrica";
            List <MostreFabrica> mostre = MostreFabrica.GetMostreFerma(fabricaid, fermacod, datatestare);
            rds.Value = mostre;
            // build dates interval
            string datatmin      = datatestare;
            string datatmax      = datatestare;
            string datatesttitlu = datatestare;

            string dataprimirii  = "";
            string datapmin      = dataprimirii;
            string datapmax      = dataprimirii;
            string dataprimtitlu = dataprimirii;

            string combi = mostre[0].Combi;

            foreach (MostreFabrica mf in mostre)
            {
                string datamin = mf.DataTestare;
                string datamax = mf.DataTestareFinala;
                dataprimirii = mf.DataPrimirii;
                if (datapmin == "")
                {
                    datapmin = dataprimirii;
                }
                if (datapmax == "")
                {
                    datapmax = dataprimirii;
                }

                if (datamin != datatmin)
                {
                    DateTime dt1 = new DateTime(Int32.Parse(datamin.Substring(6, 4)), Int32.Parse(datamin.Substring(3, 2)), Int32.Parse(datamin.Substring(0, 2)));
                    DateTime dt2 = new DateTime(Int32.Parse(datatmin.Substring(6, 4)), Int32.Parse(datatmin.Substring(3, 2)), Int32.Parse(datatmin.Substring(0, 2)));
                    if (DateTime.Compare(dt1, dt2) < 0)
                    {
                        datatmin = datamin;
                    }
                }
                if (datamax != datatmax)
                {
                    DateTime dt1 = new DateTime(Int32.Parse(datamax.Substring(6, 4)), Int32.Parse(datamax.Substring(3, 2)), Int32.Parse(datamax.Substring(0, 2)));
                    DateTime dt2 = new DateTime(Int32.Parse(datatmax.Substring(6, 4)), Int32.Parse(datatmax.Substring(3, 2)), Int32.Parse(datatmax.Substring(0, 2)));
                    if (DateTime.Compare(dt1, dt2) > 0)
                    {
                        datatmax = datamax;
                    }
                }
                // data primirii
                if (dataprimirii != datapmin)
                {
                    DateTime dt1 = new DateTime(Int32.Parse(dataprimirii.Substring(6, 4)), Int32.Parse(dataprimirii.Substring(3, 2)), Int32.Parse(dataprimirii.Substring(0, 2)));
                    DateTime dt2 = new DateTime(Int32.Parse(datapmin.Substring(6, 4)), Int32.Parse(datapmin.Substring(3, 2)), Int32.Parse(datapmin.Substring(0, 2)));
                    if (DateTime.Compare(dt1, dt2) < 0)
                    {
                        datapmin = dataprimirii;
                    }
                }
                if (dataprimirii != datapmax)
                {
                    DateTime dt1 = new DateTime(Int32.Parse(dataprimirii.Substring(6, 4)), Int32.Parse(dataprimirii.Substring(3, 2)), Int32.Parse(dataprimirii.Substring(0, 2)));
                    DateTime dt2 = new DateTime(Int32.Parse(datapmax.Substring(6, 4)), Int32.Parse(datapmax.Substring(3, 2)), Int32.Parse(datapmax.Substring(0, 2)));
                    if (DateTime.Compare(dt1, dt2) > 0)
                    {
                        datapmax = dataprimirii;
                    }
                }
            }
            if (datatmin != datatmax)
            {
                datatesttitlu = datatmin + " - " + datatmax;
            }
            if (datapmin != datapmax)
            {
                dataprimtitlu = datapmin + " si " + datapmax;
            }
            else
            {
                dataprimtitlu = datapmin;
            }

            // end dates interval
            report.DataSources.Clear();
            report.DataSources.Add(rds);

            pos++;
            report.ReportPath = "ReportFerme4.rdlc";

            report.Refresh();

            ReportParameter pDatatitlu        = new ReportParameter("datatestare", datatesttitlu);
            ReportParameter pDataprimirii     = new ReportParameter("dataprimirii", dataprimtitlu);
            ReportParameter pCombi            = new ReportParameter("combi", combi);
            ReportParameter pPos              = new ReportParameter("pos", pos.ToString());
            ReportParameter pCodferma         = new ReportParameter("codferma", codferma);
            ReportParameter pFermanume        = new ReportParameter("fermanume", fermanume);
            ReportParameter pFermaadresa      = new ReportParameter("fermaadresa", fermaadresa);
            ReportParameter pFermajudet       = new ReportParameter("fermajudet", judet);
            ReportParameter pFermaperscontact = new ReportParameter("fermaperscontact", fermaperscontact);
            ReportParameter pFermatelcontact  = new ReportParameter("fermatelcontact", fermatelcontact);
            ReportParameter versiuneRaport    = new ReportParameter("Versiune", new SettingManager(StaticDataHelper.FCCLDbContext).GetValueByName("ReportFerme4"));

            ReportParameter[] p = { pDatatitlu, pDataprimirii, pCombi,       pDatab,      pNrb,      pFabricanume,      pFabricastrada,   pFabricanumar, pFabricaoras, pFabricajudet, pLaborator, pResponsabil,
                                    pPos,       pFermanume,    pFermaadresa, pFermajudet, pCodferma, pFermaperscontact, pFermatelcontact, versiuneRaport };

            report.SetParameters(p);

            file = report.Render("PDF", deviceInfo, out mimeType, out encoding, out fileExtension, out streams, out warnings);
            // read from date fixe!!!

            fermanume = replace_special_car_null(fermanume);

            string raport_name  = "RaportFerma" + datatestare.Replace("/", "_") + "_" + fermacod + "-" + fermanume + ".pdf";
            string raport_excel = "RaportFerma" + datatestare.Replace("/", "_") + "_" + fermacod + "-" + fermanume + ".xls";

            string path_raport_http = "http://" + Request.ServerVariables.Get("HTTP_HOST") + "/" + httppath;
            string pdf_link         = path_raport_http + @"Ferme/" + raport_name;
            string pdf_file         = filepath + @"Ferme/" + raport_name;
            File.WriteAllBytes(pdf_file, file);

            filelink.Url = pdf_link;
            filelink.Des = raport_name;
            list.Add(filelink);
        }

        drferme.Close();
        cnn.Close();
        //raport cumulat
        LocalReport      report_cum = new LocalReport();
        ReportDataSource rdsc       = new ReportDataSource();

        rdsc.Name  = "MostreFabrica1";
        rdsc.Value = MostreFabrica.GetMostreFabrica(fabricaid, datatestare);

        report_cum.DataSources.Clear();
        report_cum.DataSources.Add(rdsc);

        report_cum.ReportPath = "ReportCumulat4.rdlc";
        report_cum.Refresh();

        ReportParameter pSemnlab        = new ReportParameter("semnlab", semnlab);
        ReportParameter pSemnresp       = new ReportParameter("semnresp", semnresp);
        ReportParameter pVersiuneRaport = new ReportParameter("Versiune", new SettingManager(StaticDataHelper.FCCLDbContext).GetValueByName("ReportCumulat4"));

        ReportParameter[] rp = { pDatatestare, pDatab, pNrb, pFabricanume, pFabricastrada, pFabricanumar, pFabricaoras, pFabricajudet, pLaborator, pResponsabil, pSemnlab, pSemnresp, pVersiuneRaport };

        report_cum.SetParameters(rp);

        byte[] file_cum    = report_cum.Render("PDF", deviceInfo, out mimeType, out encoding, out fileExtension, out streams, out warnings);
        string fabricanume = replace_special_car_null(fabricaname);

        string raport_name_cum = "RaportCumulat" + datatestare.Replace("/", "_") + "_" + fabricaid + "-" + fabricanume + ".pdf";

        string path_raport_http_cum = "http://" + Request.ServerVariables.Get("HTTP_HOST") + "/" + httppath;
        string pdf_link_cum         = path_raport_http_cum + @"Ferme/" + raport_name_cum;
        string pdf_file_cum         = filepath + @"Ferme/" + raport_name_cum;

        // writefile

        File.WriteAllBytes(pdf_file_cum, file_cum);
        linkall.Visible     = true;
        linkall.NavigateUrl = pdf_link_cum;
        linkall.Text        = raport_name_cum;
        //
        Repeater1.DataSource = list;
        Repeater1.DataBind();
        Repeater1.Visible = true;
    }