private void LoadData() { ArrayList al = DBLayer.ArrivalDetails.GetList(0, Date1, Date2); DataTable dt = new DataTable(); dt.Columns.Add("Id", typeof(int)); dt.Columns.Add("Date", typeof(DateTime)); dt.Columns.Add("Total", typeof(double)); dt.Columns.Add("Cost", typeof(double)); dt.Columns.Add("Good"); dt.Columns.Add("Quantity", typeof(double)); dt.Columns.Add("Supplier"); dt.Columns.Add("Dimension"); double total = 0; for (int i = 0; i < al.Count; i++) { DataRow dr = dt.Rows.Add(); DBLayer.ArrivalDetails.ArrivalDetails_WideDetails det = (DBLayer.ArrivalDetails.ArrivalDetails_WideDetails)al[i]; dr["Id"] = det.Id; dr["Supplier"] = det.SupplierName; dr["Date"] = det.Date; dr["Good"] = det.ProductName; dr["Quantity"] = det.Quantity; dr["Cost"] = det.Price; dr["Total"] = det.Price * det.Quantity; dr["Dimension"] = det.DimensionName; total += (det.Price * det.Quantity); } grGoods.DataSource = dt; advBandedGridView1.BestFitColumns(); slblTotal.Text = total.ToString(); }
public static ArrayList GetList(int id, DateTime date1, DateTime date2) { string sql = "SELECT a.*, p.[Name], d.[Name] AS DimensionName, pg.[Name] AS GroupName, "; sql += " s.[Name] AS SupplierName FROM ArrivalDetails AS a INNER JOIN Products AS p ON a.ProductId = p.[Id] "; sql += " INNER JOIN Suppliers AS s ON s.[Id] = a.[SupplierId] "; sql += " INNER JOIN ProductGroup AS pg ON pg.[Id] = p.GroupId "; sql += " INNER JOIN Dimensions AS d ON d.[Id] = p.DimensionId "; sql += " WHERE a.[Date] BETWEEN '" + date1.ToString("yyyyMMdd") + "' AND '" + date2.ToString("yyyyMMdd") + "' "; sql += " ORDER BY [Date]"; DataTable dt = ZFort.DB.Execute.ExecuteString_DataTable(sql); ArrayList al = new ArrayList(); foreach (DataRow dr in dt.Rows) { DBLayer.ArrivalDetails.ArrivalDetails_WideDetails det = new DBLayer.ArrivalDetails.ArrivalDetails_WideDetails(); if (!dr.IsNull("Id")) { det.Id = Convert.ToInt32(dr["Id"]); } if (!dr.IsNull("ArrivalId")) { det.ArrivalId = Convert.ToInt32(dr["ArrivalId"]); } if (!dr.IsNull("Price")) { det.Price = Convert.ToDouble(dr["Price"]); } if (!dr.IsNull("ProductId")) { det.ProductId = Convert.ToInt32(dr["ProductId"]); } det.ProductName = dr["Name"].ToString(); if (!dr.IsNull("Quantity")) { det.Quantity = Convert.ToDouble(dr["Quantity"]); } det.DimensionName = dr["DimensionName"].ToString(); det.GroupName = dr["GroupName"].ToString(); det.DimensionName = dr["DimensionName"].ToString(); if (!dr.IsNull("SupplierId")) { det.SupplierId = Convert.ToInt32(dr["SupplierId"]); } if (!dr.IsNull("Date")) { det.Date = Convert.ToDateTime(dr["Date"]); } det.SupplierName = dr["SupplierName"].ToString(); al.Add(det); } return(al); }