Example #1
0
        private void addButton_Click(object sender, EventArgs e)
        {
            Item item = new Item();

            item.Name = nameTextBox.Text;

            //Name unique check
            if (_itemManager.IsNameExists(item))
            {
                MessageBox.Show(nameTextBox.Text + " Already Exists!");
                return;
            }

            //Set Price as Mandatory
            if (String.IsNullOrEmpty(priceTextBox.Text))
            {
                MessageBox.Show("Price Can not be Empty!!!");
                return;
            }
            item.Price = Convert.ToDouble(priceTextBox.Text);
            bool isadded = _itemManager.AddMethod(item);

            if (isadded)
            {
                MessageBox.Show("Saved");
            }
            else
            {
                MessageBox.Show("not saved");
            }
            showDataGridView.DataSource = _itemManager.ShowMethod();
        }