public bool EditPassword(string email, string newPassword)
        {
            DatabaseManager dbManager = new DatabaseManager();
            Cryptography crypto = new Cryptography();

            return (dbManager.NonReturnQuery("UPDATE Clients set Client_Password = '******' WHERE Client_Email ='" + email + "';"));
        }
Example #2
0
        private void StartSession()
        {
            new System.Threading.Thread(() =>
            {
                Classes.Cryptography crypto = new Classes.Cryptography();

                SetLoadingStatus(true);
                DisplayNotifyBox("Attempting to Sign In", "Please wait while we sign you in");

                string passsword = crypto.EncryptString(GetPassword());

                Classes.Session session = new Classes.Session(GetUsername(), passsword);

                if (session.LoginSuccessfull)
                {
                    DisplayNotifyBox("Signed In", "Welcome " + session.username);

                    OpenAdminWindow(session.username);
                }
                else
                {
                    DisplayNotifyBox("Invalid Username or Password", "Could not sign in");
                }

                SetLoadingStatus(false);
            }).Start();
        }
        public bool EditPassword(string email, string newPassword)
        {
            DatabaseManager dbManager = new DatabaseManager();
            Cryptography crypto = new Cryptography();

            return (dbManager.NonReturnQuery("UPDATE Agent set Agent_Password = '******' WHERE Agent_Email ='" + email + "';"));
        }
        public bool AddClient(string name, string surname, string phone, string email, string password)
        {
            DatabaseManager dbManager = new DatabaseManager();
            Cryptography crypto = new Cryptography();

            return (dbManager.NonReturnQuery("INSERT INTO Clients (Client_Name , Client_Surname, Client_Phone, Client_Email, Client_Password) VALUES ('" + name + "','" + surname + "','" + phone + "','" + email + "','" + crypto.EncryptString(password) + "');"));
        }
Example #5
0
        public bool EditPassword(string username, string newPassword)
        {
            DatabaseManager dbManager = new DatabaseManager();
            Cryptography crypto = new Cryptography();

            return (dbManager.NonReturnQuery("UPDATE Admin set Admin_Password = '******' WHERE Admin_Username ='******';"));
        }
Example #6
0
        public bool AddAdmin(string username, string password)
        {
            DatabaseManager dbManager = new DatabaseManager();
            Cryptography crypto = new Cryptography();

            return (dbManager.NonReturnQuery("INSERT INTO Admin (Admin_Username , Admin_Password) VALUES ('" + username + "','" + crypto.EncryptString(password) + "');"));
        }
        public bool AddAgent(string name, string surname, string phone, string email, string password)
        {
            DatabaseManager dbManager = new DatabaseManager();
            Cryptography crypto = new Cryptography();
            MySql.Data.MySqlClient.MySqlCommand com = new MySql.Data.MySqlClient.MySqlCommand();

            return (dbManager.NonReturnQuery("INSERT INTO Agent (Agent_Name , Agent_Surname, Agent_Phone, Agent_Email, Agent_Password) VALUES ('" + name + "','" + surname + "','" + phone + "','" + email + "','" + Cryptography.CreateHash(password).ToString() + "');"));
        }
        /// <summary>
        /// Creates config file with keys and empty values
        /// </summary>
        private void CreateConfigFile()
        {
            Cryptography crypto = new Cryptography();

            if (!Directory.Exists(configDirPath))
            {
                Directory.CreateDirectory(configDirPath);
            }

            config.Options.AddOptionsRow(crypto.EncryptString(serverKey), "");
            config.Options.AddOptionsRow(crypto.EncryptString(userKey), "");
            config.Options.AddOptionsRow(crypto.EncryptString(passwordKey), "");
            config.Options.AddOptionsRow(crypto.EncryptString(dbKey), "");
            config.Options.AddOptionsRow(crypto.EncryptString(portKey), "");
            WriteConfig();
        }
Example #9
0
        public Session(string loginUsername, string loginPassword)
        {
            username = "";

            IsAdmin = UsernameInAdminTable(loginUsername);

            Cryptography crypto = new Cryptography();

            password = GetPassword(loginUsername, IsAdmin);
            username = GetUsername(loginUsername, IsAdmin);

            if (password != "" && username != "")
            {
                if ((username == loginUsername) && (password == loginPassword))
                {
                    LoginSuccessfull = true;
                }
            }

        }
Example #10
0
        /// <summary>
        /// Loads values from config XML file
        /// </summary>
        private void LoadConfig()
        {
            try
            {
                config.ReadXml(configFilePath);
                Cryptography crypto = new Cryptography();

                r = config.Options.Select("Key ='" + crypto.EncryptString(serverKey) + "'")[0];
                ServerIP = crypto.DecryptString(r[1].ToString());

                r = config.Options.Select("Key ='" + crypto.EncryptString(userKey) + "'")[0];
                ServerUser = crypto.DecryptString(r[1].ToString());

                r = config.Options.Select("Key ='" + crypto.EncryptString(passwordKey) + "'")[0];
                ServerPassword = crypto.DecryptString(r[1].ToString());

                r = config.Options.Select("Key ='" + crypto.EncryptString(dbKey) + "'")[0];
                ServerDB = crypto.DecryptString(r[1].ToString());

                r = config.Options.Select("Key ='" + crypto.EncryptString(portKey) + "'")[0];
                ServerPort = crypto.DecryptString(r[1].ToString());

                ConnectionString = "server=" + ServerIP + ";uid=" + ServerUser + ";database=" + ServerDB + ";port=" + ServerPort + ";pwd=" + ServerPassword + ";";

                ConfigLoaded = true;
            }
            /*catch
            {
                ConfigLoaded = false;
            }*/
            catch (Exception e)
            {
                Console.WriteLine("LoadConfig Exception " + e.ToString());
                ConfigLoaded = false;
            }

        }
