public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport()
        {
            CrystalReport2 rpt = new CrystalReport2();

            rpt.Site = this.Site;
            return(rpt);
        }
Exemplo n.º 2
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (textBox6.Text == "")
            {
                textBox6.Text = "0";
            }
            if (textBox14.Text == "")
            {
                textBox14.Text = "0";
            }
            if (textBox16.Text == "")
            {
                textBox16.Text = "0";
            }
            if (textBox1.Text == "")
            {
                textBox1.Text = "0";
            }
            if (textBox11.Text == "")
            {
                textBox11.Text = "0"; textBox10.Text = "0";
            }
            if (textBox17.Text == "")
            {
                textBox17.Text = "0"; textBox18.Text = "0";
            }
            if (textBox19.Text == "")
            {
                textBox19.Text = "0"; textBox20.Text = "0";
            }
            Nha2y nha2Y = new Nha2y();

            t3akodDate  = dateTimePicker1.Value.ToShortDateString();
            deliverDate = dateTimePicker2.Value.ToShortDateString();

            nha2Y.nationalId       = textBox2.Text.ToString();
            nha2Y.tare5t3akod      = t3akodDate;
            nha2Y.tare5astlam      = deliverDate;
            nha2Y.PlaceAddress     = textBox5.Text.ToString();
            nha2Y.clientAddress    = textBox3.Text.ToString();
            nha2Y.Phone            = textBox4.Text.ToString();
            nha2Y.totalPrice       = Convert.ToDecimal(textBox1.Text.ToString());
            nha2Y.totalPriceText   = textBox7.Text.ToString();
            nha2Y.dof3aMokdma      = Convert.ToDecimal(textBox6.Text.ToString());
            nha2Y.dof3aMokdmaText  = textBox8.Text.ToString();
            nha2Y.Notes            = textBox15.Text.ToString();
            nha2Y.meterPrice       = Convert.ToDecimal(textBox9.Text.ToString());
            nha2Y.metersNumber     = int.Parse(textBox10.Text.ToString());
            nha2Y.mfslatNumber     = int.Parse(textBox18.Text.ToString());
            nha2Y.mgaryNumber      = int.Parse(textBox20.Text.ToString());
            nha2Y.totalmetermatb5  = Convert.ToDecimal(textBox11.Text.ToString());
            nha2Y.totalmfslat      = Convert.ToDecimal(textBox17.Text.ToString());
            nha2Y.totalmgary       = Convert.ToDecimal(textBox19.Text.ToString());
            nha2Y.mgaryPrice       = Convert.ToDecimal(textBox12.Text.ToString());
            nha2Y.mfslatPrice      = Convert.ToDecimal(textBox13.Text.ToString());
            nha2Y.totalAccessories = Convert.ToDecimal(textBox14.Text.ToString());
            nha2Y.Name             = comboBox1.Text;
            nha2Y.modelElmtb5      = comboBox2.Text;
            nha2Y.modelelmfslat    = comboBox3.Text;
            nha2Y.modelMgary       = comboBox4.Text;
            nha2Y.m2bd             = comboBox8.Text;
            for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
            {
                Accesories accesories = new Accesories();
                accesories.Name  = dataGridView1.Rows[i].Cells[0].Value.ToString();
                accesories.Price = Convert.ToDecimal(dataGridView1.Rows[i].Cells[1].Value.ToString());
                nha2Y.Accesories.Add(accesories);
                context.SaveChanges();
            }
            for (int i = 0; i < dataGridView2.Rows.Count - 1; i++)
            {
                ArkamM2bd accesories = new ArkamM2bd();
                accesories.Arkam = dataGridView2.Rows[i].Cells[0].Value.ToString();
                nha2Y.Arkam.Add(accesories);
                context.SaveChanges();
            }
            context.Nha2s.Add(nha2Y);
            context.SaveChanges();
            Form5          f5   = new Form5();
            CrystalReport2 cr   = new CrystalReport2();
            TextObject     text = (TextObject)cr.ReportDefinition.Sections["Section1"]
                                  .ReportObjects["Text3"];

            text.Text = comboBox1.Text;
            TextObject nationalId = (TextObject)cr.ReportDefinition.Sections["Section1"]
                                    .ReportObjects["Text12"];

            nationalId.Text = textBox2.Text;
            TextObject address = (TextObject)cr.ReportDefinition.Sections["Section1"]
                                 .ReportObjects["Text13"];

            address.Text = textBox3.Text;
            TextObject phone = (TextObject)cr.ReportDefinition.Sections["Section1"]
                               .ReportObjects["Text14"];

            phone.Text = textBox4.Text;
            TextObject addressplace = (TextObject)cr.ReportDefinition.Sections["Section1"]
                                      .ReportObjects["Text15"];

            addressplace.Text = textBox5.Text;
            TextObject agmaly = (TextObject)cr.ReportDefinition.Sections["Section1"]
                                .ReportObjects["Text16"];

            agmaly.Text = textBox1.Text;
            TextObject agmalyText = (TextObject)cr.ReportDefinition.Sections["Section1"]
                                    .ReportObjects["Text22"];

            agmalyText.Text = textBox7.Text;
            TextObject dof3a = (TextObject)cr.ReportDefinition.Sections["Section1"]
                               .ReportObjects["Text17"];

            dof3a.Text = textBox6.Text;
            TextObject dof3aText = (TextObject)cr.ReportDefinition.Sections["Section1"]
                                   .ReportObjects["Text23"];

            dof3aText.Text = textBox8.Text;
            TextObject t3akod = (TextObject)cr.ReportDefinition.Sections["Section1"]
                                .ReportObjects["Text18"];

            t3akod.Text = t3akodDate;
            TextObject tslem = (TextObject)cr.ReportDefinition.Sections["Section1"]
                               .ReportObjects["Text19"];

            tslem.Text = deliverDate;
            TextObject modelMtb5 = (TextObject)cr.ReportDefinition.Sections["Section4"]
                                   .ReportObjects["Text35"];

            modelMtb5.Text = comboBox2.Text;
            TextObject meterPrice = (TextObject)cr.ReportDefinition.Sections["Section4"]
                                    .ReportObjects["Text36"];

            meterPrice.Text = textBox9.Text;
            TextObject noMeter = (TextObject)cr.ReportDefinition.Sections["Section4"]
                                 .ReportObjects["Text37"];

            noMeter.Text = textBox10.Text;
            TextObject totalMeter = (TextObject)cr.ReportDefinition.Sections["Section4"]
                                    .ReportObjects["Text38"];

            totalMeter.Text = textBox11.Text;
            TextObject no3Mfslat = (TextObject)cr.ReportDefinition.Sections["Section4"]
                                   .ReportObjects["Text43"];

            no3Mfslat.Text = comboBox3.Text;
            TextObject tklfMfslat = (TextObject)cr.ReportDefinition.Sections["Section4"]
                                    .ReportObjects["Text44"];

            tklfMfslat.Text = textBox12.Text;
            TextObject no3Mgary = (TextObject)cr.ReportDefinition.Sections["Section4"]
                                  .ReportObjects["Text45"];

            no3Mgary.Text = comboBox4.Text;
            TextObject tklfMgary = (TextObject)cr.ReportDefinition.Sections["Section4"]
                                   .ReportObjects["Text46"];

            tklfMgary.Text = textBox13.Text;
            TextObject addMfslat = (TextObject)cr.ReportDefinition.Sections["Section4"]
                                   .ReportObjects["Text33"];

            addMfslat.Text = textBox18.Text;
            TextObject agmalyMfslat = (TextObject)cr.ReportDefinition.Sections["Section4"]
                                      .ReportObjects["Text51"];

            agmalyMfslat.Text = textBox17.Text;
            TextObject addMgary = (TextObject)cr.ReportDefinition.Sections["Section4"]
                                  .ReportObjects["Text66"];

            addMgary.Text = textBox20.Text;
            TextObject agmalyMgary = (TextObject)cr.ReportDefinition.Sections["Section4"]
                                     .ReportObjects["Text67"];

            agmalyMgary.Text = textBox19.Text;
            TextObject m2bd = (TextObject)cr.ReportDefinition.Sections["Section4"]
                              .ReportObjects["Text52"];

            m2bd.Text = comboBox8.Text;
            TextObject notes = (TextObject)cr.ReportDefinition.Sections["Section4"]
                               .ReportObjects["Text64"];

            notes.Text = textBox15.Text;
            TextObject total = (TextObject)cr.ReportDefinition.Sections["Section4"]
                               .ReportObjects["Text55"];

            total.Text = textBox16.Text;
            TextObject accessoriesPrint = (TextObject)cr.ReportDefinition.Sections["Section4"]
                                          .ReportObjects["Text62"];
            TextObject accessoriesPrintPrice = (TextObject)cr.ReportDefinition.Sections["Section4"]
                                               .ReportObjects["Text63"];
            TextObject totwlAccessories = (TextObject)cr.ReportDefinition.Sections["Section4"]
                                          .ReportObjects["Text57"];

            totwlAccessories.Text = textBox14.Text;
            for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
            {
                accessoriesPrint.Text      += dataGridView1.Rows[i].Cells[0].Value.ToString();
                accessoriesPrint.Text      += "\n";
                accessoriesPrintPrice.Text += Convert.ToDecimal(dataGridView1.Rows[i].Cells[1].Value.ToString());
                accessoriesPrintPrice.Text += "\n";
            }
            TextObject dolfColor = (TextObject)cr.ReportDefinition.Sections["Section4"]
                                   .ReportObjects["Text50"];

            for (int i = 0; i < dataGridView2.Rows.Count - 1; i++)
            {
                dolfColor.Text += dataGridView2.Rows[i].Cells[0].Value.ToString();
                dolfColor.Text += "\n";
            }
            f5.crystalReportViewer1.ReportSource = cr;
            f5.ShowDialog();
        }