Exemple #1
0
        public List<Teams> GetListTeams(int ClientId)
        {
            List<Teams> list = new List<Teams>();
            Teams ins;

            //...Database Connection...
            DataBaseConnection dbConn = new DataBaseConnection();
            SqlConnection con = dbConn.SqlConn();
            SqlCommand cmdI;

            //...SQL Commands...
            cmdI = new SqlCommand("SELECT t.*,sc.CategoryName,sch.* FROM Teams t inner join SportCategory sc on t.SportCategoryID = sc.SportCategoryId inner join Schools sch on t.SchoolId =sch.SchoolId  WHERE t.ClientId = " + ClientId + " ORDER BY t.TeamsId DESC", con);
            cmdI.Connection.Open();
            SqlDataReader drI = cmdI.ExecuteReader();

            //...Retrieve Data...
            if (drI.HasRows)
            {
                while (drI.Read())
                {
                    ins = new Teams();
                    ins.TeamsId = Convert.ToInt32(drI["TeamsId"]);
                    ins.ClientId = Convert.ToInt32(drI["ClientId"]);
                    ins.Name = drI["Schoolabbreviation"].ToString();
                    ins.Age = drI["Age"].ToString();
                    ins.Ranks = drI["Ranks"].ToString();
                    ins.SportCategoryID = Convert.ToInt32(drI["SportCategoryID"]);
                    ins.sportcategory = drI["CategoryName"].ToString();
                    ins.SchoolId = Convert.ToInt32(drI["SchoolId"]);
                    ins.schoolname = drI["SchoolName"].ToString();
                    ins.PictureId = Convert.ToInt32(drI["PictureId"]);
                    list.Add(ins);
                }
            }
            drI.Close();
            con.Close();

            PictureRepository picRep = new PictureRepository();

            foreach (Teams item in list)
            {
                if (item.PictureId != 0)
                {
                    item.PicUrl = picRep.GetPicture(item.PictureId).PicUrl;
                    /*if (item.PicUrl.Contains("\\Images\\"))
                    {
                        string path = item.PicUrl.Substring(item.PicUrl.IndexOf("\\Images\\"));
                        path = path.Replace('\\', '/');
                        item.PicUrl = "http://www.netintercom.co.za" + path;
                    }*/
                }
            }
            return list;
        }
Exemple #2
0
        public List<Teams> GetListTeams()
        {
            List<Teams> list = new List<Teams>();
            Teams ins;

            //...Database Connection...
            DataBaseConnection dbConn = new DataBaseConnection();
            SqlConnection con = dbConn.SqlConn();
            SqlCommand cmdI;

            //...SQL Commands...
            cmdI = new SqlCommand("SELECT t.*,sc.CategoryName,sch.* FROM Teams t inner join SportCategory sc on t.SportCategoryID = sc.SportCategoryId inner join Schools sch on t.SchoolId =sch.SchoolId ", con);
            cmdI.Connection.Open();
            SqlDataReader drI = cmdI.ExecuteReader();

            //...Retrieve Data...
            if (drI.HasRows)
            {
                while (drI.Read())
                {
                    ins = new Teams();
                    ins.TeamsId = Convert.ToInt32(drI["TeamsId"]);
                    ins.ClientId = Convert.ToInt32(drI["ClientId"]);
                    ins.Name = drI["Name"].ToString();
                    ins.Age = drI["Age"].ToString();
                    ins.Ranks = drI["Ranks"].ToString();
                    ins.SportCategoryID = Convert.ToInt32(drI["SportCategoryID"]);
                    ins.sportcategory = drI["CategoryName"].ToString();
                    ins.SchoolId = Convert.ToInt32(drI["SchoolId"]);
                    ins.schoolname = drI["SchoolName"].ToString();
                    ins.PictureId = Convert.ToInt32(drI["PictureId"]);
                    list.Add(ins);
                }
            }
            drI.Close();
            con.Close();

            return list;
        }
Exemple #3
0
 public ActionResult _UpdateTeams(Teams ins)
 {
     //...ViewData...
     ins.ClientId = Convert.ToInt32(HttpContext.Session["ClientId"]);
     ins.Name = Convert.ToString(ins.SchoolId);
     Teams ins2 = TeamsRep.UpdateTeams(ins);
     //...Repopulate Grid...
     List<Teams> lst = new List<Teams>();
     lst = TeamsRep.GetListTeams(Convert.ToInt32(HttpContext.Session["ClientId"]));
     return View(new GridModel(lst));
 }
