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."); }
// обновление списка и структуры после изменения БД 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."); }
internal void LoadData(DataRecept data) { this.tbName.TextChanged -= new System.EventHandler(this.tbTextChanged); this.tbNum.TextChanged -= new System.EventHandler(this.tbTextChanged); this.tbWater.TextChanged -= new System.EventHandler(this.tbTextChanged); this.tbWaterPlus.TextChanged -= new System.EventHandler(this.tbTextChanged); this.tbWaterMinus.TextChanged -= new System.EventHandler(this.tbTextChanged); this.tbTotalExit.TextChanged -= new System.EventHandler(this.tbTextChanged); this.tbNormativDoc.TextChanged -= new System.EventHandler(this.tbTextChanged); this.tbSource.TextChanged -= new System.EventHandler(this.tbTextChanged); this.tbPreview.TextChanged -= new System.EventHandler(this.tbTextChanged); this.cbTotalLoss.TextChanged -= new System.EventHandler(this.cbTextChanged); this.tbAcidity.TextChanged -= new System.EventHandler(this.tbTextChanged); dgvRawList.CellValueChanged -= new DataGridViewCellEventHandler(dgvRawList_CellValueChanged); myData = data; // настраиваем список потерь if (myTotalLoss == null) { myTotalLoss = Config.DP.TotalLossList; cbTotalLoss.Items.Clear(); if (myTotalLoss != null && myTotalLoss.Count > 0) { cbTotalLoss.Items.AddRange(myTotalLoss.ToArray()); } } // настраиваем список компонент if (myRaw == null) { myRaw = Config.DP.RawList; cbName.Items.Clear(); cbSetWater.Items.Clear(); if (myRaw != null && myRaw.Count > 0) { cbName.Items.AddRange(myRaw.ToArray()); cbSetWater.Items.AddRange(myRaw.ToArray()); } } // настраиваем список производственных потерь if (myProcessLoss == null) { myProcessLoss = Config.DP.ProcessLossList; dgvRecProcessLoss.Items.Clear(); if (myProcessLoss != null && myProcessLoss.Count > 0) { dgvRecProcessLoss.Items.AddRange(myProcessLoss.ToArray()); } } // шапка формы tbName.Text = data.Name; tbNum.Text = data.Id.ToString(CultureInfo.CurrentCulture); tbWater.Text = data.water.ToString(CultureInfo.CurrentCulture); tbWaterPlus.Text = data.waterPlus.ToString(CultureInfo.CurrentCulture); tbWaterMinus.Text = data.waterMinus.ToString(CultureInfo.CurrentCulture); tbTotalExit.Text = data.TotalExit.ToString(CultureInfo.CurrentCulture); tbCountExit.Text = data.CountExit.ToString(CultureInfo.CurrentCulture); tbPreview.Text = data.preview; tbSource.Text = data.source; tbNormativDoc.Text = data.normativDoc; if (data.totalLoss != null) { cbTotalLoss.SelectedIndex = data.totalLoss.TotalLossNum; } else { cbTotalLoss.SelectedIndex = 0; } tbAcidity.Text = data.Acidity.ToString(CultureInfo.CurrentCulture); // TODO: добавить хранение элемента "вода" в настройках проги и включить отображение пункта когда он будет готов // тело формы dgvRawList.Nodes.Clear(); //dgvRawList.Rows.Clear(); LoadReceptData(dgvRawList.Nodes, data); //MessageBox.Show("Start Load2: " + dgvRawList.Nodes.Count); rbCalcExit.Checked = data.isCalcExit; rbCalcWater.Checked = data.isCalcWater; rbSetWater.Checked = data.isSetWater; this.tbName.TextChanged += new System.EventHandler(this.tbTextChanged); this.tbNum.TextChanged += new System.EventHandler(this.tbTextChanged); this.tbWater.TextChanged += new System.EventHandler(this.tbTextChanged); this.tbWaterPlus.TextChanged += new System.EventHandler(this.tbTextChanged); this.tbWaterMinus.TextChanged += new System.EventHandler(this.tbTextChanged); this.tbTotalExit.TextChanged += new System.EventHandler(this.tbTextChanged); this.tbNormativDoc.TextChanged += new System.EventHandler(this.tbTextChanged); this.tbSource.TextChanged += new System.EventHandler(this.tbTextChanged); this.tbPreview.TextChanged += new System.EventHandler(this.tbTextChanged); this.cbTotalLoss.TextChanged += new System.EventHandler(this.cbTextChanged); dgvRawList.CellValueChanged += new DataGridViewCellEventHandler(dgvRawList_CellValueChanged); this.tbAcidity.TextChanged += new System.EventHandler(this.tbTextChanged); // Устанавливаем радиокнопки выбора // this.rbCalcWater.CheckedChanged -= new System.EventHandler(this.RbCheckedChanged); // this.rbCalcExit.CheckedChanged -= new System.EventHandler(this.RbCheckedChanged); // this.rbSetWater.CheckedChanged -= new System.EventHandler(this.RbCheckedChanged); // rbCalcExit.Checked = data.isCalcExit; // rbCalcWater.Checked = data.isCalcWater; // rbSetWater.Checked = data.isSetWater; // this.rbCalcWater.CheckedChanged += new System.EventHandler(this.RbCheckedChanged); // this.rbCalcExit.CheckedChanged += new System.EventHandler(this.RbCheckedChanged); // this.rbSetWater.CheckedChanged += new System.EventHandler(this.RbCheckedChanged); myData.Changed += new EventHandler <DataBaseEventArgs> (_data_Changed); }