Exemple #1
0
 private void button3_Click(object sender, EventArgs e)
 {
     try{
         Cursor         = Cursors.WaitCursor;
         timer1.Enabled = true;
         rptStock rpt = new rptStock();
         //The report you created.
         cmd = new SqlCommand();
         SqlDataAdapter myDA = new SqlDataAdapter();
         POS_DBDataSet  myDS = new POS_DBDataSet();
         //The DataSet you created.
         con             = new SqlConnection(cs.DBConn);
         cmd.Connection  = con;
         cmd.CommandText = "SELECT * from Stock,Product,Supplier where Stock.ProductID=Product.ProductID and Stock.SupplierID=Supplier.SupplierID and StockDate Between @d1 and @d2 order by StockDate";
         cmd.Parameters.Add("@d1", SqlDbType.DateTime, 30, "StockDate").Value = dtpStockDateFrom.Value.Date;
         cmd.Parameters.Add("@d2", SqlDbType.DateTime, 30, "StockDate").Value = dtpStockDateTo.Value.Date;
         cmd.CommandType    = CommandType.Text;
         myDA.SelectCommand = cmd;
         myDA.Fill(myDS, "Stock");
         myDA.Fill(myDS, "Product");
         myDA.Fill(myDS, "Supplier");
         rpt.SetDataSource(myDS);
         frmStockReport frm = new frmStockReport();
         frm.crystalReportViewer1.ReportSource = rpt;
         frm.Visible = true;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemple #2
0
 private void button5_Click(object sender, EventArgs e)
 {
     try
     {
         if (txtProductname.Text == "")
         {
             MessageBox.Show("Please enter product name", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
             txtProductname.Focus();
             return;
         }
         Cursor         = Cursors.WaitCursor;
         timer1.Enabled = true;
         rptStock rpt = new rptStock();
         //The report you created.
         cmd = new SqlCommand();
         SqlDataAdapter myDA = new SqlDataAdapter();
         POS_DBDataSet  myDS = new POS_DBDataSet();
         //The DataSet you created.
         con                = new SqlConnection(cs.DBConn);
         cmd.Connection     = con;
         cmd.CommandText    = "SELECT * from Stock,Product,Supplier where Stock.ProductID=Product.ProductID and Stock.SupplierID=Supplier.SupplierID and ProductName like '" + txtProductname.Text + "%' order by StockDate";
         cmd.CommandType    = CommandType.Text;
         myDA.SelectCommand = cmd;
         myDA.Fill(myDS, "Stock");
         myDA.Fill(myDS, "Product");
         myDA.Fill(myDS, "Supplier");
         rpt.SetDataSource(myDS);
         frmStockReport frm = new frmStockReport();
         frm.crystalReportViewer1.ReportSource = rpt;
         frm.Visible = true;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }