Exemple #1
0
        /// <summary>
        /// Save information from the textbox to the dataset and database
        /// </summary>
        private void btnAddSaveEmployer_Click(object sender, EventArgs e)
        {
            DataRow newEmployerRow = DM.dtEmployer.NewRow();

            if ((txtAddEmployerName.Text == "") || (txtAddPhoneNumber.Text == "") || (txtAddStreetAddress.Text == "") || (txtAddSuburb.Text == ""))
            {
                MessageBox.Show("You must ype in an employer name, phone number, street address and suburb");
            }
            else
            {
                try
                {
                    newEmployerRow["EmployerName"]   = txtAddEmployerName.Text;
                    newEmployerRow["Street Address"] = txtAddStreetAddress.Text;//There is a space in between street and address
                    newEmployerRow["Suburb"]         = txtAddSuburb.Text;
                    newEmployerRow["PhoneNumber"]    = txtAddPhoneNumber.Text;
                    DM.dtEmployer.Rows.Add(newEmployerRow);
                    MessageBox.Show("Employer Added Successfully", "Success");
                    DM.UpdateEmployer();
                }
                catch
                {
                    MessageBox.Show("Please Enter The Proper type for each fields");
                }
            }
        }