private bool ValidateData(out WebTradeLog Log) { Log = new WebTradeLog(); if (loadExisting) return false; int price, priceMatched; int.TryParse(priceSubmitTextBox.Text, out price); int.TryParse(priceMatchedTextBox.Text, out priceMatched); bool matched = IsMatched(); matchedCheckBox.Checked = matched; string reason = reasonComboBox.SelectedValue.ToString(); string BS = (reason == "OpenLong" || reason == "CloseShort") ? "Buy" : "Sell"; var Time = new DateTime(dateTimePicker.Value.Year, dateTimePicker.Value.Month, dateTimePicker.Value.Day, timeTimePicker.Value.Hour, timeTimePicker.Value.Minute, 0, 0); if (price < 10000) return false; Log = new WebTradeLog { Time = Time, Reason = reason, BuySell = BS, Price = price, PriceMatched = matched ? priceMatched : 0, Volume = (int)volNum.Value, Matched = matched, }; return true; }
public NewOrderInput(newLogSaved Updatedeleagte, WebTradeLog Log, AlsiWebDataContext _dc, bool AdminRights) { InitializeComponent(); _onSaved = Updatedeleagte; loadExisting = true; EX = Log; dc = _dc; admin = AdminRights; }
private void PopuilateFromExisting(WebTradeLog ex) { dateTimePicker.Value = ex.Time.Date; timeTimePicker.Value = ex.Time; reasonComboBox.SelectedIndex = GetComboboxSelectedItemIndex(ex.Reason); volNum.Value = ex.Volume; matchedCheckBox.Checked = ex.Matched; priceSubmitTextBox.Text = ex.Price.ToString(); priceMatchedTextBox.Text = ex.PriceMatched.ToString(); saveButton.Enabled = false; loadExisting = false; }
partial void UpdateWebTradeLog(WebTradeLog instance);
partial void DeleteWebTradeLog(WebTradeLog instance);
private void tradeListView_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e) { if (tradeListView.SelectedItems.Count == 0) return; _selectedLog = (WebTradeLog)tradeListView.SelectedItems[0].Tag; deleteButton.Enabled = true; }
partial void InsertWebTradeLog(WebTradeLog instance);
private static bool CheckDbCount(AlsiWebDataContext dc, Trade trade) { int c = dc.WebTradeLogs.Count(); if (c > 0) { //var last = dc.WebTradeLogs.Skip(c - 10).Take(10); } else {//create new if db is empty WebTradeLog wtl = new WebTradeLog() { Time = trade.TimeStamp, BuySell = trade.BuyorSell.ToString(), Price = (int)trade.TradedPrice, Reason = trade.Reason.ToString(), Volume = trade.TradeVolume, PriceMatched = (int)trade.TradedPrice, Matched = false, }; dc.WebTradeLogs.InsertOnSubmit(wtl); dc.SubmitChanges(); return false; } return true; }
public static void SendOrderToWebDB(Trade trade) { var dc = new AlsiWebDataContext(); string bs = "none"; if (trade.BuyorSell == Trade.BuySell.Buy) bs = "Buy"; if (trade.BuyorSell == Trade.BuySell.Sell) bs = "Sell"; if (!CheckDbCount(dc, trade)) return; if (!trade.xlMatched) { WebTradeLog wtl = new WebTradeLog() { Time = trade.TimeStamp, BuySell = trade.BuyorSell.ToString(), Price = (int)trade.TradedPrice, Reason = trade.Reason.ToString(), Volume = trade.TradeVolume, PriceMatched = 0, Matched = false, }; // dc.WebTradeLogs.InsertOnSubmit(wtl); //dc.SubmitChanges(); } else { int c = dc.WebTradeLogs.Count(); var last = dc.WebTradeLogs.Skip(c - 1).Take(1).Single(); last.Time = trade.TimeStamp; last.Matched = true; dc.SubmitChanges(); } }