Example #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            var model = new BuildingModel();

            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();
            txtBUILDING_NAME.Focus();
            txtBUILDING_NAME.Select();
        }