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

            con.OpenConnection();
            con.ExecuteQueries("UPDATE Session SET active = 0");
            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 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();
        }
        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();
        }
        public static void AddMyFile(string path)
        {
            DatabaseCon con = new DatabaseCon();

            con.OpenConnection();
            con.ExecuteQueries("insert into my_files (file_path) values ('" + path + "')");
            con.CloseConnection();
        }
Exemplo n.º 6
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);
        }
Exemplo n.º 7
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);
        }
        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);
        }
Exemplo n.º 9
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> 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 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 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 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 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();
        }
Exemplo n.º 17
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]);
        }