Beispiel #1
0
        private void closePositionToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (this.tabControl1.SelectedIndex != 1)
            {
                return;
            }

            PositionDlg dlg = new PositionDlg();

            string name = dataGridViewLongTerm.SelectedRows[0].Cells["Name"].Value.ToString();

            StockPool.TacticalTableDataTable dt = (StockPool.TacticalTableDataTable)dataGridViewTactical.DataSource;
            if (dt.Select("Name=" + name).Length != 0)
            {
                MessageBox.Show("please underweight stock in tactical pool first");
                return;
            }

            dlg.textBoxName.Text   = dataGridViewLongTerm.SelectedRows[0].Cells["Name"].Value.ToString();
            dlg.textBoxNumber.Text = dataGridViewLongTerm.SelectedRows[0].Cells["Code"].Value.ToString();
            dlg.textBoxType.Text   = "ClosePosition";
            dlg.textBoxCount.Text  = dataGridViewLongTerm.SelectedRows[0].Cells["Amount"].Value.ToString();
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                //update statistic data
                StockPool.LongTermTableDataTable longtermdt = (StockPool.LongTermTableDataTable)dataGridViewLongTerm.DataSource;
                StockPool.LongTermTableRow       row        = (StockPool.LongTermTableRow)longtermdt.Rows[dataGridViewLongTerm.SelectedRows[0].Index];
                decimal sellprice = Convert.ToDecimal(dlg.textBoxPrice.Text);
                decimal profit    = (sellprice - row.CostPrice) * row.Amount;
                m_statData.LongTermProfit        += profit;
                m_statData.LongTermLeftCash      += sellprice * row.Amount;
                m_statData.LongTermAvailableCash += sellprice * row.Amount + row.AvailableCash;
                //insertDealRecord
                DealRecordData data = new DealRecordData();
                data.Name   = dlg.textBoxName.Text;
                data.Type   = dlg.textBoxType.Text;
                data.Price  = dlg.textBoxPrice.Text;
                data.Count  = dlg.textBoxCount.Text;
                data.Pool   = "LongTermPool";
                data.Profit = profit.ToString();
                InsertDealRecord(data);
                //delete longterm record
                DeleteFromStockPool(dataGridViewLongTerm, dataGridViewLongTerm.SelectedRows[0].Index);
            }
        }
Beispiel #2
0
        private void InsertLongTermPool(PositionDlg dlg)
        {
            StockPool.LongTermTableDataTable dt = (StockPool.LongTermTableDataTable)dataGridViewLongTerm.DataSource;

            StockPool.LongTermTableRow row = dt.NewLongTermTableRow();
            row.Name      = dlg.textBoxName.Text;
            row.Code      = dlg.textBoxNumber.Text;
            row.CostPrice = Convert.ToDecimal(dlg.textBoxPrice.Text);
            row.Amount    = Convert.ToUInt32(dlg.textBoxCount.Text);
            row.ClassType = dlg.comboBoxClassType.SelectedText;
            if (dlg.comboBoxClassType.SelectedText == "High potential")
            {
                row.AvailableCash = row.CostPrice * row.Amount / 2; //for high potential stock, long term position is 50%
            }
            else
            {
                row.AvailableCash = row.CostPrice * row.Amount / 3; //for blue chip stock, long term position is 60%
            }
            dt.Rows.Add(row);
        }
