Esempio n. 1
0
 /// <summary>
 /// init all data
 /// </summary>
 private void InitializeAllData()
 {
     listProducts             = ProductsLAO.GetAllProducts();
     dataGridView1.DataSource = null;
     dataGridView1.DataSource = listProducts;
     currentStatus            = FormStatus.nonstatus;
 }
        private void btnSearch_Click(object sender, EventArgs e)
        {
            dataGridView1.DataSource = null;
            prod.Clear();
            if (comboBox1.Text == string.Empty || textBox1.Text == string.Empty)
            {
                prod = ProductsLAO.GetAllProducts();
            }
            else
            {
                if (comboBox1.Text.ToLower() == "product id")
                {
                    Product p = new Product();
                    p = ProductsLAO.getProductById(Int32.Parse(textBox1.Text));
                    prod.Add(p);
                }
                else // product name
                {
                    Product p = new Product();
                    p = ProductsLAO.getProductByName(textBox1.Text);
                    prod.Add(p);
                }
            }

            dataGridView1.DataSource = null;
            dataGridView1.DataSource = prod;
        }
Esempio n. 3
0
 /// <summary>
 /// save button onclick
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (currentStatus == FormStatus.editing)
     {
         Product p = new Product();
         p.Instruction = txt_descrip.Text;
         p.ProductId   = Int32.Parse(txt_id.Text);
         p.ProductName = txt_Name.Text;
         p.UnitPrice   = float.Parse(txt_Price.Text);
         p.UnitType    = txt_Unit.Text.ToString();
         ProductsLAO.UpdateProduct(p);
         MessageBox.Show("Updated", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
     if (currentStatus == FormStatus.adding)
     {
         Product p = new Product();
         p.Instruction = txt_descrip.Text;
         p.ProductId   = Int32.Parse(txt_id.Text);
         p.ProductName = txt_Name.Text;
         p.UnitPrice   = float.Parse(txt_Price.Text);
         p.UnitType    = txt_Unit.Text.ToString();
         ProductsLAO.AddNewProduct(p);
         currentStatus = FormStatus.nonstatus;
         MessageBox.Show("Saved", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
     listProducts             = ProductsLAO.GetAllProducts();
     dataGridView1.DataSource = null;
     dataGridView1.DataSource = listProducts;
 }
Esempio n. 4
0
 /// <summary>
 /// add button
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnAdd_Click(object sender, EventArgs e)
 {
     SetComponentsStatus(true);
     currentStatus = FormStatus.adding;
     extenstions.ClearControls(Controls);
     dataGridView1.DataSource = listProducts;
     nextProductId            = ProductsLAO.getProductCurrentVal();
     txt_id.Text = nextProductId.ToString();
 }
Esempio n. 5
0
        /// <summary>
        /// delete button onclick
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnDelete_Click(object sender, EventArgs e)
        {
            Product temProduct = new Product();

            temProduct = listProducts[currentSelectedIndex];
            ProductsLAO.RemoveProductById(temProduct.ProductId);
            //listProducts.RemoveAt(currentSelectedIndex);
            listProducts             = ProductsLAO.GetAllProducts();
            dataGridView1.DataSource = null;
            dataGridView1.DataSource = listProducts;
        }
Esempio n. 6
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (textBox1.Text == string.Empty)
     {
         MessageBox.Show("Input the right price", "OK", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else
     {
         ProductsLAO.UpdateAllPrice(float.Parse(textBox1.Text));
         MessageBox.Show("Saved", "OK", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Esempio n. 7
0
 private void InitializeAllData()
 {
     listOrder = OrderLAO.GetAllOrders();
     dataGridView1.DataSource = null;
     dataGridView1.DataSource = listOrder;
     but_GetCustomer.Enabled  = false;
     cb_cusId.Visible         = false;
     cb_cusId.Enabled         = false;
     btn_add.Enabled          = false;
     btn_delete.Enabled       = false;
     e_custName.Enabled       = false;
     e_custName.ReadOnly      = true;
     o_number.Enabled         = false;
     listProduct = ProductsLAO.GetAllProducts();
 }