Exemplo n.º 1
0
        private void _btnDelete_Click(object sender, EventArgs e)
        {
            if (_lvProducts.SelectedItems.Count > 0)
            {
                DialogResult confirm = MessageBox.Show("Are you sure you want to delete this product?",
                                                       "Delete Confirmation", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
                if (confirm == DialogResult.OK)
                {
                    Product      product = new Product();
                    ListViewItem item    = _lvProducts.SelectedItems[0];
                    product = (Product)item.Tag;
                    bool deleted = db.deleteProduct(product.Id);

                    if (deleted)
                    {
                        products.Remove(product);
                    }
                }
            }
            else
            {
                MessageBox.Show("Select a product from the list to delete.", "Product not selected",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            _lvProducts.Items.Clear();
            ListProducts();
            ControlUtil.DisableButtons(_btnSave, _btnEdit, _btnDelete);
            ControlUtil.EnableButtons(_btnNew);
            ControlUtil.ClearTextBoxes(_txtName, _txtPrice, _txtDescription);
            ControlUtil.DisableTextBoxes(_txtName, _txtPrice, _txtDescription);
            _cbOrganic.Checked = false;
            _cbOrganic.Enabled = false;
        }
Exemplo n.º 2
0
 private void ProductForm_Load(object sender, EventArgs e)
 {
     ControlUtil.DisableButtons(_btnSave, _btnEdit, _btnDelete);
     ControlUtil.EnableButtons(_btnNew);
     ControlUtil.ClearTextBoxes(_txtName, _txtPrice, _txtDescription);
     ControlUtil.DisableTextBoxes(_txtName, _txtPrice, _txtDescription);
     _cbOrganic.Checked = false;
     _cbOrganic.Enabled = false;
 }
Exemplo n.º 3
0
 private void _btnNew_Click(object sender, EventArgs e)
 {
     ControlUtil.DisableButtons(_btnNew);
     ControlUtil.EnableButtons(_btnSave);
     ControlUtil.EnableTextBoxes(_txtName, _txtPrice, _txtDescription);
     ControlUtil.ClearTextBoxes(_txtName, _txtPrice, _txtDescription);
     _cbOrganic.Checked = false;
     _cbOrganic.Enabled = true;
     product            = proNew;
 }
Exemplo n.º 4
0
 private void ClearFields()
 {
     ControlUtil.ClearTextBoxes(this._txtName, this._txtAddress);
     this._txtPhone.Text = "";
     ResetComboBox(this._cmbZone, this._cmbType);
 }
Exemplo n.º 5
0
 //clears all fields
 private void ClearFields()
 {
     ControlUtil.ClearTextBoxes(_txtTotalCost);
     ControlUtil.ClearComboBoxes(_cboOrderClient, _cboProductSelect);
 }