public static void EndSession()
        {
            DatabaseCon con = new DatabaseCon();

            con.OpenConnection();
            con.ExecuteQueries("UPDATE Session SET active = 0");
            con.CloseConnection();
        }
예제 #2
0
        public void UpdateUserCred(string _Username, string _Password)
        {
            DatabaseCon con = new DatabaseCon();

            con.OpenConnection();
            con.ExecuteQueries("UPDATE User_Cred SET username='******',passwords='" + _Password + "' where username='******'");
            con.CloseConnection();
        }
        public static void AddNewContact(string name, string code)
        {
            DatabaseCon con = new DatabaseCon();

            con.OpenConnection();
            con.ExecuteQueries("insert into Contacts (contact_name,contact_code) values ('" + name + "', '" + code + "')");
            con.CloseConnection();
        }
예제 #4
0
        public void UpdateUserInfo(string _FirstName, string _LastName, string _Username, string _Email, string _ShareCode)
        {
            DatabaseCon con = new DatabaseCon();

            con.OpenConnection();
            con.ExecuteQueries("UPDATE Users SET first_name='" + _FirstName + "',last_name='" + _LastName + "',username='******',email='" + _Email + "',share_code='" + _ShareCode + "' where username='******'");
            con.CloseConnection();
        }
예제 #5
0
        public void AddUserInfo(string _FirstName, string _LastName, string _Username, string _Email, string _ShareCode)
        {
            DatabaseCon con = new DatabaseCon();

            con.OpenConnection();
            con.ExecuteQueries("insert into Users (first_name,last_name,username,email,share_code) values ('" + _FirstName + "','" + _LastName + "','" + _Username + "','" + _Email + "','" + _ShareCode + "')");
            con.CloseConnection();
        }
        public static void DeleteContact(string name)
        {
            DatabaseCon con = new DatabaseCon();

            con.OpenConnection();
            con.ExecuteQueries("delete from Contacts where contact_name='" + name + "'");
            con.CloseConnection();
        }
        public static void CreateSession(string username, string time, int active)
        {
            DatabaseCon con = new DatabaseCon();

            con.OpenConnection();
            con.ExecuteQueries("insert into Session values('" + username + "','" + time + "',1)");
            con.CloseConnection();
        }
예제 #8
0
        public void AddUserCred(string _Username, string _Password)
        {
            DatabaseCon con = new DatabaseCon();

            con.OpenConnection();
            con.ExecuteQueries("insert into User_Cred values ('" + _Username + "','" + _Password + "')");
            con.CloseConnection();
        }
        public static void AddMyFile(string path)
        {
            DatabaseCon con = new DatabaseCon();

            con.OpenConnection();
            con.ExecuteQueries("insert into my_files (file_path) values ('" + path + "')");
            con.CloseConnection();
        }
예제 #10
0
        public bool CheckLoginValidity(string username, string password)
        {
            DatabaseCon con = new DatabaseCon();

            con.OpenConnection();
            SqlDataReader rd = con.DataReader("select * from User_Cred where username='******' and passwords='" + password + "'");

            if (rd.Read())
            {
                rd.Close();
                con.CloseConnection();
                return(true);
            }
            return(false);
        }
예제 #11
0
        public bool SelectUsername(string username)
        {
            DatabaseCon con = new DatabaseCon();

            con.OpenConnection();
            SqlDataReader rd = con.DataReader("select * from User_Cred where username='******'");

            if (rd.HasRows)
            {
                rd.Close();
                con.CloseConnection();
                return(true);
            }
            return(false);
        }
        public static bool HasSession()
        {
            DatabaseCon con = new DatabaseCon();

            con.OpenConnection();
            SqlDataReader read = con.DataReader("select * from Session");

            if (read.Read())
            {
                read.Close();
                con.CloseConnection();
                return(true);
            }
            return(false);
        }
