Ejemplo n.º 1
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (!ValidData(true))
            {
                return;
            }
            int         rowIndex = dgvCategoryList.CurrentCell.RowIndex;
            CategoryDTO category = new CategoryDTO {
                Name = txtName.Text, ID = int.Parse(dtCategories.Rows[rowIndex]["ID"].ToString())
            };

            if (MessageBox.Show("Do you want to add new Category?", "Add Category", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                if (categoryBUS.InsertCategory(category))
                {
                    MessageBox.Show("Add category was successfull!", "Add Result", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    LoadData();
                }
                else
                {
                    MessageBox.Show("Add category was fail!", "Add Result", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }