Пример #1
0
        public SportCategory GetSportCategory(int SportCategoryId)
        {
            SportCategory ins = new SportCategory();

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

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

            //...Retrieve Data...
            if (drI.HasRows)
            {
                while (drI.Read())
                {
                    ins.SportCategoryID = Convert.ToInt32(drI["SportCategoryId"]);
                    ins.ClientID = Convert.ToInt32(drI["ClientId"]);
                    ins.CategoryName = drI["CategoryName"].ToString();

                }
            }
            drI.Close();
            con.Close();

            return ins;
        }
Пример #2
0
        public List<SportCategory> GetListSportCategoryportCategorys()
        {
            List<SportCategory> list = new List<SportCategory>();
            SportCategory ins;

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

            //...SQL Commands...
            cmdI = new SqlCommand("SELECT * from SportCategory", con);
            cmdI.Connection.Open();
            SqlDataReader drI = cmdI.ExecuteReader();

            //...Retrieve Data...
            if (drI.HasRows)
            {
                while (drI.Read())
                {
                    ins = new SportCategory();
                    ins.SportCategoryID = Convert.ToInt32(drI["SportCategoryId"]);
                    ins.ClientID = Convert.ToInt32(drI["ClientId"]);
                    ins.CategoryName = drI["CategoryName"].ToString();
                    list.Add(ins);
                }
            }
            drI.Close();
            con.Close();

            return list;
        }
Пример #3
0
        public ActionResult _UpdateSportCategory(SportCategory ins)
        {
            //...ViewData...
            ins.ClientID = Convert.ToInt32(HttpContext.Session["ClientId"]);
            SportCategory ins2 = SCRep.UpdateSport(ins);

            //...Notify...
            string regIds = AppRep.GetAllRegIds(ins.ClientID);
            if (!regIds.Equals(""))
            {
                comrep.NewUpdateData(regIds, "CMD_EDITSportCategory", ins2.SportCategoryID.ToString());
            }

            //...Repopulate Grid...
            List<SportCategory> lst = new List<SportCategory>();
            lst = SCRep.GetListSportCategory(Convert.ToInt32(HttpContext.Session["ClientId"]));
            return View(new GridModel(lst));
        }
Пример #4
0
        public ActionResult _InsertSportCategory(SportCategory ins)
        {
            ins.ClientID = Convert.ToInt32(HttpContext.Session["ClientId"]);

            //...Insert into Database...
            SportCategory ins2 = SCRep.Insert(ins);

            //...Notify...
            string regIds = AppRep.GetAllRegIds(ins.ClientID);
            List<string> reg = AppRep.GetAllRegIdsList(ins.ClientID);
            if (!regIds.Equals(""))
            {
                comrep.NewsyncData(regIds, "CMD_NEWSportCategory", reg, ins.ClientID);
            }

            //...Facebook...
            string access_token = FacebookPost.GetAccessToken(ins.ClientID);

            if (!access_token.Equals(""))
            {
                string page_id = FacebookPost.GetPageId(ins.ClientID);
                if (!page_id.Equals(""))
                {
                    FacebookPost.Post(access_token, page_id, "SportCategory Update: " + ins.CategoryName);
                }
            }

            //...Repopulate Grid...
            List<SportCategory> lst = new List<SportCategory>();
            lst = SCRep.GetListSportCategory(Convert.ToInt32(HttpContext.Session["ClientId"]));
            return View(new GridModel(lst));
        }
Пример #5
0
        public SportCategory UpdateSport(SportCategory 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_SportCategory";
            cmdI.CommandType = System.Data.CommandType.StoredProcedure;
            cmdI.Parameters.AddWithValue("@SportCategoryId", ins.SportCategoryID);
            cmdI.Parameters.AddWithValue("@ClientId", ins.ClientID);
            cmdI.Parameters.AddWithValue("@CategoryName", ins.CategoryName);
            cmdI.ExecuteNonQuery();
            cmdI.Connection.Close();

            return ins;
        }
Пример #6
0
        public SportCategory Insert(SportCategory ins)
        {
            //...Get User and Date Data...
            string strTrx = "Insert_SportCategory";

            //...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_SportCategory";
                //cmdI.Connection.Open();
                cmdI.CommandType = System.Data.CommandType.StoredProcedure;
                cmdI.Parameters.AddWithValue("@ClientId", ins.ClientID);
                cmdI.Parameters.AddWithValue("@CategoryName", ins.CategoryName);

                //...Return new ID...
                ins.SportCategoryID = (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;
        }