Beispiel #3
0
        private void closePositionToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (this.tabControl1.SelectedIndex != 1)
                return;

            PositionDlg dlg = new PositionDlg();

            string name = dataGridViewLongTerm.SelectedRows[0].Cells["Name"].Value.ToString();
            StockPool.TacticalTableDataTable dt = (StockPool.TacticalTableDataTable)dataGridViewTactical.DataSource;
            if (dt.Select("Name=" + name).Length != 0)
            {
                MessageBox.Show("please underweight stock in tactical pool first");
                return;
            }           

            dlg.textBoxName.Text = dataGridViewLongTerm.SelectedRows[0].Cells["Name"].Value.ToString();
            dlg.textBoxNumber.Text = dataGridViewLongTerm.SelectedRows[0].Cells["Code"].Value.ToString();
            dlg.textBoxType.Text = "ClosePosition";
            dlg.textBoxCount.Text = dataGridViewLongTerm.SelectedRows[0].Cells["Amount"].Value.ToString();
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                //update statistic data
                StockPool.LongTermTableDataTable longtermdt = (StockPool.LongTermTableDataTable)dataGridViewLongTerm.DataSource;
                StockPool.LongTermTableRow row = (StockPool.LongTermTableRow)longtermdt.Rows[dataGridViewLongTerm.SelectedRows[0].Index];
                decimal sellprice = Convert.ToDecimal(dlg.textBoxPrice.Text);
                decimal profit = (sellprice - row.CostPrice) * row.Amount;
                m_statData.LongTermProfit += profit;
                m_statData.LongTermLeftCash += sellprice * row.Amount;
                m_statData.LongTermAvailableCash += sellprice * row.Amount + row.AvailableCash;
                //insertDealRecord
                DealRecordData data = new DealRecordData();
                data.Name = dlg.textBoxName.Text;
                data.Type = dlg.textBoxType.Text;
                data.Price = dlg.textBoxPrice.Text;
                data.Count = dlg.textBoxCount.Text;
                data.Pool = "LongTermPool";
                data.Profit = profit.ToString() ;
                InsertDealRecord(data);
                //delete longterm record
                DeleteFromStockPool(dataGridViewLongTerm, dataGridViewLongTerm.SelectedRows[0].Index);
            }
            
        }
Beispiel #4
0
        //For ObservedPool and LongTerm pool
        private void openPosittionToolStripMenuItem_Click(object sender, EventArgs e)
        {
            PositionDlg dlg = new PositionDlg();

            switch (this.tabControl1.SelectedIndex)
            {
                case 0:
                    {
                        if (dataGridViewObserved.SelectedRows.Count != 1)
                            return;

                        dlg.textBoxName.Text = dataGridViewObserved.SelectedRows[0].Cells["Name"].Value.ToString();
                        dlg.textBoxNumber.Text = dataGridViewObserved.SelectedRows[0].Cells["Code"].Value.ToString();
                        dlg.textBoxType.Text = "OpenPosition";
                        if (dlg.ShowDialog() == DialogResult.OK)
                        {
                            InsertLongTermPool(dlg);
                            //InsertTacticalPool(dlg);
                            DealRecordData data = new DealRecordData();
                            data.Name = dlg.textBoxName.Text;
                            data.Type = dlg.textBoxType.Text;
                            data.Price = dlg.textBoxPrice.Text;
                            data.Count = dlg.textBoxCount.Text;
                            data.Pool = "LongTermPool";
                            data.Profit = dlg.sellprofit.ToString();
                            InsertDealRecord(data);
                            DeleteFromStockPool(dataGridViewObserved, dataGridViewObserved.SelectedRows[0].Index);
                            //update statistic data
                            decimal price = Convert.ToDecimal(dlg.textBoxPrice.Text);
                            uint count = Convert.ToUInt32(dlg.textBoxCount.Text);
                            if (dlg.comboBoxClassType.SelectedText == "High potential")
                                m_statData.LongTermAvailableCash -= price*count*2;
                            else
                                m_statData.LongTermAvailableCash -= price*count*5/3;
                            m_statData.LongTermLeftCash -= price * count;
                        }
                    }
                    break;
                case 1:
                    {
                        if (dataGridViewObserved.SelectedRows.Count != 0)
                            return;
                       
                        dlg.textBoxType.Text = "OpenPosition";
                        if (dlg.ShowDialog() == DialogResult.OK)
                        {
                            InsertLongTermPool(dlg);
                            //InsertTacticalPool(dlg);
                            DealRecordData data = new DealRecordData();
                            data.Name = dlg.textBoxName.Text;
                            data.Type = dlg.textBoxType.Text;
                            data.Price = dlg.textBoxPrice.Text;
                            data.Count = dlg.textBoxCount.Text;
                            data.Pool = "LongTermPool";
                            data.Profit = dlg.sellprofit.ToString();
                            InsertDealRecord(data);
                            
                            //update statistic data
                            decimal price = Convert.ToDecimal(dlg.textBoxPrice.Text);
                            uint count = Convert.ToUInt32(dlg.textBoxCount.Text);
                            if (dlg.comboBoxClassType.SelectedText == "High potential")
                                m_statData.LongTermAvailableCash -= price * count * 2;
                            else
                                m_statData.LongTermAvailableCash -= price * count * 5 / 3;
                            m_statData.LongTermLeftCash -= price * count;
                        }
                    }
                    break;
                default:
                    return;
            }
        }
