示例#1
0
        private void frmMngStocks_Load(object sender, EventArgs e)
        {
            this.WindowState = FormWindowState.Maximized;
            _theParent       = (frmMain)this.ParentForm;

            dgvLayout();
            databindingFormControls();

            //programmatically click Active stocks button
            tsbtnActiveScript.PerformClick();
            clearInputs();
            DataGridViewColumnSelector cs = new DataGridViewColumnSelector(dgvScripts);

            cs.MaxHeight = 1000;
            cs.Width     = 130;
        }
示例#2
0
        private void frmReadBSE_Load(object sender, EventArgs e)
        {
            _theParent = (frmMain)this.ParentForm; //To access MDI parent control

            WatchList_Design();
            _theParent.lblDMMsg.Text  = "Script loading..";
            tsbtnActiveScript.Checked = true;

            DataGridViewColumnSelector cs = new DataGridViewColumnSelector(dgViewQ);

            cs.MaxHeight = 1000;
            cs.Width     = 130;

            //Automatic push for loading from BSE
            //toolStripButton_UpdateAllfromBSE.PerformClick();
        }
示例#3
0
文件: frmAc.cs 项目: DeepakkSHAW/.NET
        internal void FillAc(DataTable dt)
        {
            dgvAc.DataSource = null;
            /*Set PK for seaching before data flushing into datagridview*/
            DataColumn[] dcPk = new DataColumn[1];

            // Set Primary Key
            dcPk[0]       = dt.Columns["ACID"];
            dt.PrimaryKey = dcPk;

            dgvAc.DataSource = dt;

            if (dt != null)
            {
                dgvAc.Columns[0].Visible                 = false;
                dgvAc.Columns[1].Visible                 = false;
                dgvAc.Columns[2].Visible                 = false;
                dgvAc.Columns[3].AutoSizeMode            = DataGridViewAutoSizeColumnMode.AllCells;
                dgvAc.Columns[3].DefaultCellStyle.Format = "ddd, dd-MMM-yyyy hh:mm";
                dgvAc.Columns[4].AutoSizeMode            = DataGridViewAutoSizeColumnMode.AllCells;
                dgvAc.Columns[4].Frozen                   = true;
                dgvAc.Columns[5].Width                    = 40;
                dgvAc.Columns[6].AutoSizeMode             = DataGridViewAutoSizeColumnMode.AllCells;
                dgvAc.Columns[7].AutoSizeMode             = DataGridViewAutoSizeColumnMode.AllCells;
                dgvAc.Columns[8].AutoSizeMode             = DataGridViewAutoSizeColumnMode.AllCells;
                dgvAc.Columns[9].AutoSizeMode             = DataGridViewAutoSizeColumnMode.AllCells;
                dgvAc.Columns[10].AutoSizeMode            = DataGridViewAutoSizeColumnMode.AllCells;
                dgvAc.Columns[11].AutoSizeMode            = DataGridViewAutoSizeColumnMode.AllCells;
                dgvAc.Columns[12].AutoSizeMode            = DataGridViewAutoSizeColumnMode.AllCells;
                dgvAc.Columns[13].AutoSizeMode            = DataGridViewAutoSizeColumnMode.AllCells;
                dgvAc.Columns[13].DefaultCellStyle.Format = "0.00";
                //Column selector
                DataGridViewColumnSelector cs = new DataGridViewColumnSelector(dgvAc);
                cs.MaxHeight = 1000;
                cs.Width     = 130;
            }
        }
