示例#1
0
        public bool RemoveSchoolPictures(int ClientId)
        {
            bool Removed = true;

            //...Get User and Date Data...
            string strTrx = "Remove_Picture";

            //...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 Record...
                cmdI.Parameters.Clear();
                cmdI.CommandText = "f_Admin_Remove_Picture_Per_School";
                //cmdI.Connection.Open();
                cmdI.CommandType = System.Data.CommandType.StoredProcedure;
                cmdI.Parameters.AddWithValue("@ClientId", ClientId);        // int

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

                //...Commit Transaction...
                trx.Commit();
                cmdI.Connection.Close();
            }
            catch (SqlException ex)
            {
                if (trx != null)
                {
                    trx.Rollback();
                    Removed = false;
                }
                //...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 Removed;
        }
示例#2
0
        public bool RemovePicture(int PictureId)
        {
            bool Removed = true;

            //...Check Id...
            if (PictureId != 0)
            {
                //...Get Picture...
                //Picture pic = GetPicture(PictureId);
                //string path = pic.PicUrl.Substring(pic.PicUrl.IndexOf("/Images"));
                //path = path.Replace('/','\\');
                //path = Path.Combine(Server.MapPath("~"),
                //System.IO.File.Delete(pic.PicUrl);

                //...Get User and Date Data...
                string strTrx = "Remove_Picture";

                //...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 Record...
                    cmdI.Parameters.Clear();
                    cmdI.CommandText = "f_Admin_Remove_Picture";
                    //cmdI.Connection.Open();
                    cmdI.CommandType = System.Data.CommandType.StoredProcedure;
                    cmdI.Parameters.AddWithValue("@PictureId", PictureId);        // int

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

                    //...Commit Transaction...
                    trx.Commit();
                    cmdI.Connection.Close();
                }
                catch (SqlException ex)
                {
                    if (trx != null)
                    {
                        trx.Rollback();
                        Removed = false;
                    }
                    //...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 Removed;
        }
示例#3
0
        public Client InsertClient(Client ins)
        {
            //...Get User and Date Data...
            string strTrx = "Insert_Client";

            //...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 Record...
                cmdI.Parameters.Clear();
                cmdI.CommandText = "f_Admin_Insert_Client";
                cmdI.CommandType = System.Data.CommandType.StoredProcedure;
                cmdI.Parameters.AddWithValue("@Name", ins.Name);            // varchar(50)
                cmdI.Parameters.AddWithValue("@APIKey", "");

                //...Return new ID...
                ins.ClientId = (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;
        }
示例#4
0
        public Visitors InsertVisitors(Visitors ins)
        {
            //...Get User and Date Data...
            string strTrx = "Insert_Visitors";

            //...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_Visitors";
                //cmdI.Connection.Open();
                cmdI.CommandType = System.Data.CommandType.StoredProcedure;
                cmdI.Parameters.AddWithValue("@ClientId", ins.ClientId);
                cmdI.Parameters.AddWithValue("@ClientNo", ins.ClientNo);
                cmdI.Parameters.AddWithValue("@Email", ins.VisitorNo);
                cmdI.Parameters.AddWithValue("@Passwords", ins.ModifiedDate);
                cmdI.Parameters.AddWithValue("@Approved", ins.SendReceived);

                //...Return new ID...
                ins.VisitorsId = (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;
        }
示例#5
0
        public Fixtures InsertFixtures(Fixtures ins)
        {
            //...Get User and Date Data...
            string strTrx = "Insert_Fixtures";

            //...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_Fixtures";
                //cmdI.Connection.Open();
                cmdI.CommandType = System.Data.CommandType.StoredProcedure;
                cmdI.Parameters.AddWithValue("@ClientId", ins.ClientId);
                cmdI.Parameters.AddWithValue("@TeamIdA", ins.TeamIdA);
                cmdI.Parameters.AddWithValue("@TeamIdB", ins.TeamIdB);
                cmdI.Parameters.AddWithValue("@StartTime", ins.StartTime);
                cmdI.Parameters.AddWithValue("@FieldsId", ins.FieldId);
                cmdI.Parameters.AddWithValue("@SportCategoryId", ins.SportCategoryId);
                //...Return new ID...
                ins.FixturesId = (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;
        }
示例#6
0
        public DeviceUser InsertDeviceUser(DeviceUser ins)
        {
            //...Insert DeviceUser into Database...//

            //...Transaction...
            string strTrx = "Insert_DeviceUser";

            //...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 Record...
                cmdI.Parameters.Clear();
                cmdI.CommandText = "f_Admin_Insert_DeviceUser";
                cmdI.CommandType = System.Data.CommandType.StoredProcedure;
                cmdI.Parameters.AddWithValue("@ClientId", ins.ClientId);            //  int
                cmdI.Parameters.AddWithValue("@DeviceId", ins.DeviceId);            //  varchar(max)
                cmdI.Parameters.AddWithValue("@Name", ins.Name);                    //  varchar(50)
                cmdI.Parameters.AddWithValue("@Surname ", ins.Surname);             // varchar(50)
                cmdI.Parameters.AddWithValue("@Phone", ins.Phone);                  //  varchar(15)
                cmdI.Parameters.AddWithValue("@Email", ins.Email);                  //  varchar(250)
                cmdI.Parameters.AddWithValue("@Password", ins.Password);            //  varchar(500)
                cmdI.Parameters.AddWithValue("@Approved", ins.Approved);            //  bit
                cmdI.Parameters.AddWithValue("@Address", ins.Address);              // varchar(500)

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