/// <summary> /// 进行修改数据操作 /// </summary> protected virtual void PerformUpdateData() { if (this.GridView != null && this.GridView.SelectedRows != null && this.GridView.SelectedRows.Count > 0) { var row = this.GridView.SelectedRows[0]; object pre = row.Tag; if (pre != null) { FrmDetailBase detailForm = GetDetailForm(); if (detailForm != null) { detailForm.IsAdding = false; detailForm.UpdatingItem = pre; detailForm.ItemUpdated += delegate(object obj, ItemUpdatedEventArgs args) { if (GridView != null) { GridView.Invalidate(); } }; detailForm.ShowDialog(); } } } }
/// <summary> /// 进行增加数据操作 /// </summary> protected virtual void PerformAddData() { try { FrmDetailBase detailForm = GetDetailForm(); if (detailForm != null) { detailForm.IsAdding = true; detailForm.ItemAdded += delegate(object obj, ItemAddedEventArgs args) { var item = args.AddedItem as T; if (_ShowingItems == null) { _ShowingItems = new List <T>(); } _ShowingItems.Add(item); if (_Items == null) { _Items = new List <T>(); } _Items.Add(item); if (GridView != null) { GridView.RowCount++; FreshStatusBar(); if (_ShowingItems.Count > GridView.DisplayedRowCount(false)) { GridView.FirstDisplayedScrollingRowIndex = _ShowingItems.Count - GridView.DisplayedRowCount(false) + 1; //5是随便取的一数字 } else { GridView.FirstDisplayedScrollingRowIndex = 0; } GridView.Rows[_ShowingItems.Count - 1].Selected = true; } }; detailForm.ItemUpdated += delegate(object obj, ItemUpdatedEventArgs args) { if (GridView != null) { GridView.Invalidate(); } }; detailForm.ShowDialog(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error"); } }
protected override void PerformAddData() { try { FrmDetailBase detailForm = GetDetailForm(); if (detailForm != null) { detailForm.IsAdding = true; DataGridViewRow row = null; detailForm.ItemAdded += delegate(object obj, ItemAddedEventArgs args) { _Operators = new OperatorBLL(AppSettings.Current.ConnStr).GetItems(null).QueryObjects; row = Add_And_Show_Row(args.AddedItem); }; detailForm.ShowDialog(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error"); } }
protected override void PerformUpdateData() { if (this.GridView != null && this.GridView.SelectedRows != null && this.GridView.SelectedRows.Count > 0) { object pre = this.GridView.SelectedRows[0].Tag; if (pre != null) { FrmDetailBase detailForm = GetDetailForm(); if (detailForm != null) { detailForm.IsAdding = false; detailForm.UpdatingItem = pre; detailForm.ItemUpdated += delegate(object obj, ItemUpdatedEventArgs args) { _Operators = new OperatorBLL(AppSettings.Current.ConnStr).GetItems(null).QueryObjects; ShowItemInGridViewRow(this.GridView.SelectedRows[0], args.UpdatedItem); }; detailForm.ShowDialog(); } } } }