private void AddButton(object sender, RoutedEventArgs e)
        {
            if(CategoryName.Text == "") 
            {
                MessageBox.Show("Please Enter A Category Name");
            }
            else // two cases if it already exit , else add it to database
            {
                sql_queries sql = new sql_queries("Data Source=(local);Initial Catalog=Auction_mangement_system;Integrated Security=True");
                bool found = sql.check_catagory(CategoryName.Text);

                if (found)
                {
                    MessageBox.Show("This Category is Already Exist");
                }
                else
                {
                    // e3mel query y insert Category *note that how we can make the combbobox change when insertion , delete
                    sql.Add_catagory(CategoryName.Text);
                    MessageBox.Show("Category Inserted Successfully");
                }
                

            }


        }
        private void log_in_btn(object sender, EventArgs e)
        {
            sql_queries query = new sql_queries("Data Source=(local);Initial Catalog=Auction_mangement_system;Integrated Security=True");

            if (!query.check_username_and_password(username_login_textbox.Text, password_login_passwordbox.Password))
            {
                MessageBox.Show("Invalid username or password");
            }
            else if (username_login_textbox.Text.ToLower() == "admin")
            {
                Admin_Home admin_Home = new Admin_Home();
                admin_Home.Show();
                this.Close();
            }
            else
            {
                DataTable dt = new DataTable();
                dt = query.profilename(username_login_textbox.Text);
                User.profilename = dt.Rows[0]["profile_name"].ToString();
                User.username    = dt.Rows[0]["username"].ToString();
                User.password    = dt.Rows[0]["password"].ToString();
                //  MessageBox.Show("The username is " + User.username + "   and the profilename is " + User.profilename);
                Home home = new Home();
                home.Show();
                this.Close();
            }
        }
        private void join(object sender, RoutedEventArgs e)
        {
            var         btn   = (Button)sender;
            var         x     = (product)btn.Tag;
            sql_queries query = new sql_queries("Data Source=(local);Initial Catalog=Auction_mangement_system;Integrated Security=True");

            query.delete_product(x.Id);
            MessageBox.Show("Deleted Successfully");
        }
        private void join(object sender, RoutedEventArgs e)
        {
            sql_queries query = new sql_queries("Data Source=(local);Initial Catalog=Auction_mangement_system;Integrated Security=True");
            var         btn   = (Button)sender;
            var         x     = (product)btn.Tag;
            DateTime    Start = Convert.ToDateTime(x.start_date);
            DateTime    End   = Convert.ToDateTime(x.end_date);
            int         t1    = DateTime.Compare(Start, DateTime.Now);
            int         t2    = DateTime.Compare(DateTime.Now, End);

            if (t1 > 0)
            {
                MessageBox.Show("The session didn't start yet");
            }
            else if (t2 < 0)
            {
                if (User.username == x.seller)
                {
                    MessageBox.Show("The seller can't bid for his product ! ");
                }
                else
                {
                    Session session = new Session(x.Id, x.photo, x.Title, x.Winner, x.price);
                    session.Show();
                    this.Close();
                }
            }
            else if (t2 > 0)
            {
                if (x.Winner == "")
                {
                    MessageBox.Show("No Participants !");
                }
                else if (x.Winner == User.username)
                {
                    SoundPlayer soundPlayer = new SoundPlayer("app-30.wav");
                    soundPlayer.LoadAsync();
                    soundPlayer.Play();
                    Result res = new Result(x.photo, x.Title, x.price, x.Winner);
                    res.Show();
                }
                else
                {
                    Result res = new Result(x.photo, x.Title, x.price, x.Winner);
                    res.Show();
                }
            }
        }
        public void validate_user(string new_name, string old_name, string type)
        {
            bool        valid = true;
            sql_queries query = new sql_queries("Data Source=(local);Initial Catalog=Auction_mangement_system;Integrated Security=True");

            for (int i = 0; i < new_name.Length; i++)
            {
                if (!char.IsDigit(new_name[i]) && !char.IsLetter(new_name[i]))
                {
                    valid = false;
                }
            }
            if (!valid)
            {
                MessageBox.Show("The username must contain only letters and digits !");
            }
            else if (new_name.Length == 0)
            {
                MessageBox.Show("Please enter the " + type);
            }
            else if (new_name.Length > 10 || new_name.Length < 5)
            {
                MessageBox.Show("The " + type + " must be between 5 and 10 characters");
            }
            else if (type == "username" && query.check_username(new_name))
            {
                MessageBox.Show("This username is already taken !");
            }
            else
            {
                query.update_user(new_name, old_name, type);
                if (type == "username")
                {
                    User.username = new_name;
                }
                else if (type == "profile_name")
                {
                    User.profilename = new_name;
                }
                else
                {
                    User.password = new_name;
                }
                MessageBox.Show("The " + type + " is updated successfully");
            }
        }
        public Admin_Home()
        {
            InitializeComponent();
            var products = GetProducts();

            if (products.Count > 0)
            {
                Listproduct.ItemsSource = products;
            }
            sql_queries query = new sql_queries("Data Source=(local);Initial Catalog=Auction_mangement_system;Integrated Security=True");
            DataTable   dt    = new DataTable();

            dt = query.Get_categories();
            foreach (DataRow dr in dt.Rows)
            {
                Category_Combobox.Items.Add(dr["category_name"]);
            }
        }
 private void Bid_Click(object sender, RoutedEventArgs e)
 {
     if (current_price_textbox.Text.Length == 0)
     {
         MessageBox.Show("Please Enter a value");
     }
     else if (Convert.ToDouble(current_price_textbox.Text) <= current_price)
     {
         MessageBox.Show("The entered price should be higher than the current price");
     }
     else
     {
         current_price = Convert.ToDouble(current_price_textbox.Text);
         sql_queries query = new sql_queries("Data Source=(local);Initial Catalog=Auction_mangement_system;Integrated Security=True");
         query.update_top_price(current_price, Id, User.username);
     }
     current_price_textbox.Text = "";
 }
        private List <product> GetProducts()
        {
            DataTable   dt    = new DataTable();
            sql_queries query = new sql_queries("Data Source=(local);Initial Catalog=Auction_mangement_system;Integrated Security=True");

            dt = query.Retrieve_products();
            List <product> list = new List <product>();
            BitmapImage    bmp  = new BitmapImage();

            foreach (DataRow dr in dt.Rows)
            {
                byte[] img = null;
                img = (byte[])(dr["photo"]);
                BitmapImage b = new BitmapImage();
                b = bytes_to_image(img);
                product p = new product(Convert.ToInt32(dr["ID"]), dr["Winner"].ToString(), dr["seller"].ToString(), dr["Title"].ToString(), Convert.ToDouble(dr["price"]), b, dr["category"].ToString(), dr["start_date"].ToString(), dr["end_date"].ToString(), dr["Descriptions"].ToString());
                list.Add(p);
            }
            return(list);
        }
