Example #1
0
        private void BtnRefrescar_Click(object sender, EventArgs e)
        {
            this.dataGridView1.Columns[0].Visible = true;
            DataSet DS = DatosEntidad.Dataset("LiquidacionPeriodo", "", Convert.ToInt32(this.CmbPeriodos.SelectedValue), 0.00);

            dataGridView1.DataSource = DS.Tables[0];
            dataGridView1.AutoResizeColumns();

            TotalGrid.MarcarSeleccion(this.dataGridView1);
            TotalGrid.HabilitarCheck(this.dataGridView1);
            this.ToolStripTxbRegistros.Text = TotalGrid.RegistrosSeleccionados(dataGridView1);
            this.ToolStripTxbDetalle.Text   = TotalGrid.TotalLiquidacion(this.dataGridView1);

            #region Aplicando accion del chech que activo Grupo Damasa
            if (this.ChbOmitirDamasa.Checked)
            {
                foreach (DataGridViewRow row in this.dataGridView1.Rows)
                {
                    if (Convert.ToString(row.Cells[1].Value).Trim() == "039" || Convert.ToString(row.Cells[1].Value).Trim() == "080" || Convert.ToString(row.Cells[1].Value).Trim() == "089")
                    {
                        row.Cells[0].Value = false;
                    }
                }
            }
            else
            {
                foreach (DataGridViewRow row in this.dataGridView1.Rows)
                {
                    if (Convert.ToString(row.Cells[1].Value).Trim() == "039" || Convert.ToString(row.Cells[1].Value).Trim() == "080" || Convert.ToString(row.Cells[1].Value).Trim() == "089")
                    {
                        row.Cells[0].Value = true;
                    }
                }
            }
            #endregion


            #region Aplicando accion del chech que activo Grupo Masora
            if (this.ChbOmitirMasora.Checked)
            {
                foreach (DataGridViewRow row in this.dataGridView1.Rows)
                {
                    if (Convert.ToString(row.Cells[1].Value).Trim() == "020" || Convert.ToString(row.Cells[1].Value).Trim() == "090" || Convert.ToString(row.Cells[1].Value).Trim() == "091")
                    {
                        row.Cells[0].Value = false;
                    }
                }
            }
            else
            {
                foreach (DataGridViewRow row in this.dataGridView1.Rows)
                {
                    if (Convert.ToString(row.Cells[1].Value).Trim() == "020" || Convert.ToString(row.Cells[1].Value).Trim() == "090" || Convert.ToString(row.Cells[1].Value).Trim() == "091")
                    {
                        row.Cells[0].Value = true;
                    }
                }
            }
            #endregion
        }
Example #2
0
 private void ChkMarcar_CheckedChanged(object sender, EventArgs e)
 {
     if (this.ChkMarcar.Checked)
     {
         foreach (DataGridViewRow row in dataGridView1.Rows)
         {
             int index = row.Index;
             if (Convert.ToInt32(row.Cells[8].Value) == 0)
             {
                 row.Cells[0].Value = false;
                 this.dataGridView1.Rows[index].DefaultCellStyle.BackColor = Color.LightSkyBlue;
             }
             else
             {
                 row.Cells[0].Value = true;
             }
         }
     }
     else
     {
         foreach (DataGridViewRow row in dataGridView1.Rows)
         {
             row.Cells[0].Value = false;
         }
     }
     this.ToolStripTxbRegistros.Text = TotalGrid.RegistrosSeleccionados(dataGridView1);
     this.ToolStripTxbDetalle.Text   = TotalGrid.TotalLiquidacion(dataGridView1);
 }
        private void CellChanged(object sender, DataGridCellEditEndingEventArgs e)
        {
            var dataContext = this.DataContext as TimeSheetViewModel;

            if (dataContext == null)
            {
                return;
            }
            dataContext.CalculateTotalRecordData();
            TotalGrid.UpdateLayout();
        }
