예제 #1
0
        private void SaveButton_Click(object sender, EventArgs e)
        {
            ItemVM itemVm = new ItemVM();

            item.Company      = companyComboBox.GetItemText(companyComboBox.SelectedItem);
            item.Category     = categoryComboBox.GetItemText(categoryComboBox.SelectedItem);
            item.Name         = nameTextBox.Text;
            item.ErrorText    = itemErrorLabel.Text;
            item.ReorderError = reorderErrorLabel.Text;
            item.Reorder      = reorderTextBox.Text;

            itemVm.Name     = nameTextBox.Text;
            itemVm.Company  = companyComboBox.GetItemText(companyComboBox.SelectedItem);
            itemVm.Category = categoryComboBox.GetItemText(categoryComboBox.SelectedItem);
            itemVm.Reorder  = reorderTextBox.Text;

            bool verify = itemManagement.IsVerified(item);

            if (verify)
            {
                MessageBox.Show("Field Must Not Be Empty!!");
                return;
            }


            bool error = itemManagement.IsError(item);

            if (error)
            {
                MessageBox.Show("Please Resolve Your Error!!");
                return;
            }


            //Check Existing Item
            bool isExist = itemManagement.IsExisted(item);

            if (isExist)
            {
                itemErrorLabel.Text = "* This Item Already Existed!!";
                return;
            }
            itemErrorLabel.Text = "";

            disItemVms.Add(itemVm);

            bool isAdd = itemManagement.IsAdded(item);

            if (isAdd)
            {
                //MessageBox.Show("New Item Successfully Add!!");

                itemDataGridView.DataSource = null;
                itemDataGridView.DataSource = disItemVms;

                nameTextBox.Clear();
                reorderTextBox.Clear();
                reorderErrorLabel.Text = "";
            }
        }