public bool Check(OleDbConnection connection) { var obj = ADOSQLHelper.ExecuteScalar(connection, string.IsNullOrEmpty(WhereClause) ? string.Format("Select Count(*) from {0}", TableName) : string.Format("Select Count(*) from {0} where {1}", TableName, WhereClause)); var count = 0; if (int.TryParse(obj.ToString(), out count)) { if (count == 0) { var info = string.IsNullOrEmpty(WhereClause) ? string.Format("表:{0}数据量为空", TableName) : string.Format("表:{0}在条件:{1}下数据量为空", TableName, WhereClause); Console.WriteLine(info); QuestionManager.Add(new Models.Question { Code = "2101", Name = Name, Project = Models.CheckProject.图层完整性, TableName = TableName, Description = info }); } return(true); } return(false); }
private void GainAccess() { var a = 0; var b = .0; var val = string.Empty; foreach (var xzc in List) { var result = new List <ExcelField>(); foreach (var field in Fields) { var obj = ADOSQLHelper.ExecuteScalar(Connection, string.Format("Select {0} from {1} where XZCDM = '{2}' AND XZCMC = '{3}'", field.SQL, TableName, xzc.XZCDM, xzc.XZCMC)); if (field.Type == ExcelType.Double) { double.TryParse(obj.ToString(), out b); switch (field.Unit) { case "亩": b = b / 15; break; case "平方米": b = b / 10000; break; default: break; } val = Math.Round(b, 4).ToString(); } else { int.TryParse(obj.ToString(), out a); val = a.ToString(); } field.Val = val; //field.Value = val; result.Add(field); } _dict.Add(xzc, result); } }
private FieldValue GainCommon(ExcelField field, string dmWhere, string tableName) { var a = 0; var b = .0; var val = string.Empty; var sb = new StringBuilder(string.Format("Select {0} from ", field.SQL)); if (string.IsNullOrEmpty(field.View)) { if (string.IsNullOrEmpty(field.FieldTableName)) { sb.Append(tableName); } else { sb.Append(field.FieldTableName); } } else { sb.AppendFormat("({0})", field.View); } sb.AppendFormat(" Where ( {0} )", dmWhere); if (!string.IsNullOrEmpty(field.WhereClause)) { sb.AppendFormat(" AND {0}", field.WhereClause); } Console.WriteLine("{0}:{1}", tableName, sb.ToString()); var obj = ADOSQLHelper.ExecuteScalar(Connection, sb.ToString()); if (obj == null) { return(null); } if (field.Type == ExcelType.Double) { double.TryParse(obj.ToString(), out b); switch (field.Unit) { case "亩": b = b / 15; break; case "平方米": b = b / 10000; break; default: break; } val = Math.Round(b, 4).ToString(); } else { int.TryParse(obj.ToString(), out a); val = a.ToString(); } var result = new FieldValue { Index = field.Index, Type = field.Type, Title = field.Title, Val = val }; return(result); }