Esempio n. 1
0
 private void StockChecked_CallBack(SmpStock stock)
 {
     if (stock != null)
     {
         StockChangedEventArgs args = new StockChangedEventArgs(stock);
         OnStockChecked(args);
     }
 }
Esempio n. 2
0
        private void addListData(ListView listView, SmpStock stock)
        {
            ListViewItem item = new ListViewItem(stock.Code);

            item.SubItems.Add(stock.Name);
            listView.Items.Add(item);
            listView.Sort();
        }
Esempio n. 3
0
 private void StockChecked_CallBack(SmpStock stock)
 {
     if (stock != null && stock.Code.Length == STOCK_CODE_LEN)
     {
         StockChangedEventArgs args = new StockChangedEventArgs(stock);
         OnStockChecked(args);
     }
 }
Esempio n. 4
0
        public static List <CodeInfo> getStockByName(ref SmpStock stock)
        {
            List <CodeInfo> list = getStockIndexByName(stock.Name);

            if (list == null && list.Count == 0)
            {
                return(null);
            }
            return(list);
        }
        public static bool getStockByCode(ref SmpStock stock)
        {
            StockType st = getStockMarket(stock.Code);

            if (st != null)
            {
                stock.Name = st.Name;
                return(true);
            }
            return(false);
        }
Esempio n. 6
0
 private void StockList_Update(SmpStock stock)
 {
     if (lst_Stocks.Contains(stock))
     {
         int idx = lst_Stocks.IndexOf(stock);
         if (idx >= 0 && idx < lst_Stocks.Count)
         {
             lst_Stocks[idx].Checked = stock.Checked;
         }
     }
 }
Esempio n. 7
0
 public void RemoveStockData(SmpStock stock)
 {
     foreach (ListViewItem item in this.Items)
     {
         string stk_code = item.SubItems[0].Text;
         if (stk_code.Equals(stock.Code))
         {
             this.Items.Remove(item);
             break;
         }
     }
 }
Esempio n. 8
0
        void StockList_ItemChecked(object sender, ItemCheckedEventArgs e)
        {
            ListView     lw   = (ListView)sender;
            ListViewItem item = e.Item;

            string code = item.SubItems[0].Text;
            string name = item.SubItems[1].Text;

            SmpStock stock = new SmpStock(code, name);

            stock.Checked = item.Checked;
            StockChecked_CallBack(stock);
        }
Esempio n. 9
0
        private void MainDialog_Load(object sender, EventArgs e)
        {
            DialogLogin loginDlg = new DialogLogin();

            loginDlg.SettingConfigs = m_SettingConfigs;

            if (loginDlg.ShowDialog() != System.Windows.Forms.DialogResult.OK)
            {
                Environment.Exit(0);
            }
            this.Text = getCaption(loginDlg.apiSection.ApiElement.AppID);
            if (m_StockConfigs.load())
            {
                foreach (KeyValuePair <string, string> kvce in m_StockConfigs.appConfigs)
                {
                    SmpStock stock = new SmpStock(kvce.Key, kvce.Value);
                    stock.Checked = true;
                    lst_Stocks.Add(stock);
                }
            }
            if (m_NewsConfigs.load())
            {
                foreach (KeyValuePair <string, string> kvce in m_NewsConfigs.appConfigs)
                {
                    Links theNews = new Links(kvce.Key, kvce.Value);
                    lst_News.Add(theNews);
                }
            }
            m_NewsPanel = new NewsPanel(lst_News);
            TabPage_News.Controls.Add(m_NewsPanel);

            m_StockPanel.InitData(lst_Stocks);

            m_UpdateTimer.Interval = 1000;
            m_UpdateTimer.Enabled  = true;
            m_UpdateTimer.Tick    += new EventHandler(UpdateTimer_Tick_EventHandler);
            m_UpdateTimer.Start();

            m_SecondTimer.Interval = 1000;
            m_SecondTimer.Enabled  = true;
            m_SecondTimer.Tick    += new EventHandler(SecondTimer_Tick_EventHandler);
            m_SecondTimer.Start();

            CfgManager.ReadConnectionStrings();
            CfgManager.MapMachineConfiguration();
            SNTPTime.calibrationTime();

            m_HandleShowApi.BgWorkerCompleted += new EventHandler <BgWorkerEventArgs>(HandleShowApi_BgWorkerCompleted);
        }
