コード例 #1
0
ファイル: RMS.cs プロジェクト: jeem200/RMS
        private void addItemBtn_Click(object sender, EventArgs e)
        {
            string name, category;
            double unitPrice;

            try
            {
                ItemDataAccess ob = new ItemDataAccess();
                name     = addItemName.Text.ToString().ToUpper();
                category = addCategoryName.Text.ToString().ToUpper();
                if (name.CompareTo("") != 0 && category.CompareTo("") != 0 && addPrice.Text.ToString().CompareTo("") != 0)
                {
                    unitPrice = Convert.ToDouble(addPrice.Text);
                    int rowCount = ob.addItem(name, category, unitPrice);
                    if (rowCount <= 0)
                    {
                        MetroFramework.MetroMessageBox.Show(this, "Item Added");
                        itemCategoryComboboxFill();
                        itemListCategoryComboboxDefaultSelect();
                        autoCompleteItemNameTbox();
                        autoCompleteItemCategoryTbox();
                    }
                    else
                    {
                        MetroFramework.MetroMessageBox.Show(this, "Error: An Item Is Already Registered With This Name");
                    }
                }
                else
                {
                    MetroFramework.MetroMessageBox.Show(this, "Error: Input Can't be Blank");
                }
                addItemName.Text     = "";
                addCategoryName.Text = "";
                addPrice.Text        = "";
            }

            catch (FormatException)
            {
                MetroFramework.MetroMessageBox.Show(this, "Error: Wrong Input");
            }

            catch (Exception exc)
            {
                MetroFramework.MetroMessageBox.Show(this, exc.ToString());
            }
        }