コード例 #1
0
        private void exportFileImage(XtraReport report)
        {
            ImageExportOptions imageOptions = report.ExportOptions.Image;

            imageOptions.Format = ImageFormat.Png;
            string         reportPath = "";
            SaveFileDialog sf         = new SaveFileDialog();

            sf.FileName = "Save Here.png";
            if (sf.ShowDialog() == DialogResult.OK)
            {
                reportPath = Path.GetDirectoryName(sf.FileName) + sf.FileName;
                try
                {
                    report.ExportToImage(sf.FileName);
                    MessageBox.Show("Lưu thành công!");
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
コード例 #2
0
ファイル: Download.aspx.cs プロジェクト: ShunkevichDV/FIS
    protected void Page_Load(object sender, EventArgs e)
    {
        string Type=Request.Form.Get("type");

        //Section "Восстановить у пользователя"
        if (Type == DOWNLOAD_FILE_RECOVER_USER)
        {
            if (Request.Form.Get("dataBlockId") != null)
            {
                int dataBlockId = Convert.ToInt32(Request.Form.Get("dataBlockId"));
                string connectionString = ConfigurationManager.AppSettings["fleetnetbaseConnectionString"];
                DataBlock dataBlock = new DataBlock(connectionString, ConfigurationManager.AppSettings["language"]);
                dataBlock.OpenConnection();
                byte[] fileBytes = dataBlock.GetDataBlock_BytesArray(dataBlockId);
                string fileName = dataBlock.GetDataBlock_FileName(dataBlockId);
                dataBlock.CloseConnection();

                Response.Clear();
                Response.AddHeader("Content-Disposition", String.Format("attachment;filename=\"{0}\"", fileName));
                Response.AddHeader("Content-Length", fileBytes.Length.ToString());
                Response.ContentType = "application/octet-stream";
                Response.OutputStream.Write(fileBytes, 0, fileBytes.Length);
                Response.End();
                return;
            }
        }

        //Section "PLF Файлы"
        if (Type == GET_PLF_REPORT)
        {
            string CardID=Request.Form.Get("CardID");
            string PLFID=Request.Form.Get("PLFID");
            string UserName = Request.Form.Get("UserName");
            string Format = Request.Form.Get("Format");
            string ReportType = Request.Form.Get("ReportType");
            if (string.IsNullOrEmpty(ReportType))
            {
                ReportType = "Полный отчет";
            }

            int dataBlockId = int.Parse(PLFID);
            List<int> dataBlockIDS = new List<int>();
            dataBlockIDS.Add(dataBlockId);
            int cardID = int.Parse(CardID);

            string connectionString = System.Configuration.ConfigurationManager.AppSettings["fleetnetbaseConnectionString"];
            BLL.DataBlock dataBlock = new BLL.DataBlock(connectionString, ConfigurationManager.AppSettings["language"]);
            dataBlock.OpenConnection();

            DateTime from = new DateTime();
            from = dataBlock.plfUnitInfo.Get_START_PERIOD(dataBlockId);

            DateTime to = new DateTime();
            to = dataBlock.plfUnitInfo.Get_END_PERIOD(dataBlockId);

            string vehicle = dataBlock.plfUnitInfo.Get_VEHICLE(dataBlockId);
            string deviceID = dataBlock.plfUnitInfo.Get_ID_DEVICE(dataBlockId);

            DataSet dataset = new DataSet();

            int userId = dataBlock.usersTable.Get_UserID_byName(UserName);

            List<PLFUnit.PLFRecord> records = new List<PLFUnit.PLFRecord>();
            dataset = ReportDataSetLoader.Get_PLF_ALLData(dataBlockIDS,
                new DateTime(from.Year, from.Month, from.Day), new DateTime(to.Year, to.Month, to.Day),
                cardID, userId, ref records);

            dataBlock.CloseConnection();

            //gets table PlfHeader_1
            DataTable dt = dataset.Tables[0];
            //gets the first row
            DataRow dr = dt.Rows[0];
            string driverName = dr["Имя водителя"].ToString();

            //load needed template
            string path = HttpContext.Current.Server.MapPath("~/templates_plf") + "\\";
            XtraReport report = new XtraReport();
            report.LoadLayout(path + ReportType+".repx");
            report.DataSource = dataset;
            MemoryStream reportStream = new MemoryStream();
            switch (Format)
            {
                case "html": report.ExportToHtml(reportStream); break;
                case "pdf": report.ExportToPdf(reportStream); break;
                case "rtf": report.ExportToRtf(reportStream); break;
                case "png": report.ExportToImage(reportStream,ImageFormat.Png); break;
            }

            Response.Clear();
            Response.AddHeader("Content-Disposition", String.Format("attachment;filename=\"{0}\"", "Отчет " + driverName + " " +
                new DateTime(from.Year, from.Month, from.Day).ToString("dd_MM_yyyy") + "-" + new DateTime(to.Year, to.Month, to.Day).ToString("dd_MM_yyyy") + "." + Format));
            Response.AddHeader("Content-Length", reportStream.GetBuffer().Length.ToString());
            Response.ContentType = "application/octet-stream";
            Response.OutputStream.Write(reportStream.GetBuffer(), 0, reportStream.GetBuffer().Length);
            Response.End();
            return;
        }

        if (Type == GET_PLF_REPORT_FOR_PERIOD)
        {
            string CardID = Request.Form.Get("CardID");
            string StartDate = Request.Form.Get("StartDate");
            string EndDate = Request.Form.Get("EndDate");
            string UserName = Request.Form.Get("UserName");
            string Format = Request.Form.Get("Format");
            string ReportType = Request.Form.Get("ReportType");
            if (string.IsNullOrEmpty(ReportType))
            {
                ReportType = "Полный отчет";
            }

            int cardID = int.Parse(CardID);

            string connectionString = System.Configuration.ConfigurationManager.AppSettings["fleetnetbaseConnectionString"];
            BLL.DataBlock dataBlock = new BLL.DataBlock(connectionString, ConfigurationManager.AppSettings["language"]);
            dataBlock.OpenConnection();

            DateTime from = DateTime.Parse(StartDate);
            DateTime to = DateTime.Parse(EndDate);

            DataSet dataset = new DataSet();
            List<int> dataBlockIDS = dataBlock.cardsTable.GetAllDataBlockIds_byCardId(cardID);

            int userId = dataBlock.usersTable.Get_UserID_byName(UserName);

            List<PLFUnit.PLFRecord> records = new List<PLFUnit.PLFRecord>();
            dataset = ReportDataSetLoader.Get_PLF_ALLData(dataBlockIDS,
                new DateTime(from.Year, from.Month, from.Day), new DateTime(to.Year, to.Month, to.Day),
                cardID, userId, ref records);

            dataBlock.CloseConnection();

            //gets table PlfHeader_1
            DataTable dt = dataset.Tables[0];
            //gets the first row
            DataRow dr = dt.Rows[0];
            string driverName = dr["Имя водителя"].ToString();

            //load needed template
            string path = HttpContext.Current.Server.MapPath("~/templates_plf") + "\\";
            XtraReport report = new XtraReport();
            report.LoadLayout(path + ReportType + ".repx");
            report.DataSource = dataset;
            MemoryStream reportStream = new MemoryStream();
            switch (Format)
            {
                case "html": report.ExportToHtml(reportStream); break;
                case "pdf": report.ExportToPdf(reportStream); break;
                case "rtf": report.ExportToRtf(reportStream); break;
                case "png": report.ExportToImage(reportStream, ImageFormat.Png); break;
            }

            Response.Clear();
            Response.AddHeader("Content-Disposition", String.Format("attachment;filename=\"{0}\"", "Отчет " + driverName + " " +
                new DateTime(from.Year, from.Month, from.Day).ToString("dd_MM_yyyy") + "-" + new DateTime(to.Year, to.Month, to.Day).ToString("dd_MM_yyyy") + "." + Format));
            Response.AddHeader("Content-Length", reportStream.GetBuffer().Length.ToString());
            Response.ContentType = "application/octet-stream";
            Response.OutputStream.Write(reportStream.GetBuffer(), 0, reportStream.GetBuffer().Length);
            Response.End();

            return;
        }

        //Section "Транспортные средства"
        if (Type == GET_DDD_REPORT)
        {
            string DataBlockID = Request.Form.Get("DataBlockID");
            string UserName = Request.Form.Get("UserName");
            string Format = Request.Form.Get("Format");
            string ReportType = Request.Form.Get("ReportType");
            if (string.IsNullOrEmpty(ReportType))
            {
                ReportType = "Полный отчет";
            }

            int dataBlockId = int.Parse(DataBlockID);
            List<int> dataBlockIDS = new List<int>();
            dataBlockIDS.Add(dataBlockId);

            string connectionString = System.Configuration.ConfigurationManager.AppSettings["fleetnetbaseConnectionString"];
            DataBlock dataBlock = new DataBlock(connectionString, ConfigurationManager.AppSettings["language"]);
            dataBlock.OpenConnection();

            DataSet dataset = new DataSet();

            string VIN = dataBlock.vehicleUnitInfo.Get_VehicleOverview_IdentificationNumber(dataBlockId).ToString();
            string RegNumb = dataBlock.vehicleUnitInfo.Get_VehicleOverview_RegistrationIdentification(dataBlockId).vehicleRegistrationNumber.ToString();
            int vehicleId = dataBlock.vehiclesTables.GetVehicleId_byVinRegNumbers(VIN, RegNumb);

            List<DateTime> vehsCardPeriod = dataBlock.vehicleUnitInfo.Get_StartEndPeriod(dataBlockId);

            int userId = dataBlock.usersTable.Get_UserID_byName(UserName);

            dataset = ReportDataSetLoader.Get_Vehicle_ALLDate(vehicleId,
                dataBlockIDS, vehsCardPeriod[0], vehsCardPeriod[1], userId);

            dataBlock.CloseConnection();

            //load needed template
            string path = HttpContext.Current.Server.MapPath("~/templates_ddd") + "\\";
            XtraReport report = new XtraReport();
            report.LoadLayout(path + ReportType + ".repx");
            report.DataSource = dataset;
            MemoryStream reportStream = new MemoryStream();
            switch (Format)
            {
                case "html": report.ExportToHtml(reportStream); break;
                case "pdf": report.ExportToPdf(reportStream); break;
                case "rtf": report.ExportToRtf(reportStream); break;
                case "png": report.ExportToImage(reportStream, ImageFormat.Png); break;
            }

            Response.Clear();
            Response.AddHeader("Content-Disposition", String.Format("attachment;filename=\"{0}\"", "Отчет " + VIN + "_" + RegNumb + " " +
                vehsCardPeriod[0].ToString("dd_MM_yyyy") + "-" + vehsCardPeriod[1].ToString("dd_MM_yyyy") + "." + Format));
            Response.AddHeader("Content-Length", reportStream.GetBuffer().Length.ToString());
            Response.ContentType = "application/octet-stream";
            Response.OutputStream.Write(reportStream.GetBuffer(), 0, reportStream.GetBuffer().Length);
            Response.End();
            return;
        }

        //Section "Транспортные средства"
        if (Type == GET_DDD_REPORT_FOR_PERIOD)
        {
            string CardID = Request.Form.Get("CardID");
            string StartDate = Request.Form.Get("StartDate");
            string EndDate = Request.Form.Get("EndDate");
            string UserName = Request.Form.Get("UserName");
            string Format = Request.Form.Get("Format");
            string ReportType = Request.Form.Get("ReportType");
            if (string.IsNullOrEmpty(ReportType))
            {
                ReportType = "Полный отчет";
            }

            string connectionString = System.Configuration.ConfigurationManager.AppSettings["fleetnetbaseConnectionString"];
            DataBlock dataBlock = new DataBlock(connectionString, ConfigurationManager.AppSettings["language"]);
            dataBlock.OpenConnection();

            DataSet dataset = new DataSet();
            int cardId = int.Parse(CardID);

            string VIN = dataBlock.vehiclesTables.GetVehicleVin(cardId);
            string RegNumb = dataBlock.vehiclesTables.GetVehicleGOSNUM(cardId);

            int vehicleId = dataBlock.vehiclesTables.GetVehicle_byCardId(cardId);
            List<int> dataBlockIDS = dataBlock.cardsTable.GetAllDataBlockIds_byCardId(cardId);

            int userId = dataBlock.usersTable.Get_UserID_byName(UserName);

            DateTime from = DateTime.Parse(StartDate);
            DateTime to = DateTime.Parse(EndDate);

            dataset = ReportDataSetLoader.Get_Vehicle_ALLDate(vehicleId,
                dataBlockIDS, from, to, userId);

            dataBlock.CloseConnection();

            //load needed template
            string path = HttpContext.Current.Server.MapPath("~/templates_ddd") + "\\";
            XtraReport report = new XtraReport();
            report.LoadLayout(path + ReportType + ".repx");
            report.DataSource = dataset;
            MemoryStream reportStream = new MemoryStream();
            switch (Format)
            {
                case "html": report.ExportToHtml(reportStream); break;
                case "pdf": report.ExportToPdf(reportStream); break;
                case "rtf": report.ExportToRtf(reportStream); break;
                case "png": report.ExportToImage(reportStream, ImageFormat.Png); break;
            }

            Response.Clear();
            Response.AddHeader("Content-Disposition", String.Format("attachment;filename=\"{0}\"", "Отчет " + VIN + "_" + RegNumb + " " +
                from.ToString("dd_MM_yyyy") + "-" + to.ToString("dd_MM_yyyy") + "." + Format));
            Response.AddHeader("Content-Length", reportStream.GetBuffer().Length.ToString());
            Response.ContentType = "application/octet-stream";
            Response.OutputStream.Write(reportStream.GetBuffer(), 0, reportStream.GetBuffer().Length);
            Response.End();
            return;
        }
    }
コード例 #3
0
    private MemoryStream PrintDeliveryOrder(string orderNo, string id, string jobType)
    {
        XtraReport rpt      = new XtraReport();
        string     hardCopy = "";

        if (SafeValue.SafeInt(id, 0) > 0)
        {
            rpt.LoadLayout(Server.MapPath(@"~\PagesContTrucking\Report\repx\DO.repx"));

            string sql = string.Format(@"select epodHardCopy from ctm_jobdet2 where Id={0}", id);
            hardCopy = SafeValue.SafeString(ConnectSql.ExecuteScalar(sql));
            if (hardCopy == "HardCopy")
            {
                rpt.LoadLayout(Server.MapPath(@"~\PagesContTrucking\Report\repx\DO_HardCopy.repx"));
            }
            set_signed_barcode_byid(rpt, orderNo, id, "", "");
        }
        else if (jobType == "tr")
        {
            rpt.LoadLayout(Server.MapPath(@"~\PagesContTrucking\Report\repx\Transfer.repx"));
        }
        else if (jobType.ToLower() == "cra")
        {
            rpt.LoadLayout(Server.MapPath(@"~\PagesContTrucking\Report\repx\DeliveryOrder_CRA.repx"));
            if (hardCopy == "HardCopy")
            {
                rpt.LoadLayout(Server.MapPath(@"~\PagesContTrucking\Report\repx\DO_HardCopy.repx"));
                set_signed_barcode_byid(rpt, orderNo, id, "", "");
            }
        }
        else
        {
            string path1    = string.Format("~/files/photos/");
            string path2    = path1.Replace(' ', '_').Replace('\'', '_');
            string pathx    = path2.Substring(1);
            string path3    = MapPath(path2);
            string filename = string.Format(@"{0}.jpg", orderNo);
            if (!Directory.Exists(path3))
            {
                Directory.CreateDirectory(path3);
            }
            string p = string.Format(@"~\files\photos\{0}", filename);

            string     e_file      = HttpContext.Current.Server.MapPath(p);
            DateTime   now         = DateTime.Now;
            string     file        = string.Format(@"~\html\{0}", jobType.ToUpper());
            string     htmlName    = string.Format(@"{0}.html", orderNo);
            string     httpPath    = HttpContext.Current.Request.Url.Host.ToString() + "/html/" + jobType.ToUpper() + "/" + htmlName;
            XtraReport rpt_barcode = new XtraReport();
            if (jobType.ToLower() == "tp")
            {
                rpt.LoadLayout(Server.MapPath(@"~\PagesContTrucking\Report\repx\TransportOrder.repx"));
            }
            else
            {
                rpt.LoadLayout(Server.MapPath(@"~\PagesContTrucking\Report\repx\DO.repx"));
            }


            if (SafeValue.SafeInt(id, 0) > 0)
            {
                rpt_barcode.DataSource = DocPrint.PrintDeliveryTrip(orderNo, id, jobType);
                set_signed_barcode_byid(rpt_barcode, orderNo, id, httpPath, filename);
            }
            else
            {
                rpt_barcode.DataSource = DocPrint.PrintDeliveryOrder(orderNo, jobType);
                set_signed_barcode(rpt_barcode, orderNo, httpPath, filename);
            }

            rpt_barcode.CreateDocument();
            rpt_barcode.ExportToImage(e_file);

            Dictionary <string, string> d = new Dictionary <string, string>();
            string http_Photo_Path        = "http://" + HttpContext.Current.Request.Url.Host.ToString() + "/files/photos/" + filename;
            string value = string.Format(@"<img src='{0}' alt=''/>", http_Photo_Path);
            d.Add("title", orderNo);
            d.Add("content", value);

            string temp = string.Format(@"~\html\template.html");


            html.CreateHtml(temp, file, htmlName, d, "");
            if (jobType.ToLower() == "tp")
            {
                rpt_barcode.LoadLayout(Server.MapPath(@"~\PagesContTrucking\Report\repx\TransportOrder.repx"));
            }
            else
            {
                rpt_barcode.LoadLayout(Server.MapPath(@"~\PagesContTrucking\Report\repx\DO.repx"));
            }
            if (SafeValue.SafeInt(id, 0) > 0)
            {
                set_signed_barcode_byid(rpt, orderNo, id, httpPath, filename);
            }
            else
            {
                set_signed_barcode(rpt, orderNo, httpPath, filename);
            }
        }
        if (SafeValue.SafeInt(id, 0) > 0)
        {
            rpt.DataSource = DocPrint.PrintDeliveryTrip(orderNo, id, jobType);
        }
        else
        {
            rpt.DataSource = DocPrint.PrintDeliveryOrder(orderNo, jobType);
        }
        System.IO.MemoryStream str = new MemoryStream();
        rpt.CreateDocument();
        rpt.ExportToPdf(str);


        return(str);
    }
コード例 #4
0
    private MemoryStream PrintJobSheet(string orderNo, string jobType, string tripId)
    {
        XtraReport rpt = new XtraReport();

        string path1    = string.Format("~/files/photos/");
        string path2    = path1.Replace(' ', '_').Replace('\'', '_');
        string pathx    = path2.Substring(1);
        string path3    = MapPath(path2);
        string filename = string.Format(@"{0}.jpg", orderNo);

        if (!Directory.Exists(path3))
        {
            Directory.CreateDirectory(path3);
        }
        string p = string.Format(@"~\files\photos\{0}", filename);

        string     e_file      = HttpContext.Current.Server.MapPath(p);
        DateTime   now         = DateTime.Now;
        string     file        = string.Format(@"~\html\{0}", jobType.ToUpper());
        string     htmlName    = string.Format(@"{0}.html", orderNo);
        string     httpPath    = HttpContext.Current.Request.Url.Host.ToString() + "/html/" + jobType.ToUpper() + "/" + htmlName;
        XtraReport rpt_barcode = new XtraReport();

        rpt_barcode.LoadLayout(Server.MapPath(@"~\PagesContTrucking\Report\repx\DeliveryOrder_CRA.repx"));
        rpt_barcode.DataSource = DocPrint.PrintJobSheet(orderNo, jobType, tripId);
        set_signed_barcode(rpt_barcode, orderNo, httpPath, filename);
        rpt_barcode.CreateDocument();
        rpt_barcode.ExportToImage(e_file);

        Dictionary <string, string> d = new Dictionary <string, string>();
        string http_Photo_Path        = "http://" + HttpContext.Current.Request.Url.Host.ToString() + "/files/photos/" + filename;
        string value = string.Format(@"<img src='{0}' alt=''/>", http_Photo_Path);

        d.Add("title", orderNo);
        d.Add("content", value);

        string temp = string.Format(@"~\html\template.html");


        html.CreateHtml(temp, file, htmlName, d, "");
        rpt.LoadLayout(Server.MapPath(@"~\PagesContTrucking\Report\repx\DeliveryOrder_CRA.repx"));
        string sql      = string.Format(@"select epodHardCopy from ctm_jobdet2 where Id={0}", tripId);
        string hardCopy = SafeValue.SafeString(ConnectSql.ExecuteScalar(sql));

        if (hardCopy == "HardCopy")
        {
            rpt.LoadLayout(Server.MapPath(@"~\PagesContTrucking\Report\repx\DO_HardCopy.repx"));
        }

        set_signed_barcode_byid(rpt, orderNo, tripId, httpPath, filename);

        DataSet   set  = DocPrint.PrintJobSheet(orderNo, jobType, tripId);
        DataTable Mast = set.Tables[0].Copy();

        Mast.TableName = "Mast";
        if (Mast.Rows.Count > 0)
        {
            string epodCB1 = SafeValue.SafeString(Mast.Rows[0]["EpodCB1"]);
            string epodCB2 = SafeValue.SafeString(Mast.Rows[0]["EpodCB2"]);
            string epodCB3 = SafeValue.SafeString(Mast.Rows[0]["EpodCB3"]);
            string epodCB4 = SafeValue.SafeString(Mast.Rows[0]["EpodCB4"]);
            string epodCB5 = SafeValue.SafeString(Mast.Rows[0]["EpodCB5"]);
            string epodCB6 = SafeValue.SafeString(Mast.Rows[0]["EpodCB6"]);
            DevExpress.XtraReports.UI.DetailBand details = rpt.Report.Bands["detailBand1"] as DevExpress.XtraReports.UI.DetailBand;
            if (details != null)
            {
                DevExpress.XtraReports.UI.XRCheckBox ckb1 = details.FindControl("ckb1", false) as DevExpress.XtraReports.UI.XRCheckBox;
                if (epodCB1 == "Yes")
                {
                    ckb1.Checked = true;
                }
                DevExpress.XtraReports.UI.XRCheckBox ckb2 = details.FindControl("ckb2", false) as DevExpress.XtraReports.UI.XRCheckBox;
                if (epodCB2 == "Yes")
                {
                    ckb2.Checked = true;
                }
                DevExpress.XtraReports.UI.XRCheckBox ckb3 = details.FindControl("ckb3", false) as DevExpress.XtraReports.UI.XRCheckBox;
                if (epodCB3 == "Yes")
                {
                    ckb3.Checked = true;
                }
                DevExpress.XtraReports.UI.XRCheckBox ckb4 = details.FindControl("ckb4", false) as DevExpress.XtraReports.UI.XRCheckBox;
                if (epodCB4 == "Yes")
                {
                    ckb4.Checked = true;
                }
                DevExpress.XtraReports.UI.XRCheckBox ckb5 = details.FindControl("ckb5", false) as DevExpress.XtraReports.UI.XRCheckBox;
                if (epodCB5 == "Yes")
                {
                    ckb5.Checked = true;
                }
                DevExpress.XtraReports.UI.XRCheckBox ckb6 = details.FindControl("ckb6", false) as DevExpress.XtraReports.UI.XRCheckBox;
                if (epodCB6 == "Yes")
                {
                    ckb6.Checked = true;
                }
            }
        }
        rpt.DataSource = set;

        System.IO.MemoryStream str = new MemoryStream();
        rpt.CreateDocument();
        rpt.ExportToPdf(str);


        return(str);
    }
コード例 #5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string Type = Request.Form.Get("type");

        //Section "Восстановить у пользователя"
        if (Type == DOWNLOAD_FILE_RECOVER_USER)
        {
            if (Request.Form.Get("dataBlockId") != null)
            {
                int       dataBlockId      = Convert.ToInt32(Request.Form.Get("dataBlockId"));
                string    connectionString = ConfigurationManager.AppSettings["fleetnetbaseConnectionString"];
                DataBlock dataBlock        = new DataBlock(connectionString, ConfigurationManager.AppSettings["language"]);
                dataBlock.OpenConnection();
                byte[] fileBytes = dataBlock.GetDataBlock_BytesArray(dataBlockId);
                string fileName  = dataBlock.GetDataBlock_FileName(dataBlockId);
                dataBlock.CloseConnection();

                Response.Clear();
                Response.AddHeader("Content-Disposition", String.Format("attachment;filename=\"{0}\"", fileName));
                Response.AddHeader("Content-Length", fileBytes.Length.ToString());
                Response.ContentType = "application/octet-stream";
                Response.OutputStream.Write(fileBytes, 0, fileBytes.Length);
                Response.End();
                return;
            }
        }

        //Section "PLF Файлы"
        if (Type == GET_PLF_REPORT)
        {
            string CardID     = Request.Form.Get("CardID");
            string PLFID      = Request.Form.Get("PLFID");
            string UserName   = Request.Form.Get("UserName");
            string Format     = Request.Form.Get("Format");
            string ReportType = Request.Form.Get("ReportType");
            if (string.IsNullOrEmpty(ReportType))
            {
                ReportType = "Полный отчет";
            }

            int        dataBlockId  = int.Parse(PLFID);
            List <int> dataBlockIDS = new List <int>();
            dataBlockIDS.Add(dataBlockId);
            int cardID = int.Parse(CardID);

            string        connectionString = System.Configuration.ConfigurationManager.AppSettings["fleetnetbaseConnectionString"];
            BLL.DataBlock dataBlock        = new BLL.DataBlock(connectionString, ConfigurationManager.AppSettings["language"]);
            dataBlock.OpenConnection();

            DateTime from = new DateTime();
            from = dataBlock.plfUnitInfo.Get_START_PERIOD(dataBlockId);

            DateTime to = new DateTime();
            to = dataBlock.plfUnitInfo.Get_END_PERIOD(dataBlockId);

            string vehicle  = dataBlock.plfUnitInfo.Get_VEHICLE(dataBlockId);
            string deviceID = dataBlock.plfUnitInfo.Get_ID_DEVICE(dataBlockId);

            DataSet dataset = new DataSet();

            int userId = dataBlock.usersTable.Get_UserID_byName(UserName);

            List <PLFUnit.PLFRecord> records = new List <PLFUnit.PLFRecord>();
            dataset = ReportDataSetLoader.Get_PLF_ALLData(dataBlockIDS,
                                                          new DateTime(from.Year, from.Month, from.Day), new DateTime(to.Year, to.Month, to.Day),
                                                          cardID, userId, ref records);

            dataBlock.CloseConnection();

            //gets table PlfHeader_1
            DataTable dt = dataset.Tables[0];
            //gets the first row
            DataRow dr         = dt.Rows[0];
            string  driverName = dr["Имя водителя"].ToString();

            //load needed template
            string     path   = HttpContext.Current.Server.MapPath("~/templates_plf") + "\\";
            XtraReport report = new XtraReport();
            report.LoadLayout(path + ReportType + ".repx");
            report.DataSource = dataset;
            MemoryStream reportStream = new MemoryStream();
            switch (Format)
            {
            case "html": report.ExportToHtml(reportStream); break;

            case "pdf": report.ExportToPdf(reportStream); break;

            case "rtf": report.ExportToRtf(reportStream); break;

            case "png": report.ExportToImage(reportStream, ImageFormat.Png); break;
            }

            Response.Clear();
            Response.AddHeader("Content-Disposition", String.Format("attachment;filename=\"{0}\"", "Отчет " + driverName + " " +
                                                                    new DateTime(from.Year, from.Month, from.Day).ToString("dd_MM_yyyy") + "-" + new DateTime(to.Year, to.Month, to.Day).ToString("dd_MM_yyyy") + "." + Format));
            Response.AddHeader("Content-Length", reportStream.GetBuffer().Length.ToString());
            Response.ContentType = "application/octet-stream";
            Response.OutputStream.Write(reportStream.GetBuffer(), 0, reportStream.GetBuffer().Length);
            Response.End();
            return;
        }

        if (Type == GET_PLF_REPORT_FOR_PERIOD)
        {
            string CardID     = Request.Form.Get("CardID");
            string StartDate  = Request.Form.Get("StartDate");
            string EndDate    = Request.Form.Get("EndDate");
            string UserName   = Request.Form.Get("UserName");
            string Format     = Request.Form.Get("Format");
            string ReportType = Request.Form.Get("ReportType");
            if (string.IsNullOrEmpty(ReportType))
            {
                ReportType = "Полный отчет";
            }

            int cardID = int.Parse(CardID);

            string        connectionString = System.Configuration.ConfigurationManager.AppSettings["fleetnetbaseConnectionString"];
            BLL.DataBlock dataBlock        = new BLL.DataBlock(connectionString, ConfigurationManager.AppSettings["language"]);
            dataBlock.OpenConnection();

            DateTime from = DateTime.Parse(StartDate);
            DateTime to   = DateTime.Parse(EndDate);

            DataSet    dataset      = new DataSet();
            List <int> dataBlockIDS = dataBlock.cardsTable.GetAllDataBlockIds_byCardId(cardID);

            int userId = dataBlock.usersTable.Get_UserID_byName(UserName);

            List <PLFUnit.PLFRecord> records = new List <PLFUnit.PLFRecord>();
            dataset = ReportDataSetLoader.Get_PLF_ALLData(dataBlockIDS,
                                                          new DateTime(from.Year, from.Month, from.Day), new DateTime(to.Year, to.Month, to.Day),
                                                          cardID, userId, ref records);

            dataBlock.CloseConnection();

            //gets table PlfHeader_1
            DataTable dt = dataset.Tables[0];
            //gets the first row
            DataRow dr         = dt.Rows[0];
            string  driverName = dr["Имя водителя"].ToString();

            //load needed template
            string     path   = HttpContext.Current.Server.MapPath("~/templates_plf") + "\\";
            XtraReport report = new XtraReport();
            report.LoadLayout(path + ReportType + ".repx");
            report.DataSource = dataset;
            MemoryStream reportStream = new MemoryStream();
            switch (Format)
            {
            case "html": report.ExportToHtml(reportStream); break;

            case "pdf": report.ExportToPdf(reportStream); break;

            case "rtf": report.ExportToRtf(reportStream); break;

            case "png": report.ExportToImage(reportStream, ImageFormat.Png); break;
            }


            Response.Clear();
            Response.AddHeader("Content-Disposition", String.Format("attachment;filename=\"{0}\"", "Отчет " + driverName + " " +
                                                                    new DateTime(from.Year, from.Month, from.Day).ToString("dd_MM_yyyy") + "-" + new DateTime(to.Year, to.Month, to.Day).ToString("dd_MM_yyyy") + "." + Format));
            Response.AddHeader("Content-Length", reportStream.GetBuffer().Length.ToString());
            Response.ContentType = "application/octet-stream";
            Response.OutputStream.Write(reportStream.GetBuffer(), 0, reportStream.GetBuffer().Length);
            Response.End();

            return;
        }

        //Section "Транспортные средства"
        if (Type == GET_DDD_REPORT)
        {
            string DataBlockID = Request.Form.Get("DataBlockID");
            string UserName    = Request.Form.Get("UserName");
            string Format      = Request.Form.Get("Format");
            string ReportType  = Request.Form.Get("ReportType");
            if (string.IsNullOrEmpty(ReportType))
            {
                ReportType = "Полный отчет";
            }

            int        dataBlockId  = int.Parse(DataBlockID);
            List <int> dataBlockIDS = new List <int>();
            dataBlockIDS.Add(dataBlockId);

            string    connectionString = System.Configuration.ConfigurationManager.AppSettings["fleetnetbaseConnectionString"];
            DataBlock dataBlock        = new DataBlock(connectionString, ConfigurationManager.AppSettings["language"]);
            dataBlock.OpenConnection();

            DataSet dataset = new DataSet();

            string VIN       = dataBlock.vehicleUnitInfo.Get_VehicleOverview_IdentificationNumber(dataBlockId).ToString();
            string RegNumb   = dataBlock.vehicleUnitInfo.Get_VehicleOverview_RegistrationIdentification(dataBlockId).vehicleRegistrationNumber.ToString();
            int    vehicleId = dataBlock.vehiclesTables.GetVehicleId_byVinRegNumbers(VIN, RegNumb);

            List <DateTime> vehsCardPeriod = dataBlock.vehicleUnitInfo.Get_StartEndPeriod(dataBlockId);

            int userId = dataBlock.usersTable.Get_UserID_byName(UserName);

            dataset = ReportDataSetLoader.Get_Vehicle_ALLDate(vehicleId,
                                                              dataBlockIDS, vehsCardPeriod[0], vehsCardPeriod[1], userId);

            dataBlock.CloseConnection();

            //load needed template
            string     path   = HttpContext.Current.Server.MapPath("~/templates_ddd") + "\\";
            XtraReport report = new XtraReport();
            report.LoadLayout(path + ReportType + ".repx");
            report.DataSource = dataset;
            MemoryStream reportStream = new MemoryStream();
            switch (Format)
            {
            case "html": report.ExportToHtml(reportStream); break;

            case "pdf": report.ExportToPdf(reportStream); break;

            case "rtf": report.ExportToRtf(reportStream); break;

            case "png": report.ExportToImage(reportStream, ImageFormat.Png); break;
            }

            Response.Clear();
            Response.AddHeader("Content-Disposition", String.Format("attachment;filename=\"{0}\"", "Отчет " + VIN + "_" + RegNumb + " " +
                                                                    vehsCardPeriod[0].ToString("dd_MM_yyyy") + "-" + vehsCardPeriod[1].ToString("dd_MM_yyyy") + "." + Format));
            Response.AddHeader("Content-Length", reportStream.GetBuffer().Length.ToString());
            Response.ContentType = "application/octet-stream";
            Response.OutputStream.Write(reportStream.GetBuffer(), 0, reportStream.GetBuffer().Length);
            Response.End();
            return;
        }

        //Section "Транспортные средства"
        if (Type == GET_DDD_REPORT_FOR_PERIOD)
        {
            string CardID     = Request.Form.Get("CardID");
            string StartDate  = Request.Form.Get("StartDate");
            string EndDate    = Request.Form.Get("EndDate");
            string UserName   = Request.Form.Get("UserName");
            string Format     = Request.Form.Get("Format");
            string ReportType = Request.Form.Get("ReportType");
            if (string.IsNullOrEmpty(ReportType))
            {
                ReportType = "Полный отчет";
            }

            string    connectionString = System.Configuration.ConfigurationManager.AppSettings["fleetnetbaseConnectionString"];
            DataBlock dataBlock        = new DataBlock(connectionString, ConfigurationManager.AppSettings["language"]);
            dataBlock.OpenConnection();

            DataSet dataset = new DataSet();
            int     cardId  = int.Parse(CardID);

            string VIN     = dataBlock.vehiclesTables.GetVehicleVin(cardId);
            string RegNumb = dataBlock.vehiclesTables.GetVehicleGOSNUM(cardId);

            int        vehicleId    = dataBlock.vehiclesTables.GetVehicle_byCardId(cardId);
            List <int> dataBlockIDS = dataBlock.cardsTable.GetAllDataBlockIds_byCardId(cardId);

            int userId = dataBlock.usersTable.Get_UserID_byName(UserName);

            DateTime from = DateTime.Parse(StartDate);
            DateTime to   = DateTime.Parse(EndDate);

            dataset = ReportDataSetLoader.Get_Vehicle_ALLDate(vehicleId,
                                                              dataBlockIDS, from, to, userId);

            dataBlock.CloseConnection();

            //load needed template
            string     path   = HttpContext.Current.Server.MapPath("~/templates_ddd") + "\\";
            XtraReport report = new XtraReport();
            report.LoadLayout(path + ReportType + ".repx");
            report.DataSource = dataset;
            MemoryStream reportStream = new MemoryStream();
            switch (Format)
            {
            case "html": report.ExportToHtml(reportStream); break;

            case "pdf": report.ExportToPdf(reportStream); break;

            case "rtf": report.ExportToRtf(reportStream); break;

            case "png": report.ExportToImage(reportStream, ImageFormat.Png); break;
            }

            Response.Clear();
            Response.AddHeader("Content-Disposition", String.Format("attachment;filename=\"{0}\"", "Отчет " + VIN + "_" + RegNumb + " " +
                                                                    from.ToString("dd_MM_yyyy") + "-" + to.ToString("dd_MM_yyyy") + "." + Format));
            Response.AddHeader("Content-Length", reportStream.GetBuffer().Length.ToString());
            Response.ContentType = "application/octet-stream";
            Response.OutputStream.Write(reportStream.GetBuffer(), 0, reportStream.GetBuffer().Length);
            Response.End();
            return;
        }
    }