Exemplo n.º 1
0
        public static bool Subscribe(int ID)
        {
            int    userID             = Subscription.GetID();
            string myConnectionString = "server=ibless.cx7whwbxrpt3.us-east-1.rds.amazonaws.com;uid=iBLESS_Trac;" +
                                        "pwd=marjaime1;database=iBLESS;";

            try
            {
                using (MySqlConnection conn = new MySqlConnection())
                {
                    conn.ConnectionString = myConnectionString;

                    string       commandText = "UPDATE Companies SET `Chargify_ID`=@char_ID WHERE ID=@id";
                    MySqlCommand cmd         = new MySqlCommand(commandText, conn);

                    cmd.Parameters.AddWithValue("@char_ID", ID);
                    cmd.Parameters.AddWithValue("@id", userID);

                    conn.Open();
                    cmd.ExecuteNonQuery();
                }
            }
            catch (MySql.Data.MySqlClient.MySqlException ex)
            {
                Debug.WriteLine(ex.Message);
                return(false);
            }

            UpdateBossID(userID);
            return(true);
        }
        public static String Delete(String Type, int TypeID)
        {
            int    ID = Subscription.GetID();
            string myConnectionString = "server=ibless.cx7whwbxrpt3.us-east-1.rds.amazonaws.com;uid=iBLESS_Trac;" +
                                        "pwd=marjaime1;database=iBLESS;";
            string result = "";

            try
            {
                using (MySqlConnection conn = new MySql.Data.MySqlClient.MySqlConnection())
                {
                    conn.ConnectionString = myConnectionString;
                    conn.Open();

                    string stm = @"DELETE FROM " + ID + "_Arch WHERE Type=@type";

                    MySqlCommand cmd = new MySqlCommand(stm, conn);
                    cmd.Parameters.AddWithValue("@type", Type);
                    cmd.ExecuteNonQuery();
                }
            }
            catch (MySql.Data.MySqlClient.MySqlException ex)
            {
                Debug.WriteLine(ex.Message);
                return(" ");
            }

            DeleteFromUsers(TypeID, ID);
            result = GetReadyTable(false);
            return(result);
        }
        public static bool UpdateInfo(int ID, String Type, bool CanCreate)
        {
            int BossID = Database.GetBossID(Subscription.GetID().ToString());

            string myConnectionString = "server=ibless.cx7whwbxrpt3.us-east-1.rds.amazonaws.com;uid=iBLESS_Trac;" +
                                        "pwd=marjaime1;database=iBLESS;";

            try
            {
                using (MySqlConnection conn = new MySql.Data.MySqlClient.MySqlConnection())
                {
                    conn.ConnectionString = myConnectionString;

                    string       commandText = "UPDATE " + BossID + "_Arch SET Type=@type, `Can_Create`=@create WHERE ID=@currentID";
                    MySqlCommand cmd         = new MySqlCommand(commandText, conn);

                    cmd.Parameters.AddWithValue("@currentID", ID);
                    cmd.Parameters.AddWithValue("@type", Type);
                    cmd.Parameters.AddWithValue("@create", CanCreate);

                    conn.Open();
                    cmd.ExecuteNonQuery();
                }
            }
            catch (MySql.Data.MySqlClient.MySqlException ex)
            {
                Debug.WriteLine(ex.Message);
                return(false);
            }

            return(true);
        }
        /// <summary>
        /// Creates hierarchy table in case it does not exist
        /// </summary>
        /// <returns></returns>
        private static bool Create()
        {
            int    ID = Subscription.GetID();
            string myConnectionString = "server=ibless.cx7whwbxrpt3.us-east-1.rds.amazonaws.com;uid=iBLESS_Trac;" +
                                        "pwd=marjaime1;database=iBLESS;";

            try
            {
                using (MySqlConnection conn = new MySql.Data.MySqlClient.MySqlConnection())
                {
                    conn.ConnectionString = myConnectionString;
                    String       commandText = "CREATE TABLE IF NOT EXISTS " + ID + "_Arch(ID int NOT NULL,Type char(50) UNIQUE,Can_Create boolean,PRIMARY KEY (ID))";
                    MySqlCommand cmd         = new MySqlCommand(commandText, conn);

                    conn.Open();
                    cmd.ExecuteNonQuery();
                }
            }
            catch (MySql.Data.MySqlClient.MySqlException ex)
            {
                Debug.WriteLine(ex.Message);
                return(false);
            }

            return(true);
        }
        /// <summary>
        /// Updates users from the users table under current company in order to synchronize changes to the hierarchy table with the users table
        /// </summary>
        /// <param name="row_ID"></param>
        /// <returns></returns>
        private static bool GetUsers(int row_ID)
        {
            int    ID = Subscription.GetID();
            string myConnectionString = "server=ibless.cx7whwbxrpt3.us-east-1.rds.amazonaws.com;uid=iBLESS_Trac;" +
                                        "pwd=marjaime1;database=iBLESS;";

            try
            {
                using (MySqlConnection conn = new MySql.Data.MySqlClient.MySqlConnection())
                {
                    conn.ConnectionString = myConnectionString;
                    conn.Open();

                    string stm = @"Select Type, ID FROM " + ID + "_Users WHERE Type>@id ORDER BY Type DESC";

                    MySqlCommand cmd = new MySqlCommand(stm, conn);
                    cmd.Parameters.AddWithValue("@id", row_ID);

                    using (MySqlDataReader rdr = cmd.ExecuteReader())
                        IncrementResultsUsers(rdr, ID);
                }
            }
            catch (MySql.Data.MySqlClient.MySqlException ex)
            {
                Debug.WriteLine(ex.Message);
                return(false);
            }

            return(true);
        }
        public static int MakeSubscription(String Company, String Address, String Type, String SubscriptionType, String SPL_Type, String Tagline, String Description, String Weblink, int CharID)
        {
            string myConnectionString;
            string date = DateTime.Now.ToString("yyyy/M/dd");  // important to keep this time format since the system relies on it.
            string time = DateTime.Now.ToString("h:mm:ss tt"); // important to keep this time format since the system relies on it.
            int    id   = Subscription.GetID();

            myConnectionString = "server=ibless.cx7whwbxrpt3.us-east-1.rds.amazonaws.com;uid=iBLESS_Trac;" +
                                 "pwd=marjaime1;database=iBLESS;";

            try
            {
                using (MySqlConnection conn = new MySql.Data.MySqlClient.MySqlConnection())
                {
                    conn.ConnectionString = myConnectionString;

                    string commandText = @"REPLACE INTO Companies SET ID=@ID, Name=@Name, Date=@Date, Time=@Time, Address=@Address, Type=@Type, Subscription=@Subscription, `SPL_Type`=@splType," +
                                         "TagLine=@tag, Website=@web, Description=@description, `Chargify_ID`=@charID";
                    MySqlCommand cmd = new MySqlCommand(commandText, conn);

                    cmd.Parameters.AddWithValue("@ID", id);
                    cmd.Parameters.AddWithValue("@Name", Company);
                    cmd.Parameters.AddWithValue("@Date", date);
                    cmd.Parameters.AddWithValue("@Time", time);
                    cmd.Parameters.AddWithValue("@Address", Address);
                    cmd.Parameters.AddWithValue("@Type", Type);
                    cmd.Parameters.AddWithValue("@Subscription", SubscriptionType);
                    cmd.Parameters.AddWithValue("@splType", SPL_Type);
                    cmd.Parameters.AddWithValue("@tag", Tagline);
                    cmd.Parameters.AddWithValue("@web", Weblink);
                    cmd.Parameters.AddWithValue("@description", Description);
                    cmd.Parameters.AddWithValue("@charID", CharID);

                    conn.Open();
                    cmd.ExecuteNonQuery();
                }
            }
            catch (MySql.Data.MySqlClient.MySqlException ex)
            {
                Debug.WriteLine(ex.Message);
                return(-1);
            }

            return(0);
        }
        public static String InsertAfter(int row_ID, bool CanCreate, String NewType)
        {
            int    ID = Subscription.GetID();
            string myConnectionString = "server=ibless.cx7whwbxrpt3.us-east-1.rds.amazonaws.com;uid=iBLESS_Trac;" +
                                        "pwd=marjaime1;database=iBLESS;";
            string result = "";

            try
            {
                using (MySqlConnection conn = new MySql.Data.MySqlClient.MySqlConnection())
                {
                    conn.ConnectionString = myConnectionString;
                    conn.Open();

                    string stm = @"Select ID, Type, `Can_Create` FROM " + ID + "_Arch WHERE ID>@id ORDER BY ID DESC";

                    MySqlCommand cmd = new MySqlCommand(stm, conn);
                    cmd.Parameters.AddWithValue("@id", row_ID);

                    using (MySqlDataReader rdr = cmd.ExecuteReader())
                    {
                        IncrementResults(rdr, ID);
                        Insert(NewType, CanCreate, row_ID + 1, ID);
                    }
                }
            }
            catch (MySql.Data.MySqlClient.MySqlException ex)
            {
                Debug.WriteLine(ex.Message);
                return(" ");
            }

            GetUsers(row_ID);
            result = GetReadyTable(false);
            return(result);
        }
 public static string GetInformation()
 {
     return(Database.GetTotalInformationJSON(Subscription.GetID().ToString()));
 }
Exemplo n.º 9
0
 public static String GetParents()
 {
     return(Database.GetParentsJSON(Subscription.GetID().ToString()));
 }
Exemplo n.º 10
0
 public static String GetHierarchy()
 {
     Database.CreateUsersTable(Subscription.GetID());
     return(CreateTable.GetReadyTable(false));
 }
 public static String GetInformationAdmin()
 {
     return(Database.GetAdminInformationJSON(Subscription.GetID().ToString()));
 }