private void barBtnDel_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (string.IsNullOrEmpty(vsRowNum.ToString())) { MessageBox.Show("错误信息:\n必须选中一行"); } else { int[] Rows = gridView1.GetSelectedRows(); for (int i = 0; i < Rows.Length; i++) { selectRows.ImportRow(sampleSumTable.Rows[Rows[i]]); } SampleAduit Aduit = new SampleAduit(); for (int j = 0; j < Rows.Length; j++) { Aduit.RemoveRow(sampleSumTable, selectRows.Rows[selectRows.Rows.Count - 1 - j][0]); } barBtnUndo.Enabled = true; rowsIndex.Clear(); deleted = deleted + Rows.Length; qualified = sampleSum - deleted; barStatic.Caption = string.Format("样本总数:{0} 已删样本数 {1} 合格样本数 {2}", sampleSum, deleted, qualified); if (!(Overview == null || Overview.IsDisposed)) { Overview.Activate(); Overview.UpdateSeries(sampleSumTable); } } }
private void barBtnRedo_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { ChkDoEnable(); if (!barBtnRedo.Enabled) { return; } //for (int j = 0; j < rowsIndex.Count; j++) //{ // SampleAduit Aduit = new SampleAduit(); // //sampleSumTable.Rows.Remove(sampleSumTable.Rows[j]); // string foundKey = sampleSumTable.Columns[0].ColumnName + "=" + rowsIndex[rowsIndex.Count - 1 - j]; // DataRow[] foundRow = sampleSumTable.Select(foundKey); // foreach (DataRow row in foundRow) // { // selectRows.ImportRow(row); // } // Aduit.RemoveRow(sampleSumTable, rowsIndex[rowsIndex.Count - 1 - j]); // rowsIndex.RemoveAt(rowsIndex.Count - 1-j); //} SampleAduit Aduit = new SampleAduit(); string queryStr = "FID = " + rowsIndex[rowsIndex.Count - 1]; DataRow[] foundRow = sampleSumTable.Select(queryStr); if (foundRow.Length > 0) { selectRows.ImportRow(foundRow[0]); Aduit.RemoveRow(sampleSumTable, rowsIndex[rowsIndex.Count - 1]); rowsIndex.RemoveAt(rowsIndex.Count - 1); deleted++; qualified = sampleSum - deleted; barStatic.Caption = string.Format("样本总数:{0} 已删样本数 {1} 合格样本数 {2}", sampleSum, deleted, qualified); } if (!(Overview == null || Overview.IsDisposed)) { Overview.Activate(); Overview.UpdateSeries(sampleSumTable); } ChkDoEnable(); }