private void RejectOffer()
    {
        //sends an email to the person making the offer and delete the offer from the database
        //
        //var to store the email address of the person making the offer
        string OfferEMail;
        //var to store the user name of the person making the offer
        string OfferUserName;
        //var to store the title of the offer
        string OfferTitle;
        //declare an instance of my email object
        clsEMail AnEMail = new clsEMail();
        //var to store successful sending of the email
        Boolean Success;

        //get the email address of the person making the offer
        OfferEMail = GetOfferEMail(OfferNo);
        //get the user name of the person making the offer
        OfferUserName = GetOfferUserName(OfferNo);
        //get the title of the item on offer
        OfferTitle = GetOfferTitle(OfferNo);
        //send a rejection email to the person who made the offer
        Success = AnEMail.SendEMail("dvd.mdb", OfferEMail, "Your swap shop offer", ThisSite.SiteOwner + " has declined your offer of " + OfferTitle);
        //find the record for this offer in the database
        clsDataConnection AnOffer = new clsDataConnection("select * from offer where offerno=" + OfferNo);

        //if the record is found
        if (AnOffer.Count == 1)
        {
            //delete it
            AnOffer.RemoveRecord(0);
            //save the changes
            AnOffer.SaveChanges();
        }
    }
Example #2
0
    //create SignUp here

    //Create GetHashString here
    public string SignUp(string Email, string Password, string PasswordConfirm)
    //public method allowing the user to sign up for an account
    {
        //var to store any errors
        string ErrorMsg = "";

        //if the two passwords match
        if (Password == PasswordConfirm)
        {
            //get the hash of the plain text password
            string HashPassword = GetHashString(Password + Email);
            //add the record to the database
            clsDataConnection DB = new clsDataConnection("select * from Users");
            DB.NewRecord["Email"]        = Email;
            DB.NewRecord["UserPassword"] = HashPassword;
            DB.AddNewRecord();
            DB.SaveChanges();
        }
        //if the passwords do not match
        else
        {
            //generate an error message
            ErrorMsg = "The passwords do not match.";
        }
        //return the error message (if there is one)
        return(ErrorMsg);
    }
    public bool SendEMail(string SenderEMail, string RecipientEMail, string SubjectLine, string Message)
    {
        clsDataConnection DB = new clsDataConnection("select * from tblEmail");

        DB.NewRecord["SenderEMail"]    = SenderEMail;
        DB.NewRecord["RecipientEMail"] = RecipientEMail;
        DB.NewRecord["SubjectLine"]    = SubjectLine;
        DB.NewRecord["Message"]        = Message;
        DB.AddNewRecord();
        DB.SaveChanges();
        return(true);
    }
    private void AddWishListItem(string WishListItem)
    {
        //this sub adds a wish list item to the database
        //
        //open the wish list table
        clsDataConnection WishList = new clsDataConnection("select * from wishlist");

        //set the description
        WishList.NewRecord["Description"] = WishListItem;
        //add the record
        WishList.AddNewRecord();
        //save the changes
        WishList.SaveChanges();
    }
    void ChangePassword(string EMail, string NewPW)
    {
        //this sub changes the password for the user specified by their email address
        //find that user in the database
        clsDataConnection AUser = new clsDataConnection("select * from Users where EMail='" + EMail + "'");

        //if the user has been found
        if (AUser.Count == 1)
        {
            //change the password
            AUser.DataTable.Rows[0]["UserPassword"] = NewPW;
            //save the changes
            AUser.SaveChanges();
        }
    }
    private void RemoveWishListItem(int WishListID)
    {
        //this sub removes a wish list item identified by wish list id (primary key)
        //
        //open a connection to the wish list table
        clsDataConnection WishList = new clsDataConnection("select * from wishlist where wishlistno=" + WishListID);

        //if the record is found
        if (WishList.Count == 1)
        {
            //remove the record
            WishList.RemoveRecord(0);
            //save the changes
            WishList.SaveChanges();
        }
    }
