Пример #1
0
        public DataTable GetOrdersForSalesReport(DateTime fromDate, DateTime toDate)
        {
            DataTable dtOrderData = new DataTable();

            dtOrderData.TableName = "OrderCustomer";

            dtOrderData.Columns.Add("CreateDate");
            dtOrderData.Columns.Add("Id");
            dtOrderData.Columns.Add("FirstName");
            dtOrderData.Columns.Add("LastName");
            dtOrderData.Columns.Add("CustomerId");
            dtOrderData.Columns.Add("GrandTotal");
            dtOrderData.Columns.Add("HstAmount");
            dtOrderData.Columns.Add("PaidAmount");
            dtOrderData.Columns.Add("BalanceDue");

            try
            {
                var orders = orderDataAccess.GetCompleteOrders(fromDate, toDate);
                for (int i = 0; i < orders.Rows.Count; i++)
                {
                    DataRow dr = dtOrderData.NewRow();
                    dr["CreateDate"] = orders.Rows[i]["CreateDate"];
                    dr["Id"]         = orders.Rows[i]["Id"];
                    dr["CustomerId"] = orders.Rows[i]["CustomerId"];

                    var customerInfo = customerDataAccess.GetCustomerById(Convert.ToInt32(dr["CustomerId"]));
                    if (customerInfo != null)
                    {
                        dr["FirstName"] = customerInfo.FirstName;
                        dr["LastName"]  = customerInfo.LastName;
                    }

                    dr["GrandTotal"] = orders.Rows[i]["GrandTotal"];
                    dr["HstAmount"]  = orders.Rows[i]["HstAmount"];
                    dr["PaidAmount"] = orders.Rows[i]["PaidAmount"];
                    dr["BalanceDue"] = orders.Rows[i]["BalanceDue"];

                    dtOrderData.Rows.Add(dr);
                }
            }
            catch (Exception ex)
            {
                //
            }

            return(dtOrderData);
        }