public void FieldRef_Change(object sender, EventArgs e) { StringBuilder query = new StringBuilder(); DataSet ds = DatabaseConnection.CreateDataset("SELECT * FROM ADDEDFIELD_DROPDOWN WHERE ID=" + DatabaseConnection.FilterInjection(FieldRef.SelectedValue)); if (ds.Tables[0].Rows.Count > 0) { DataRow dr = ds.Tables[0].Rows[0]; switch (dr["QueryType"].ToString()) { case "0": query.AppendFormat("SELECT {0} AS V1,{1} AS V2 FROM {2} ", dr["SonFieldValue"].ToString(), dr["SonFieldTxt"].ToString(), dr["SonTable"].ToString()); query.AppendFormat("WHERE LANG='{0}'", UC.Culture.Substring(0, 2)); break; case "1": query.AppendFormat("SELECT {0} AS V1,{1} AS V2 FROM {2} ", dr["SonFieldValue"].ToString(), dr["SonFieldTxt"].ToString(), dr["SonTable"].ToString()); break; } FieldRefValue.DataTextField = "v2"; FieldRefValue.DataValueField = "v1"; FieldRefValue.DataSource = DatabaseConnection.CreateDataset(query.ToString()); FieldRefValue.DataBind(); FieldRefValue.Items.Insert(0, Root.rm.GetString("SQLFree0")); FieldRefValue.Items[0].Value = "0"; } }
private void RepContacts_Command(object sender, RepeaterCommandEventArgs e) { switch (e.CommandName) { case "DelField": string delSql = "DELETE FROM ADDEDFIELDS WHERE ID =" + int.Parse(((Literal)e.Item.FindControl("FieldID")).Text); DatabaseConnection.DoCommand(delSql); break; case "ModField": AddContactFields.Visible = true; string sqlStringMod = "SELECT * FROM ADDEDFIELDS WHERE ID =" + int.Parse(((Literal)e.Item.FindControl("FieldID")).Text); DataSet ds = DatabaseConnection.CreateDataset(sqlStringMod); Field.Text = ds.Tables[0].Rows[0]["Name"].ToString(); ViewOrderField.Text = ds.Tables[0].Rows[0]["ViewOrder"].ToString(); Groups.SetGroups(ds.Tables[0].Rows[0]["Groups"].ToString()); FieldID.Text = ((Literal)e.Item.FindControl("FieldID")).Text; Type.SelectedIndex = -1; foreach (ListItem li in Type.Items) { if (li.Value == ds.Tables[0].Rows[0]["Type"].ToString()) { li.Selected = true; break; } } DataSet dsDrop = DatabaseConnection.CreateDataset("SELECT * FROM ADDEDFIELD_DROPDOWN WHERE REFERENCETABLE=" + ds.Tables[0].Rows[0]["tablename"].ToString()); DataSet dsdropvalue = new DataSet(); FieldRef.Items.Clear(); foreach (DataRow dr in dsDrop.Tables[0].Rows) { ListItem li = new ListItem(); li.Text = Root.rm.GetString("SQLFree" + dr["rmValue"].ToString()); li.Value = dr["ID"].ToString(); if (ds.Tables[0].Rows[0]["ParentField"].ToString() == dr["ReferenceField"].ToString()) { li.Selected = true; dsdropvalue = DatabaseConnection.CreateDataset("SELECT * FROM ADDEDFIELD_DROPDOWN WHERE ID=" + int.Parse(dr["id"].ToString())); } FieldRef.Items.Add(li); } FieldRef.Items.Insert(0, Root.rm.GetString("SQLFree0")); FieldRef.Items[0].Value = "0"; if (dsdropvalue.Tables.Count > 0) { DataRow drdropvalue = dsdropvalue.Tables[0].Rows[0]; StringBuilder query = new StringBuilder(); switch (drdropvalue["querytype"].ToString()) { case "0": query.AppendFormat("SELECT {0} AS V1,{1} AS V2 FROM {2} ", drdropvalue["SonFieldValue"].ToString(), drdropvalue["SonFieldTxt"].ToString(), drdropvalue["SonTable"].ToString()); query.AppendFormat("WHERE LANG='{0}'", UC.Culture); break; case "1": query.AppendFormat("SELECT {0} AS V1,{1} AS V2 FROM {2} ", drdropvalue["SonFieldValue"].ToString(), drdropvalue["SonFieldTxt"].ToString(), drdropvalue["SonTable"].ToString()); break; } FieldRefValue.DataTextField = "v2"; FieldRefValue.DataValueField = "v1"; FieldRefValue.DataSource = DatabaseConnection.CreateDataset(query.ToString()); FieldRefValue.DataBind(); FieldRefValue.Items.Insert(0, Root.rm.GetString("SQLFree0")); FieldRefValue.Items[0].Value = "0"; } foreach (ListItem li in FieldRefValue.Items) { if (li.Value == ds.Tables[0].Rows[0]["ParentFieldValue"].ToString()) { li.Selected = true; break; } } if ((byte)ds.Tables[0].Rows[0]["Type"] == (byte)FreeFields.FreeFieldsType.select) { Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>ShowHideItems(document.getElementById('Type'));</script>"); } ds.Clear(); break; } this.TabSwitch(true); }