void dp_Changed(object sender, DataProviderEventArgs args) { if (args.TotalLossChanged) { if (myTotalLoss != null) { myTotalLoss = Config.DP.TotalLossList; cbTotalLoss.Items.Clear(); cbTotalLoss.Items.AddRange(myTotalLoss.ToArray()); } } if (args.RawChanged) { if (myRaw != null) { myRaw = Config.DP.RawList; cbName.Items.Clear(); cbName.Items.AddRange(myRaw.ToArray()); } } if (args.ProcessLossChanged) { if (myProcessLoss != null) { myProcessLoss = Config.DP.ProcessLossList; dgvRecProcessLoss.Items.Clear(); dgvRecProcessLoss.Items.AddRange(myProcessLoss.ToArray()); } } //throw new Exception("The method or operation is not implemented."); }
protected virtual void OnChanged(DataProviderEventArgs args) { if (args.ProcessLossChanged) { myProcessLossList = null; myProcessLossHash = null; } if (args.RawChanged) { myRawHash = null; myRawList = null; } if (args.TotalLossChanged) { myTotalLossList = null; myTotalLossHash = null; } if (Changed != null) { Changed(this, args); } }
// обновление списка и структуры после изменения БД void dp_Changed(object sender, DataProviderEventArgs args) { //int prevIDnum = currentRecord.id; //panelTotalLossData1._data = null; //panelRawData1._data = null; int curItem = listBox1.SelectedIndices[0]; switch (myRecType) { case DataBaseType.TotalLossType: if (!args.TotalLossChanged) { return; // если обновление не тех данных, то просто выходим } SortableBindingList <DataTotalLoss> newLoss = Config.DP.TotalLossList; for (int i = 0; i < newLoss.Count; i++) { if (newLoss[i].Equals(listBox1.Items[curItem])) { curItem = i; break; } } listBox1.Items.Clear(); listBox1.Items.AddRange(newLoss.ToArray()); break; case DataBaseType.RawType: if (!args.RawChanged) { return; } SortableBindingList <DataRawStruct> newRaw = Config.DP.RawList; for (int i = 0; i < newRaw.Count; i++) { if (((DataRawStruct)newRaw[i]).Equals(listBox1.Items[curItem])) { curItem = i; break; } } listBox1.Items.Clear(); listBox1.Items.AddRange(Config.DP.RawList.ToArray()); break; case DataBaseType.ProcessLossType: if (!args.ProcessLossChanged) { return; } newRaw = Config.DP.ProcessLossList; for (int i = 0; i < newRaw.Count; i++) { if (newRaw[i].Equals(listBox1.Items[curItem])) { curItem = i; break; } } listBox1.Items.Clear(); listBox1.Items.AddRange(Config.DP.ProcessLossList.ToArray()); break; default: throw new NotImplementedException("Not implemented"); } if (listBox1.Items.Count > curItem) { listBox1.SelectedIndex = curItem; } else { listBox1.SelectedIndex = listBox1.Items.Count - 1; } this.IsDataChanged = false; //throw new Exception("The method or operation is not implemented."); }