Exemplo n.º 1
0
        public DataTable GetVoidOrders(DateTime fromDate, DateTime toDate)
        {
            DataTable dtOrderData = new DataTable();

            dtOrderData.TableName = "VoidOrder";

            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");
            dtOrderData.Columns.Add("VoidDate");
            dtOrderData.Columns.Add("Remarks");

            try
            {
                var orders = orderDataAccess.GetVoidOrders(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"];
                    dr["VoidDate"]   = orders.Rows[i]["VoidDate"];
                    dr["Remarks"]    = orders.Rows[i]["Remarks"];

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

            return(dtOrderData);
        }