public static string CreateDetailComponent(FieldInfo field) { switch (field.DataType) { case FieldInfo.DATATYPE_STRING: return field.ColSpan > 4 ? CreateTextArea(field) : CreateTextBox(field); case FieldInfo.DATATYPE_DATE: case FieldInfo.DATATYPE_DATETIME: return CreateDatePicker(field); //case FieldInfo.DATATYPE_TIME: // return UIManager.GenerateTimePicker(field); case FieldInfo.DATATYPE_LIST: return CreateDropdownList(field); case FieldInfo.DATATYPE_LIST2: return CreateDropdownList(field, true); case FieldInfo.DATATYPE_LIST_SQL: return CreateDropdownListSql(field); case FieldInfo.DATATYPE_LIST_SQL2: return CreateDropdownListSql2(field); case FieldInfo.DATATYPE_FLOAT: case FieldInfo.DATATYPE_INT: case FieldInfo.DATATYPE_DOUBLE: case FieldInfo.DATATYPE_PERCENT: return CreateNumberBox(field); case FieldInfo.DATATYPE_CHECKBOXLIST: return CreateCheckBoxList(field); case FieldInfo.DATATYPE_QUERY: return CreateQueryBox(field); //case FieldInfo.DATATYPE_BOOLEAN: // return UIManager.GenerateCheckBox(field); } return ""; }
public static string CreateCheckBoxList(FieldInfo field) { StringBuilder strControl = new StringBuilder(); DataTable dt = (DataTable)GetKeyValueCache(field.KeyValueSource); strControl.AppendFormat("<div class='control-group' {1} ><label class='control-label bolder blue'>{0}</label>", field.FieldName, GetVisible(field)); if (dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { string val = Convert.ToString(dr["Value"]); string selected = String.Compare(val, GetComponentValue(field)) == 0 ? " selected" : ""; strControl.AppendFormat(@"<div class='checkbox'><label> <input name='form-field-checkbox' class='ace ace-checkbox-2' type='checkbox'> <span class='lbl'>{0}</span> </label> </div>", dr["Value"], selected); } } strControl.Append("</div>"); return strControl.ToString(); }
public static string CreateDetailComponentAndLable(FieldInfo field, int colSpan, Dictionary<int,Dictionary<string, string>> componentWidth) { int catetoryColSpan = colSpan; string lableWidth = ""; string comWidth = ""; if (componentWidth != null && componentWidth.ContainsKey(catetoryColSpan)) { Dictionary<string, string> cw = componentWidth[catetoryColSpan]; lableWidth = cw["lableWidth"]; comWidth = cw["comWidth"]; } else { switch (catetoryColSpan) { case 2: lableWidth = "20%"; comWidth = "80%"; break; case 4: lableWidth = "10%"; comWidth = "40%"; break; case 6: lableWidth = "10%"; comWidth = "23%"; break; case 10: lableWidth = "10%"; comWidth = "10%"; break; default: lableWidth = "10%"; comWidth = "15%"; break; } } string fontColor = field.WFRequiredOption == RequiredOption.Required ? "color:red" : "color:#336199"; StringBuilder sb = new StringBuilder(); sb.AppendFormat("<td style=\"background-color:#edf3f4;border:1px solid #dcebf7;width:{1};{2} \" >{0}</td>", field.DisplayName, lableWidth, fontColor); sb.AppendFormat("<td style=\"border:1px dotted #dcebf7;width:{1}\" colspan={0}>", field.ColSpan, comWidth); sb.Append(CreateDetailComponent(field)); sb.Append("</td>"); if (field.ExtEmptyColSpan > 0) { for (int i = 0; i < field.ExtEmptyColSpan; i++) { sb.AppendFormat("<td style=\"background-color:#edf3f4;border:1px dotted #dcebf7;\"> </td>"); } } return sb.ToString(); }
public bool FieldIsEmpty(FieldInfo field) { string fieldValue = String.Format("{0}", field.DataValue); if (String.IsNullOrWhiteSpace(fieldValue)) { return true; } else { switch ((field.DataType)) { case FieldInfo.DATATYPE_DOUBLE: case FieldInfo.DATATYPE_FLOAT: case FieldInfo.DATATYPE_INT: case FieldInfo.DATATYPE_PERCENT: double dValue = 0; double.TryParse(fieldValue, out dValue); if (dValue == 0) { return true; } break; } } return false; }
private static string GetVisible(FieldInfo field) { return field.Visible == 0 ? " disabled=\"disabled\"" : ""; }
public bool IsNumber(FieldInfo field) { switch (field.DataType) { case FieldInfo.DATATYPE_INT: case FieldInfo.DATATYPE_DOUBLE: case FieldInfo.DATATYPE_FLOAT: case FieldInfo.DATATYPE_PERCENT: return true; } return false; }
public static string GetComponentDateTimeValue(FieldInfo field) { object dataValue = field.GetFieldValue(); DateTime inpVal = ParseHelper.Parse<DateTime>(dataValue); DateTime defVal = field.DefaultValue == "Now" ? DateTime.Now : (ParseHelper.Parse<DateTime>(field.DefaultValue)); if (inpVal == DateTime.MinValue) { if (defVal != DateTime.MinValue) { return GetComponentDateTimeValue(field, defVal); } } else { return GetComponentDateTimeValue(field, inpVal); } return ""; }
public static string GetComponentValue(FieldInfo field) { object dataValue = field.GetFieldValue(); string inpVal = dataValue == null ? "" : Convert.ToString(dataValue).Trim(); string defVal = field.DefaultValue == null ? "" : Convert.ToString(field.DefaultValue).Trim(); return inpVal == "" ? defVal : inpVal; }
//Print public static string CreatePrintComponent(FieldInfo field) { if (field.DataType == "float") { return String.Format(" <label style=\"width:100%\" id=\"{0}\" name=\"{0}\"{2}> {1}</label>", field.FieldName, string.Format("{0:C0}", field.DataValue), GetVisible(field)); } else { return String.Format(" <label style=\"width:100%\" id=\"{0}\" name=\"{0}\"{2}> {1}</label>", field.FieldName, GetComponentValue(field), GetVisible(field)); } }
public static string CreateTextArea(FieldInfo field) { return String.Format("<textarea class=\"form-control\" style=\"width:100% !important\" id=\"{0}\" name=\"{0}\" value=\"{1}\"{2}>{1}</textarea>", field.FieldName, GetComponentValue(field), GetVisible(field)); }
public static string CreateDropdownList(FieldInfo field, bool hasEmpty) { StringBuilder strControl = new StringBuilder(); DataTable dt = (DataTable)GetKeyValueCache(field.KeyValueSource); strControl.AppendFormat("<select class=\"form-control form-field\" style=\"width:100% !important\" name=\"{0}\" id=\"{0}\"{1}>", field.FieldName, GetVisible(field)); if (hasEmpty) { strControl.AppendFormat("<option value=\"\"></option>"); } if (dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { string val = Convert.ToString(dr["Value"]); string selected = String.Compare(val, GetComponentValue(field)) == 0 ? " selected" : ""; strControl.AppendFormat("<option value=\"{0}\"{1}>{0}</option>", dr["Value"], selected); } } else { strControl.Append("<option value=\"\"></option>"); } strControl.Append("</select>"); return strControl.ToString(); }
public static string CreateDropdownList(FieldInfo field) { StringBuilder strControl = new StringBuilder(); DataTable dt = SqlText.ExecuteDataset("SELECT [Key],[Value] FROM SGP_KeyValue WHERE [Key]=@Key AND Status=1 AND ISNULL([Value],'')<>'' ORDER BY [Sort]", new SqlParameter("@Key", field.KeyValueSource)).Tables[0]; strControl.AppendFormat("<select class=\"form-control\" style=\"width:100% !important\" name=\"{0}\" id=\"{0}\"{1}>", field.FieldName, GetVisible(field)); if (dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { string val = Convert.ToString(dr["Value"]); string selected = String.Compare(val, GetComponentValue(field)) == 0 ? " selected" : ""; strControl.AppendFormat("<option value=\"{0}\"{1}>{0}</option>", dr["Value"], selected); } } else { strControl.Append("<option value=\"\"></option>"); } strControl.Append("</select>"); return strControl.ToString(); }
public static string CreateDropdownList(FieldInfo field) { return CreateDropdownList(field, false); }
private bool FieldIsEmpty(FieldInfo field, string fieldValue) { if (String.IsNullOrWhiteSpace(fieldValue)) { return true; } else { switch ((field.DataType)) { case FieldInfo.DATATYPE_DOUBLE: case FieldInfo.DATATYPE_FLOAT: case FieldInfo.DATATYPE_INT: double dValue = 0; double.TryParse(fieldValue, out dValue); if (dValue == 0 && !this.Options.AllowZero) { return true; } break; } } return false; }
private void InitSCMPriceMasterType(FieldInfo field) { if (!string.IsNullOrEmpty(this.PageType)) { } }
public static void CheckDataType(FieldInfo field, object value, SystemMessages sysMsg, int line) { string strLine = line == 0 ? "" : "(line:" + line + ")"; switch (field.DataType) { case FieldInfo.DATATYPE_INT: if (!UIComponent.IsInt(value)) { sysMsg.isPass = false; sysMsg.Messages.Add(field.DisplayName + strLine, String.Format("[{0}] is not numeric type", value)); } break; case FieldInfo.DATATYPE_DATE: case FieldInfo.DATATYPE_DATETIME: if (!UIComponent.IsDate(value)) { sysMsg.isPass = false; sysMsg.Messages.Add(field.DisplayName + strLine, String.Format("[{0}] is not datetime type", value)); } break; case FieldInfo.DATATYPE_DOUBLE: case FieldInfo.DATATYPE_FLOAT: if (!UIComponent.IsFloat(value)) { sysMsg.isPass = false; sysMsg.Messages.Add(field.DisplayName + strLine, String.Format("[{0}] is not float type", value)); } break; case FieldInfo.DATATYPE_PERCENT: if (!UIComponent.IsPercent(value)) { sysMsg.isPass = false; sysMsg.Messages.Add(field.DisplayName + strLine, String.Format("[{0}] is not numeric type", value)); } break; case FieldInfo.DATATYPE_LIST: if (!UIComponent.IsList(field.KeyValueSource, value)) { sysMsg.isPass = false; sysMsg.Messages.Add(field.DisplayName + strLine, String.Format("[{0}] not exist in data list", value)); } break; case FieldInfo.DATATYPE_LIST_SQL: if (!UIComponent.IsListSql(value, field.KeyValueSource)) { sysMsg.isPass = false; sysMsg.Messages.Add(field.DisplayName + strLine, String.Format("[{0}] not exist in data list", value)); } break; } }
private object GetFieldValue(FieldInfo field) { string fieldValue = String.Format("{0}", field.DataValue); object pv = null; if (String.IsNullOrEmpty(fieldValue.Trim())) { if (IsNumber(field)) { pv = ParseHelper.Parse<double>(fieldValue); } else { pv = DBNull.Value; } } else { if (field.DataType == FieldInfo.DATATYPE_PERCENT) { pv = ParseHelper.Parse<double>(fieldValue.Replace("%", "")) / 100; } else { pv = fieldValue; } } return pv; }
public static string CreateDropdownListSql(FieldInfo field) { StringBuilder strControl = new StringBuilder(); DataTable dt = SqlText.ExecuteDataset(field.KeyValueSource.ToString()).Tables[0]; strControl.AppendFormat("<select class=\"form-control\" style=\"width:100% !important\" name=\"{0}\" id=\"{0}\"{1}>", field.FieldName, GetVisible(field)); if (dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { string val = Convert.ToString(dr["Value"]); string comVal = GetComponentValue(field); if (comVal == "CurrentUser") comVal = AccessControl.CurrentLogonUser.Name; string selected = String.Compare(val, comVal) == 0 ? " selected" : ""; strControl.AppendFormat("<option value=\"{0}\"{1}>{0}</option>", dr["Value"], selected); } } else { strControl.Append("<option value=\"\"></option>"); } strControl.Append("</select>"); return strControl.ToString(); }
public static string CreateQueryBox(FieldInfo field) { string comVal = GetComponentValue(field); return String.Format("<span class=\"input-icon input-icon-right\" style=\"width:100% !important;\" onclick=\"{3}\"><input class=\"form-field\" style=\"cursor:pointer;width:100% !important\" id=\"{0}\" name=\"{0}\" type=\"text\" value=\"{1}\"{2}><i class=\"icon-search green\" style=\"cursor:pointer;\"></i></span>", field.FieldName, comVal, GetVisible(field), field.KeyValueSource); }
public static string CreateCheckBox(FieldInfo field) { return String.Format("<label><input id=\"{0}\" name=\"{0}\" type=\"checkbox\" class=\"ace\"><span class=\"lbl\">{1}</span></label>", field.FieldName, field.DisplayName); }
public static string CreateTextBox(FieldInfo field) { string comVal = GetComponentValue(field); if (comVal == "CurrentUser") { comVal = AccessControl.CurrentLogonUser.Name; } return String.Format("<input class=\"form-field\" style=\"width:100% !important\" id=\"{0}\" name=\"{0}\" type=\"text\" value=\"{1}\"{2}>", field.FieldName, HttpContext.Current.Server.HtmlEncode(comVal), GetVisible(field)); }
public static string CreateTextBox(FieldInfo field) { return String.Format("<input style=\"width:100% !important\" id=\"{0}\" name=\"{0}\" type=\"text\" value=\"{1}\"{2}>", field.FieldName, GetComponentValue(field), GetVisible(field)); }
/// <summary> /// Create WorkFlow status icon for ProductInformation in VVIPricingDetail /// </summary> /// <param name="field"></param> /// <returns></returns> /// Lance Chen 20150129 public static string CreateWFStatusIconForVVI(FieldInfo field) { string fieldValue = GetComponentValue(field); string strreturn = ""; if (!string.IsNullOrWhiteSpace(fieldValue) && fieldValue == "9") { strreturn=strreturn+ "<span class=\"label label-success arrowed arrowed-right\">Closed</span>"; } else { strreturn=strreturn+ "<span class=\"label label-info arrowed arrowed-right\">Launch</span>"; } return strreturn; }
public static string GetComponentDateTimeValue(FieldInfo field, DateTime dt) { if (field.DataType == FieldInfo.DATATYPE_DATETIME) { return dt.ToString("MM/dd/yyyy HH:mm:ss"); } else { return dt.ToString("MM/dd/yyyy"); } }
public static string CreateDetailComponentAndLable(FieldInfo field) { return CreateDetailComponentAndLable(field, null); }
public static string CreateDatePicker(FieldInfo field) { return String.Format("<div class=\"input-group\"><input style=\"height:28px !important\" id=\"{0}\" name=\"{0}\" value=\"{1}\"{2} type=\"text\" class=\"form-control date-picker\" data-date-format=\"mm/dd/yyyy\"><span style=\"height:24px !important\" class=\"input-group-addon\"><i class=\"icon-calendar bigger-110\"></i></span></div>", field.FieldName, GetComponentDateTimeValue(field), GetVisible(field)); }
public static string CreateDetailComponentAndLable(FieldInfo field, Dictionary<int, Dictionary<string, string>> componentWidth) { return CreateDetailComponentAndLable(field, field.Category == null ? 8 : field.Category.ColSpan, componentWidth); }
public static string CreateDetailComponentAndLable(FieldInfo field, string pageType) { int catetoryColSpan = field.Category == null ? 8 : field.Category.ColSpan; string lableWidth = ""; string comWidth = ""; switch (catetoryColSpan) { case 2: lableWidth = "20%"; comWidth = "80%"; break; case 4: lableWidth = "10%"; comWidth = "40%"; break; case 6: lableWidth = "13%"; comWidth = "20%"; break; case 10: lableWidth = "10%"; comWidth = "10%"; break; default: lableWidth = "10%"; comWidth = "15%"; break; } string fontColor = field.WFRequiredOption == RequiredOption.Required ? "color:red" : "color:#336199"; StringBuilder sb = new StringBuilder(); if (pageType == "Detail") { sb.AppendFormat("<td style=\"background-color:#edf3f4;border:1px solid #dcebf7;width:{1};{2} \" >{0}</td>", field.DisplayName, lableWidth, fontColor); sb.AppendFormat("<td style=\"border:1px dotted #dcebf7;width:{1}\" colspan={0}>", field.ColSpan, comWidth); sb.Append(CreateDetailComponent(field)); } else { sb.AppendFormat("<td style=\"width:{1} \" >{0}</td>", field.DisplayName, lableWidth); sb.AppendFormat("<td style=\"width:{1}\" colspan={0}>", field.ColSpan, comWidth); sb.Append(CreatePrintComponent(field)); } sb.Append("</td>"); if (field.ExtEmptyCol == 1) { if (pageType == "Detail") { for (int i = 0; i < field.ExtEmptyColSpan; i++) { sb.AppendFormat("<td style=\"border:1px dotted #dcebf7;\"> </td>"); } } else { for (int i = 0; i < field.ExtEmptyColSpan; i++) { sb.AppendFormat("<td> </td>"); } } } return sb.ToString(); }
public bool FieldDataQquals(FieldInfo field, object data) { switch (field.DataType) { case FieldInfo.DATATYPE_INT: case FieldInfo.DATATYPE_DOUBLE: case FieldInfo.DATATYPE_FLOAT: return ParseHelper.Parse<double>(field.DataValue) == ParseHelper.Parse<double>(data); default: return Convert.ToString(field.DataValue).Trim() == Convert.ToString(data).Trim(); } }