Ejemplo n.º 1
0
        // function to insert a new user
        public bool insertUser(string fname, string lname, string username, string password, MemoryStream picture)
        {
            SqlCommand command = new SqlCommand("INSERT INTO [user](fname, lname, username, pass, pic) VALUES(@fn, @ln, @un, @pass, @pic)", db.getConnection);


            command.Parameters.AddWithValue("@id", USERID);
            command.Parameters.AddWithValue("@fn", fname);
            command.Parameters.AddWithValue("@ln", lname);
            command.Parameters.AddWithValue("@un", username);
            command.Parameters.AddWithValue("@pass", password);
            command.Parameters.AddWithValue("@pic", picture.ToArray());

            db.openConnection();

            if (command.ExecuteNonQuery() == 1)
            {
                db.closeConnection();
                return(true);
            }
            else
            {
                db.closeConnection();
                return(false);
            }
        }
Ejemplo n.º 2
0
        // function to insert a new contact
        public bool insertContact(string fname, string lname, string phone, string address, string email, int userid, int groupid, MemoryStream picture)
        {
            SqlCommand command = new SqlCommand("INSERT INTO [mycontact](fname, lname, group_id, phone, email, address, pic, userid) VALUES (@fn, @ln, @grp, @phn, @mail, @adrs, @pic, @uid)", mydb.getConnection);

            command.Parameters.AddWithValue("@fn", fname);
            command.Parameters.AddWithValue("@ln", lname);
            command.Parameters.AddWithValue("@grp", groupid);
            command.Parameters.AddWithValue("@phn", phone);
            command.Parameters.AddWithValue("@mail", email);
            command.Parameters.AddWithValue("@adrs", address);
            command.Parameters.AddWithValue("@uid", userid);
            command.Parameters.AddWithValue("@pic", picture.ToArray());

            mydb.openConnection();

            if ((command.ExecuteNonQuery() == 1))
            {
                mydb.closeConnection();
                return(true);
            }
            else
            {
                mydb.closeConnection();
                return(false);
            }
        }
Ejemplo n.º 3
0
        // function to insert a new group for a specific user
        public bool insertGroup(string gname, int userid)
        {
            SqlCommand command = new SqlCommand("INSERT INTO [mygroups](name, userid) VALUES (@gn, @uid)", mydb.getConnection);

            command.Parameters.AddWithValue("@gn", gname);
            command.Parameters.AddWithValue("@uid", userid);

            mydb.openConnection();

            if (command.ExecuteNonQuery() == 1)
            {
                mydb.closeConnection();
                return(true);
            }
            else
            {
                mydb.closeConnection();
                return(false);
            }
        }