public List <ViewSalesReport> GetSalesAllItems(DateTime fromDate, DateTime toDate) { connection.ConnectionString = connectionString; cmd = new SqlCommand(); cmd.CommandText = "SELECT * FROM ViewSalesReport "; cmd.Connection = connection; cmd.Parameters.Clear(); cmd.Parameters.Add("@fromDate", SqlDbType.DateTime).Value = fromDate; cmd.Parameters.Add("@toDate", SqlDbType.DateTime).Value = toDate; //cmd.Parameters.AddWithValue("Item", Item); //cmd.Parameters.AddWithValue("Quantity", Quantity); connection.Open(); reader = cmd.ExecuteReader(); List <ViewSalesReport> salesItems = new List <ViewSalesReport>(); while (reader.Read()) { var viewSalesReport = new ViewSalesReport(); viewSalesReport.ItemName = reader["ItemName"].ToString(); viewSalesReport.Quantity = Convert.ToInt32(reader["Quantity"]); salesItems.Add(viewSalesReport); } reader.Close(); connection.Close(); return(salesItems); }
protected void searchButton_Click(object sender, EventArgs e) { //List<StockOut> itemListByCompanyAndCategory = stockOutManager.ViewSales(fromDateTextBox.Text, toDateTextBox.Text); //showGridView.DataSource = itemListByCompanyAndCategory; //showGridView.DataBind(); //if (fromDateTextBox.Text == "" && toDateTextBox.Text == "") //{ // showGridView.DataSource = stockOutManager.ViewSales(fromDateTextBox.Text, toDateTextBox.Text); // showGridView.DataBind(); //} ViewSalesReport vsr = new ViewSalesReport(); String starting = Page.Request.Form["start"]; String ending = Page.Request.Form["end"]; vsr.StartDate = starting; vsr.EndDate = ending; showGridView.DataSource = stockOutManager.ViewSales(vsr.StartDate, vsr.EndDate); showGridView.DataBind(); }
public async Task <List <ViewSalesReport> > GetSalespersonsReportAsync() { var sales = await _Context.Sales.OrderBy(c => c.SalesDate) .Include("Product") .Include("Salesperson") .ToListAsync(); if (sales.Count > 0) { List <ViewSalesReport> vsl = new List <ViewSalesReport>(); foreach (var sale in sales) { ViewSalesReport vs = new ViewSalesReport() { Salesperson = sale.Salesperson.FirstName + " " + sale.Salesperson.LastName, CommissionDate = sale.SalesDate, SalespersonCommission = sale.Product.CommissionPercentage * (float)sale.SalesPrice / 100 }; vsl.Add(vs); } return(vsl); } return(null); }