Beispiel #1
0
        public ReportViewer()
        {
            CultureInfo ci = new CultureInfo("en", true);

            System.Threading.Thread.CurrentThread.CurrentCulture = ci;
            ci.DateTimeFormat.DateSeparator = "-";

            InitializeComponent();

            isUpdating     = true;
            dateTo.Value   = DateLastMinute(DateTime.Now);
            dateTo.MaxDate = DateLastMinute(dateTo.Value);
            dateFrom.Value = DateFirstMinute(dateTo.Value);
            isUpdating     = false;

            EmployeesQuery.GetAllEmployees().ForEach(employee =>
            {
                txtTagID.AutoCompleteCustomSource.Add(employee.ID.ToString());
            });
        }
Beispiel #2
0
        private void btnGenerate_Click(object sender, EventArgs e)
        {
            if (rbAlarms.Checked)
            {
                Nullable <ushort>   tagID = null;
                Nullable <DateTime> from  = null;
                Nullable <DateTime> to    = null;

                ushort id;
                if (chkTagID.Checked && ushort.TryParse(txtTagID.Text, out id))
                {
                    tagID = id;
                }
                if (chkFrom.Checked)
                {
                    from = dateFrom.Value;
                }
                if (chkTo.Checked)
                {
                    to = dateTo.Value;
                }

                System.Drawing.Printing.PageSettings page = new System.Drawing.Printing.PageSettings();
                page.Landscape = true;
                page.Margins   = new System.Drawing.Printing.Margins(50, 50, 0, 0);
                reportViewer1.SetPageSettings(page);
                reportViewer1.LocalReport.ReportEmbeddedResource = "AWI.SmartTracker.ReportClass.Alarms.rdlc";
                EmployeeBindingSource.DataSource = EmployeeHistoryQuery.GetEmployeeHistory(tagID, from, to);
            }
            else if (rbEmployees.Checked)
            {
                System.Drawing.Printing.PageSettings page = new System.Drawing.Printing.PageSettings();
                page.Landscape = false;
                page.Margins   = new System.Drawing.Printing.Margins(50, 50, 0, 0);
                reportViewer1.SetPageSettings(page);
                reportViewer1.LocalReport.ReportEmbeddedResource = "AWI.SmartTracker.ReportClass.Employees.rdlc";
                EmployeeBindingSource.DataSource = EmployeesQuery.GetAllEmployees();
            }
            else if (rbEmployeeHistory.Checked)
            {
                Nullable <ushort>   tagID = null;
                Nullable <DateTime> from  = null;
                Nullable <DateTime> to    = null;

                ushort id;
                if (chkTagID.Checked && ushort.TryParse(txtTagID.Text, out id))
                {
                    tagID = id;
                }
                if (chkFrom.Checked)
                {
                    from = dateFrom.Value;
                }
                if (chkTo.Checked)
                {
                    to = dateTo.Value;
                }

                System.Drawing.Printing.PageSettings page = new System.Drawing.Printing.PageSettings();
                page.Landscape = false;
                page.Margins   = new System.Drawing.Printing.Margins(50, 50, 0, 0);
                reportViewer1.SetPageSettings(page);
                reportViewer1.LocalReport.ReportEmbeddedResource = "AWI.SmartTracker.ReportClass.EmployeeHistory.rdlc";
                EmployeeBindingSource.DataSource = EmployeeHistoryQuery.GetEmployeeHistory(tagID, from, to);
            }

            try
            {
                reportViewer1.RefreshReport();
            }
            catch (Exception exception)
            {
                MessageBox.Show(string.Format("Failed to load report: {0}", exception), "Report Viewer", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }