private void ValidateInputNoValue(string value, bool showConfirmMessage = true) { int value1, value2; int recordNo = workGrid.FocusedRecord + 1; string[] inputNos = value.Split(','); EItemCode code = (EItemCode)workGrid.GetCellValue( workGrid.VisibleRows[(int)EWorkItem.ItemCode], workGrid.FocusedRecord); switch (code) { case EItemCode.N_PULSE_M: case EItemCode.N_MINUS_M: case EItemCode.N_MULTIPLY_M: case EItemCode.N_DIVIDE_M: if ((inputNos.Length == 2) && (int.TryParse(inputNos[0], out value1) == true) && (int.TryParse(inputNos[1], out value2) == true) && (value1 < recordNo) && (value2 < recordNo)) { workGrid.SetCellValue(workGrid.VisibleRows[(int)EWorkItem.InputNo], workGrid.FocusedRecord, value); } else { if (showConfirmMessage == true) { MessageBox.Show("Invalid value! Try to key in again!", AppRes.Caption, MessageBoxButtons.OK, MessageBoxIcon.Error); } workGrid.SetCellValue(workGrid.VisibleRows[(int)EWorkItem.InputNo], workGrid.FocusedRecord, ""); } break; default: if ((inputNos.Length == 1) && (int.TryParse(inputNos[0], out value1) == true) && (value1 <= recordNo)) { workGrid.SetCellValue(workGrid.VisibleRows[(int)EWorkItem.InputNo], workGrid.FocusedRecord, value); } else { if (showConfirmMessage == true) { MessageBox.Show("Invalid value! Try to key in again!", AppRes.Caption, MessageBoxButtons.OK, MessageBoxIcon.Error); } workGrid.SetCellValue(workGrid.VisibleRows[(int)EWorkItem.InputNo], workGrid.FocusedRecord, ""); } break; } }
private void workInputNoTextEdit_Leave(object sender, EventArgs e) { int value1, value2; int recordNo = workGrid.FocusedRecord + 1; TextEdit textEdit = sender as TextEdit; string editValue = (string)textEdit.EditValue; string[] inputNos = editValue.Trim().Split(','); EItemCode code = (EItemCode)workGrid.GetCellValue( workGrid.VisibleRows[(int)EWorkItem.ItemCode], workGrid.FocusedRecord); switch (code) { case EItemCode.N_PULSE_M: case EItemCode.N_MINUS_M: case EItemCode.N_MULTIPLY_M: case EItemCode.N_DIVIDE_M: if ((inputNos.Length != 2) || (int.TryParse(inputNos[0], out value1) == false) || (int.TryParse(inputNos[1], out value2) == false) || (value1 >= recordNo) || (value2 >= recordNo)) { workGrid.SetCellValue(workGrid.FocusedRow, workGrid.FocusedRecord, ""); } break; default: if ((inputNos.Length != 1) || (int.TryParse(inputNos[0], out value1) == false) || (value1 > recordNo)) { workGrid.SetCellValue(workGrid.FocusedRow, workGrid.FocusedRecord, ""); } break; } }