Beispiel #1
0
        public List <ReportingDocumentDTO> GetReports(String filter)
        {
            List <ReportingDocumentDTO> reportList = new List <ReportingDocumentDTO>();

            String query = "SELECT DocCode, DocName, PaperSize, Width, Height FROM RDOC WHERE " + filter;

            if (String.IsNullOrEmpty(filter))
            {
                query = "SELECT DocCode, DocName, PaperSize FROM RDOC";
            }
            SqlCommand    command    = new SqlCommand(query, sqlServerConnection);
            SqlDataReader dataReader = command.ExecuteReader();

            while (dataReader.Read())
            {
                ReportingDocumentDTO report = new ReportingDocumentDTO();
                report.DocCode   = GetStringValue(dataReader, "DocCode");
                report.DocName   = GetStringValue(dataReader, "DocName");
                report.PaperSize = GetStringValue(dataReader, "PaperSize");
                report.Width     = GetSmallIntValue(dataReader, "Width");
                report.Height    = GetSmallIntValue(dataReader, "Height");

                reportList.Add(report);
            }
            dataReader.Close();

            return(reportList);
        }
Beispiel #2
0
        public Form2()
        {
            InitializeComponent();
            dataConnector = new DataConnector();

            dataConnector.OpenConnection("sqlServer");
            ReportingDocumentDAO reportingDocumentDAO = new ReportingDocumentDAO(dataConnector.SqlServerConnection);
            ReportingElementDAO  reportingElementDAO  = new ReportingElementDAO(dataConnector.SqlServerConnection);

            ReportingDocumentDTO reportDoc = reportingDocumentDAO.GetReport(docCode);
            Bitmap   bmp    = new Bitmap(reportDoc.Width, reportDoc.Height);
            Graphics graphs = Graphics.FromImage(bmp);

            graphs.Clear(System.Drawing.Color.White);

            List <ReportingElementDTO> elementList = reportingElementDAO.GetElements(docCode, "Type=10");

            foreach (ReportingElementDTO element in elementList)
            {
                Rectangle rect = new Rectangle(element.left, element.top, element.width, element.height);
                graphs.FillRectangle(new SolidBrush(System.Drawing.Color.LightYellow), rect);
                if (element.borderTop > 0)
                {
                    graphs.DrawRectangle(new Pen(System.Drawing.Color.Black, element.borderTop), rect);
                }
                if (element.borderBottom > 0)
                {
                    graphs.DrawRectangle(new Pen(System.Drawing.Color.Black, element.borderBottom), rect);
                }
                if (element.borderLeft > 0)
                {
                    graphs.DrawRectangle(new Pen(System.Drawing.Color.Black, element.borderLeft), rect);
                }
                if (element.borderRight > 0)
                {
                    graphs.DrawRectangle(new Pen(System.Drawing.Color.Black, element.borderRight), rect);
                }
            }

            List <ReportingElementDTO> imageList = reportingElementDAO.GetElements(docCode, "Type=11");

            foreach (ReportingElementDTO image in imageList)
            {
                Rectangle rect   = new Rectangle(image.left, image.top, image.width, image.height);
                Bitmap    bitmap = new Bitmap(bitmapPath + image.caption);
                graphs.DrawImage(bitmap, rect);
            }

            graphs.Flush();
            imgReport.Image = bmp;

            dataConnector.CloseConnection();
        }
Beispiel #3
0
        public ReportingDocumentDTO GetReport(String docCode)
        {
            ReportingDocumentDTO report = null;

            String        query      = "SELECT DocCode, DocName, PaperSize, Width, Height FROM RDOC WHERE DocCode='" + docCode + "'";
            SqlCommand    command    = new SqlCommand(query, sqlServerConnection);
            SqlDataReader dataReader = command.ExecuteReader();

            if (dataReader.Read())
            {
                report           = new ReportingDocumentDTO();
                report.DocCode   = GetStringValue(dataReader, "DocCode");
                report.DocName   = GetStringValue(dataReader, "DocName");
                report.PaperSize = GetStringValue(dataReader, "PaperSize");
                report.Width     = GetSmallIntValue(dataReader, "Width");
                report.Height    = GetSmallIntValue(dataReader, "Height");
            }
            dataReader.Close();

            return(report);
        }