public static SWBaseTag GetTag(string type) { if (String.IsNullOrWhiteSpace(type)) { return(null); } type = type.ToLower(); SWBaseTag tag = null; switch (type) { case SWInputTextTag.Type: tag = new SWInputTextTag(); break; case SWDateTag.Type: tag = new SWDateTag(); break; case SWVarTag.Type: tag = new SWVarTag(); break; case SWQueryTag.Type: tag = new SWQueryTag(); break; case SWSelectTag.Type: tag = new SWSelectTag(); break; case SWInputDateTag.Type: tag = new SWInputDateTag(); break; case SWInputTimeTag.Type: tag = new SWInputTimeTag(); break; } return(tag); }
public static SWBaseTag GetTag(string type) { if (String.IsNullOrWhiteSpace(type)) return null; type = type.ToLower(); SWBaseTag tag = null; switch (type) { case SWInputTextTag.Type: tag = new SWInputTextTag(); break; case SWDateTag.Type: tag = new SWDateTag(); break; case SWVarTag.Type: tag = new SWVarTag(); break; case SWQueryTag.Type: tag = new SWQueryTag(); break; case SWSelectTag.Type: tag = new SWSelectTag(); break; case SWInputDateTag.Type: tag = new SWInputDateTag(); break; case SWInputTimeTag.Type: tag = new SWInputTimeTag(); break; } return tag; }
private string ProcessSelectTag_Form(SWSelectTag tag, out string errormessage) { errormessage = ""; if (tag == null) return ""; tag = (from t in this.ReportItem.FormTags where tag.Name.ToLower().Equals(t.Name.ToLower()) && tag.TagType.Equals(t.TagType) select t as SWSelectTag).FirstOrDefault(); if (tag == null) return ""; string result = String.Format("<select class=\"form-control\" name=\"{0}\" onchange=\"this.form.submit()\">", tag.Name); DbDataReader reader = null; DbConnection conn = null; try { reader = ConnectionItem.GetReader(this.ReportItem.ConnectionItem, tag.Value, out errormessage, out conn, this.SetupQueryParameters(tag as SWBaseSQLTag)); if (reader != null && reader.FieldCount >= 2) { while (reader.Read()) { if (!this.PhysicalFormValues.ContainsKey(tag.Name)) { this.PhysicalFormValues.Add(tag.Name, reader[0].ToString()); } string selected = ""; if (reader[0].ToString().Equals(this.PhysicalFormValues[tag.Name])) { selected = "selected"; } result += String.Format("<option {2} value=\"{0}\">{1}</option>", WebUtility.HtmlEncode(reader[0].ToString()), WebUtility.HtmlEncode(reader[1].ToString()), selected); } } } catch (Exception ex) { errormessage = ex.Message; } finally { if (reader != null) { reader.Close(); reader.Dispose(); reader = null; } if (conn != null) { conn.Close(); conn = null; } } result += "</select>"; return result; }
private string ProcessSelectTag_Template(SWSelectTag tag, out string errormessage) { errormessage = ""; if (tag == null) return ""; tag = (from t in this.ReportItem.FormTags where tag.Name.ToLower().Equals(t.Name.ToLower()) && tag.TagType.Equals(t.TagType) select t as SWSelectTag).FirstOrDefault(); if (tag == null) return ""; if(!this.PhysicalFormValues.ContainsKey(tag.Name)) { return ""; } DbDataReader reader = null; DbConnection conn = null; try { reader = ConnectionItem.GetReader(this.ReportItem.ConnectionItem, tag.Value, out errormessage, out conn, this.SetupQueryParameters(tag as SWBaseSQLTag)); if (reader != null && reader.FieldCount >= 2) { while (reader.Read()) { if (reader[0].ToString().Equals(this.PhysicalFormValues[tag.Name])) { return WebUtility.HtmlEncode(reader[1].ToString()); } } } } catch (Exception ex) { errormessage = ex.Message; } finally { if (reader != null) { reader.Close(); reader.Dispose(); reader = null; } if (conn != null) { conn.Close(); conn = null; } } return ""; }
private string ProcessSelectTag(SWSelectTag tag, DBContent.TagValueItemTypes htmlType, out string errormessage) { errormessage = ""; switch (htmlType) { case DBContent.TagValueItemTypes.Template: return ProcessSelectTag_Template(tag, out errormessage); case DBContent.TagValueItemTypes.Form: return ProcessSelectTag_Form(tag, out errormessage); } return ""; }