public static object ConvertImport(ModuleFieldInfo fieldInfo, object value, string fieldName) { try { if (fieldInfo.Nullable == CODES.DEFMODFLD.NULLABLE.YES && (value == null || string.IsNullOrEmpty(value.ToString().Trim()))) { return(null); } switch (fieldInfo.ImportType) { case CODES.DEFMODFLD.FLDTYPE.INT32: return(System.Convert.ToInt32(value, App.Environment.ClientInfo.Culture)); case CODES.DEFMODFLD.FLDTYPE.INT64: return(System.Convert.ToInt64(value, App.Environment.ClientInfo.Culture)); case CODES.DEFMODFLD.FLDTYPE.FLOAT: return(System.Convert.ToSingle(value, App.Environment.ClientInfo.Culture)); case CODES.DEFMODFLD.FLDTYPE.DOUBLE: return(System.Convert.ToDouble(value, App.Environment.ClientInfo.Culture)); case CODES.DEFMODFLD.FLDTYPE.DATE: if (string.IsNullOrEmpty(fieldInfo.FieldFormat)) { return(DateTime.ParseExact(value.ToString(), CONSTANTS.DEFAULT_DATETIME_FORMAT, null)); } return(DateTime.ParseExact(value.ToString(), fieldInfo.FieldFormat, null)); default: return(value); } } catch { var errorFormat = LangUtils.TranslateBasic("Convert column {0} failed", "IMPORT_DATA_CONVERT_FAIL"); throw ErrorUtils.CreateErrorWithSubMessage(ERR_IMPORT.ERR_CONVERT_IMPORT_DATA_FAIL, string.Format(errorFormat, fieldName)); } }
public static string BuildSearchConditionKey(ModuleInfo moduleInfo, SearchConditionInstance conditionIntance) { if (conditionIntance.SQLLogic != null) { var conditions = new List <string>(); foreach (var pCondition in conditionIntance.SubCondition) { var strCondition = BuildSearchConditionKey(moduleInfo, pCondition); if (!string.IsNullOrEmpty(strCondition)) { conditions.Add(strCondition); } } if (conditions.Count == 0) { return(string.Empty); } switch (conditionIntance.SQLLogic) { case CODES.SQL_EXPRESSION.SQL_LOGIC.OR: return("(" + string.Join(" OR ", conditions.ToArray()) + ")"); default: return("(" + string.Join(" AND ", conditions.ToArray()) + ")"); } } var condition = FieldUtils.GetModuleFieldByID(moduleInfo.ModuleID, conditionIntance.ConditionID); string conditionFormat; switch (conditionIntance.Operator) { case CODES.DEFMODFLD.CONDITION_OPERATOR.LIKE: conditionFormat = "{0} LIKE '%{1}%'"; break; case CODES.DEFMODFLD.CONDITION_OPERATOR.NOTLIKE: conditionFormat = "{0} NOT LIKE '%{1}%'"; break; case CODES.DEFMODFLD.CONDITION_OPERATOR.NOTEQUAL: conditionFormat = "{0} <> {1}"; break; case CODES.DEFMODFLD.CONDITION_OPERATOR.BEGINWITH: conditionFormat = "{0} LIKE '{1}%'"; break; case CODES.DEFMODFLD.CONDITION_OPERATOR.ENDWITH: conditionFormat = "{0} LIKE '%{1}'"; break; case CODES.DEFMODFLD.CONDITION_OPERATOR.LARGER: conditionFormat = "{0} > {1}"; break; case CODES.DEFMODFLD.CONDITION_OPERATOR.LARGEROREQUAL: conditionFormat = "{0} >= {1}"; break; case CODES.DEFMODFLD.CONDITION_OPERATOR.SMALLER: conditionFormat = "{0} < {1}"; break; case CODES.DEFMODFLD.CONDITION_OPERATOR.SMALLEROREQUAL: conditionFormat = "{0} <= {1}"; break; case CODES.DEFMODFLD.CONDITION_OPERATOR.INARRAY: conditionFormat = "{0} IN ({1})"; break; case CODES.DEFMODFLD.CONDITION_OPERATOR.NOTINARRAY: conditionFormat = "{0} NOT IN ({1})"; break; default: conditionFormat = "{0}={1}"; break; } string fieldName; if (App.Environment.EnvironmentType == EnvironmentType.CLIENT_APPLICATION) { fieldName = string.Format("[{0}]", LangUtils.Translate( LangType.LABEL_FIELD, moduleInfo.ModuleName, condition.FieldName)); } else { fieldName = condition.ParameterName; } if (conditionIntance.Value == null) { return(string.Format(conditionFormat, fieldName, null)); } return(string.Format(conditionFormat, fieldName, conditionIntance.Value)); }