Esempio n. 10
0
 private void StockText_TextChanged_EventHandler(object sender, EventArgs e)
 {
     if (sender is TextBox)
     {
         TextBox textBox = (TextBox)sender;
         if (textBox.SelectionStart > 0)
         {
             if (textBox.Text.IndexOf('\n') > 0)
             {
                 char[]   separator = { '\r', '\n', };
                 string[] splits    = textBox.Text.Split(separator, StringSplitOptions.RemoveEmptyEntries);
                 if (splits.Length > 0)
                 {
                     string pattern = @"[0-9]{6,6}";
                     Regex  rgx     = new Regex(pattern);
                     //if (splits[0].Length == STOCK_CODE_LEN && Int32.TryParse(splits[0], out nCode))
                     if (rgx.IsMatch(splits[0]))
                     {
                         // Find matches.
                         MatchCollection matches = rgx.Matches(splits[0]);
                         Match           match   = matches[0];
                         GroupCollection groups  = match.Groups;
                         if (groups[0].Value.Length == STOCK_CODE_LEN)
                         {
                             SmpStock stock = new SmpStock(groups[0].Value, "--");
                             StockChanged_CallBack(stock);
                             stockText.TextChanged -= new EventHandler(StockText_TextChanged_EventHandler);
                             textBox.Text           = groups[0].Value;
                             textBox.SelectAll();
                             stockText.TextChanged += new EventHandler(StockText_TextChanged_EventHandler);
                         }
                     }
                     else
                     {
                         SmpStock stock = new SmpStock("", splits[0]);
                         StockChanged_CallBack(stock);
                         stockText.TextChanged -= new EventHandler(StockText_TextChanged_EventHandler);
                         textBox.Clear();
                         stockText.TextChanged += new EventHandler(StockText_TextChanged_EventHandler);
                     }
                     //textBox.SelectionStart = textBox.Text.Length;
                 }
             }
         }
     }
 }
Esempio n. 11
0
        void ListView_ItemChecked(object sender, ItemCheckedEventArgs e)
        {
            ListView     lw   = (ListView)sender;
            ListViewItem item = e.Item;

            if (item.Checked)
            {
                this.listView1.ItemChecked -= new ItemCheckedEventHandler(ListView_ItemChecked);

                string code = item.SubItems[0].Text;
                string name = item.SubItems[1].Text;

                SmpStock stock = new SmpStock(code, name);
                stock.Checked = item.Checked;
                StockChecked_CallBack(stock);

                this.DialogResult = System.Windows.Forms.DialogResult.OK;
            }
        }
Esempio n. 12
0
 private void StockPanel_Update(SmpStock stock)
 {
     if (stock.Code.Length > 0)
     {
         if (!lst_Stocks.Contains(stock))
         {
             if (ShowAPI.getStockByCode(ref stock))
             {
                 lst_Stocks.Add(stock);
                 m_StockPanel.AddStockData(stock);
             }
         }
     }
     else if (stock.Name.Length > 0)
     {
         do
         {
             List <CodeInfo> list = ShowAPI.getStockByName(ref stock);
             if (list != null && list.Count > 0)
             {
                 DialogStockList infoDlg = new DialogStockList();
                 infoDlg.InitData(stock.Name, list);
                 infoDlg.StockChecked += new EventHandler <StockChangedEventArgs>(StockPanel_StockChanged_EventHandler);
                 infoDlg.ShowDialog();
                 infoDlg.StockChecked -= new EventHandler <StockChangedEventArgs>(StockPanel_StockChanged_EventHandler);
                 break;
             }
             else
             {
                 DialogResult box = System.Windows.Forms.MessageBox.Show("操作不存在的代码.", "错误",
                                                                         System.Windows.Forms.MessageBoxButtons.AbortRetryIgnore,
                                                                         System.Windows.Forms.MessageBoxIcon.Warning);
                 if (box == System.Windows.Forms.DialogResult.Abort ||
                     box == System.Windows.Forms.DialogResult.Ignore)
                 {
                     break;
                 }
             }
         } while (true);
     }
 }
Esempio n. 13
0
 public StockChangedEventArgs(SmpStock stock)
 {
     this.stock = stock;
 }
Esempio n. 14
0
 public void AddStockData(SmpStock stock)
 {
     addListData(stockList, stock);
 }