Example #7
0
    private void DeleteSwap()
    {
        //this sub deletes the swap identified by swapno
        //
        //find the record in the database
        clsDataConnection ASwap = new clsDataConnection("select * from swap where swapno=" + SwapNo);

        //if the record is found
        if (ASwap.Count == 1)
        {
            //remove the record
            ASwap.RemoveRecord(0);
            //save the changes
            ASwap.SaveChanges();
        }
    }
    private void AddSwap(string SwapTitle, string SwapDescription, string ImageFile)
    {
        //this sub adds a new swap to the swap table
        //
        //open a connection to the swap table
        clsDataConnection Swaps = new clsDataConnection("select * from swap");

        //set the title
        Swaps.NewRecord["Title"] = SwapTitle;
        //set the description
        Swaps.NewRecord["Description"] = SwapDescription;
        //set the name of the image file
        Swaps.NewRecord["ImageFile"] = ImageFile;
        //add the record
        Swaps.AddNewRecord();
        //save the changes
        Swaps.SaveChanges();
    }
    private void UpdateSwap(string SwapTitle, string SwapDescription, string ImageFile)
    {
        //this sub adds a new swap to the swap table
        //
        //open a connection to the swap table
        clsDataConnection Swaps = new clsDataConnection("select * from swap where swapno=" + SwapNo);

        if (Swaps.Count == 1)
        {
            //set the title
            Swaps.DataTable.Rows[0]["Title"] = SwapTitle;
            //set the description
            Swaps.DataTable.Rows[0]["Description"] = SwapDescription;
            //set the name of the image file
            Swaps.DataTable.Rows[0]["ImageFile"] = ImageFile;
            //save the changes
            Swaps.SaveChanges();
        }
    }
Example #10
0
    private void SaveOffer(int SwapNo, int UserNo, string OfferTitle, string OfferDescription)
    {
        //this sub saves the offer to the database
        //
        //open a connection to the database table
        clsDataConnection Offers = new clsDataConnection("select * from offer");

        //save the swap no to the new record
        Offers.NewRecord["SwapNo"] = SwapNo;
        //save the user no to the new record
        Offers.NewRecord["UserNo"] = UserNo;
        //save the offer title to the new record
        Offers.NewRecord["Title"] = OfferTitle;
        //save the offer description to the new record
        Offers.NewRecord["Description"] = OfferDescription;
        //add the new record
        Offers.AddNewRecord();
        //save the new record
        Offers.SaveChanges();
    }
    private void CreateAccount(string FirstName, string LastName, string EMail, string Password)
    {
        //this sub creates a new account for the user
        //accepts four parameters FirstName LastName EMail and Password
        //
        //create a connection to the database table users
        clsDataConnection Users = new clsDataConnection("select * from users");

        //store the first name in the new record object
        Users.NewRecord["FirstName"] = FirstName;
        //store the last name in the new record object
        Users.NewRecord["LastName"] = LastName;
        //stor the email in the new record object
        Users.NewRecord["EMail"] = EMail;
        //store the password
        Users.NewRecord["UserPassword"] = Password;
        //add the new record
        Users.AddNewRecord();
        //save the changes (the new user is added to the database)
        Users.SaveChanges();
    }
Example #12
0
    private void AcceptOffer(int SwapNo, int OfferNo)
    {
        //this sub accepst an offer made on a swap
        //it accepts two parameters the swap number and the offer number
        //it sends an email to the person making the offer
        //and another email to the site owner
        //the offer is date stamped so that the site owner knows when the offer was accepted
        //
        //my email object used to send emails
        clsEMail AnEmail = new clsEMail();
        //var to store the email address of the person making the offer
        string OfferEMail;
        //var to store the title of the offered item
        string OfferTitle;
        //var to store the title of the swap
        string SwapTitle;
        //var to store the name of the person making the offer
        string OfferUserName;

        //get the email address of the person making the offer
        OfferEMail = GetOfferEMail(OfferNo);
        //get the title of the item being swapped
        SwapTitle = GetSwapTitle(SwapNo);
        //get the title of the item being offered
        OfferTitle = GetOfferTitle(OfferNo);
        //get the name of the person making the offer
        OfferUserName = GetOfferUserName(OfferNo);
        //construct and send an acceptance email to the person making the offer
        AnEmail.SendEMail(ThisSite.OwnerEMail, OfferEMail, "Your offer has been accepted", ThisSite.SiteOwner + " has accepted your offer of " + OfferTitle + " for " + SwapTitle + " please reply to this email to arrange the exchange.");
        //construct and send an email to the owner of the site
        AnEmail.SendEMail(OfferEMail, ThisSite.OwnerEMail, "You have accepted my offer", OfferUserName + " is going to swap " + OfferTitle + " for " + SwapTitle + " reply to this message to arrange an exchange.");
        //date stamp the swap
        //open a connection to the database finding the record for this offer
        clsDataConnection AnOffer = new clsDataConnection("select * from Offer where OfferNo = " + OfferNo);

        //date stamp the offer
        AnOffer.DataTable.Rows[0]["AcceptanceDate"] = DateTime.Now.Day + "/" + DateTime.Now.Month + "/" + DateTime.Now.Year;
        //save the changes
        AnOffer.SaveChanges();
    }