Ejemplo n.º 1
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;
 }
Ejemplo n.º 2
0
 public DealInfo(string code, Int16 amount, double cost, double tax, DateTime date)
 {
     this._stock  = new SmpStock(code, "");
     this._amount = amount;
     this._cost   = cost;
     this._date   = date;
     this._tax    = tax;
     this._halt   = false;
     this._price  = 0;
 }
Ejemplo n.º 3
0
 public static bool getStockByCode(ref SmpStock stock)
 {
     StockType st = getStockIndexByCode(stock.Code);
     if (st != null)
     {
         stock.Name = st.Name;
         return true;
     }
     return false;
 }
Ejemplo n.º 4
0
 public DealInfo(string code, Int16 amount, double cost, double tax, DateTime date)
 {
     this._stock = new SmpStock(code, "");
     this._amount = amount;
     this._cost = cost;
     this._date = date;
     this._tax = tax;
     this._halt = false;
     this._price = 0;
 }
Ejemplo n.º 5
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;
         }
     }
 }
Ejemplo n.º 6
0
 public override bool Equals(Object obj)
 {
     if (obj != null && obj is SmpStock)
     {
         SmpStock sstk = (SmpStock)obj;
         if (sstk.Code.Equals(this.Code))
         {
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 7
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);
        }
Ejemplo n.º 8
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();
 }
Ejemplo n.º 9
0
 private void StockChecked_CallBack(SmpStock stock)
 {
     if (stock != null)
     {
         StockChangedEventArgs args = new StockChangedEventArgs(stock);
         OnStockChecked(args);
     }
 }
Ejemplo 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;
                 }
             }
         }
     }
 }
Ejemplo n.º 11
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);
     }
 }
Ejemplo n.º 12
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;
            }
        }
Ejemplo n.º 13
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;
         }
     }
 }
Ejemplo n.º 14
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);
        }
Ejemplo n.º 15
0
 private void StockChecked_CallBack(SmpStock stock)
 {
     if (stock != null && stock.Code.Length == STOCK_CODE_LEN)
     {
         StockChangedEventArgs args = new StockChangedEventArgs(stock);
         OnStockChecked(args);
     }
 }
Ejemplo n.º 16
0
 public StockChangedEventArgs(SmpStock stock)
 {
     this.stock = stock;
 }
Ejemplo n.º 17
0
 public void AddStockData(SmpStock stock)
 {
     addListData(stockList, stock);
 }