Example #4
0
        /// <summary>
        /// Update total scoreboard. Called after adding / removing / loading rounds
        /// </summary>
        public void UpdateTotalScore()
        {
            // 0 names       // 6 Birdies
            // 1 throws      // 7 Par
            // 2 from par    // 8 Bogeys
            // 3 from leader // 9 Double bogeys
            // 4 from next   // 10 others
            // 5 Eagles

            TotalGrid.Rows.Clear();
            TotalGrid.Refresh();

            List <string> names         = new List <string>();
            List <int>    throws        = new List <int>();
            int           par           = 0;
            List <int>    eagles        = new List <int>();
            List <int>    birdies       = new List <int>();
            List <int>    pars          = new List <int>();
            List <int>    bogeys        = new List <int>();
            List <int>    doublesBogeys = new List <int>();
            List <int>    others        = new List <int>();
            int           stages        = td.data.Select(x => x.pars.Length).Sum();

            TotalGrid.Columns[0].HeaderText = td.data.Count + " | " + stages.ToString() + " Name";

            int i; // current player index

            foreach (TurneeData.RoundData rd in RoundsListBox.Items)
            {
                par += rd.pars.Sum();
                // Players on round
                for (int p = 0; p < rd.playerScores.Length; p++)
                {
                    var indexOf = names.IndexOf(rd.playerScores[p].playerName);
                    if (indexOf != -1)
                    {
                        i = indexOf;
                    }
                    else
                    {
                        Debug.WriteLine("." + rd.playerScores[p].playerName + ".");
                        names.Add(rd.playerScores[p].playerName);
                        throws.Add(0);
                        eagles.Add(0);
                        birdies.Add(0);
                        pars.Add(0);
                        bogeys.Add(0);
                        doublesBogeys.Add(0);
                        others.Add(0);
                        i = names.Count - 1;
                    }
                    // stages (väylät)
                    for (int v = 0; v < rd.pars.Length; v++)
                    {
                        throws[i] += rd.playerScores[p].scores[v];
                        switch (rd.playerScores[p].scores[v] - rd.pars[v])
                        {
                        case -2:
                            eagles[i]++;
                            break;

                        case -1:
                            birdies[i]++;
                            break;

                        case 0:
                            pars[i]++;
                            break;

                        case 1:
                            bogeys[i]++;
                            break;

                        case 2:
                            doublesBogeys[i]++;
                            break;

                        default:
                            others[i]++;
                            break;
                        } // switch
                    }     // for stages
                }         // for players
            }             // for rounds

            for (i = 0; i < names.Count; i++)
            {
                var query      = throws.Where(x => x < throws[i]);
                int nextLowest = query.Any() || query.Count() > 1 ? query.Max() : throws[i];
                TotalGrid.Rows.Add(new string[] {
                    names[i],
                    throws[i].ToString(),
                    (throws[i] - par).ToString(),
                    (throws[i] - throws.Min()).ToString(),
                    (throws[i] - nextLowest).ToString(),
                    eagles[i].ToString() + " (" + ((float)eagles[i] * 100 / (float)stages).ToString("0.0") + "%)",
                    birdies[i].ToString() + " (" + ((float)birdies[i] * 100 / (float)stages).ToString("0.0") + "%)",
                    pars[i].ToString() + " (" + ((float)pars[i] * 100 / (float)stages).ToString("0.0") + "%)",
                    bogeys[i].ToString() + " (" + ((float)bogeys[i] * 100 / (float)stages).ToString("0.0") + "%)",
                    doublesBogeys[i].ToString() + " (" + ((float)doublesBogeys[i] * 100 / (float)stages).ToString("0.0") + "%)",
                    others[i].ToString() + " (" + ((float)others[i] * 100 / (float)stages).ToString("0.0") + "%)",
                });
            }

            UpdateComponentSizes();
        }
Example #5
0
 private void ToolStripTxbRegistros_Enter(object sender, EventArgs e)
 {
     this.ToolStripTxbRegistros.Text = TotalGrid.RegistrosSeleccionados(dataGridView1);
     this.ToolStripTxbDetalle.Text   = TotalGrid.TotalLiquidacion(dataGridView1);
 }