public DataTable GetSalesReport(SalesDatesClass salesDatesClass) { DataTable dt = new DataTable(); dt = salesDatesRepository.GetSalesReport(salesDatesClass); return(dt); }
public DataTable GetSalesReport(SalesDatesClass salesDatesClass) { SqlCommand command = new SqlCommand(@"Select i.ItemName AS Item,Sum(s.StockOutQuantity) AS Quantity From [Stock Out] s Inner Join Item i On i.ItemId=s.ItemId WHERE Date Between '" + salesDatesClass.FromDateTime + "' AND '" + salesDatesClass.ToDateTime + "' AND StockOutType='Sell' Group By i.ItemName ORDER BY Item DESC", connection); connection.Open(); DataTable dt = new DataTable(); SqlDataAdapter da = new SqlDataAdapter(command); da.Fill(dt); connection.Close(); return(dt); }
//*****************************************************************// private void SearchButton_Click(object sender, EventArgs e) { SalesDatesClass salesDatesClass = new SalesDatesClass(); salesDatesClass.FromDateTime = Convert.ToDateTime(fromDateTimePicker.Text); salesDatesClass.ToDateTime = Convert.ToDateTime(toDateTimePicker.Text); if (salesDatesClass.FromDateTime > salesDatesClass.ToDateTime) { MessageBox.Show("Enter valid range of date to search!"); return; } DataTable dt = new DataTable(); dt = salesDatesManager.GetSalesReport(salesDatesClass); if (dt.Rows.Count == 0) { MessageBox.Show("No Transanction taken place between" + salesDatesClass.FromDateTime + " to " + salesDatesClass.ToDateTime + "!"); return; } saleReportDataGridView.DataSource = dt; }