Exemplo n.º 1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            var model = new StaffModel();

            model.STAFF_CONTACT = txtSTAFF_CONTACT.Text;
            model.STAFF_EMAIL   = txtSTAFF_EMAIL.Text;
            model.STAFF_NAME    = txtSTAFF_NAME.Text;

            model.ROOM_NAME     = txtROOM_NAME.Text;
            model.BUILDING_NAME = txtBUILDING_NAME.Text;
            model.LOCATION_NAME = txtLOCATION_NAME.Text;

            int.TryParse(txtID.Text, out int id);
            model.ID = id;

            if (model.Validate() == false)
            {
                MessageBox.Show(this, "All values are required", "Save Action failed !", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            model.Save();

            txtID.Text = model.ID.ToString();
            txtSTAFF_EMAIL.Focus();
            txtSTAFF_EMAIL.Select();
        }