Example #11
0
        /// <summary>
        /// Saves data and writes it encrypted to config XML file
        /// </summary>
        /// <param name="server">Server IP address string</param>
        /// <param name="username">Server username</param>
        /// <param name="password">Server password</param>
        /// <param name="database">Server database</param>
        /// <param name="portno">Server port number</param>
        /// <returns>Boolean if saved</returns>
        public bool SaveConfig(string server, string username, string password, string database, string portno)
        {
            try
            {
                Cryptography crypto = new Cryptography();
                ServerIP = server;
                ServerUser = username;
                ServerPassword = password;
                ServerDB = database;
                ServerPort = portno;

                r = config.Options.Select("Key = '" + crypto.EncryptString(serverKey) + "'")[0];
                r[1] = crypto.EncryptString(ServerIP);

                r = config.Options.Select("Key = '" + crypto.EncryptString(userKey) + "'")[0];
                r[1] = crypto.EncryptString(ServerUser);

                r = config.Options.Select("Key = '" + crypto.EncryptString(passwordKey) + "'")[0];
                r[1] = crypto.EncryptString(ServerPassword);

                r = config.Options.Select("Key = '" + crypto.EncryptString(dbKey) + "'")[0];
                r[1] = crypto.EncryptString(ServerDB);

                r = config.Options.Select("Key = '" + crypto.EncryptString(portKey) + "'")[0];
                r[1] = crypto.EncryptString(ServerPort);

                WriteConfig();
                LoadConfig();

                return true;
            }
            catch
            {
                return false;
            }
        }
        public bool AddAdmin(string username, string password)
        {
            DatabaseManager dbManager = new DatabaseManager();
            Cryptography    crypto    = new Cryptography();

            return(dbManager.NonReturnQuery("INSERT INTO Admin (Admin_Username , Admin_Password) VALUES ('" + username + "','" + Cryptography.CreateHash(password) + "');"));
        }
        public bool AddAgent(string name, string surname, string phone, string email, string password)
        {
            DatabaseManager dbManager = new DatabaseManager();
            Cryptography    crypto    = new Cryptography();

            MySql.Data.MySqlClient.MySqlCommand com = new MySql.Data.MySqlClient.MySqlCommand();

            return(dbManager.NonReturnQuery("INSERT INTO Agent (Agent_Name , Agent_Surname, Agent_Phone, Agent_Email, Agent_Password) VALUES ('" + name + "','" + surname + "','" + phone + "','" + email + "','" + Cryptography.CreateHash(password).ToString() + "');"));
        }
        private void StartSession()
        {
            new System.Threading.Thread(() =>
            {
                Classes.Cryptography crypto = new Classes.Cryptography();

                SetLoadingStatus(true);
                DisplayNotifyBox("Attempting to Sign In", "Please wait while we sign you in");

                string passsword = crypto.EncryptString(GetPassword());

                Classes.Session session = new Classes.Session(GetUsername(), passsword);

                if (session.LoginSuccessfull)
                {
                    DisplayNotifyBox("Signed In", "Welcome " + session.username);

                    if( session.IsAdmin )
                    {
                        OpenAdminWindow(session.username);
                    }
                    else
                    {
                        OpenAgentWindow(session.username);
                    }

                }
                else
                {
                    DisplayNotifyBox("Invalid Username or Password", "Could not sign in");
                }

                SetLoadingStatus(false);
            }).Start();
        }
        public bool SaveFTPConfig(string webdir, string username, string password)
        {
            try
            {
                Cryptography crypto = new Cryptography();
                FtpWebDirectory = webdir;
                FtpUser = username;
                FtpPassword = password;

                r = config.Options.Select("Key = '" + crypto.EncryptString(ftpWebdirKey) + "'")[0];
                r[1] = crypto.EncryptString(webdir);

                r = config.Options.Select("Key = '" + crypto.EncryptString(ftpUserKey) + "'")[0];
                r[1] = crypto.EncryptString(FtpUser);

                r = config.Options.Select("Key = '" + crypto.EncryptString(ftpPasswordKey) + "'")[0];
                r[1] = crypto.EncryptString(FtpPassword);

                WriteConfig();
                LoadConfig();

                return true;
            }
            catch
            {
                return false;
            }
        }
Example #16
0
        public bool AddClient(string name, string surname, string phone, string email, string password)
        {
            DatabaseManager dbManager = new DatabaseManager();
            Cryptography    crypto    = new Cryptography();

            return(dbManager.NonReturnQuery("INSERT INTO Clients (Client_Name , Client_Surname, Client_Phone, Client_Email, Client_Password) VALUES ('" + name + "','" + surname + "','" + phone + "','" + email + "','" + Cryptography.CreateHash(password) + "');"));
        }