public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport() { CrystalReport2 rpt = new CrystalReport2(); rpt.Site = this.Site; return(rpt); }
private void flatButton2_Click(object sender, EventArgs e) { if (metroTextBox4.Text == "0") { MessageBox.Show("لايمكن الحفظ لأن مبلغ الفاتورة= 0 /n هناك تغييرات لم تقم بحفظها يرجى التحديث ثم معاودة الحفظ ", "خطأ", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { if (metroTextBox3.Text == string.Empty) { MessageBox.Show("يرجى أدخال تاريخ التعديل وشكرا", "خطأ", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { string sql1 = "data source = Data.db"; SQLiteConnection conn1 = new SQLiteConnection(sql1); conn1.Open(); string query_save1 = "update Bills2 set Bills_date=@Bills_date,Bills_date_update=@Bills_date_update,Bills_sum=@Bills_sum where Bills_id = '" + Convert.ToInt64(metroTextBox1.Text) + "'"; SQLiteCommand cmd1 = new SQLiteCommand(query_save1, conn1); cmd1.Parameters.AddWithValue("@Bills_date", metroTextBox5.Text); cmd1.Parameters.AddWithValue("@Bills_date_update", metroTextBox3.Text); cmd1.Parameters.AddWithValue("@Bills_sum", Convert.ToInt64(metroTextBox4.Text)); cmd1.ExecuteNonQuery(); string query_save3 = "update Bills set Bills_date_update=@Bills_date_update,Bills_sum=@Bills_sum where Bills_id = '" + Convert.ToInt64(metroTextBox1.Text) + "'"; SQLiteCommand cmd3 = new SQLiteCommand(query_save3, conn1); cmd3.Parameters.AddWithValue("@Bills_sum", Convert.ToInt64(metroTextBox4.Text)); cmd3.Parameters.AddWithValue("@Bills_date_update", metroTextBox3.Text); cmd3.Parameters.AddWithValue("@Bills_date", metroTextBox5.Text); cmd3.ExecuteNonQuery(); conn1.Close(); string sql = "data source = Data.db"; SQLiteConnection con4 = new SQLiteConnection(sql); DS1 ds = new DS1(); CrystalReport2 cr2 = new CrystalReport2(); Print p = new Print(); con4.Open(); SQLiteDataAdapter da1 = new SQLiteDataAdapter("select Bills_id,Bills_members_name,Bills_pharm_name,Bills_pharm_ghram,Bills_pharm_quan,Bills_pharm_price,Bills_count,Bills_unit from Bills where Bills_id=@Bills_id", con4); da1.SelectCommand.Parameters.AddWithValue("@Bills_id", Convert.ToInt64(dataGridView1.CurrentRow.Cells[0].Value.ToString())); da1.Fill(ds, "Bills"); cr2.SetDataSource(ds.Tables["Bills"]); p.crystalReportViewer1.ReportSource = cr2; p.Show(); this.Close(); } } }
private void flatButton7_Click(object sender, EventArgs e) { if (dataGridView1.CurrentRow == null) { MessageBox.Show("لم يتم تحديد أي فاتورة", "خطأ", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { string sql = "data source = Data.db"; SQLiteConnection con = new SQLiteConnection(sql); DS ds = new DS(); CrystalReport2 cr2 = new CrystalReport2(); Print p = new Print(); con.Open(); SQLiteDataAdapter da = new SQLiteDataAdapter("select Bills_id,Bills_members_name,Bills_pharm_name,Bills_pharm_ghram,Bills_pharm_quan,Bills_pharm_price,Bills_count,Bills_unit from Bills where Bills_id=@Bills_id", con); da.SelectCommand.Parameters.AddWithValue("@Bills_id", Convert.ToInt64(dataGridView1.CurrentRow.Cells[0].Value.ToString())); da.Fill(ds, "Bills"); cr2.SetDataSource(ds.Tables["Bills"]); p.crystalReportViewer1.ReportSource = cr2; p.Show(); this.Close(); } }