Exemplo n.º 1
0
        private void InsertShortTermPool(DealDlg dlg, DataGridView gridview)
        {
            StockPool.ShortTermTableDataTable dt = (StockPool.ShortTermTableDataTable)gridview.DataSource;

            StockPool.ShortTermTableRow row = dt.NewShortTermTableRow();
            row.Name      = dlg.textBoxName.Text;
            row.Code      = dlg.textBoxNumber.Text;
            row.CostPrice = Convert.ToDecimal(dlg.textBoxPrice.Text);
            row.Amount    = Convert.ToUInt32(dlg.textBoxCount.Text);

            dt.Rows.Add(row);
        }
Exemplo n.º 2
0
        private void InsertTacticalPool(DealDlg dlg, int index)
        {
            StockPool.TacticalTableDataTable dt = (StockPool.TacticalTableDataTable)dataGridViewTactical.DataSource;

            StockPool.TacticalTableRow row = dt.NewTacticalTableRow();
            row.Name      = dlg.textBoxName.Text;
            row.Code      = dlg.textBoxNumber.Text;
            row.CostPrice = Convert.ToDecimal(dlg.textBoxPrice.Text);
            row.DealCount = Convert.ToUInt32(dlg.textBoxCount.Text);

            if (index != -1)
            {
                dt.Rows.InsertAt(row, index);
            }
            else
            {
                dt.Rows.Add(row);
            }
        }
Exemplo n.º 3
0
        private void underwweightToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (this.tabControl1.SelectedIndex != 2)
            {
                return;
            }

            DealDlg dlg = new DealDlg();

            dlg.textBoxName.Text   = dataGridViewTactical.SelectedRows[0].Cells["Name"].Value.ToString();
            dlg.textBoxNumber.Text = dataGridViewTactical.SelectedRows[0].Cells["Code"].Value.ToString();
            dlg.textBoxCount.Text  = dataGridViewTactical.SelectedRows[0].Cells["DealCount"].Value.ToString();
            dlg.textBoxType.Text   = "UnderWeight";
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                decimal price = Convert.ToDecimal(dlg.textBoxPrice.Text);
                uint    count = Convert.ToUInt16(dlg.textBoxCount.Text);
                StockPool.LongTermTableDataTable dt  = (StockPool.LongTermTableDataTable)dataGridViewLongTerm.DataSource;
                StockPool.LongTermTableRow       row = (StockPool.LongTermTableRow)dt.Select("Name=" + dlg.textBoxName.Text)[0];
                decimal profit = (price - row.CostPrice) * count;
                row.AvailableCash           += price * count;
                m_statData.TacticalProfit   += profit;
                m_statData.LongTermLeftCash += price * count; //real left cash

                //delete tactical record
                DeleteFromStockPool(dataGridViewTactical, dataGridViewTactical.SelectedRows[0].Index);

                //insert deal record
                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   = "TacticalPool";
                data.Profit = dlg.sellprofit.ToString();
                InsertDealRecord(data);
            }
        }
Exemplo n.º 4
0
        private void BuyToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DealDlg dlg = new DealDlg();

            if (this.tabControl1.SelectedIndex == 3)
            {//ShortTermPool
                if (dataGridViewShortTerm.SelectedRows.Count == 1)
                {
                    dlg.textBoxName.Text   = dataGridViewShortTerm.SelectedRows[0].Cells["Name"].Value.ToString();
                    dlg.textBoxNumber.Text = dataGridViewShortTerm.SelectedRows[0].Cells["Code"].Value.ToString();
                }
                dlg.textBoxType.Text = "Buy";

                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    InsertShortTermPool(dlg, dataGridViewShortTerm);
                    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   = "ShortTermPool";
                    data.Profit = dlg.sellprofit.ToString();
                    InsertDealRecord(data);

                    //update Stastistic data
                    decimal price = Convert.ToDecimal(dlg.textBoxPrice.Text);
                    int     count = Convert.ToInt32(dlg.textBoxCount.Text);
                    decimal cash  = price * count;
                    m_statData.ShortTermLeftCash -= cash;
                }
            }
            else
            {
                return;
            }
        }
Exemplo n.º 5
0
        private void overweightToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            if (this.tabControl1.SelectedIndex != 1)
            {
                return;
            }

            DealDlg dlg = new DealDlg();

            dlg.textBoxName.Text   = dataGridViewLongTerm.SelectedRows[0].Cells["Name"].Value.ToString();
            dlg.textBoxNumber.Text = dataGridViewLongTerm.SelectedRows[0].Cells["Code"].Value.ToString();
            dlg.textBoxType.Text   = "OverWeight";
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                //update stock available cash in long term pool
                decimal price = Convert.ToDecimal(dlg.textBoxPrice.Text);
                uint    count = Convert.ToUInt16(dlg.textBoxCount.Text);
                StockPool.LongTermTableDataTable dt  = (StockPool.LongTermTableDataTable)dataGridViewLongTerm.DataSource;
                StockPool.LongTermTableRow       row = (StockPool.LongTermTableRow)dt.Rows[dataGridViewLongTerm.SelectedRows[0].Index];
                row.AvailableCash           -= price * count;
                m_statData.LongTermLeftCash -= price * count;

                //insert tactical record
                InsertTacticalPool(dlg, -1);

                //insert deal record
                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   = "TacticalPool";
                data.Profit = dlg.sellprofit.ToString();
                InsertDealRecord(data);
            }
        }
