Ejemplo n.º 1
0
        /// <summary>
        /// Updates ground information. Returns 3 if all tables were updated sucessfully.
        /// </summary>
        /// <param name="ground">Ground</param>
        /// <returns>Returns the number of records updated. Should be 3</returns>
        internal static int updateGroundInfo(clsGround ground)
        {
            int result = 0;

            SqlCeTransaction trans = connection.CON.BeginTransaction();
            SqlCeCommand     com   = new SqlCeCommand();

            com.Connection  = connection.CON;
            com.Transaction = trans;

            try
            {
                com.CommandText = "UPDATE tblStadium SET stadiumName=@p1,capacity=@p2,countryId=@p3 WHERE stadiumId=@p4";
                com.Parameters.AddWithValue("@p1", ground.stadiumName);
                com.Parameters.AddWithValue("@p2", ground.capacity);
                com.Parameters.AddWithValue("@p3", ground.countryId);
                com.Parameters.AddWithValue("@p4", ground.stadiumId);
                result += com.ExecuteNonQuery();

                com.CommandText = "UPDATE tblEnds SET endName=@pe1 WHERE endId=@pe2";
                com.Parameters.AddWithValue("@pe1", ground.end1.endName);
                com.Parameters.AddWithValue("@pe2", ground.end1.endId);
                result += com.ExecuteNonQuery();

                com.CommandText = "UPDATE tblEnds SET endName=@pe11 WHERE endId=@pe12";
                com.Parameters.AddWithValue("@pe11", ground.end2.endName);
                com.Parameters.AddWithValue("@pe12", ground.end2.endId);
                result += com.ExecuteNonQuery();

                trans.Commit();
                return(result);
            }
            catch (Exception e)
            {
                try
                {
                    clsMessages.showMessage(clsMessages.msgType.error, e.Message);
                    trans.Rollback();
                }
                catch (Exception ext)
                {
                    clsMessages.showMessage(clsMessages.msgType.error, ext.Message);
                }
            }

            return(result);
        }
Ejemplo n.º 2
0
        internal static int addGround(clsGround ground)
        {
            int results = 0;
            SqlCeTransaction trans;

            trans = connection.CON.BeginTransaction();
            SqlCeCommand com = new SqlCeCommand();

            com.Connection = connection.CON;

            try
            {
                com.CommandText = "INSERT INTO tblStadium VALUES(@p1,@p2,@p3,@p4)";
                com.Parameters.AddWithValue("@p1", ground.stadiumId);
                com.Parameters.AddWithValue("@p2", ground.stadiumName);
                com.Parameters.AddWithValue("@p3", ground.capacity);
                com.Parameters.AddWithValue("@p4", ground.countryId);
                results += com.ExecuteNonQuery();

                com.CommandText = "INSERT INTO tblEnds VALUES(@e11,@e12,@e13)";
                com.Parameters.AddWithValue("e11", ground.end1.endId);
                com.Parameters.AddWithValue("@e12", ground.end1.endName);
                com.Parameters.AddWithValue("@e13", ground.stadiumId);
                results += com.ExecuteNonQuery();

                com.CommandText = "INSERT INTO tblEnds VALUES(@e21,@e22,@e23)";
                com.Parameters.AddWithValue("e21", ground.end2.endId);
                com.Parameters.AddWithValue("@e22", ground.end2.endName);
                com.Parameters.AddWithValue("@e23", ground.stadiumId);
                results += com.ExecuteNonQuery();

                trans.Commit();
            }
            catch (Exception e)
            {
                clsMessages.showMessage(clsMessages.msgType.error, e.Message);
                try
                {
                    trans.Rollback();
                }
                catch (Exception etr)
                {
                    clsMessages.showMessage(clsMessages.msgType.error, etr.Message);
                }
            }
            return(results);
        }
Ejemplo n.º 3
0
        internal static clsGround getGround(string groundName)
        {
            clsGround ground;

            SqlCeCommand com = new SqlCeCommand("SELECT * FROM tblStadium WHERE stadiumName=@p1", connection.CON);

            com.Parameters.AddWithValue("@p1", groundName);

            SqlCeDataAdapter ad = new SqlCeDataAdapter(com);
            DataSet          ds = new DataSet("tblStadium");

            ad.Fill(ds, "tblStadium");
            DataRow r = ds.Tables["tblStadium"].Rows[0];

            List <clsEnds> ends;

            ends = clsEnds.getEndsByGroundId(Convert.ToInt32(r[0].ToString()));

            ground = new clsGround(Convert.ToInt32(r[0].ToString()), r[1].ToString(), Convert.ToInt32(r[2]), Convert.ToInt32(r[3]), ends[0], ends[1]);
            return(ground);
        }
Ejemplo n.º 4
0
        public clsMatch(int matchid, string mName, clsMatchTypes type, DateTime mDate, string mPath, clsCountry country, clsGround ground, List <clsTeams> squad, string tossWon, string firstBat)
        {
            matchID   = matchid;
            matchName = mName;
            matchType = type;
            matchDate = mDate;

            savePath       = mPath;
            countryPlayed  = country;
            groundPlayed   = ground;
            currentSquards = squad;

            tossWonBy    = tossWon;
            firstBatting = firstBat;

            team1 = squad[0];
            team2 = squad[1];

            //currentMatch = this;
            currentMatch = this;
        }