public override ValidationResult Validate(object value, CultureInfo cultureInfo) { BindingGroup bindingGroup = (BindingGroup)value; if (bindingGroup.Items.Count > 0) { object obj = bindingGroup.Items[0]; PgM.PgTableBaseM tableM = obj as PgM.PgTableBaseM; String schemeName = (String)bindingGroup.GetValue(tableM, "SchemeName"); String baseName = (String)bindingGroup.GetValue(tableM, "Name"); String systemName = (String)bindingGroup.GetValue(tableM, "Text"); AbsM.EGeomType geomType = (AbsM.EGeomType)((EnumWrapper)(bindingGroup.GetValue(tableM, "GeomType"))).Value; if (String.IsNullOrEmpty(schemeName)) { return(new ValidationResult(false, "Схема не должна быть пустой")); } if (String.IsNullOrEmpty(baseName)) { return(new ValidationResult(false, "Название таблицы в базе не должно быть пустым")); } if (String.IsNullOrEmpty(systemName)) { return(new ValidationResult(false, "Название таблицы в системе не должно быть пустым")); } if (tableM.IsLayer && geomType == AbsM.EGeomType.None) { return(new ValidationResult(false, "Слой карты должен иметь тип геометрии")); } } return(ValidationResult.ValidResult); }
public override ValidationResult Validate(object value, System.Globalization.CultureInfo cultureInfo) { BindingGroup bindingGroup = (BindingGroup)value; if (bindingGroup.Items.Count > 0) { SourcePostgres.Model.PgStyleLayerM layerStyle = (SourcePostgres.Model.PgStyleLayerM)bindingGroup.Items[0]; String fontName = (String)bindingGroup.GetValue(layerStyle, "FontName"); if (String.IsNullOrWhiteSpace(fontName)) { return(new ValidationResult(false, "Не задан шрифт точечных объектов")); } object penWidthObj = bindingGroup.GetValue(layerStyle, "PenWidth"); int penWidth = -1; try { penWidth = Convert.ToInt32(penWidthObj); } catch (Exception ex) { String mes = "Ошибка в значении толщины линий: \n" + ex.Message; return(new ValidationResult(false, mes)); } return(ValidationResult.ValidResult); } else { return(new ValidationResult(false, "Не выбран объект для отображения")); } }
public override ValidationResult Validate(object value, System.Globalization.CultureInfo cultureInfo) { BindingGroup bg = value as BindingGroup; Customer cust = bg.Items[0] as Customer; if (cust == null) { return(new ValidationResult(false, "Customer is not the source object")); } Region region = (Region)bg.GetValue(cust, "Location"); ServiceRep rep = bg.GetValue(cust, "ServiceRepresentative") as ServiceRep; string customerName = bg.GetValue(cust, "Name") as string; if (region == rep.Area) { return(ValidationResult.ValidResult); } else { StringBuilder sb = new StringBuilder(); sb.AppendFormat("{0} must be assigned a sales representative that serves the {1} region. \n ", customerName, region); return(new ValidationResult(false, sb.ToString())); } }
public override ValidationResult Validate(object value, System.Globalization.CultureInfo cultureInfo) { BindingGroup bg = value as BindingGroup; Type1 object1 = null; Type2 object2 = null; foreach (object item in bg.Items) { if (item is Type1) { object1 = item as Type1; } if (item is Type2) { object2 = item as Type2; } } if (object1 == null || object2 == null) { return(new ValidationResult(false, "BindingGroup did not find source object.")); } string string1 = bg.GetValue(object1, "PropertyA") as string; string string2 = bg.GetValue(object2, "PropertyB") as string; if (string1 != string2) { return(new ValidationResult(false, "The two strings must be identical.")); } return(ValidationResult.ValidResult); }
public override ValidationResult Validate(object value, CultureInfo cultureInfo) { try { BindingGroup bindingGroup = (BindingGroup)value; MyListItem eli = (MyListItem)bindingGroup.Items[0]; int reamin = Convert.ToInt32(bindingGroup.GetValue(eli, "Remain")); int num = Convert.ToInt32(bindingGroup.GetValue(eli, "Num")); if (num < 0) { return(new ValidationResult(false, "输入的数字不合法")); } if (num > reamin) { return(new ValidationResult(false, "租赁数量超过剩余数量")); } else { return(new ValidationResult(true, null)); } } catch (Exception ex) { return(new ValidationResult(false, ex.Message)); } }
public override ValidationResult Validate(object value, CultureInfo cultureInfo) { BindingGroup bindingGroup = (BindingGroup)value; if (bindingGroup.Items.Count > 0) { VmpM.VMPTableBaseModel vmpLayer = (VmpM.VMPTableBaseModel)(bindingGroup.Items[0]); VmpVM.VMPDataRepositoryVM vmpRepo = vmpLayer.Source as VmpVM.VMPDataRepositoryVM; BooleanYesNoConverter boolYesNo = new BooleanYesNoConverter(); bool useBounds = Convert.ToBoolean(boolYesNo.ConvertBack(bindingGroup.GetValue(vmpLayer, "UseBounds"), null, null, null)); object minScaleObj = bindingGroup.GetValue(vmpLayer, "MinScale"); object maxScaleObj = bindingGroup.GetValue(vmpLayer, "MaxScale"); int minScale = -1; int maxScale = -1; try { minScale = Convert.ToInt32(minScaleObj); } catch (Exception ex) { String mes = "Ошибка в значении нижней границы масштаба: \n" + ex.Message; return(new ValidationResult(false, mes)); } try { maxScale = Convert.ToInt32(maxScaleObj); } catch (Exception ex) { String mes = "Ошибка в значении верхней границы масштаба: \n" + ex.Message; return(new ValidationResult(false, mes)); } if (minScale < 0) { return(new ValidationResult(false, "Минимальное значение не может быть отрицательным числом")); } if (maxScale < 0) { return(new ValidationResult(false, "Максимальное значение не может быть отрицательным числом")); } if (minScale > maxScale) { return(new ValidationResult(false, "Минимальное значение не может быть больше максимального")); } } return(ValidationResult.ValidResult); }
public override ValidationResult Validate(object value, System.Globalization.CultureInfo cultureInfo) { BindingGroup bindingGroup = (BindingGroup)value; if (bindingGroup.Items.Count > 0) { Object layerStyle = null; if (bindingGroup.Items[0] is SourcePostgres.Model.PgStyleLayerM) { layerStyle = (SourcePostgres.Model.PgStyleLayerM)bindingGroup.Items[0]; } else if (bindingGroup.Items[0] is SourcePostgres.Model.PgStyleObjectM) { layerStyle = (SourcePostgres.Model.PgStyleObjectM)bindingGroup.Items[0]; } if (layerStyle != null) { object penWidthObj = bindingGroup.GetValue(layerStyle, "PenWidth"); int penWidth = -1; try { penWidth = Convert.ToInt32(penWidthObj); if (penWidth < 0) { throw new Exception("Толщина линии не может быть отрицательной"); } } catch (Exception ex) { String mes = "Ошибка в значении толщины линий: \n" + ex.Message; return(new ValidationResult(false, mes)); } if (bindingGroup.GetValue(layerStyle, "PenType") == null) { return(new ValidationResult(false, "Не выбран тип карандаша")); } } else { return(new ValidationResult(false, "Не задан объект стиля")); } return(ValidationResult.ValidResult); } else { return(new ValidationResult(false, "Не выбран объект для отображения")); } }
public override ValidationResult Validate(object value, System.Globalization.CultureInfo cultureInfo) { BindingGroup bindingGroup = (BindingGroup)value; if (bindingGroup.Items.Count == 1) { User user = (User)bindingGroup.Items[0]; string firstName = (string)bindingGroup.GetValue(user, "FirstName"); string lastName = (string)bindingGroup.GetValue(user, "LastName"); if (string.IsNullOrWhiteSpace(firstName) || string.IsNullOrWhiteSpace(lastName)) { return(new ValidationResult(false, "Both fields required")); } } return(ValidationResult.ValidResult); }
public override ValidationResult Validate(object value, CultureInfo cultureInfo) { BindingGroup group = (BindingGroup)value; var item = group.Items[0]; string inputString = (group.GetValue(item, "Name") ?? string.Empty).ToString(); if (true || string.IsNullOrEmpty(inputString) || inputString.Length < MinimumLength) { return(new ValidationResult(false, this.ErrorMessage)); } return(ValidationResult.ValidResult); }
public override ValidationResult Validate(object value, CultureInfo cultureInfo) { BindingGroup bindingGroup = (BindingGroup)value; // This product has the original values. Product product = (Product)bindingGroup.Items[0]; // Check the new values. string newModelName = (string)bindingGroup.GetValue(product, "ModelName"); string newModelNumber = (string)bindingGroup.GetValue(product, "ModelNumber"); if ((newModelName == "") && (newModelNumber == "")) { return(new ValidationResult(false, "A product requires a ModelName or ModelNumber.")); } else { return(new ValidationResult(true, null)); } }
public override ValidationResult Validate(object value, System.Globalization.CultureInfo cultureInfo) { BindingGroup bindingGroup = (BindingGroup)value; if (bindingGroup.Items.Count > 0) { Object layerStyle = null; if (bindingGroup.Items[0] is SourcePostgres.Model.PgStyleLayerM) { layerStyle = (SourcePostgres.Model.PgStyleLayerM)bindingGroup.Items[0]; } else if (bindingGroup.Items[0] is SourcePostgres.Model.PgStyleObjectM) { layerStyle = (SourcePostgres.Model.PgStyleObjectM)bindingGroup.Items[0]; } if (layerStyle != null) { if (bindingGroup.GetValue(layerStyle, "BrushStyle") == null || bindingGroup.GetValue(layerStyle, "BrushHatch") == null) { return(new ValidationResult(false, "Не выбран тип кисти стиля полигона")); } } else { return(new ValidationResult(false, "Не задан объект стиля")); } return(ValidationResult.ValidResult); } else { return(new ValidationResult(false, "Не выбран объект для отображения")); } }
public override ValidationResult Validate(object value, CultureInfo cultureInfo) { BindingGroup bindingGroup = (BindingGroup)value; UserManager user = (UserManager)bindingGroup.Items[0]; string fullName = (string)bindingGroup.GetValue(user, "fullName"); if (string.IsNullOrEmpty(fullName)) { return(new ValidationResult(false, "姓名不能为空")); } else { return(new ValidationResult(true, null)); } }
public override ValidationResult Validate(object value, CultureInfo cultureInfo) { try { BindingGroup bindingGroup = (BindingGroup)value; MyListItem mli = (MyListItem)bindingGroup.Items[0]; int num = Convert.ToInt32((string)bindingGroup.GetValue(mli, "Num")); if (num < 0) { return(new ValidationResult(false, "请输入大于等于0的数字")); } if (num > mli.Remain) { return(new ValidationResult(false, "输入的数量超过上限")); } return(new ValidationResult(true, null)); } catch (Exception ex) { return(new ValidationResult(false, "请输入合法的数字")); } }
public override ValidationResult Validate(object value, System.Globalization.CultureInfo cultureInfo) { BindingGroup bindingGroup = (BindingGroup)value; if (bindingGroup.Items.Count > 0) { Object layerStyle = null; if (bindingGroup.Items[0] is SourcePostgres.Model.PgStyleLayerM) { layerStyle = (SourcePostgres.Model.PgStyleLayerM)bindingGroup.Items[0]; } else if (bindingGroup.Items[0] is SourcePostgres.Model.PgStyleObjectM) { layerStyle = (SourcePostgres.Model.PgStyleObjectM)bindingGroup.Items[0]; } if (layerStyle != null) { String fontName = (String)bindingGroup.GetValue(layerStyle, "FontName"); if (String.IsNullOrWhiteSpace(fontName)) { return(new ValidationResult(false, "Не задан шрифт точечных объектов")); } } else { return(new ValidationResult(false, "Не задан объект стиля")); } return(ValidationResult.ValidResult); } else { return(new ValidationResult(false, "Не выбран объект для отображения")); } }
public override ValidationResult Validate(object value, CultureInfo cultureInfo) { BindingGroup bindingGroup = (BindingGroup)value; if (bindingGroup.Items.Count > 0) { RasM.RastTableBaseM rastrLayer = (RasM.RastTableBaseM)(bindingGroup.Items[0]); RasVM.RastrDataRepositoryVM rastrRepo = rastrLayer.Source as RasVM.RastrDataRepositoryVM; Object filePathObject = null; if (bindingGroup.TryGetValue(rastrLayer, "FilePath", out filePathObject)) { String filePath = Convert.ToString(filePathObject); bool fileExists = false; fileExists = filePath != "" && System.IO.File.Exists(filePath); if (!fileExists) { if (filePath.StartsWith(".")) { filePath = System.Windows.Forms.Application.StartupPath + "\\" + filePath.TrimStart(new char[] { '.', '\\' }); if (System.IO.File.Exists(filePath)) { fileExists = true; } } } if (!fileExists) { return(new ValidationResult(false, "Путь к файлу задан неправильно")); } else { foreach (var iTable in rastrRepo.Tables) { RasM.RastTableBaseM rastrTable = iTable as RasM.RastTableBaseM; if (rastrTable != rastrLayer && rastrTable.FilePath == filePath) { return(new ValidationResult(false, "В системе уже присутствует растровый слой который указывает на этот файл")); } } } } else { return(new ValidationResult(false, "Не задано свойство \"Путь к файлу\"")); } String rastrName = (String)bindingGroup.GetValue(rastrLayer, "Text"); if (String.IsNullOrEmpty(rastrName.Trim())) { return(new ValidationResult(false, "Не задано название растрового слоя")); } bool rastrNameExists = (from AbsM.TableBaseM rastrTable in rastrRepo.Tables where (rastrTable.Text == rastrName && rastrLayer != rastrTable) select rastrTable).Count() > 0; if (rastrNameExists) { return(new ValidationResult(false, "Слой с таким названием уже существует")); } BooleanYesNoConverter boolYesNo = new BooleanYesNoConverter(); bool useBounds = Convert.ToBoolean(boolYesNo.ConvertBack(bindingGroup.GetValue(rastrLayer, "UseBounds"), null, null, null)); object minScaleObj = bindingGroup.GetValue(rastrLayer, "MinScale"); object maxScaleObj = bindingGroup.GetValue(rastrLayer, "MaxScale"); int minScale = -1; int maxScale = -1; try { minScale = Convert.ToInt32(minScaleObj); } catch (Exception ex) { String mes = "Ошибка в значении нижней границы масштаба: \n" + ex.Message; return(new ValidationResult(false, mes)); } try { maxScale = Convert.ToInt32(maxScaleObj); } catch (Exception ex) { String mes = "Ошибка в значении верхней границы масштаба: \n" + ex.Message; return(new ValidationResult(false, mes)); } if (useBounds) { if (minScale < 0) { return(new ValidationResult(false, "Минимальное значение не может быть отрицательным числом")); } if (maxScale < 0) { return(new ValidationResult(false, "Максимальное значение не может быть отрицательным числом")); } if (minScale > maxScale) { return(new ValidationResult(false, "Минимальное значение не может быть больше максимального")); } } return(ValidationResult.ValidResult); } else { return(new ValidationResult(false, "Не выбран объект для отображения")); } }
public override ValidationResult Validate(object value, System.Globalization.CultureInfo cultureInfo) { BindingGroup bindingGroup = (BindingGroup)value; if (bindingGroup.Items.Count > 0) { CosmeticTableBaseM cosmLayer = (CosmeticTableBaseM)bindingGroup.Items[0]; SourcePostgres.Model.PgStyleLayerM layerStyle = (SourcePostgres.Model.PgStyleLayerM)bindingGroup.Items[1]; CosmeticDataRepositoryVM cosmRepo = cosmLayer.Source as CosmeticDataRepositoryVM; String cosmName = (String)bindingGroup.GetValue(cosmLayer, "Text"); if (String.IsNullOrWhiteSpace(cosmName)) { return(new ValidationResult(false, "Не задано название косметического слоя")); } bool cosmNameExists = (from TableBaseM cosmTable in cosmRepo.Tables where (cosmTable.Text == cosmName && cosmLayer != cosmTable) select cosmTable).Count() > 0; if (cosmNameExists) { return(new ValidationResult(false, "Слой с таким названием уже существует")); } BooleanYesNoConverter boolYesNo = new BooleanYesNoConverter(); bool useBounds = Convert.ToBoolean(boolYesNo.ConvertBack(bindingGroup.GetValue(layerStyle, "UseBounds"), null, null, null)); object minScaleObj = bindingGroup.GetValue(layerStyle, "MinScale"); object maxScaleObj = bindingGroup.GetValue(layerStyle, "MaxScale"); int minScale = -1; int maxScale = -1; try { minScale = Convert.ToInt32(minScaleObj); } catch (Exception ex) { String mes = "Ошибка в значении нижней границы масштаба: \n" + ex.Message; return(new ValidationResult(false, mes)); } try { maxScale = Convert.ToInt32(maxScaleObj); } catch (Exception ex) { String mes = "Ошибка в значении верхней границы масштаба: \n" + ex.Message; return(new ValidationResult(false, mes)); } if (useBounds) { if (minScale < 0) { return(new ValidationResult(false, "Минимальное значение не может быть отрицательным числом")); } if (maxScale < 0) { return(new ValidationResult(false, "Максимальное значение не может быть отрицательным числом")); } if (minScale > maxScale) { return(new ValidationResult(false, "Минимальное значение не может быть больше максимального")); } } return(ValidationResult.ValidResult); } else { return(new ValidationResult(false, "Не выбран объект для отображения")); } }
public override ValidationResult Validate(object value, System.Globalization.CultureInfo cultureInfo) { BindingGroup bindingGroup = (BindingGroup)value; if (bindingGroup.Items.Count > 0) { SourcePostgres.Model.PgStyleLableM labelStyle = (SourcePostgres.Model.PgStyleLableM)(bindingGroup.Items[0]); String fontName = (String)bindingGroup.GetValue(labelStyle, "LabelFontName"); if (String.IsNullOrWhiteSpace(fontName)) { return(new ValidationResult(false, "Не задан шрифт подписи")); } bool useBounds = Convert.ToBoolean(bindingGroup.GetValue(labelStyle, "LabelUseBounds")); object minScaleObj = bindingGroup.GetValue(labelStyle, "LabelMinScale"); object maxScaleObj = bindingGroup.GetValue(labelStyle, "LabelMaxScale"); int minScale = -1; int maxScale = -1; try { minScale = Convert.ToInt32(minScaleObj); } catch (Exception ex) { String mes = "Ошибка в значении нижней границы масштаба: \n" + ex.Message; return(new ValidationResult(false, mes)); } try { maxScale = Convert.ToInt32(maxScaleObj); } catch (Exception ex) { String mes = "Ошибка в значении верхней границы масштаба: \n" + ex.Message; return(new ValidationResult(false, mes)); } if (useBounds) { if (minScale < 0) { return(new ValidationResult(false, "Минимальное значение не может быть отрицательным числом")); } if (maxScale < 0) { return(new ValidationResult(false, "Максимальное значение не может быть отрицательным числом")); } if (minScale > maxScale) { return(new ValidationResult(false, "Минимальное значение не может быть больше максимального")); } } return(ValidationResult.ValidResult); } else { return(new ValidationResult(false, "Не выбран объект для отображения")); } }