private void loadPrint() { if (salescommit == "1") { string q1 = "select itemCode,itemName,quantity,unitPrice,Amount,sReturn from Sales where salesNo='" + sl + "'"; string q2 = "select salesNo,sDate,total,salesType,creditCardPer,discountPer,vatAmount,grandTotal,receive,change from SalesSummary where salesNo='" + sl + "'"; try { aa.Open(); SqlDataAdapter da = new SqlDataAdapter(); da.SelectCommand = new SqlCommand(q1, aa); DataSet1 mydataset = new DataSet1(); da.Fill(mydataset, "Sales"); da.Dispose(); SqlDataAdapter da2 = new SqlDataAdapter(); da2.SelectCommand = new SqlCommand(q2, aa); da2.Fill(mydataset, "SalesSummary"); CrystalReport1 myreport = new CrystalReport1(); myreport.SetDataSource(mydataset); PrintMemo pm = new PrintMemo(); pm.crystalReportViewer1.ReportSource = myreport; pm.Show(); } catch (Exception ex) { MessageBox.Show(ex.Message.ToString(), "error!!!", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { aa.Close(); } } else { MessageBox.Show("First commit sales by Clicking Save Button!", "error!!!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void loadPrint() { if(commit == "1") { string q1 = "select itemCode,itemName,quantity,unitPrice,Amount,sReturn from Sales where salesNo='" + sl + "'"; string q2 = "select salesNo,sDate,total,salesType,creditCardPer,discountPer,vatAmount,grandTotal,receive,change from SalesSummary where salesNo='" + sl + "'"; try { aa.Open(); SqlDataAdapter da = new SqlDataAdapter(); da.SelectCommand = new SqlCommand(q1, aa); DataSet1 mydataset = new DataSet1(); da.Fill(mydataset, "Sales"); da.Dispose(); SqlDataAdapter da2 = new SqlDataAdapter(); da2.SelectCommand = new SqlCommand(q2, aa); da2.Fill(mydataset, "SalesSummary"); CrystalReport1 myreport = new CrystalReport1(); myreport.SetDataSource(mydataset); PrintMemo pm = new PrintMemo(); pm.crystalReportViewer1.ReportSource = myreport; pm.Show(); } catch (Exception ex) { MessageBox.Show(ex.Message.ToString(), "error!!!", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { aa.Close(); } } else { MessageBox.Show("First commit sales by Clicking Save Button!", "error!!!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }