private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            string userName = txtLUName.Text;

            if (string.IsNullOrEmpty(userName))
            {
                MessageBox.Show("Please enter a User Name");
            }
            else
            {
                LogicTier.User u = database.getUser(userName);
                if (u == null)
                {
                    MessageBox.Show("Invalid User Name");
                }
                else
                {
                    var fromAddress = new MailAddress("*****@*****.**", "Neighborhood Informant");
                    try
                    {
                        var          toAddress    = new MailAddress(u.Email, u.FirstName + " " + u.LastName);
                        const string fromPassword = "******";
                        const string subject      = "Neighborhood Informant Password Reset";
                        const string body         = "Your password for has been changed to 123";
                        var          smtp         = new SmtpClient
                        {
                            Host                  = "smtp.gmail.com",
                            Port                  = 587,
                            EnableSsl             = true,
                            DeliveryMethod        = SmtpDeliveryMethod.Network,
                            UseDefaultCredentials = false,
                            Credentials           = new NetworkCredential(fromAddress.Address, fromPassword),
                            Timeout               = 20000
                        };
                        try
                        {
                            using (var message = new MailMessage(fromAddress, toAddress)
                            {
                                Subject = subject,
                                Body = body
                            })
                            {
                                smtp.Send(message);
                            }
                            database.changePassword(u, "123");
                            MessageBox.Show("Password has been reset and emailed to " + u.Email);
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show("Unable to send email to " + u.Email);
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Unable to send email to " + u.Email);
                    }
                }
            }
        }
 private void logoff()
 {
     currUser = null;
     btnMessageSearch.Visible  = false;
     btnSearchLogin.Visible    = true;
     btnSearchLogOff.Visible   = false;
     buttonGoToLogin.Enabled   = true;
     buttonToMessages.Enabled  = false;
     buttonMapMessage.Visible  = false;
     buttonBuyerLogoff.Visible = false;
     buttonSeller.Enabled      = false;
     buttonBToSettings.Visible = false;
 }
 /**
  * Login Button on login page
  *
  **/
 private void buttonLogin_Click(object sender, EventArgs e)
 {
     currUser = database.login(txtLUName.Text, txtLPass.Text);
     if (currUser == null)
     {
         MessageBox.Show("Invalid user name and/or password. Please check your credentials!");
     }
     else
     {
         login();
         clearLogin();
         if (currUser.Seller)// seller
         {
             buttonSeller.Enabled = true;
             if (prevPage == panelSearch)// coming from search page
             {
                 panelSearch.Show();
             }
             else// coming from home page
             {
                 dataGridView1.DataSource          = null;
                 dataGridView1.DataSource          = database.listingsFromUser(currUser);
                 dataGridView1.AutoGenerateColumns = false;
                 panelSellerHome.Show();
             }
         }
         else// buyer
         {
             if (prevPage == panelSearch)// coming from search page
             {
                 panelSearch.Show();
             }
             else// coming from home page
             {
                 panelBuyerHome.Show();
             }
         }
         panelLogin.Hide();
         prevPage = panelLogin;
     }
 }
        private void buttonChangePassword_Click(object sender, EventArgs e)
        {
            string nPass = textBoxChangePass.Text;

            if (string.IsNullOrEmpty(nPass))
            {
                MessageBox.Show("Error: Please enter a vaild password");
            }
            else
            {
                if (database.changePassword(currUser, nPass))
                {
                    MessageBox.Show("Password has been changed");
                    currUser = database.login(currUser.UserName, nPass);
                }
                else
                {
                    MessageBox.Show("Error: Please enter a vaild password");
                }
            }
        }
        private void buttonChangeUName_Click(object sender, EventArgs e)
        {
            string nUName = textBoxSUName.Text;

            if (string.IsNullOrEmpty(nUName))
            {
                MessageBox.Show("Error: Please enter a vaild user name");
            }
            else
            {
                if (database.changeUserName(currUser, nUName))
                {
                    MessageBox.Show("User Name has been changed to: " + nUName);
                    currUser = database.login(nUName, currUser.Password);
                }
                else
                {
                    MessageBox.Show("Error: Please enter a vaild user name");
                }
            }
        }
        public Form1()
        {
            //set up UI
            InitializeComponent();
            panelRegistration.Hide();
            panelLogin.Hide();
            panelSearch.Hide();
            panelListing.Hide();
            panelSellerHome.Hide();
            panelMap.Hide();
            panelBuyerHome.Hide();
            panelSendMessage.Hide();
            panelMessage.Hide();
            panelSettings.Hide();

            comboBoxMin.SelectedIndex            = 0;
            comboBoxMax.SelectedIndex            = 14;
            comboBoxSqMin.SelectedIndex          = 0;
            comboBoxSqMax.SelectedIndex          = 10;
            comboBoxSearchBathsMin.SelectedIndex = 0;
            comboBoxSearchBathsMax.SelectedIndex = 18;
            comboBoxSearchBedsMin.SelectedIndex  = 0;
            comboBoxSearchBedsMax.SelectedIndex  = 9;
            //comboBoxRType.SelectedIndex = 0;


            //set up data export file
            exportFile = null;
            //set up database and user info
            database               = new LogicTier.DataAPI();
            currUser               = null;
            currListing            = null;
            currMessage            = null;
            prevPage               = panelHome;
            pictureBoxSearch.Image = Image.FromFile(@"C:\Users\minuf\Documents\Visual Studio 2013\Projects\NeighborhoodInformant\NeighborhoodInformant\bin\Debug\homeforsale.jpg");
            pictureBoxMap.Image    = Image.FromFile(@"C:\Users\minuf\Documents\Visual Studio 2013\Projects\NeighborhoodInformant\NeighborhoodInformant\bin\Debug\homeforsale.jpg");
        }