Esempio n. 1
0
        // METHOD TO FILTER THE PRODUCT BY THE PRICE PROVIDED
        private void button8_Click(object sender, EventArgs e)
        {
            decimal.TryParse(textBox5.Text, out decimal d);
            try
            {
                if (textBox5.Text != "")
                {
                    if (d > 0 && decimal.TryParse(textBox5.Text, out decimal _))
                    {
                        // Method to filter the product list by the price inputted
                        this.dataGridView1.DataSource = ResProd.FilterProductByPrice(d);
                        textBox5.Text = "";
                    }
                }

                else
                {
                    // Method to populate back the product list by its offset
                    this.dataGridView1.DataSource = ResProd.GetAllProductByOffSet(Offset, Span);
                    textBox5.Text = "";
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Invalid Details");
            }
        }
Esempio n. 2
0
        // METHOD TO ADD PRODUCT
        private void button1_Click(object sender, EventArgs e)
        {
            decimal.TryParse(textBox2.Text, out decimal d);

            try
            {
                if (textBox1.Text != "" && textBox2.Text != "")
                {
                    if (d > 0 && decimal.TryParse(textBox2.Text, out decimal _))
                    {
                        // Method to add to the Product table
                        ResProd.AddProduct(textBox1.Text, d);
                        // Method to Populate the Data Grid View
                        this.dataGridView1.DataSource = ResProd.GetAllProductByOffSet(Offset, Span);
                        MessageBox.Show("Product Added Successfully");
                    }
                    else
                    {
                        MessageBox.Show("Enter a Positive Value");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Fill all the Boxes available");
            }

            // Change the text to empty string
            textBox1.Text = "";
            textBox2.Text = "";
        }
Esempio n. 3
0
        // METHOD TO EDIT AND UPDATE PRODUCT
        private void button2_Click(object sender, EventArgs e)
        {
            decimal.TryParse(textBox3.Text, out decimal d);

            try
            {
                if (textBox3.Text != "" && textBox4.Text != "")
                {
                    if (d > 0 && decimal.TryParse(textBox3.Text, out decimal _))
                    {
                        // Method to edit to the Product table
                        ResProd.EditProduct(ID, textBox4.Text, d);
                        // Method to Populate the Data Grid View
                        this.dataGridView1.DataSource = ResProd.GetAllProductByOffSet(Offset, Span);
                        MessageBox.Show("Product Updated Successfully");
                    }
                    else
                    {
                        MessageBox.Show("Invalid Details");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Fill all the Boxes Available");
            }

            // Change the Text Box Data
            textBox3.Text = "";
            textBox4.Text = "";
        }
Esempio n. 4
0
 // METHOD TO PERFORM WHEN THE FORM LOAD
 private void ShoppingCartUI_Load(object sender, EventArgs e)
 {
     // Open the connection
     Conn.OpenConnection();
     ResProd.GetAllProduct();
     this.dataGridView1.DataSource = ResProd.GetAllProductByOffSet(Offset, Span);
     this.dataGridView2.DataSource = ResCart.GetAllCart();
     // Close the connection
     Conn.CloseConnection();
 }
Esempio n. 5
0
 // METHOD TO GO PREVIOUS OF PRODUCTLIST
 private void button6_Click(object sender, EventArgs e)
 {
     try
     {
         Offset -= 5;
         this.dataGridView1.DataSource = ResProd.GetAllProductByOffSet(Offset, Span);
     }
     catch (Exception)
     {
         Offset += 5;
     }
 }
Esempio n. 6
0
        // METHOD TO GO NEXT OF PRODUCTLIST
        private void button7_Click(object sender, EventArgs e)
        {
            Offset += 5;
            var list = ResProd.GetAllProductByOffSet(Offset, Span);

            if (list.Count == 0)
            {
                Offset -= 5;
                list    = ResProd.GetAllProductByOffSet(Offset, Span);
            }
            this.dataGridView1.DataSource = list;
        }
Esempio n. 7
0
        // METHOD TO REMOVE FROM PRODUCT
        private void button3_Click(object sender, EventArgs e)
        {
            if (ID > 0)
            {
                // Method to remove from the Product table
                ResProd.RemoveProduct(ID);
                // Method to Populate the Data Grid View
                this.dataGridView1.DataSource = ResProd.GetAllProductByOffSet(Offset, Span);
                this.dataGridView2.DataSource = ResCart.GetAllCart();

                MessageBox.Show("Product Deleted Successfully");
            }
            else
            {
                MessageBox.Show("Invalid Details");
            }
        }
Esempio n. 8
0
 // METHOD TO FILTER THE PRODUCT BY THE NAME PROVIDED
 private void button9_Click(object sender, EventArgs e)
 {
     try
     {
         if (textBox5.Text != "")
         {
             // Method to filter the product list by the name inputted
             this.dataGridView1.DataSource = ResProd.FilterProductByProductName(textBox5.Text);
             textBox5.Text = "";
         }
         else
         {
             // Method to populate back the product list by its offset
             this.dataGridView1.DataSource = ResProd.GetAllProductByOffSet(Offset, Span);
             textBox5.Text = "";
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Invalid Details                                                                                                                                                                                                                                ");
     }
 }
Esempio n. 9
0
 // METHOD TO REFRESH THE PRODUCT DATAGRIDVIEW
 private void button10_Click(object sender, EventArgs e)
 {
     this.dataGridView1.DataSource = ResProd.GetAllProductByOffSet(Offset, Span);
 }