public string getJSONData(int IdDeclare, string flt, int N, int LenP, string sort, string order, string Query, Dictionary <string, object> Params = null, string MainSQL = null) { if (string.IsNullOrEmpty(MainSQL)) { MainSQL = getSQL(IdDeclare, Query); } if (!string.IsNullOrEmpty(sort) & !string.IsNullOrEmpty(order)) { //Добавляем свою сортировку int n = MainSQL.ToUpper().IndexOf("ORDER BY"); if (n == -1) { throw new Exception("not find ORDER BY section!"); } MainSQL = MainSQL.Substring(0, n) + " order by " + DBClient.sortCreate(sort, order); } Dictionary <string, string> formats = new Dictionary <string, string>(); string sql = "select D.*, P.ParamValue from t_rpDeclare D(nolock) inner join t_sysParams P(nolock) on 'GridFind' + D.DecName = P.ParamName where IdDeclare = @IdDeclare"; DataTable decTab = new DataTable(); SqlDataAdapter da = new SqlDataAdapter(sql, DBClient.CnStr); da.SelectCommand.Parameters.AddWithValue("@IdDeclare", IdDeclare); da.Fill(decTab); string s = decTab.Rows[0]["ParamValue"].ToString(); XmlDocument xm = new XmlDocument(); XmlElement xRoot; xm.LoadXml(s); xRoot = xm.DocumentElement; foreach (XmlNode xNod in xRoot.SelectNodes("COLUMN")) { XmlElement xCol = (XmlElement)xNod; string FName = xCol.Attributes["FieldName"].Value; string DisplayFormat = xCol.Attributes["DisplayFormat"].Value; if (!String.IsNullOrEmpty(DisplayFormat)) { formats.Add(FName, DisplayFormat); } } //Итоги 03.08.2016 string SumFields = xRoot.GetAttribute("SumFields"); //string FROZENCOLS = xRoot.GetAttribute("FROZENCOLS"); string LabelText = xRoot.GetAttribute("LabelText"); string LabelField = xRoot.GetAttribute("LabelField"); return(getJSONData(MainSQL, flt, N, LenP, formats, Params, SumFields, LabelText, LabelField)); }