public void DeleteSelection() { if (setDataGrid.SelectedRows != null && setDataGrid.SelectedRows.Count > 0) { if (setDataGrid.SelectedRows.Count == setDataGrid.Rows.Count) { MessageBox.Show("请确保订单中含有器械包", "信息提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information); return; } string warnmingMessage = "请确认是否把一下器械包移出该订单?\r\n"; foreach (DataGridViewRow item in setDataGrid.SelectedRows) { if (item.Cells["setNameCol"] != null) { warnmingMessage += item.Cells["setNameCol"].Value + "\r\n"; } } if (MessageBox.Show(warnmingMessage, "信息提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == DialogResult.OK) { for (int i = 0; i < setDataGrid.SelectedRows.Count; i++) { if (setDataGrid.SelectedRows[i].Cells["setBarCodeCol"] != null) { string setBarCode = setDataGrid.SelectedRows[i].Cells["setBarCodeCol"].Value.ToString(); for (int j = 0; j < ScanBarCodes.Count; j++) { if (setBarCode == ScanBarCodes.GetKey(j).ToString()) { ScanBarCodes.RemoveAt(j); j--; } } setDataGrid.Rows.Remove(setDataGrid.SelectedRows[i]); } } } setDataGrid.Rows[0].Selected = true; } }
public virtual void DeleteSets() { DataGridView setDataGrid = CnasUtilityTools.FindControl <DataGridView>(this, "setDataGrid"); if (setDataGrid != null) { if (setDataGrid.SelectedRows != null && setDataGrid.SelectedRows.Count > 0) { if (setDataGrid.SelectedRows.Count == setDataGrid.Rows.Count) { MessageBox.Show(PromptMessageXmlHelper.Instance.GetPromptMessage("setgridhasdata", EnumPromptMessage.warning), "信息提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information); return; } string warnmingMessage = PromptMessageXmlHelper.Instance.GetPromptMessage("cfmsetremove", EnumPromptMessage.warning); List <string> removedBarCode = new List <string>(); foreach (DataGridViewRow item in setDataGrid.SelectedRows) { if (setDataGrid.Columns.Contains("setNameCol") && item.Cells["setNameCol"] != null) { warnmingMessage += string.Format("\r\n名称: {0}", item.Cells["setNameCol"].Value); } if (item.Cells["setBarCodeCol"].Value != null) { removedBarCode.Add(item.Cells["setBarCodeCol"].Value.ToString()); } } if (MessageBox.Show(warnmingMessage, "信息提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == DialogResult.OK) { int selectedCount = setDataGrid.SelectedRows.Count; foreach (DataGridViewRow item in setDataGrid.SelectedRows) { string setBarCode = item.Cells["setBarCodeCol"].Value.ToString(); if (removedBarCode.Contains(setBarCode)) { for (int j = 0; j < ScanBarCodes.Count; j++) { if (ScanBarCodes.GetKey(j).ToString().Contains(setBarCode)) { ScanBarCodes.RemoveAt(j); j--; } } setDataGrid.Rows.Remove(item); } } } TextBox setNumTxt = CnasUtilityTools.FindControl <TextBox>(this, "setNumTxt"); if (setNumTxt != null) { setNumTxt.Text = setDataGrid.RowCount.ToString(); } } else { MessageBox.Show(PromptMessageXmlHelper.Instance.GetPromptMessage("notfindSetGrid", EnumPromptMessage.error), "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }