private void btnSave_Click(object sender, EventArgs e) { try { if (txtUnitName.Text == "") { MessageBox.Show("You Must Enter Unit Name"); return; } unit.Add(new Unit() { Unit_Code = int.Parse(txtUnitCode.Text), Unit_Name = txtUnitName.Text, CatCode = int.Parse(CategorySearch.EditValue.ToString()) }); btnSave.Enabled = false; btnAddNew.Enabled = btnModify.Enabled = true; txtUnitCode.Text = txtUnitName.Text = ""; MessageBox.Show("New Unit Successfully Added"); FRM_Unit_Load(null, null); btnLast_Click(null, null); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void unitButton_Click(object sender, EventArgs e) { unit.Units = unitTextBox.Text; if (_unitManager.Add(unit)) { MessageBox.Show("Added"); showDataGridView.DataSource = _unitManager.Display(); } else { MessageBox.Show("Not Added"); } }
/// <summary> /// Creates the unit. /// </summary> /// <param name="unitViewModel">The unit view model.</param> public bool CreateUnit(UnitViewModel unitViewModel) { try { if (unitViewModel != null) { Unit unit = ObjectMapper.Map <UnitViewModel, Model.Entities.Unit>(unitViewModel); unit = UnitManager.Add(unit); return(true); } } catch (Exception ex) { ExceptionManager.HandleException(ex, PolicyNameType.ExceptionReplacing); } return(false); }