示例#4
0
        private void frmCumulAvg_Load(object sender, EventArgs e)
        {
            frmMain theParent = (frmMain)this.ParentForm; //To access MDI parent control

            theParent.lblDMMsg.Text = "Please wait data loading..";

            try
            {
                dblTotal = 0;
                dblGain  = 0;
                dblValue = 0;
                decimal dicAvgPrice = 0, dicPerct = 0;

                DataTable dtQuickView = new DataTable();
                theParent.pBarDM.Visible = true;
                Application.DoEvents();

                if (_Caller == 1) //Avg
                {
                    dtQuickView = _pdalStock_CA.StockAvgAfterSale();

                    /*Adding Columns Header to Datagrid*/

                    /*foreach (DataColumn dtcol in dtQuickView.Columns)
                     *  dgViewQ.Columns.Add(dtcol.ColumnName, dtcol.ColumnName);*/

                    dgViewQ.Columns.Add("Stock Name", "Stock Name");
                    dgViewQ.Columns.Add("Shrs", "Shrs");
                    dgViewQ.Columns.Add("Current", "Current");
                    dgViewQ.Columns.Add("SID", "SID");
                    dgViewQ.Columns.Add("AvgPrice", "Avg");
                    dgViewQ.Columns.Add("Percentage", "%");
                    dgViewQ.Columns.Add("Gain", "T Gain");
                    dgViewQ.Columns.Add("PricePaid", "Paid");
                }

                else
                {
                    dtQuickView = _pdalStock_CA.LatestValue();
                    /*Adding Columns Header to Datagrid*/
                    foreach (DataColumn dtcol in dtQuickView.Columns)
                    {
                        dgViewQ.Columns.Add(dtcol.ColumnName, dtcol.ColumnName);
                    }

                    dgViewQ.Columns.Add("AvgPrice", "Avg");
                    dgViewQ.Columns.Add("Percentage", "%");
                    dgViewQ.Columns.Add("Gain", "T Gain");
                    dgViewQ.Columns.Add("PricePaid", "Paid");
                }

                /* Data grid format display*/

                dgViewQ.Columns[0].Width   = 180;   //Name
                dgViewQ.Columns[1].Width   = 40;    //Total Stock
                dgViewQ.Columns[2].Width   = 60;    //Current Price
                dgViewQ.Columns[3].Visible = false; // StockID

                dgViewQ.Columns[4].Width = 60;      //Avg. Price
                dgViewQ.Columns[5].Width = 45;      //%
                dgViewQ.Columns[6].Width = 50;      //Gain
                dgViewQ.Columns[7].Width = 60;      // TCost
                //dgViewQ.Columns[7].Visible = false; //%
                dgViewQ.RowHeadersWidth = 60;
                int iCount = 0;

                theParent.pBarDM.Maximum = dtQuickView.Rows.Count;

                foreach (DataRow dtrow in dtQuickView.Rows)
                {
                    dgViewQ.Rows.Add();

                    //Noticed No Effect, Hance Commented

                    /*dgViewQ.Columns[1].InheritedStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
                     * dgViewQ.Columns[2].InheritedStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
                     * dgViewQ.Columns[3].InheritedStyle.Alignment = DataGridViewContentAlignment.MiddleRight;*/
                    if (_Caller == 2)
                    {
                        dgViewQ[0, iCount].Value = dtrow[0];
                        dgViewQ[1, iCount].Value = dtrow[1];
                        dgViewQ[2, iCount].Value = dtrow[2];

                        dicAvgPrice = _pdalStock_CA.StockAvg((int)dtrow[3]);
                        dgViewQ[4, iCount].Value = dicAvgPrice;

                        dgViewQ[6, iCount].Value = ((decimal)(dgViewQ[2, iCount].Value) - dicAvgPrice) * (decimal)(double)(dgViewQ[1, iCount].Value);
                        dgViewQ[7, iCount].Value = dicAvgPrice * (decimal)(double)dgViewQ[1, iCount].Value;

                        //dgViewQ[0, 0].Style.BackColor = Color.RoyalBlue;
                    }
                    else if (_Caller == 1)
                    {
                        dgViewQ[0, iCount].Value = dtrow[1];
                        dgViewQ[1, iCount].Value = dtrow[2];
                        dgViewQ[2, iCount].Value = dtrow[4];
                        dgViewQ[3, iCount].Value = dtrow[0];
                        dgViewQ[4, iCount].Value = dtrow[3];
                        dgViewQ[5, iCount].Value = dtrow[5];
                        dgViewQ[6, iCount].Value = dtrow[6];
                        dgViewQ[7, iCount].Value = dtrow[7];
                    }
                    //dgViewQ[3, iCount].Value = dtrow[3];

                    //dgViewQ[4, iCount].Value = dtrow[4];
                    //double tmpValue = Convert.ToDouble(dgViewQ[4, iCount].Value);
                    dicPerct = (decimal)((Convert.ToDouble(dgViewQ[2, iCount].Value) / Convert.ToDouble(dgViewQ[4, iCount].Value)) - 1) * 100;
                    dicPerct = decimal.Round(dicPerct, 2);
                    dgViewQ[5, iCount].Value = dicPerct;

                    /* int iR = 255, iG = 255, iB = 255;
                     * int iMax = 0, iMin = 0;
                     *
                     * //http://www.flounder.com/csharp_color_table.htm (for color coding)
                     * if (dicPerct < 0)
                     * {
                     *   iMin = 255 - (int)(dicPerct * -4);
                     *   if ((iMin < 0) || (iMin > 255)) iMin = 0;
                     *
                     *   iG = iMin;
                     *   iB = iMin;
                     * }
                     * else
                     * {
                     *   iMax = 255 - (int)(dicPerct * 4);
                     *   if ((iMax < 0) || (iMax > 255)) iMax = 0;
                     *   iR = iMax;
                     *   iB = iMax;
                     * }
                     * dgViewQ[5, iCount].Style.BackColor = Color.FromArgb(iR, iG, iB);*/
                    dgViewQ[5, iCount].Style.BackColor = Color.FromArgb(CommonDoubleM.GetColorcode((double)dicPerct));
                    dblValue = dblValue +
                               Convert.ToDouble(dgViewQ[1, iCount].Value) *
                               Convert.ToDouble(dgViewQ[2, iCount].Value);

                    dblGain  = dblGain + Convert.ToDouble(dgViewQ[6, iCount].Value);
                    dblTotal = dblTotal + Convert.ToDouble(dgViewQ[7, iCount].Value);


                    iCount++;
                    theParent.pBarDM.Value = iCount;
                }
                //dgViewQ.Rows[iCount].Selected = true;
                /*Summary at bottom*/
                dgViewQ[0, iCount].Value = "Summary";
                dgViewQ[2, iCount].Value = dblValue;
                dgViewQ[5, iCount].Value = decimal.Round(((decimal)((dblValue / dblTotal) - 1) * 100), 2);
                dgViewQ[6, iCount].Value = dblGain;
                dgViewQ[7, iCount].Value = dblTotal;

                DataGridViewColumnSelector cs = new DataGridViewColumnSelector(dgViewQ);
                cs.MaxHeight = 1000;
                cs.Width     = 130;

                theParent.lblDMMsg.Text = "Done..";
            }
            catch (Exception ex)
            {
                theParent.lblDMMsg.Text = ex.Message;
            }
            finally
            {
                theParent.pBarDM.Visible = false;
            }
        }