private void AddEdit(FrmAddEditItem itemForm) { DialogResult callback = itemForm.ShowDialog(this); if (DialogResult.OK == callback) { RefreshList(); } }
private void FillOlv() { try { ovlItem.Clear(); List <ListViewColumnsInfo> list = new List <ListViewColumnsInfo>(); list.Add(new ListViewColumnsInfo() { ColumnSize = 150, Header = helper.GetMemberName((ItemModel c) => c.MeasurmentName), Visible = true }); list.Add(new ListViewColumnsInfo() { ColumnSize = 300, Header = helper.GetMemberName((ItemModel c) => c.ItemName), Visible = true }); list.Add(new ListViewColumnsInfo() { ColumnSize = 55, Header = helper.GetMemberName((ItemModel c) => c.IsActive), Visible = true }); list.Add(new ListViewColumnsInfo() { ColumnSize = 50, Header = helper.GetMemberName((ItemModel c) => c.Update), Visible = true, IsButton = true }); list.Add(new ListViewColumnsInfo() { ColumnSize = 50, Header = helper.GetMemberName((ItemModel c) => c.Delete), Visible = true, IsButton = true }); helper.GenerateListView(ovlItem, list); this.ovlItem.ButtonClick += delegate(object sender, CellClickEventArgs e) { switch (e.ColumnIndex) { case 3: FrmAddEditItem updateItem = new FrmAddEditItem(e.Model as ItemModel); AddEdit(updateItem); break; case 4: var model = e.Model as ItemModel; DialogResult result = MessageBox.Show(String.Format("Are you sure? you want to delete measurement => {0}", model.ItemName), "Delete!", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result.Equals(DialogResult.Yes)) { itemReciever.Delete(model); RefreshList(); } break; } }; } catch (Exception ex) { } }
private void btnAdd_Click(object sender, EventArgs e) { FrmAddEditItem addItem = new FrmAddEditItem(); AddEdit(addItem); }