Пример #1
0
        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);
        }
Пример #2
0
        private void deleteButton_Click(object sender, EventArgs e)
        {
            Cursor = Cursors.WaitCursor;

            string matchedSt = "";

            if (_selectedLog.Matched)
            {
                matchedSt = "Matched @ " + _selectedLog.PriceMatched;
            }
            else
            {
                matchedSt = "Not Macthed";
            }
            string dial = _selectedLog.Time.ToString() + "  " + _selectedLog.BuySell + " " + _selectedLog.Volume + " @ " + _selectedLog.Price + " " + matchedSt;

            DialogResult dr = MessageBox.Show("Delete :\n" + dial, "Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (dr == DialogResult.No)
            {
                Cursor = Cursors.Default;
                return;
            }
            dc.WebTradeLogs.DeleteOnSubmit(_selectedLog);
            dc.SubmitChanges();
            LoadListview();
            Cursor = Cursors.Default;
        }
Пример #3
0
        public static void ClearTradeLog()
        {
            var dc     = new AlsiWebDataContext();
            var delall = dc.WebTradeLogs;

            dc.WebTradeLogs.DeleteAllOnSubmit(delall);
            dc.SubmitChanges();
        }
Пример #4
0
        public static void ClearEmailList()
        {
            var dc     = new AlsiWebDataContext();
            var delall = dc.tblEmails;

            dc.tblEmails.DeleteAllOnSubmit(delall);
            dc.SubmitChanges();
        }
Пример #5
0
        public static void DeleteUserFromSmsList(int UserID)
        {
            var dc   = new AlsiWebDataContext();
            var user = dc.tblSMs.Where(z => z.SMS_ID == UserID).First();

            dc.tblSMs.DeleteOnSubmit(user);
            dc.SubmitChanges();
            GetSmsList();
        }
Пример #6
0
        public static void CheckUncheckSmsListUser(int UserID)
        {
            var dc   = new AlsiWebDataContext();
            var user = dc.tblSMs.Where(z => z.SMS_ID == UserID).First();

            user.Active = !user.Active;
            dc.SubmitChanges();
            GetSmsList();
        }
Пример #7
0
        public static bool InsertNewUsertoSmsList(tblSM user)
        {
            var dc     = new AlsiWebDataContext();
            var insert = (!dc.tblSMs.Any(z => z.TelNr == user.TelNr));

            if (insert)
            {
                user.Active = true;
                dc.tblSMs.InsertOnSubmit(user);
                dc.SubmitChanges();
                GetSmsList();
            }
            return(insert);
        }
Пример #8
0
        public static bool InsertNewUsertoEmailList(tblEmail user)
        {
            var dc     = new AlsiWebDataContext();
            var insert = (!dc.tblEmails.Any(z => z.Email == user.Email));

            if (insert)
            {
                user.Active = true;
                dc.tblEmails.InsertOnSubmit(user);
                dc.SubmitChanges();
                GetEmailList();
            }
            return(insert);
        }
Пример #9
0
        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();
            }
        }
Пример #10
0
 private void saveButton_Click(object sender, EventArgs e)
 {
     if (EX == null)
     {
         dc.WebTradeLogs.InsertOnSubmit(tl);
     }
     else
     {
         EX.BuySell      = tl.BuySell;
         EX.Matched      = tl.Matched;
         EX.Price        = tl.Price;
         EX.PriceMatched = tl.PriceMatched;
         EX.Price        = tl.Price;
         EX.Reason       = tl.Reason;
         EX.Time         = tl.Time;
         EX.Volume       = tl.Volume;
     }
     dc.SubmitChanges();
     _onSaved();
     saveButton.Enabled = false;
 }