コード例 #1
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";
            }
            abtda2y abtda2Y    = new abtda2y();
            string  t3akodDate = (dateTimePicker1.Value.ToShortDateString());

            abtda2Y.nationalId       = textBox2.Text.ToString();
            abtda2Y.tare5t3akod      = t3akodDate;
            abtda2Y.PlaceAddress     = textBox5.Text.ToString();
            abtda2Y.clientAddress    = textBox3.Text.ToString();
            abtda2Y.Phone            = textBox4.Text.ToString();
            abtda2Y.totalPrice       = Convert.ToDecimal(textBox1.Text.ToString());
            abtda2Y.totalPriceText   = textBox7.Text.ToString();
            abtda2Y.dof3aMokdma      = Convert.ToDecimal(textBox6.Text.ToString());
            abtda2Y.dof3aMokdmaText  = textBox8.Text.ToString();
            abtda2Y.Notes            = textBox15.Text.ToString();
            abtda2Y.meterPrice       = Convert.ToDecimal(textBox9.Text.ToString());
            abtda2Y.metersNumber     = int.Parse(textBox10.Text.ToString());
            abtda2Y.mfslatNumber     = int.Parse(textBox18.Text.ToString());
            abtda2Y.mgaryNumber      = int.Parse(textBox20.Text.ToString());
            abtda2Y.totalmetermatb5  = Convert.ToDecimal(textBox11.Text.ToString());
            abtda2Y.totalmfslat      = Convert.ToDecimal(textBox17.Text.ToString());
            abtda2Y.totalmgary       = Convert.ToDecimal(textBox19.Text.ToString());
            abtda2Y.mgaryPrice       = Convert.ToDecimal(textBox12.Text.ToString());
            abtda2Y.mfslatPrice      = Convert.ToDecimal(textBox13.Text.ToString());
            abtda2Y.totalAccessories = Convert.ToDecimal(textBox14.Text.ToString());
            abtda2Y.Name             = comboBox1.Text;
            abtda2Y.modelElmtb5      = comboBox2.Text;
            abtda2Y.modelelmfslat    = comboBox3.Text;
            abtda2Y.modelMgary       = comboBox4.Text;
            abtda2Y.m2bd             = comboBox8.Text;
            for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
            {
                abtda2yAcces accesories = new abtda2yAcces();
                accesories.Name  = dataGridView1.Rows[i].Cells[0].Value.ToString();
                accesories.Price = Convert.ToDecimal(dataGridView1.Rows[i].Cells[1].Value.ToString());
                abtda2Y.Accesories.Add(accesories);
                context.SaveChanges();
            }
            for (int i = 0; i < dataGridView2.Rows.Count - 1; i++)
            {
                abtda2yArkam accesories = new abtda2yArkam();
                accesories.Arkam = dataGridView2.Rows[i].Cells[0].Value.ToString();
                abtda2Y.Abtda2YArkams.Add(accesories);
                context.SaveChanges();
            }
            context.Abtda2s.Add(abtda2Y);
            context.SaveChanges();

            Form6          f6   = new Form6();
            CrystalReport3 cr   = new CrystalReport3();
            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 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["Text68"];

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

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

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

            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 totwlAccessories = (TextObject)cr.ReportDefinition.Sections["Section4"]
                                          .ReportObjects["Text57"];

            totwlAccessories.Text = textBox14.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"];

            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";
            }
            f6.crystalReportViewer1.ReportSource = cr;
            f6.Show();
        }