void GetItems(string ID) { var Data = new List <SaleItm>(); foreach (var item in client.ps.History.Sessions) { foreach (var s in DBHistory.ViewSession(item).Sales) { if (s.Value.SaleID.ToString().Contains(ID)) { foreach (var i in s.Value.items) { Data.Add(new SaleItm { Item_ID = i.itemID, Name = client.ps.Live.Items[i.itemID].name, Qty = i.Quantity, Total = (i.Quantity * client.ps.Live.Items[i.itemID].outPrice) }); } } } } foreach (var s in client.ps.Live.Session.Sales) { if (s.Value.SaleID.ToString().Contains(ID)) { foreach (var i in s.Value.items) { Data.Add(new SaleItm { Item_ID = i.itemID, Name = client.ps.Live.Items[i.itemID].name, Qty = i.Quantity, Total = (i.Quantity * client.ps.Live.Items[i.itemID].outPrice) }); } } } DGVit.DataSource = Data; }
void GetRec_Data(DateTime Date) { var Data = new List <Rec_data>(); DataBases.DBSession d; if (Date.Date == DateTime.Now.Date) { d = client.ps.Live.Session; } else { d = DBHistory.ViewSession(Date); } if (d != null) { foreach (var item in client.ps.Live.Items) { decimal Out = 0; decimal In = 0; decimal Bbal = 0; foreach (var sale in d.Sales) { foreach (var i in sale.Value.items) { if (item.Value.itemID == i.itemID) { Out += i.Quantity; } } } foreach (var sin in d.StockIntakes) { if (item.Value.itemID == sin.Value.item.itemID) { In += sin.Value.item.Quantity; } } foreach (var bal in d.BeginingItems) { if (item.Value.itemID == bal.Value.itemID) { Bbal = bal.Value.Quantity; } } Data.Add(new Rec_data { Name = item.Value.name, Begin_Balance = Bbal, IN = In, OUT = Out, Final_Balance = Bbal + In - Out, Total_Value = item.Value.outPrice * (Bbal + In - Out) }); } DGVin.DataSource = Data; } else { MessageBox.Show($"No Records Found On {Date.Date}.", "LankaStocks > Sale History!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
void GetRecM_Data(DateTime Date) { var Data = new List <Rec_data>(); var DateList = client.ps.History.Sessions.Select(x => GetValidDate(x)).Where(a => a.Year == Date.Year && a.Month == Date.Month).ToList(); if (DateTime.Now.Year == Date.Year && DateTime.Now.Month == Date.Month) { DateList.Add(DateTime.Now); } foreach (var item in client.ps.Live.Items) { decimal Out = 0; decimal In = 0; decimal Bbal = 0; foreach (var s in DateList) { DataBases.DBSession d; //if (Date.Year == DateTime.Now.Year && Date.Month == DateTime.Now.Month) d = client.ps.Live.Session; //else if (s.Date == DateTime.Now.Date) { d = client.ps.Live.Session; } else { d = DBHistory.ViewSession(s); } if (d != null) { foreach (var sale in d.Sales) { foreach (var i in sale.Value.items) { if (item.Value.itemID == i.itemID) { Out += i.Quantity; } } } foreach (var sin in d.StockIntakes) { if (item.Value.itemID == sin.Value.item.itemID) { In += sin.Value.item.Quantity; } } if (s == DateList.Min()) { foreach (var bal in d.BeginingItems) { if (item.Value.itemID == bal.Value.itemID) { Bbal = bal.Value.Quantity; } } } } } Data.Add(new Rec_data { Name = item.Value.name, Begin_Balance = Bbal, IN = In, OUT = Out, Final_Balance = Bbal + In - Out, Total_Value = item.Value.outPrice * (Bbal + In - Out) }); } DGVin.DataSource = Data; }
void GetHis(bool all, DateTime Date, string ID) { var Data = new List <SaleHis>(); if (all) { foreach (var item in client.ps.History.Sessions) { foreach (var s in DBHistory.ViewSession(item).Sales) { if (s.Value.SaleID.ToString().Contains(ID)) { s.Value.CalculateTotal(); Data.Add(new SaleHis { Sale_ID = s.Value.SaleID, Date = s.Value.date, Total_Items = s.Value.items.Count, Total = s.Value.total }); } } } foreach (var s in client.ps.Live.Session.Sales) { if (s.Value.SaleID.ToString().Contains(ID)) { s.Value.CalculateTotal(); Data.Add(new SaleHis { Sale_ID = s.Value.SaleID, Date = s.Value.date, Total_Items = s.Value.items.Count, Total = s.Value.total }); } } } else { DataBases.DBSession d; if (Date.Date == DateTime.Now.Date) { d = client.ps.Live.Session; } else { d = DBHistory.ViewSession(Date); } if (d != null) { foreach (var s in d.Sales) { if (s.Value.SaleID.ToString().Contains(ID)) { s.Value.CalculateTotal(); Data.Add(new SaleHis { Sale_ID = s.Value.SaleID, Date = s.Value.date, Total_Items = s.Value.items.Count, Total = s.Value.total }); } } } else { MessageBox.Show($"No Records Found On {Date.Date}.", "LankaStocks > Sale History!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } DGVin.DataSource = Data; }