protected bool set_attribute(section.type_section st, long id, section_attr a, object val, bool delete = true) { string qry_val = null; if (val != null) { try { if (a.type == section_attr.section_attr_type.datetime) { qry_val = db_provider.dt_qry(Convert.ToDateTime(val)); } else if (a.type == section_attr.section_attr_type.integer) { qry_val = Convert.ToInt32(val).ToString(); } else { qry_val = db_provider.str_qry(val.ToString()); } } catch { throw new Exception(string.Format("il valore {0} dev'essere di tipo {3} e non è corretto. elemento '{1}' id: {2}" , val.ToString(), st.ToString(), id, a.type.ToString())); } exec_set_attribute(st, id, a.type, a.code, qry_val); return(true); } else { if (delete) { exec_del_attribute(st, id, a.type, a.code); return(true); } } return(false); }
protected void exec_del_attribute(section.type_section st, long id, section_attr.section_attr_type at, string code) { db_conn.exec(core.parse_query("sections.delete-attribute" , new Dictionary <string, object>() { { "section_id", id }, { "attr_type", at.ToString() } , { "attr_code", code }, { "section_type", st } })); }
protected void exec_set_attribute(section.type_section st, long id, section_attr.section_attr_type at, string code, string qry_val) { db_conn.exec(core.parse_query("sections.set-attribute" , new Dictionary <string, object>() { { "attr_type", at }, { "attr_value", qry_val } , { "section_id", id }, { "attr_code", code }, { "section_type", st } })); }
public section_attr(section.type_section st, int id, string code, section_attr_type type) { this.s_type = st; this.id = id; this.code = code; this.type = type; }