Beispiel #5
0
 private void InsertLongTermPool(PositionDlg dlg)
 {
     StockPool.LongTermTableDataTable dt = (StockPool.LongTermTableDataTable)dataGridViewLongTerm.DataSource;
     
     StockPool.LongTermTableRow row = dt.NewLongTermTableRow();
     row.Name = dlg.textBoxName.Text;
     row.Code = dlg.textBoxNumber.Text;
     row.CostPrice = Convert.ToDecimal(dlg.textBoxPrice.Text);
     row.Amount = Convert.ToUInt32(dlg.textBoxCount.Text);
     row.ClassType = dlg.comboBoxClassType.SelectedText;
     if (dlg.comboBoxClassType.SelectedText == "High potential")
         row.AvailableCash = row.CostPrice * row.Amount / 2; //for high potential stock, long term position is 50%
     else
         row.AvailableCash = row.CostPrice * row.Amount / 3; //for blue chip stock, long term position is 60%
    
     dt.Rows.Add(row);
 }
Beispiel #6
0
        //For ObservedPool and LongTerm pool
        private void openPosittionToolStripMenuItem_Click(object sender, EventArgs e)
        {
            PositionDlg dlg = new PositionDlg();

            switch (this.tabControl1.SelectedIndex)
            {
            case 0:
            {
                if (dataGridViewObserved.SelectedRows.Count != 1)
                {
                    return;
                }

                dlg.textBoxName.Text   = dataGridViewObserved.SelectedRows[0].Cells["Name"].Value.ToString();
                dlg.textBoxNumber.Text = dataGridViewObserved.SelectedRows[0].Cells["Code"].Value.ToString();
                dlg.textBoxType.Text   = "OpenPosition";
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    InsertLongTermPool(dlg);
                    //InsertTacticalPool(dlg);
                    DealRecordData data = new DealRecordData();
                    data.Name   = dlg.textBoxName.Text;
                    data.Type   = dlg.textBoxType.Text;
                    data.Price  = dlg.textBoxPrice.Text;
                    data.Count  = dlg.textBoxCount.Text;
                    data.Pool   = "LongTermPool";
                    data.Profit = dlg.sellprofit.ToString();
                    InsertDealRecord(data);
                    DeleteFromStockPool(dataGridViewObserved, dataGridViewObserved.SelectedRows[0].Index);
                    //update statistic data
                    decimal price = Convert.ToDecimal(dlg.textBoxPrice.Text);
                    uint    count = Convert.ToUInt32(dlg.textBoxCount.Text);
                    if (dlg.comboBoxClassType.SelectedText == "High potential")
                    {
                        m_statData.LongTermAvailableCash -= price * count * 2;
                    }
                    else
                    {
                        m_statData.LongTermAvailableCash -= price * count * 5 / 3;
                    }
                    m_statData.LongTermLeftCash -= price * count;
                }
            }
            break;

            case 1:
            {
                if (dataGridViewObserved.SelectedRows.Count != 0)
                {
                    return;
                }

                dlg.textBoxType.Text = "OpenPosition";
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    InsertLongTermPool(dlg);
                    //InsertTacticalPool(dlg);
                    DealRecordData data = new DealRecordData();
                    data.Name   = dlg.textBoxName.Text;
                    data.Type   = dlg.textBoxType.Text;
                    data.Price  = dlg.textBoxPrice.Text;
                    data.Count  = dlg.textBoxCount.Text;
                    data.Pool   = "LongTermPool";
                    data.Profit = dlg.sellprofit.ToString();
                    InsertDealRecord(data);

                    //update statistic data
                    decimal price = Convert.ToDecimal(dlg.textBoxPrice.Text);
                    uint    count = Convert.ToUInt32(dlg.textBoxCount.Text);
                    if (dlg.comboBoxClassType.SelectedText == "High potential")
                    {
                        m_statData.LongTermAvailableCash -= price * count * 2;
                    }
                    else
                    {
                        m_statData.LongTermAvailableCash -= price * count * 5 / 3;
                    }
                    m_statData.LongTermLeftCash -= price * count;
                }
            }
            break;

            default:
                return;
            }
        }