private void btnLocations_Click(object sender, EventArgs e) { Helper.WaitCursor(this); frmSetupDetails frm = new frmSetupDetails(); frm.LoadGridWithDataDatasource <Entities.Location>(() => { return(new LocationService().GetAll()); }); frm.ShowDialog(); Helper.DefaultCursor(this); }
private void btnSave_Click(object sender, EventArgs e) { try { switch (_entityState) { case EntityState.New: new BusinessLayer.GenericService <Entities.Location>() .Add(new Entities.Location { Name = txtName.Text, Comment = txtComment.Text }); break; case EntityState.Dirty: Entities.Location location = new Entities.Location { Id = LocationID, Name = txtName.Text, Comment = txtComment.Text }; new BusinessLayer.GenericService <Entities.Location>().Update(location, l => l.Id == location.Id); break; default: break; } Helper.ClearForm(this); btnSave.Text = "Save"; _entityState = EntityState.New; Helper.ShowMessage("Location saved successfully", "Location Saved", MessageBoxButtons.OK, MessageBoxIcon.Information); frmSetupDetails frmSetup = Helper.CreateInstanceFor <frmSetupDetails>("frmSetupDetails"); if (frmSetup != null) { frmSetup.LoadGridWithDataDatasource(() => new BusinessLayer.GenericService <Entities.Location>().GetAll()); } } catch (Exception ex) { _logger.LogError(ex, "An error occurred", "frmAddLocation", "btnSave"); Helper.ShowMessage("Location was not saved successfully \n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnMeasurement_Click(object sender, EventArgs e) { if (!Helper.IsAdmin()) { return; } Helper.WaitCursor(this); frmSetupDetails frm = new frmSetupDetails(); frm.LoadGridWithDataDatasource <Entities.Measurement>(() => { return(new BusinessLayer.GenericService <Entities.Measurement>().GetAll().ToList()); }); frm.SetFormTitle = "Measurement Set up"; frm.SetGroupBoxTitle = "Measurement List"; frm.ShowDialog(); Helper.DefaultCursor(this); }
//public string Desc { private get; // set {txtComment.Text = value} private void btnSave_Click(object sender, EventArgs e) { try { switch (_entityState) { case EntityState.New: new CategoryService().Add(new Category { Comment = txtComment.Text, Name = txtName.Text }); break; case EntityState.Dirty: Entities.Category category = new Entities.Category { Comment = txtComment.Text, Name = txtName.Text, CategoryID = CategoryID }; new CategoryService().Update(category); break; default: break; } Helper.ClearForm(this); btnSave.Text = "Save"; _entityState = EntityState.New; Helper.ShowMessage("Category saved successfully", "Category Saved", MessageBoxButtons.OK, MessageBoxIcon.Information); frmSetupDetails frmSetup = Helper.CreateInstanceFor <frmSetupDetails>("frmSetupDetails"); if (frmSetup != null) { frmSetup.LoadGridWithDataDatasource(() => new CategoryService().GetAll()); } } catch (Exception ex) { _logger.LogError(ex, "An error occurred", "frmAddCategory", "btnSave"); Helper.ShowMessage("Category was not saved successfully \n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnAddLocation_Click(object sender, EventArgs e) { if (!Helper.IsAdmin()) { return; } Helper.WaitCursor(this); frmSetupDetails frm = new frmSetupDetails(); frm.LoadGridWithDataDatasource <Entities.Location>(() => { return(new LocationService().GetAll()); }); frm.SetFormTitle = "Location Set up"; frm.SetGroupBoxTitle = "Location List"; frm.ShowDialog(); Helper.DefaultCursor(this); }