Exemplo n.º 6
0
        private void overweightToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            if (this.tabControl1.SelectedIndex != 1)
                return;

            DealDlg dlg = new DealDlg();
            dlg.textBoxName.Text = dataGridViewLongTerm.SelectedRows[0].Cells["Name"].Value.ToString();
            dlg.textBoxNumber.Text = dataGridViewLongTerm.SelectedRows[0].Cells["Code"].Value.ToString();
            dlg.textBoxType.Text = "OverWeight";
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                //update stock available cash in long term pool
                decimal price = Convert.ToDecimal(dlg.textBoxPrice.Text);
                uint count = Convert.ToUInt16(dlg.textBoxCount.Text);
                StockPool.LongTermTableDataTable dt = (StockPool.LongTermTableDataTable)dataGridViewLongTerm.DataSource;
                StockPool.LongTermTableRow row = (StockPool.LongTermTableRow)dt.Rows[dataGridViewLongTerm.SelectedRows[0].Index];
                row.AvailableCash -= price * count;
                m_statData.LongTermLeftCash -= price * count;

                //insert tactical record
                InsertTacticalPool(dlg,-1);

                //insert deal record
                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 = "TacticalPool";
                data.Profit = dlg.sellprofit.ToString();
                InsertDealRecord(data);
            }
        }
Exemplo n.º 7
0
        private void underwweightToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (this.tabControl1.SelectedIndex != 2)
                return;

            DealDlg dlg = new DealDlg();
            dlg.textBoxName.Text = dataGridViewTactical.SelectedRows[0].Cells["Name"].Value.ToString();
            dlg.textBoxNumber.Text = dataGridViewTactical.SelectedRows[0].Cells["Code"].Value.ToString();
            dlg.textBoxCount.Text = dataGridViewTactical.SelectedRows[0].Cells["DealCount"].Value.ToString();
            dlg.textBoxType.Text = "UnderWeight";
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                decimal price = Convert.ToDecimal(dlg.textBoxPrice.Text);
                uint count = Convert.ToUInt16(dlg.textBoxCount.Text);
                StockPool.LongTermTableDataTable dt = (StockPool.LongTermTableDataTable)dataGridViewLongTerm.DataSource;
                StockPool.LongTermTableRow row = (StockPool.LongTermTableRow)dt.Select("Name=" + dlg.textBoxName.Text)[0];
                decimal profit = (price - row.CostPrice) * count;
                row.AvailableCash += price * count;
                m_statData.TacticalProfit += profit;                
                m_statData.LongTermLeftCash += price * count; //real left cash

                //delete tactical record
                DeleteFromStockPool(dataGridViewTactical, dataGridViewTactical.SelectedRows[0].Index);

                //insert deal record
                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 = "TacticalPool";
                data.Profit = dlg.sellprofit.ToString();
                InsertDealRecord(data);
            }
        }
Exemplo n.º 8
0
        private void sellToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DealDlg dlg = new DealDlg();

            if (this.tabControl1.SelectedIndex == 3)
            {//ShortTermPool
                if (dataGridViewShortTerm.SelectedRows.Count != 1)
                    return;

                dlg.textBoxName.Text = dataGridViewShortTerm.SelectedRows[0].Cells["Name"].Value.ToString();
                dlg.textBoxNumber.Text = dataGridViewShortTerm.SelectedRows[0].Cells["Code"].Value.ToString();
                dlg.textBoxType.Text = "Sell";

                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    //decrese count from specific stockpool, if left count is 0, then delete item
                    decimal oriPrice = Convert.ToDecimal(dataGridViewShortTerm.SelectedRows[0].Cells["CostPrice"].Value.ToString());
                    decimal sellPrice = Convert.ToDecimal(dlg.textBoxPrice.Text);
                    dlg.sellprofit = (sellPrice - oriPrice) / oriPrice;
                    int count = Convert.ToInt32(dlg.textBoxCount.Text);
                    int current = Convert.ToInt32(dataGridViewShortTerm.SelectedRows[0].Cells["Amount"].Value.ToString());
                    int left = current - count;
                    if (left < 0)
                    {
                        MessageBox.Show("Count is more than the holding number.");
                        return;
                    }
                    else if (left == 0)
                    {
                        //delete item from gridview
                        //DataRowView view = gridview.SelectedRows[0].DataBoundItem as DataRowView;
                        //int index = view.Row.
                        DeleteFromStockPool(dataGridViewShortTerm, dataGridViewShortTerm.SelectedRows[0].Index);
                    }
                    else
                    {
                        dataGridViewShortTerm.SelectedRows[0].Cells["Amount"].Value = left;
                    }

                    //insert DealRecord
                    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 = "ShortTermPool";
                    data.Profit = dlg.sellprofit.ToString();
                    InsertDealRecord(data);

                    //update Stastistic data      
                    m_statData.ShortTermProfit += dlg.sellprofit;
                    decimal cash = sellPrice * count;
                    m_statData.ShortTermLeftCash += cash;
                }                   
            }           
            else
                return;
        }       
