Example #1
0
        private void reLoad()
        {
            panel1.Dock    = DockStyle.Fill;
            panel1.Anchor  = AnchorStyles.Left;
            panel2.Dock    = DockStyle.Fill;
            panel2.Anchor  = AnchorStyles.Left;
            panel1.Visible = true;
            panel2.Visible = true;
            panel1.Show();
            panel2.Hide();
            TopPerformers.DataSource = db.getTopPerformers();
            DataTable dt10      = new DataTable();
            DataTable curstocks = new DataTable();

            curstocks.Columns.Add("Stock_Name");
            curstocks.Columns.Add("stock_quantity");
            dt10 = db.select_allstockhistory(account_id);
            foreach (DataRow dr in dt10.Rows)
            {
                if (dr["sh_type"].ToString() == "BUY")
                {
                    bool found = false;

                    foreach (DataRow dr2 in curstocks.Rows)
                    {
                        if (dr2[0].ToString() == dr["s_name"].ToString())
                        {
                            dr2["stock_quantity"] = decimal.Parse(dr2["stock_quantity"].ToString()) + decimal.Parse(dr["quantity"].ToString());

                            found = true;
                            break;
                        }
                        dr2.AcceptChanges();
                    }
                    if (!found)
                    {
                        curstocks.Rows.Add(dr["s_name"], dr["quantity"]);
                    }
                }
                if (dr["sh_type"].ToString() == "SELL")
                {
                    foreach (DataRow dr2 in curstocks.Rows)
                    {
                        if (dr2[0].ToString() == dr["s_name"].ToString())
                        {
                            dr2["stock_quantity"] = (decimal.Parse(dr2["stock_quantity"].ToString()) - decimal.Parse(dr["quantity"].ToString()));


                            break;
                        }
                        dr2.AcceptChanges();
                    }
                }
            }
            stocksview.DataSource       = curstocks;
            cdview.DataSource           = db.select_allcd(account_id);
            bondsview.DataSource        = db.select_allbonds(account_id);
            Cashview.DataSource         = db.select_allcash(account_id);
            currentcdview.DataSource    = db.select_allcd(account_id);
            currentbondview.DataSource  = db.select_allbonds(account_id);
            stockhistoryview.DataSource = db.select_allstockhistory(account_id);
            historybondsview.DataSource = db.select_allbondshistory(account_id);
            historyCDview.DataSource    = db.select_allcdhistory(account_id);
            cash.Text     = db.select_cash(account_id);
            netvalue.Text = db.getnetvalue(account_id);
            DataTable dt4 = new DataTable();

            dt4             = db.select_user(user_id);
            usernametb.Text = dt4.Rows[0][0].ToString();
            passwordtb.Text = dt4.Rows[0][1].ToString();
            phonetb.Text    = dt4.Rows[0][2].ToString();
            emailtb.Text    = dt4.Rows[0][3].ToString();
            lnametb.Text    = dt4.Rows[0][4].ToString();
            fnametb.Text    = dt4.Rows[0][5].ToString();
        }