Exemplo n.º 1
0
        private void btnAddNew_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtBoxName.Text.Trim().Length == 0)
                {
                    MessageBox.Show(this, "Product Line Name cannot be empty", "Manage Product Line", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                if (CommonFunctions.ListProductLines.FindIndex(s => s.Name.Equals(txtBoxName.Text.Trim(), StringComparison.InvariantCultureIgnoreCase)) >= 0)
                {
                    MessageBox.Show(this, "Specified Product Line already exists", "Manage Product Line", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                CommonFunctions.AddNewProductLine(txtBoxName.Text.Trim(), cmbBoxProductLine.SelectedIndex);

                MessageBox.Show(this, "New ProductLine \"" + txtBoxName.Text + "\" created successfully", "Manage Product Line", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.Close();
            }
            catch (Exception ex)
            {
                CommonFunctions.ShowErrorDialog("ManageProductLineForm.btnAddNew_Click()", ex);
            }
        }