public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport() { bar_rp rpt = new bar_rp(); rpt.Site = this.Site; return(rpt); }
private void bar_prnt_btn_Click(object sender, EventArgs e) { try { SqlCommand delete_cmd = connect_sal.CreateCommand(); delete_cmd.CommandText = "delete from barcode_table"; connect_sal.Open(); delete_cmd.ExecuteNonQuery(); connect_sal.Close(); SqlCommand insert_bar_cmd = connect_sal.CreateCommand(); if (bar_grid.Rows.Count > 0) { string bar = ""; for (int i = 0; i < bar_grid.Rows.Count; i++) { for (int count = 0; count < Convert.ToInt32(bar_grid.Rows[i].Cells[2].Value.ToString()); count++) { bar = "*0000" + bar_grid.Rows[i].Cells[0].Value.ToString() + "*"; insert_bar_cmd.CommandText = "insert into barcode_table(sanf_code_b, sanf_code, price, sanf_name, qat_pric" + ")values('" + bar + "','" + bar_grid.Rows[i].Cells[0].Value.ToString() + "','" + meth.select_sanf_data_by_barcode_orcode(bar_grid.Rows[i].Cells[0].Value.ToString().Trim()).Rows[0][3].ToString() + "','" + meth.select_sanf_data_by_barcode_orcode(bar_grid.Rows[i].Cells[0].Value.ToString().Trim()).Rows[0][1].ToString() + "','" + meth.select_sanf_data_by_barcode_orcode(bar_grid.Rows[i].Cells[0].Value.ToString().Trim()).Rows[0][4].ToString() + "')"; connect_sal.Open(); insert_bar_cmd.ExecuteNonQuery(); connect_sal.Close(); } } if (a4_compl_rdbnt.Checked) { repoerts_form report_frm = new repoerts_form(); bar_rp br = new bar_rp(); PageMargins margins; // Get the PageMargins structure and set the // margins for the report. margins = br.PrintOptions.PageMargins; margins.bottomMargin = 0; margins.leftMargin = 0; margins.rightMargin = 0; margins.topMargin = 0 ; // Apply the page margins. br.PrintOptions.ApplyPageMargins(margins); // Select the printer. br.PrintOptions.PrinterName = p_name.Trim();// "HP LaserJet Professional P1102"; /* PrinterSettings p_s=new PrinterSettings(); * //p_s.PrinterName = "HP LaserJet Professional P1102"; * p_s.PrinterName = "HP LaserJet Professional P1102"; * PaperSize s=new PaperSize(); * * * PageSettings ps=new PageSettings(); * * float ds=0; * // ps.PaperSize.RawKind = ps.PaperSize.PaperName; * ds= ps.HardMarginY-1; * // MessageBox.Show(ds.ToString()); * ps.Margins.Top = 0; * ps.Margins.Bottom = 0; * * ps.Margins.Right = 0; * ps.Margins.Left = 0;*/ // report_frm.rep_crst.ReportSource = br; br.Refresh(); ////////////// // br.PrintToPrinter(p_s,ps,false); //////////////////////// if (copy_n_bx.Text.Trim() != "") { br.PrintToPrinter(Int32.Parse(copy_n_bx.Text.Trim()), true, 1, 1); bar_grid.Rows.Clear(); } else { MessageBox.Show("من فضلك ادخل عدد النسخ"); } } else if (a4_splited_rdbtn.Checked) { repoerts_form report_frm = new repoerts_form(); barcode br = new barcode(); PageMargins margins; // Get the PageMargins structure and set the // margins for the report. /* margins = br.PrintOptions.PageMargins; * margins.bottomMargin = 0; * margins.leftMargin = 0; * margins.rightMargin = 0; * margins.topMargin = 1300; * // Apply the page margins. * // br.PrintOptions.ApplyPageMargins(margins); * * // Select the printer. * br.PrintOptions.PrinterName = p_name.Trim();// "HP LaserJet Professional P1102"; * * br.Refresh(); * * ////////////// * // br.PrintToPrinter(p_s,ps,false); * //////////////////////// * if (copy_n_bx.Text.Trim() != "") * { * br.PrintToPrinter(Int32.Parse(copy_n_bx.Text.Trim()), true, 1, 1); * bar_grid.Rows.Clear(); * } * else * MessageBox.Show("من فضلك ادخل عدد النسخ");*/ br.Refresh(); br.ExportToDisk(ExportFormatType.PortableDocFormat, "2.pdf"); string path = "2.pdf"; //<- your path here. if (path.EndsWith(".pdf")) { if (File.Exists(path)) { ProcessStartInfo info = new ProcessStartInfo(); info.Verb = "open"; info.FileName = path; info.CreateNoWindow = true; info.WindowStyle = ProcessWindowStyle.Hidden; Process p = new Process(); p.StartInfo = info; p.Start(); /* p.WaitForInputIdle(); * System.Threading.Thread.Sleep(6000); * if (false == p.CloseMainWindow()) * p.Kill();*/ } } } } } catch (Exception dd) { MessageBox.Show(dd.Message); connect_sal.Close(); } }
private void show_bef_prnt_btn_Click(object sender, EventArgs e) { try { SqlCommand delete_cmd = connect_sal.CreateCommand(); delete_cmd.CommandText = "delete from barcode_table"; connect_sal.Open(); delete_cmd.ExecuteNonQuery(); connect_sal.Close(); SqlCommand insert_bar_cmd = connect_sal.CreateCommand(); if (bar_grid.Rows.Count > 0) { string bar = ""; for (int i = 0; i < bar_grid.Rows.Count; i++) { for (int count = 0; count < Convert.ToInt32(bar_grid.Rows[i].Cells[2].Value.ToString()); count++) { bar = "*" + bar_grid.Rows[i].Cells[0].Value.ToString() + "*"; insert_bar_cmd.CommandText = "insert into barcode_table(sanf_code_b, sanf_code, price, sanf_name, qat_pric" + ")values('" + bar + "','" + bar_grid.Rows[i].Cells[0].Value.ToString() + "','" + meth.select_sanf_data_by_barcode_orcode(bar_grid.Rows[i].Cells[0].Value.ToString().Trim()).Rows[0][3].ToString() + "','" + meth.select_sanf_data_by_barcode_orcode(bar_grid.Rows[i].Cells[0].Value.ToString().Trim()).Rows[0][1].ToString() + "','" + meth.select_sanf_data_by_barcode_orcode(bar_grid.Rows[i].Cells[0].Value.ToString().Trim()).Rows[0][4].ToString() + "')"; connect_sal.Open(); insert_bar_cmd.ExecuteNonQuery(); connect_sal.Close(); } } if (a4_compl_rdbnt.Checked) { repoerts_form report_frm = new repoerts_form(); bar_rp br = new bar_rp(); report_frm.rep_crst.ReportSource = br; br.Refresh(); report_frm.rep_crst.ExportReport(); report_frm.ShowDialog(); } else if (a4_splited_rdbtn.Checked) { repoerts_form report_frm = new repoerts_form(); barcode br2 = new barcode(); report_frm.rep_crst.ReportSource = br2; //CrystalDecisions.Shared.ExportOptions op = new ExportOptions(); // op.ExportFormatOptions = CrystalDecisions.Shared.ExportOptions.CreateHTMLFormatOptions(); // op.ExportFormatType = CrystalDecisions.Shared.ExportFormatType.HTML40; br2.Refresh(); // br2.Export(op); //.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.HTML40, "1"); report_frm.ShowDialog(); } } } catch (Exception dd) { MessageBox.Show(dd.Message); connect_sal.Close(); } }