public string this[string columnName] { get { string result = null; if (columnName == "WorkPlaceMode") { if (WorkPlaceMode != null && WorkPlaceMode.ToString().Length > 3) { result = "WorkPlaceMode exceeds maximum length (3 digits)."; //WorkPlaceMode = (int?)int.Parse(WorkPlaceMode.ToString().Substring(0, 3)); } } if (columnName == "WorkPlaceEmpId") { if (WorkPlaceEmpId != null && WorkPlaceEmpId.ToString().Length > 8) { result = "WorkPlaceEmpId exceeds maximum length (8 digits)."; //WorkPlaceEmpId = (int?)int.Parse(WorkPlaceEmpId.ToString().Substring(0, 8)); } } return(result); } }
public string this[string columnName] { get { string result = null; if (columnName == "WorkPlaceMode") { if (WorkPlaceMode != null && WorkPlaceMode.ToString().Length > 3) { result = "WorkPlaceMode exceeds maximum length (3 digits)."; //WorkPlaceMode = (int?)int.Parse(WorkPlaceMode.ToString().Substring(0, 3)); } else if (!WorkPlaceMode.HasValue) { result = "WorkPlace Mode is mandatory."; } } if (columnName == "WorkPlaceEmpId") { if (WorkPlaceEmpId != null && WorkPlaceEmpId.ToString().Length > 8) { result = "WorkPlaceEmpId exceeds maximum length (8 digits)."; //WorkPlaceEmpId = (int?)int.Parse(WorkPlaceEmpId.ToString().Substring(0, 8)); } } if (columnName == "WorkPlaceStartDate") { if (!WorkPlaceStartDate.HasValue) { result = "WorkPlace Start Date is mandatory."; } } if (columnName == "WorkPlaceHours") { if (WorkPlaceHours != null && WorkPlaceHours.Length > 0) { int number; bool valid = Int32.TryParse(WorkPlaceHours, out number); if (!valid) { result += String.Format("{0} has non numeric values. this will NOT be SAVED !!!", columnName); } } else if (WorkPlaceHours == null || WorkPlaceHours.ToString().Length == 0) { result = "Work Place Hours is required\r\n"; } } return(result); } }