예제 #13
0
        public bool SelectEmail(string email)
        {
            DatabaseCon con = new DatabaseCon();

            con.OpenConnection();
            SqlDataReader rd = con.DataReader("select * from Users where email='" + email + "'");

            if (rd.HasRows)
            {
                rd.Close();
                con.CloseConnection();
                return(true);
            }
            return(false);
        }
        public static List <string> GetAllContactList()
        {
            List <string> contacts = new List <string>();
            DatabaseCon   con      = new DatabaseCon();

            con.OpenConnection();
            SqlDataReader read = con.DataReader("select * from Contacts");

            while (read.Read())
            {
                contacts.Add((string)read["contact_name"]);
            }
            read.Close();
            con.CloseConnection();
            return(contacts);
        }
        public static string GetShareCode(string name)
        {
            string      code = "";
            DatabaseCon con  = new DatabaseCon();

            con.OpenConnection();
            SqlDataReader read = con.DataReader("select contact_code from Contacts where contact_name='" + name + "'");

            while (read.Read())
            {
                code = (string)read["contact_code"];
            }
            read.Close();
            con.CloseConnection();
            return(code);
        }
        public static int VersionCount(string path)
        {
            DatabaseCon con = new DatabaseCon();

            con.OpenConnection();
            SqlDataReader read    = con.DataReader("select * from version where file_id=(select file_id from my_files where file_path='" + path + "')");
            int           counter = 0;

            while (read.Read())
            {
                counter++;
            }
            con.CloseConnection();
            read.Close();
            return(counter);
        }
        public static List <string> GetMyFilePath()
        {
            DatabaseCon con = new DatabaseCon();

            con.OpenConnection();
            List <string> path = new List <string>();
            SqlDataReader read = con.DataReader("select * from my_files");

            while (read.Read())
            {
                path.Add((string)read["file_path"]);
            }
            read.Close();
            con.CloseConnection();
            return(path);
        }
        public static bool IsExist(string name, string code)
        {
            DatabaseCon con = new DatabaseCon();

            con.OpenConnection();
            SqlDataReader read = con.DataReader("select * from Contacts where contact_name='" + name + "' or contact_code='" + code + "'");

            if (read.Read())
            {
                read.Close();
                con.CloseConnection();
                return(true);
            }
            read.Close();
            con.CloseConnection();
            return(false);
        }
        public static string CurrentSession()
        {
            string      username = null;
            DatabaseCon con      = new DatabaseCon();

            con.OpenConnection();
            SqlDataReader read = con.DataReader("select username from Session where active = 1");

            if (read.Read())
            {
                username = (string)read["username"];
                Console.WriteLine(username);
            }
            read.Close();
            con.CloseConnection();

            return(username);
        }
        public static void AddFileVersion(string parent, string child)
        {
            DatabaseCon con = new DatabaseCon();

            con.OpenConnection();
            SqlDataReader read   = con.DataReader("select * from my_files where file_path='" + parent + "'");
            int           FileID = -1;

            while (read.Read())
            {
                FileID = (int)read["file_id"];
            }
            read.Close();
            if (FileID >= 0)
            {
                con.ExecuteQueries("insert into version (file_id,file_path) values (" + FileID + ",'" + child + "')");
            }
            con.CloseConnection();
        }
예제 #21
0
        public static Users GetUserInformation()
        {
            Users       usr = new Users();
            DatabaseCon con = new DatabaseCon();

            con.OpenConnection();

            SqlDataReader read = con.DataReader("select * from Users where username='******'");

            while (read.Read())
            {
                usr.FirstName = (string)read["first_name"];
                usr.LastName  = (string)read["last_name"];
                usr.Username  = (string)read["username"];
                usr.Email     = (string)read["email"];
                usr.ShareCode = (string)read["share_code"];
                Console.WriteLine("Username: " + usr.ShareCode);
            }
            con.CloseConnection();
            return(usr);
        }
        public static string SelectedVersionPath(string path, int index)
        {
            List <string> dirs = new List <string>();
            DatabaseCon   con  = new DatabaseCon();

            con.OpenConnection();
            SqlDataReader read   = con.DataReader("select * from my_files where file_path='" + path + "'");
            int           FileID = -1;

            while (read.Read())
            {
                FileID = (int)read["file_id"];
            }
            read.Close();

            SqlDataReader readx = con.DataReader("select file_path from version where file_id=" + FileID + "");

            while (readx.Read())
            {
                dirs.Add((string)readx["file_path"]);
            }
            readx.Close();
            return(dirs[index]);
        }