private void button3_Click(object sender, EventArgs e) { try { MySql.Data.MySqlClient.MySqlConnection mysqlconnect = new MySql.Data.MySqlClient.MySqlConnection("Server=localhost ; User Id=root; Password= ;Database=algdb(2.0)"); string query = "SELECT * FROM stocks_print"; mysqlconnect.Open(); MySqlCommand cmd = new MySqlCommand(query, dbcon.mysqlconnect); MySqlDataAdapter adp = new MySqlDataAdapter(); DataSet dt = new DataSet(); adp.SelectCommand = cmd; adp.Fill(dt, "dsStock"); CrystalReportStock reporting = new CrystalReportStock(); reporting.SetDataSource(dt); frmReports frmreports = new frmReports(); frmreports.crystalReportViewer.ReportSource = reporting; frmreports.crystalReportViewer.Refresh(); cmd.Dispose(); adp.Dispose(); dt.Dispose(); dbcon.mysqlconnect.Close(); frmreports.ShowDialog(); } catch (Exception) { throw; } }
private void button2_Click(object sender, EventArgs e) { MySql.Data.MySqlClient.MySqlConnection mysqlconnect = new MySql.Data.MySqlClient.MySqlConnection("Server=localhost ; User Id=root; Password= ;Database=algdb(2.0)"); CrystalReportReceipt reporting = new CrystalReportReceipt(); //dbcon.mysqlconnect.Open(); mysqlconnect.Open(); string query = "SELECT * FROM transactions,products,prod_trans_rela,product_prices,brands,categories WHERE transactions.transac_ID = '10000001'AND prod_trans_rela.transac_ID = transactions.transac_ID AND product_prices.product_ID = prod_trans_rela.product_ID AND products.product_ID = prod_trans_rela.product_ID AND brands.brand_ID = products.brand_ID AND categories.category_ID = products.category_ID"; //string query = "SELECT * FROM transactions,customers,products,prod_trans_rela,product_prices,brands,categories WHERE transactions.transac_ID = '10000001'AND transactions.customer_ID = customers.cust_ID AND prod_trans_rela.transac_ID = transactions.transac_ID AND product_prices.product_ID = prod_trans_rela.product_ID AND products.product_ID = prod_trans_rela.product_ID AND brands.brand_ID = products.brand_ID AND categories.category_ID = products.category_ID"; MySqlCommand cmd = new MySqlCommand(query, dbcon.mysqlconnect); MySqlDataAdapter adp = new MySqlDataAdapter(); DataSet dt = new DataSet(); adp.SelectCommand = cmd; adp.Fill(dt, "dsreceipt"); string query1 = "SELECT * FROM services"; MySqlCommand cmd1 = new MySqlCommand(query1, dbcon.mysqlconnect); MySqlDataAdapter adp1 = new MySqlDataAdapter(); DataSet dt1 = new DataSet(); adp1.SelectCommand = cmd1; adp1.Fill(dt1, "services"); reporting.SetDataSource(dt); //reporting.Database.Tables["dsreceipt"].SetDataSource(dt.Tables[0]); //reporting.Database.Tables["services"].SetDataSource(dt1.Tables[0]); frmReports frmreports = new frmReports(); frmreports.crystalReportViewer.ReportSource = reporting; frmreports.crystalReportViewer.Refresh(); cmd.Dispose(); cmd1.Dispose(); adp1.Dispose(); adp.Dispose(); dt.Dispose(); dbcon.mysqlconnect.Close(); frmreports.ShowDialog(); }
public void printreceipt(string transacID) { try { CrystalReportReceipt reporting = new CrystalReportReceipt(); dbcon.mysqlconnect.Open(); string query = $"SELECT * FROM transactions,customers,products,prod_trans_rela,product_prices,brands,categories WHERE transactions.transac_ID = '{transacID}'AND transactions.customer_ID = customers.cust_ID AND prod_trans_rela.transac_ID = transactions.transac_ID AND product_prices.product_ID = prod_trans_rela.product_ID AND products.product_ID = prod_trans_rela.product_ID AND brands.brand_ID = products.brand_ID AND categories.category_ID = products.category_ID"; MySqlCommand cmd = new MySqlCommand(query, dbcon.mysqlconnect); MySqlDataAdapter adp = new MySqlDataAdapter(); DataSet dt = new DataSet(); adp.SelectCommand = cmd; adp.Fill(dt, "dsreceipt"); reporting.SetDataSource(dt); frmReports frmreports = new frmReports(); frmreports.crystalReportViewer.ReportSource = reporting; frmreports.crystalReportViewer.Refresh(); cmd.Dispose(); adp.Dispose(); dt.Dispose(); dbcon.mysqlconnect.Close(); frmreports.ShowDialog(); } catch (Exception) { throw; } }
public void printproduct(string search, string searchBy) { try { MySql.Data.MySqlClient.MySqlConnection mysqlconnect = new MySql.Data.MySqlClient.MySqlConnection("Server=localhost ; User Id=root; Password= ;Database=algdb(2.0)"); //string query = $"SELECT * FROM product_print WHERE category_name = 'Gasoline Engine Oil'"; string query; if (searchBy == "Product ID") { query = $"SELECT * FROM product_print WHERE product_ID LIKE '{search}'"; } else if (searchBy == "Product Name") { query = $"SELECT * FROM product_print WHERE product_name LIKE '{search}'"; } else if (searchBy == "Brand") { query = $"SELECT * FROM product_print WHERE brand_name LIKE '{search}'"; } else if (searchBy == "Category") { query = $"SELECT * FROM product_print WHERE category_name LIKE '{search}'"; } else if (searchBy == "Description") { query = $"SELECT * FROM product_print WHERE product_desc_value LIKE '{search}'"; } else #region old query #endregion { query = "SELECT * FROM product_print"; } mysqlconnect.Open(); MySqlCommand cmd = new MySqlCommand(query, dbcon.mysqlconnect); MySqlDataAdapter adp = new MySqlDataAdapter(); DataSet dt = new DataSet(); adp.SelectCommand = cmd; adp.Fill(dt, "dsProduct"); CrystalReportProduct reporting = new CrystalReportProduct(); reporting.SetDataSource(dt); frmReports frmreports = new frmReports(); frmreports.crystalReportViewer.ReportSource = reporting; frmreports.crystalReportViewer.Refresh(); cmd.Dispose(); adp.Dispose(); dt.Dispose(); dbcon.mysqlconnect.Close(); frmreports.ShowDialog(); } catch (Exception ex) { throw; } }
private void button4_Click(object sender, EventArgs e) { MySql.Data.MySqlClient.MySqlConnection mysqlconnect = new MySql.Data.MySqlClient.MySqlConnection("Server=localhost ; User Id=root; Password= ;Database=algdb(2.0)"); frmReports frmreports = new frmReports(); mysqlconnect.Open(); MySqlDataAdapter adp = new MySqlDataAdapter("getTransaction", mysqlconnect); adp.SelectCommand.CommandType = CommandType.StoredProcedure; adp.SelectCommand.Parameters.Add("ID", MySql.Data.MySqlClient.MySqlDbType.Int32, 20).Value = textBox1.Text; DataSet dt = new System.Data.DataSet(); adp.Fill(dt, "transaction"); mysqlconnect.Close(); //CrystalReport1 reporting = new CrystalReport1(); //reporting.Database.Tables["transactions"].SetDataSource(dt.Tables[0]); //frmreports.crystalReportViewer.ReportSource = null; //frmreports.crystalReportViewer.ReportSource = reporting; }