Exemplo n.º 9
0
        private void InsertTacticalPool(DealDlg dlg, int index)
        {
            StockPool.TacticalTableDataTable dt = (StockPool.TacticalTableDataTable)dataGridViewTactical.DataSource;

            StockPool.TacticalTableRow row = dt.NewTacticalTableRow();
            row.Name = dlg.textBoxName.Text;
            row.Code = dlg.textBoxNumber.Text;
            row.CostPrice = Convert.ToDecimal(dlg.textBoxPrice.Text);
            row.DealCount = Convert.ToUInt32(dlg.textBoxCount.Text);

            if (index != -1)
                dt.Rows.InsertAt(row, index);
            else
                dt.Rows.Add(row);            
        }
Exemplo n.º 10
0
        private void InsertShortTermPool(DealDlg dlg, DataGridView gridview)
        {
            StockPool.ShortTermTableDataTable dt = (StockPool.ShortTermTableDataTable)gridview.DataSource;

            StockPool.ShortTermTableRow row = dt.NewShortTermTableRow();           
            row.Name = dlg.textBoxName.Text;
            row.Code = dlg.textBoxNumber.Text;
            row.CostPrice = Convert.ToDecimal(dlg.textBoxPrice.Text);
            row.Amount = Convert.ToUInt32(dlg.textBoxCount.Text);            

            dt.Rows.Add(row);
        }
Exemplo n.º 11
0
        private void BuyToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DealDlg dlg = new DealDlg();

            if (this.tabControl1.SelectedIndex == 3)
            {//ShortTermPool
                if (dataGridViewShortTerm.SelectedRows.Count == 1)
                {
                    dlg.textBoxName.Text = dataGridViewShortTerm.SelectedRows[0].Cells["Name"].Value.ToString();
                    dlg.textBoxNumber.Text = dataGridViewShortTerm.SelectedRows[0].Cells["Code"].Value.ToString();
                }
                dlg.textBoxType.Text = "Buy";                   
                        
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    InsertShortTermPool(dlg, dataGridViewShortTerm);
                    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 = "ShortTermPool";
                    data.Profit = dlg.sellprofit.ToString();
                    InsertDealRecord(data);

                    //update Stastistic data
                    decimal price = Convert.ToDecimal(dlg.textBoxPrice.Text);
                    int count = Convert.ToInt32(dlg.textBoxCount.Text);
                    decimal cash = price * count;
                    m_statData.ShortTermLeftCash -= cash; 
                }                   
            }           
            else
                return;
        } 
Exemplo n.º 12
0
        private void sellToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DealDlg dlg = new DealDlg();

            if (this.tabControl1.SelectedIndex == 3)
            {//ShortTermPool
                if (dataGridViewShortTerm.SelectedRows.Count != 1)
                {
                    return;
                }

                dlg.textBoxName.Text   = dataGridViewShortTerm.SelectedRows[0].Cells["Name"].Value.ToString();
                dlg.textBoxNumber.Text = dataGridViewShortTerm.SelectedRows[0].Cells["Code"].Value.ToString();
                dlg.textBoxType.Text   = "Sell";

                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    //decrese count from specific stockpool, if left count is 0, then delete item
                    decimal oriPrice  = Convert.ToDecimal(dataGridViewShortTerm.SelectedRows[0].Cells["CostPrice"].Value.ToString());
                    decimal sellPrice = Convert.ToDecimal(dlg.textBoxPrice.Text);
                    dlg.sellprofit = (sellPrice - oriPrice) / oriPrice;
                    int count   = Convert.ToInt32(dlg.textBoxCount.Text);
                    int current = Convert.ToInt32(dataGridViewShortTerm.SelectedRows[0].Cells["Amount"].Value.ToString());
                    int left    = current - count;
                    if (left < 0)
                    {
                        MessageBox.Show("Count is more than the holding number.");
                        return;
                    }
                    else if (left == 0)
                    {
                        //delete item from gridview
                        //DataRowView view = gridview.SelectedRows[0].DataBoundItem as DataRowView;
                        //int index = view.Row.
                        DeleteFromStockPool(dataGridViewShortTerm, dataGridViewShortTerm.SelectedRows[0].Index);
                    }
                    else
                    {
                        dataGridViewShortTerm.SelectedRows[0].Cells["Amount"].Value = left;
                    }

                    //insert DealRecord
                    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   = "ShortTermPool";
                    data.Profit = dlg.sellprofit.ToString();
                    InsertDealRecord(data);

                    //update Stastistic data
                    m_statData.ShortTermProfit += dlg.sellprofit;
                    decimal cash = sellPrice * count;
                    m_statData.ShortTermLeftCash += cash;
                }
            }
            else
            {
                return;
            }
        }