public string OnControllerAction(string ID, string What, string Data) { string ret = ""; if (What == "TryToAdd") { string StrignData = (string)Data; Dictionary <string, string> decoded = WebStuffHelper.DecodeJsonFormData(StrignData); Dictionary <string, string> dd = WebStuffHelper.GetRidOfParentID(decoded); ////////////////////////////////////////////////////////////////////////////////////////// string SQL; int off; string NewLabelID = dd["fNewLabelID"]; List <string> LanguageIDs = new List <string>(); StringBuilder sb = new StringBuilder(); foreach (KeyValuePair <string, string> entry in dd) { if (entry.Key == "fNewLabelID") { NewLabelID = dd["fNewLabelID"]; } else { off = entry.Key.IndexOf("-o"); LanguageIDs.Add(entry.Key.Substring(off + 2)); } } for (int i = 0; i < LanguageIDs.Count; i++) { sb.AppendLine("INSERT INTO Labels (LabelID, LanguageID) SELECT " + NewLabelID + ", '" + LanguageIDs[i] + "';"); } ////////////////////////////////////////////////////////////////////////////////////////// SQL = sb.ToString(); if (SQL.Length != 0) { using (SqlConnection con = new SqlConnection(DBUtil.GetSqlConnectionString())) { con.Open(); int r = -1; r = DBUtil.RunSQLQuery(con, SQL); if (r == -1) { ret = "Could not insert requested labels."; } else { ret = "ok"; } } } } else if (What == "AddMenu") { return(WebStuffHelper.GetString(GetNewLabelSuggestions())); } else if (What == "RefreshData") { string[] FilterValues = Data.Split('&'); DataGrid.ApplyFilters(FilterValues, FilteringType.StartWith); return(WebStuffHelper.GetString(DataGrid.HtmlTextTableBody())); } else if (What == "AjaxSave") { Dictionary <string, string> decoded = DecodeJsonFormData(Data); Save(decoded); ret = "ok"; } return(ret); }