Esempio n. 1
0
        private void print_op()
        {
            int index = comboBox1.SelectedIndex + 1;

            print_rec      print    = new print_rec();
            CrystalReport2 cr       = new CrystalReport2();
            TextObject     visit_id = (TextObject)cr.ReportDefinition.Sections["Section1"].ReportObjects["Text1"];

            BoxObject box = (BoxObject)cr.ReportDefinition.Sections["Section1"].ReportObjects["Box1"];


            if (index == 1)
            {
                box.FillColor = Color.WhiteSmoke;
            }
            else if (index == 2)
            {
                box.FillColor = Color.Blue;
            }
            else if (index == 3)
            {
                box.FillColor = Color.Green;
            }
            else if (index == 4)
            {
                box.FillColor = Color.Yellow;
            }
            else if (index == 5)
            {
                box.FillColor = Color.Orange;
            }
            else if (index == 6)
            {
                box.FillColor = Color.Red;
            }

            string query = "SELECT MAX(id) FROM visits";

            try
            {
                MySqlConnection conn = connection_config.GetDBConnection();
                conn.Open();
                MySqlCommand    command = new MySqlCommand(query, conn);
                MySqlDataReader reader  = command.ExecuteReader();

                while (reader.Read())
                {
                    visit_id.Text = (reader.GetString(0));
                }
                conn.Close();
                reader.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            print.crystalReportViewer1.ReportSource = cr;
            print.Show();
        }
Esempio n. 2
0
        public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport()
        {
            CrystalReport2 rpt = new CrystalReport2();

            rpt.Site = this.Site;
            return(rpt);
        }