Esempio n. 9
0
 private void RemoveButton(object sender, RoutedEventArgs e)
 {
     if (UserName.Text == "")
     {
         MessageBox.Show("Please Enter UserName");
     }
     else // two cases if it not found , else remove it from database
     {
         sql_queries sql   = new sql_queries("Data Source=(local);Initial Catalog=Auction_mangement_system;Integrated Security=True");
         bool        found = sql.check_username(UserName.Text);
         if (found) // e3mel delete query ll username
         {
             sql.Delete_user(UserName.Text);
             MessageBox.Show("User Removed Successfully");
         }
         else
         {
             MessageBox.Show("This UserName isn't Exist");
         }
     }
 }
Esempio n. 10
0
        private void RemoveButton(object sender, RoutedEventArgs e)
        {
            if (DeleteCategoryName.Text == "")
            {
                MessageBox.Show("Please Enter A Category Name");
            }
            else // two cases if exist delete else print not exist
            {
                sql_queries sql   = new sql_queries("Data Source=(local);Initial Catalog=Auction_mangement_system;Integrated Security=True");
                bool        found = sql.check_catagory(DeleteCategoryName.Text);
                if (found) // delete
                {
                    // e3mal query y delete el category

                    sql.Delete_catagory(DeleteCategoryName.Text);
                    sql.update_catagories(DeleteCategoryName.Text);
                    MessageBox.Show("Category Removed Successfully");
                }
                else
                {
                    MessageBox.Show("This Category isn't Exist");
                }
            }
        }
        public void validate_signup(string username, string password, string repassword, string profilenme)
        {
            bool        valid = true; string notvalid = "";
            sql_queries query = new sql_queries("Data Source=(local);Initial Catalog=Auction_mangement_system;Integrated Security=True");

            for (int i = 0; i < username.Length; i++)
            {
                if (!char.IsDigit(username[i]) && !char.IsLetter(username[i]))
                {
                    notvalid = "username";
                    valid    = false;
                }
            }
            for (int i = 0; i < password.Length; i++)
            {
                if (!char.IsDigit(password[i]) && !char.IsLetter(password[i]))
                {
                    notvalid = "password";
                    valid    = false;
                }
            }
            for (int i = 0; i < profilenme.Length; i++)
            {
                if (!char.IsDigit(profilenme[i]) && !char.IsLetter(profilenme[i]))
                {
                    notvalid = "profile_name";
                    valid    = false;
                }
            }

            if (!valid)
            {
                MessageBox.Show("The " + notvalid + " must contain only letters and digits !");
            }
            else if (username == "" || password == "" || profilenme == "")
            {
                MessageBox.Show("Fill the username , password and profile name first");
            }
            else if (password.Length > 10 || password.Length < 5)
            {
                MessageBox.Show("The password should be between 5 and 10 characters ");
            }
            else if (username.Length > 10 || username.Length < 5)
            {
                MessageBox.Show("The username should be between 5 and 10 characters ");
            }
            else if (profilenme.Length > 10 || profilenme.Length < 5)
            {
                MessageBox.Show("The profile name should be between 5 and 10 characters ");
            }
            else if (repassword.Length == 0)
            {
                MessageBox.Show("Confirm the password");
            }
            else if (repassword != password)
            {
                MessageBox.Show("The two password don't match !");
            }
            else
            {
                if (query.check_username(username))
                {
                    MessageBox.Show("This username is already taken!");
                }
                else
                {
                    query.insert_user_information(profilenme, username, password);
                    MessageBox.Show("Registrated successifly!");
                    Sign_in    signin     = new Sign_in();
                    MainWindow mainWindow = new MainWindow();
                    mainWindow.Close();
                    signin.Show();
                }
            }
        }