Beispiel #1
0
        } // DeleteComponent_Click

        private void SaveComponent_Click(object sender, EventArgs e) // SaveComponent_Click
        {
            try
            {
                // Buffer to store text
                string ComponentName         = ComponentName_Textbox.Text.ToString();
                string ComponentCategory     = ((BoxFormat)ComponentCategory_comboBox.SelectedItem).databaseID;
                string ComponentPrice        = ComponentPrice_Textbox.Text.ToString();
                string ComponentCost         = ComponentCost_Textbox.Text.ToString();
                string ComponentHighQuantity = ComponentHighQuantity_Textbox.Text.ToString();
                string ComponentLowQuantity  = ComponentLowQuantity_Textbox.Text.ToString();

                if (String.IsNullOrWhiteSpace(ComponentName) || String.IsNullOrWhiteSpace(ComponentCategory) || String.IsNullOrWhiteSpace(ComponentPrice) ||
                    String.IsNullOrWhiteSpace(ComponentCost) || String.IsNullOrWhiteSpace(ComponentHighQuantity) || String.IsNullOrWhiteSpace(ComponentLowQuantity))
                {
                    MessageBox.Show("Not All Fields Filled In!", "Save Component", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

                    return;
                }

                // connect to DB if it is not connected
                if (!nsadb.Connected())
                {
                    nsadb.OpenConnection();
                }

                // Save the Component data to the Database
                nsadb.ManagerSaveComponent(ComponentName, ComponentCategory, ComponentPrice, ComponentCost, ComponentHighQuantity, ComponentLowQuantity);

                //Refresh List
                LoadManagerComponentList();

                // Inform user that account was successfully created.
                MessageBox.Show("Component - " + ComponentName + " Created.", "Save Component", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Shouldnt Be Seeing This!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }