コード例 #1
0
ファイル: AddCategory.cs プロジェクト: joeseggie/PoS
 private void buttonAdd_Click(object sender, EventArgs e)
 {
     try
     {
         if (this.textBoxCategory.Text.Trim().ToString().Length != 0)
         {
             Category newCategory = new Category
                 {
                     Name = this.textBoxCategory.Text.Trim().ToString()
                 };
             repository.Add(newCategory);
             this.textBoxCategory.Text = string.Empty;
             MessageBox.Show("New stock category has been added.", "Add New Category");
         }
         else
         {
             MessageBox.Show("Please enter a category.", "Add New Category");
         }
     }
     catch (Exception)
     {
         MessageBox.Show("ERROR: Adding new category failed.", "Add New Category", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }