private void btnViewDBHis_Click(object sender, EventArgs e) { DBHistory dBHistory = new DBHistory(); this.Hide(); dBHistory.Show(); }
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; }
public List <DBHistory> GetDBHistories() { using (IDbConnection con = new SqlConnection(Settings.Default.DBMoneyManage)) { IDbCommand command = new SqlCommand("SELECT * FROM MyDBMoneyManager"); command.Connection = con; con.Open(); IDataReader reader = command.ExecuteReader(); List <DBHistory> HistoryDB = new List <DBHistory>(); DBHistory history = new DBHistory(); while (reader.Read()) { history.Id = reader.GetInt32(0); history.UserName = reader.GetString(1); history.Money = reader.GetDecimal(2); history.Date = reader.GetDateTime(3); HistoryDB.Add(history); } return(HistoryDB); } }
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); } }
private async void OnClearCommand(object obj) { if (this.BookList.Count < 1) { return; } if (!IsEditing) { return; } int count = 0; ObservableCollection <BookEntity> tempList = new ObservableCollection <BookEntity>(); foreach (var item in this.BookList) { if (item.IsSelected) { tempList.Add(item); count++; } } if (count == 0) { ToastHeplper.ShowMessage("请选择需要删除的记录"); return; } var msgDialog = new Windows.UI.Popups.MessageDialog("\n确定删除历史记录?") { Title = "历史记录" }; msgDialog.Commands.Add(new Windows.UI.Popups.UICommand("确定", uiCommand => { foreach (var item in tempList) { this.BookList.Remove(item); DBHistory.DeleteHistory(AppDataPath.GetHistoryDBPath(), item); } this.InitData(); SetBookEditStatus(false); })); msgDialog.Commands.Add(new Windows.UI.Popups.UICommand("取消", uiCommand => { return; })); await msgDialog.ShowAsync(); }
public HistoryDataStoreCache() { _tickBySecurity = new Dictionary <string, List <Tick> >(); _minuteBars = new Dictionary <string, Bar>(); _dailyBars = new Dictionary <string, Bar>(); _minDataCached = new Dictionary <string, bool>(); _dayDataCached = new Dictionary <string, bool>(); _dataFeeds = new List <IDataFeed>(); _dbHistory = new DBHistory(); _tickForDb = new List <Tick>(); _totalDailyAskVolume = new Dictionary <string, Tuple <Dictionary <int, decimal>, DateTime> >(); _totalDailyBidVolume = new Dictionary <string, Tuple <Dictionary <int, decimal>, DateTime> >(); _manuallyRequestedMinData = new List <string>(); _manuallyRequestedDayData = new List <string>(); _minCacheRequestTimer = new Timer(2 * 60 * 1000); _dayCacheRequestTimer = new Timer(2 * 60 * 1000); _writeTicksToDB = new Timer(30 * 1000); _tickMessages = new Queue <Tick>(); _minCacheRequestTimer.Elapsed += delegate { var items = _minDataCached.Where(p => !p.Value).Select(p => p.Key).ToList(); lock (_minDataCached) { foreach (var item in items) { _minDataCached.Remove(item); } } }; _dayCacheRequestTimer.Elapsed += delegate { var items = _dayDataCached.Where(p => !p.Value).Select(p => p.Key).ToList(); lock (_dayDataCached) { foreach (var item in items) { _dayDataCached.Remove(item); } } }; _writeTicksToDB.Elapsed += delegate { AddTicksToDB(); }; }
public void AddToHistoryList(BookEntity entity) { Task.Run(() => { var temp = entity.Clone(); temp.UpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); if (BookList.ToList().Find(p => p.BookID == entity.BookID) == null) { DispatcherHelper.CheckBeginInvokeOnUI(() => { BookList.Insert(0, temp); }); } bool result = DBHistory.InsertOrUpdateBookHistory(AppDataPath.GetHistoryDBPath(), temp); }); }
private IDBHistory GetContent(TextBox name, TextBox money) { decimal sum; history = new DBHistory(); history.UserName = name.Text; bool result = decimal.TryParse(money.Text, out sum); if (!result) { MessageBox.Show("Неверные данные"); history.Money = 0; return(history); } else { history.Money = sum; return(history); } }
public void InitHitoryData() { if (IsLoading) { return; } IsLoading = true; BookList.Clear(); Task.Run(() => { try { var list = DBHistory.GetBookHistories(AppDataPath.GetHistoryDBPath()); if (list != null) { DispatcherHelper.CheckBeginInvokeOnUI(() => { list.ForEach(x => this.BookList.Add(x)); }); } } catch (Exception) { DispatcherHelper.CheckBeginInvokeOnUI(() => { ToastHeplper.ShowMessage("加载历史记录有误"); }); } finally { DispatcherHelper.CheckBeginInvokeOnUI(() => { IsLoading = false; }); } }); }
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; }