コード例 #1
0
        public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport()
        {
            CrystalReport1 rpt = new CrystalReport1();

            rpt.Site = this.Site;
            return(rpt);
        }
コード例 #2
0
        public void button2_Click(object sender, EventArgs e)
        {
            string[] rec = new string[5] {
                "", "", "", "", ""
            };
            string[] dos = new string[5] {
                "", "", "", "", ""
            };


            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                rec[row.Index] = row.Cells[0].Value.ToString().Trim();
            }

            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                dos[row.Index] = row.Cells[1].Value.ToString().Trim();
            }

            string result = string.Join(",", rec.Where(s => !string.IsNullOrEmpty(s)));

            print_rec print = new print_rec();

            if (textBox3.Text == "" || textBox6.Text == "" || textBox7.Text == "" || textBox5.Text == "")
            {
                MessageBox.Show("Uzupełnij wszystkie pola");
            }
            else
            {
                if (dataGridView1.Rows.Count == 0)
                {
                    //archiwizacja !!!
                    query = "INSERT INTO archive SELECT NULL, dr_pesel, visit_day, pesel, hour, NULL, ward_id FROM visits WHERE pesel = '" + textBox11.Text + "' AND visit_day='" + textBox4.Text + "' AND hour='" + textBox5.Text + "'; " +
                            "SET @id = LAST_INSERT_ID(); " +
                            "INSERT INTO file(id, interview, examination, diagnosis, drugs, kat_id) VALUES(NULL, '" + textBox3.Text + "', '" + textBox6.Text + "', '" + textBox7.Text + "', '" + result + "', @id);" +
                            " DELETE FROM visits WHERE pesel = '" + textBox11.Text + "' AND visit_day='" + textBox4.Text + "' AND hour='" + textBox5.Text + "';";

                    conn.Open();

                    command = new MySqlCommand(query, conn);
                    command.ExecuteNonQuery();
                    MessageBox.Show("Pomyślnie zakończono wizytę");
                    conn.Close();

                    this.Close();
                }
                else
                {
                    randomizer();
                    CrystalReport1 cr       = new CrystalReport1();
                    TextObject     patient  = (TextObject)cr.ReportDefinition.Sections["Section3"].ReportObjects["Text10"];
                    TextObject     doctor   = (TextObject)cr.ReportDefinition.Sections["Section3"].ReportObjects["Text11"];
                    TextObject     drph     = (TextObject)cr.ReportDefinition.Sections["Section3"].ReportObjects["Text12"];
                    TextObject     datatime = (TextObject)cr.ReportDefinition.Sections["Section3"].ReportObjects["Text13"];
                    TextObject     r1       = (TextObject)cr.ReportDefinition.Sections["Section3"].ReportObjects["Text14"];
                    TextObject     r2       = (TextObject)cr.ReportDefinition.Sections["Section3"].ReportObjects["Text28"];
                    TextObject     r3       = (TextObject)cr.ReportDefinition.Sections["Section3"].ReportObjects["Text30"];
                    TextObject     r4       = (TextObject)cr.ReportDefinition.Sections["Section3"].ReportObjects["Text32"];
                    TextObject     r5       = (TextObject)cr.ReportDefinition.Sections["Section3"].ReportObjects["Text34"];
                    TextObject     d1       = (TextObject)cr.ReportDefinition.Sections["Section3"].ReportObjects["Text15"];
                    TextObject     d2       = (TextObject)cr.ReportDefinition.Sections["Section3"].ReportObjects["Text27"];
                    TextObject     d3       = (TextObject)cr.ReportDefinition.Sections["Section3"].ReportObjects["Text29"];
                    TextObject     d4       = (TextObject)cr.ReportDefinition.Sections["Section3"].ReportObjects["Text31"];
                    TextObject     d5       = (TextObject)cr.ReportDefinition.Sections["Section3"].ReportObjects["Text33"];
                    TextObject     rec_code = (TextObject)cr.ReportDefinition.Sections["Section3"].ReportObjects["Text3"];
                    r1.Text       = rec[0];
                    r2.Text       = rec[1];
                    r3.Text       = rec[2];
                    r4.Text       = rec[3];
                    r5.Text       = rec[4];
                    d1.Text       = dos[0];
                    d2.Text       = dos[1];
                    d3.Text       = dos[2];
                    d4.Text       = dos[3];
                    d5.Text       = dos[4];
                    rec_code.Text = code;
                    patient.Text  = textBox1.Text;
                    doctor.Text   = textBox2.Text;
                    drph.Text     = "+48 " + drphone;
                    DateTime dt = DateTime.Parse(textBox5.Text);
                    textBox5.Text = dt.ToString("HH:mm");
                    datatime.Text = control_date + " godz. " + control_hour;
                    print.crystalReportViewer1.ReportSource = cr;

                    query = "INSERT INTO archive SELECT NULL, dr_pesel, visit_day, pesel, hour, NULL, ward_id FROM visits WHERE pesel = '" + textBox11.Text + "' AND visit_day='" + textBox4.Text + "' AND hour='" + textBox5.Text + "'; " +
                            "SET @id = LAST_INSERT_ID(); " +
                            "UPDATE archive SET rec_code='" + code + "' WHERE id=@id;" +
                            "INSERT INTO file(id, interview, examination, diagnosis, drugs, kat_id) VALUES(NULL, '" + textBox3.Text + "', '" + textBox6.Text + "', '" + textBox7.Text + "', '" + result + "', @id);" +
                            " DELETE FROM visits WHERE pesel = '" + textBox11.Text + "' AND visit_day='" + textBox4.Text + "' AND hour='" + textBox5.Text + "';";

                    conn.Open();

                    command = new MySqlCommand(query, conn);
                    command.ExecuteNonQuery();
                    MessageBox.Show("Pomyślnie zakończono wizytę");
                    conn.Close();

                    this.Close();
                    print.Show();

                    code = "";
                }
            }
        }