Ejemplo n.º 1
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            //validate to check data is available for name and price
            if (!textBoxNameValidating() || !textBoxPriceValidating())
            {
                return;
            }

            //validation to check the Mfg date of the product should be less than today
            //todo: (validation to check the Mfg date of the product should be less than today)

            string returnData = string.Empty;

            //add the new data to the dataGridView
            if ((returnData = addDataToProductsGrid()) == null)
            {
                MessageBox.Show(Common.MESSAGE03_New_ROW_ADDED_SUCCESS, Common.APPLICATION_NAME,
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
                //Clear the textBoxes and Date Control in the UI
                UIHandler.ClearControl(textBoxName, textBoxPrice, dateTimePickerMfgDate);
            }
            else
            {
                MessageBox.Show(returnData, Common.APPLICATION_NAME,
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 2
0
        private void Home_Load(object sender, EventArgs e)
        {
            //Clear all the controls at the load of the form
            UIHandler.ClearControl(textBoxName, textBoxPrice, dateTimePickerMfgDate);

            //Populate the DataGridView with data from the database
            this.populateRecords();

            //Set properties for the dataGridView (read-only), column width, cell alignment etc..
            string status = UIHandler.DataGridViewProperties(dataGridViewProducts, this.Width);

            //no errors are identified
            if (!string.IsNullOrEmpty(status))
            {
                MessageBox.Show(status, Common.APPLICATION_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            //Set the focus on the textBox (Name)
            textBoxName.Focus();
        }