直接上例子吧,用一些标识可以简化一些判断操作!
case 2: //标识 int is1In3 = 0; int isBreak = 0; var selectLineId = ""; for (int k = 1; k <= userObjectForm.SALESHIP_LINES1s.Matrix.RowCount; k++) { ckbChoose = userObjectForm.SALESHIP_LINES1s.Matrix.Columns.Item("112").Cells.Item(k).Specific as CheckBox; if (ckbChoose.Checked) { isBreak = 1; } } if (isBreak == 1) { for (int i = 1; i <= userObjectForm.SALESHIP_LINES1s.Matrix.RowCount; i++) { ckbChoose = userObjectForm.SALESHIP_LINES1s.Matrix.Columns.Item("112").Cells.Item(i).Specific as CheckBox; if (ckbChoose.Checked) { selectLineId = (userObjectForm.SALESHIP_LINES1s.Matrix.Columns.Item("1").Cells.Item(i).Specific as EditText).Value; } } for (int i = 1; i <= userObjectForm.SALESHIP_LINES2s.Matrix.RowCount; i++) { var LineId1 = (userObjectForm.SALESHIP_LINES2s.Matrix.Columns.Item("1").Cells.Item(i).Specific as EditText).Value; if (Convert.ToInt32(selectLineId) == Convert.ToInt32(LineId1)) { is1In3 = 1; break; } } if (is1In3 == 1) { Context.Application.MessageBox( "删除的行和装船里有相同的数据,请先删除装船里的行数据", 1, "", "", ""); bubbleEvent = false; } else { userObjectForm.SALESHIP_LINES1s.RemoveRow(); break; } } else { Context.Application.MessageBox( "必须先勾选一行!", 1, "", "", ""); bubbleEvent = false; }
时间: 2024-10-09 20:35:16