private string CheckData(string columnName) { string errorInfo = null; switch (columnName) { case "StyleCode": { if (string.IsNullOrEmpty(StyleCode)) { errorInfo = "不能为空"; } else { var style = _distributionLinqOP.Search <ProStyle>(o => o.Code == StyleCode).FirstOrDefault(); if (style == null) { errorInfo = "款号不正确"; StyleID = default(int); StyleName = ""; BrandName = ""; Price = 0; } else { StyleID = style.ID; StyleName = VMGlobalBase.ProNames.Find(o => o.ID == style.NameID).Name; var brandID = _distributionLinqOP.GetById <ProBYQ>(style.BYQID).BrandID; var brand = VMGlobalBase.PoweredBrands.Find(o => o.ID == brandID); BrandName = brand == null ? "" : brand.Name; } } } break; case "ColorID": if (ColorID == default(int)) { errorInfo = "不能为空"; } break; case "SizeID": if (SizeID == default(int)) { errorInfo = "不能为空"; } break; } return(errorInfo); }