Exemple #4
0
        public Teams UpdateTeams(Teams ins)
        {
            //...Database Connection...
            DataBaseConnection dbConn = new DataBaseConnection();
            SqlConnection con = dbConn.SqlConn();
            con.Open();
            SqlCommand cmdI = con.CreateCommand();
            cmdI.Connection = con;

            //...Update Picture...

            //...Update Record...
            cmdI.Parameters.Clear();
            cmdI.CommandText = "f_Admin_Update_Teams";
            cmdI.CommandType = System.Data.CommandType.StoredProcedure;
            cmdI.Parameters.AddWithValue("@TeamsId", ins.TeamsId);
            cmdI.Parameters.AddWithValue("@ClientId", ins.ClientId);
            cmdI.Parameters.AddWithValue("@Name", ins.Name);
            cmdI.Parameters.AddWithValue("@Age", ins.Age);
            cmdI.Parameters.AddWithValue("@Ranks", ins.Ranks);
            cmdI.Parameters.AddWithValue("@SportCategoryID", ins.SportCategoryID);
            cmdI.Parameters.AddWithValue("@SchoolId", ins.SchoolId);
            cmdI.ExecuteNonQuery();
            cmdI.Connection.Close();

            return ins;
        }
Exemple #5
0
        public Teams InsertTeams(Teams ins)
        {
            //...Get User and Date Data...
            string strTrx = "Insert_Teams";

            //...Database Connection...
            DataBaseConnection dbConn = new DataBaseConnection();
            SqlConnection con = dbConn.SqlConn();
            con.Open();

            //...Command Interface...
            SqlCommand cmdI = con.CreateCommand();
            SqlTransaction trx;
            trx = con.BeginTransaction(strTrx);
            cmdI.Connection = con;
            cmdI.Transaction = trx;

            try
            {
                //...Insert Picture...

                //...Insert Record...
                cmdI.Parameters.Clear();
                cmdI.CommandText = "f_Admin_Insert_Teams";
                //cmdI.Connection.Open();
                cmdI.CommandType = System.Data.CommandType.StoredProcedure;
                cmdI.Parameters.AddWithValue("@ClientId", ins.ClientId);
                cmdI.Parameters.AddWithValue("@Name", ins.Name);
                cmdI.Parameters.AddWithValue("@Age", ins.Age);
                cmdI.Parameters.AddWithValue("@Ranks", ins.Ranks);
                cmdI.Parameters.AddWithValue("@SportCategoryID", ins.SportCategoryID);
                cmdI.Parameters.AddWithValue("@SchoolId", ins.SchoolId);

                //...Return new ID...
                ins.TeamsId = (int)cmdI.ExecuteScalar();

                //...Commit Transaction...
                trx.Commit();
                cmdI.Connection.Close();
            }
            catch (SqlException ex)
            {
                if (trx != null) trx.Rollback();
                //...Save Error to Log...
                Functions func = new Functions();
                func.LogError(ex.ToString());
            }
            finally
            {
                //...Check for close and respond accordingly..
                if (con.State != ConnectionState.Closed)
                {
                    con.Close();
                }

                //...Clean up...
                con.Dispose();
                cmdI.Dispose();
                trx.Dispose();
            }

            return ins;
        }
Exemple #6
0
        public Teams GetTeamA(int? TeamsId)
        {
            Teams ins = new Teams();
            int sport = 0;
            //...Database Connection...
            DataBaseConnection dbConn = new DataBaseConnection();
            SqlConnection con = dbConn.SqlConn();
            SqlCommand cmdI;

            //...SQL Commands...
            cmdI = new SqlCommand("SELECT * FROM Teams WHERE TeamsId =" + TeamsId, con);
            cmdI.Connection.Open();
            SqlDataReader drI = cmdI.ExecuteReader();

            //...Retrieve Data...
            if (drI.HasRows)
            {
                while (drI.Read())
                {
                    ins.TeamsId = Convert.ToInt32(drI["TeamsId"]);
                    ins.Name = drI["Name"].ToString();
                    ins.Age = drI["Age"].ToString();
                    ins.Ranks = drI["Ranks"].ToString();
                    ins.ClientId = Convert.ToInt32(drI["ClientId"]);
                    ins.SportCategoryID = Convert.ToInt32(drI["SportCategoryID"]);
                    ins.SchoolId = Convert.ToInt32(drI["SchoolId"]);
                }
            }
            drI.Close();
            con.Close();

            return ins;
        }