Ejemplo n.º 1
0
        private void button_add_Click(object sender, RoutedEventArgs e)//add another button returns to clerk page again
        {
            //returns user to clerkhomepage without emptying the cart
            ClerkHome ch = new ClerkHome();

            ch.Show();
            this.Close();
        }
Ejemplo n.º 2
0
        private void button_yes_Click(object sender, RoutedEventArgs e)//yes cancel
        {
            //remove all items from cart
            BookData bd = new BookData();

            bd.ClearCart();
            listBox.Items.Clear();
            //send user back to clerk homepage
            ClerkHome ch = new ClerkHome();

            ch.Show();
            this.Close();
        }
Ejemplo n.º 3
0
        private void rect_confirm_btn_Click(object sender, RoutedEventArgs e)//processes the  order
        {
            string   value = rect_email_textBox.Text;
            Regex    rg    = new Regex("[a-zA-Z0-9]{1,25}@[a-zA-Z0-9]{1,25}.[a-zA-Z]{2,3}");//valid email layout
            DateTime today = DateTime.Today;

            if (rg.IsMatch(value) && (value.Contains(".com") || value.Contains(".net") || value.Contains(".edu") || value.Contains(".gov") || value.Contains(".org")) && value != "")
            {
                BookData      bd         = new BookData();
                List <string> isbns      = listISBNs();
                string        isbnholder = "";
                double        price      = Convert.ToDouble(label_totalCost.Content.ToString().Replace("$", ""));
                foreach (var item in isbns)
                {
                    bd.RentBook(item);
                    isbnholder += item + ",";
                }
                Boolean processed = bd.addRent(rect_fname_textBox.Text, rect_lname_textBox.Text, isbnholder, price, rect_email_textBox.Text, today);
                if (processed)
                {
                    MessageBox.Show("Order has been processed. " + label_numberOfBooks.Content + " books rented for a total price: " + label_totalCost.Content + ".\nReturn date: " + today.AddMonths(6).ToString("D"));
                    bd.ClearCart();
                    ClerkHome ch = new ClerkHome();
                    ch.Show();
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Error processing order.");
                }
            }
            else
            {
                MessageBox.Show("Please verify you entered the email correctly.");
            }
        }
Ejemplo n.º 4
0
        private void button_Click(object sender, RoutedEventArgs e)//login button
        {
            LoginPclass log = new LoginPclass();

            log.UserName = txtuname.Text;
            log.Password = passwordBox.Password;
            bool auth = log.AdminLogin(log.UserName, log.Password);

            if (txtuname.Text == "" || passwordBox.Password == "")//display errors
            {
                if (txtuname.Text == "")
                {
                    nameandpassword.Content = "";
                    username.Content        = "Username required";
                }
                else
                {
                    username.Content = "";
                }
                if (passwordBox.Password == "")
                {
                    nameandpassword.Content = "";
                    password.Content        = "Password required";
                }
                else
                {
                    password.Content = "";
                }
            }
            else
            {
                username.Content = "";
                password.Content = "";
                if (radAdmin.IsChecked == true)//admin login
                {
                    if (auth == true)
                    {
                        //send user to admin homepage
                        AdminHome adh = new AdminHome();
                        adh.Show();
                        this.Close();
                        //MessageBox.Show("user name and password correct");
                    }
                    else//invalid admin login credentials
                    {
                        username.Content        = "";
                        password.Content        = "";
                        nameandpassword.Content = ("Username or Password incorrect.");
                    }
                }
                else if (radUser.IsChecked == true)//user/clerk login
                {
                    log.UserName = txtuname.Text;
                    log.Password = passwordBox.Password;
                    Boolean authorized = log.UserLogin(log.UserName, log.Password);
                    if (authorized)
                    {
                        ClerkHome ch = new ClerkHome();
                        ch.Show();
                        this.Close();
                    }
                    else//invalid clerk login credentials
                    {
                        nameandpassword.Content = ("Username or Password incorrect.");
                    }
                }
            }
        }