Exemplo n.º 1
0
        private static DataTable CalcularScores(DataTable dt, DataTable dtJornadas)
        {
            int nroRow      = 0;
            int totalNeto   = 0;
            int totalGross  = 0;
            int parjornadas = 0;

            if (dt.Columns.Count > (dtJornadas.Rows.Count * 4) + 6)
            {
                parjornadas = GolfHoyoPar.GetParTotal() * dtJornadas.Rows.Count;
                dt.Columns.Add("Total Gross");
                dt.Columns.Add("Total Neto");
                dt.Columns.Add("Score", typeof(Int32));
                foreach (DataRow dr in dt.Rows)
                {
                    totalNeto  = 0;
                    totalGross = 0;
                    for (int i = 1; i <= dtJornadas.Rows.Count; i++)
                    {
                        if (totalGross == 0)
                        {
                            totalGross = totalGross + Convert.ToInt32(dr["Gross"]);
                        }
                        else
                        {
                            if (string.IsNullOrEmpty(dr["Gross" + " " + i].ToString()))
                            {
                                totalGross = totalGross + 500;
                            }
                            else
                            {
                                totalGross = totalGross + Convert.ToInt32(dr["Gross" + " " + i]);
                            }
                        }

                        if (totalNeto == 0)
                        {
                            try
                            {
                                totalNeto = totalNeto + Convert.ToInt32(dr["Neto"]);
                            }
                            catch { }
                        }
                        else
                        {
                            if (string.IsNullOrEmpty(dr["Neto" + " " + i].ToString()))
                            {
                                totalNeto = totalNeto + 500;
                            }
                            else
                            {
                                totalNeto = totalNeto + Convert.ToInt32(dr["Neto" + " " + i]);
                            }
                        }
                    }
                    dt.Rows[nroRow]["Total Gross"] = totalGross;
                    dt.Rows[nroRow]["Total Neto"]  = totalNeto;
                    dt.Rows[nroRow]["Score"]       = totalGross - parjornadas;
                    nroRow++;
                }
            }
            else
            {
                parjornadas = GolfHoyoPar.GetParTotal();
                dt.Columns.Add("Score", typeof(Int32));
                foreach (DataRow dr in dt.Rows)
                {
                    totalGross = Convert.ToInt32(dr["Gross"]);
                    dt.Rows[nroRow]["Score"] = totalGross - parjornadas;
                    nroRow++;
                }
            }
            return(dt);
        }
Exemplo n.º 2
0
        private static DataTable CalcularScoresJor(DataTable dt)
        {
            int    nroRow      = 0;
            int    sumatoria   = 0;
            int    totalGross  = 0;
            int    parjornadas = 0;
            string s           = "";
            int    Handicap    = 0;


            foreach (DataRow dr in dt.Rows)
            {
                s = dr["Handicap"].ToString();
                string[] words = s.Split('-');
                Handicap = Convert.ToInt32(words[0]);

                sumatoria = sumatoria + Handicap;
            }

            if (sumatoria > 0)
            {
                parjornadas = GolfHoyoPar.GetParTotal();
                dt.Columns.Add("Score", typeof(Int32));
                foreach (DataRow dr in dt.Rows)
                {
                    if (string.IsNullOrEmpty(dr["Total"].ToString()))
                    {
                        nroRow++;
                    }
                    else
                    {
                        totalGross = Convert.ToInt32(dr["Total"].ToString());
                        dt.Rows[nroRow]["Score"] = totalGross - parjornadas;
                        nroRow++;
                    }
                }
            }
            else
            {
                parjornadas = GolfHoyoPar.GetParTotal();
                dt.Columns.Add("Score", typeof(Int32));
                foreach (DataRow dr in dt.Rows)
                {
                    if (string.IsNullOrEmpty(dr["Total"].ToString()))
                    {
                        nroRow++;
                    }
                    else
                    {
                        totalGross = Convert.ToInt32(dr["Total"].ToString());
                        dt.Rows[nroRow]["Score"] = totalGross - parjornadas;
                        nroRow++;
                    }
                }


                dt.Columns.Remove("Handicap");
                dt.Columns.Remove("TotalNeto");
            }



            return(dt);
        }