Example #1
0
        public string GetItemCostMethodList(int userId, string session, int currPage, int NumberRowOfPage)
        {
            //string pInput = string.Format("<InputValue PageIndex='{0}' RowsPerPage='{1}' />", currPage, NumberRowOfPage);
            string InputValue = CXmlPara.CreatePara(new KeyValuePair <string, string>[]
            {
                new KeyValuePair <string, string>("PageIndex", currPage.ToString()),
                new KeyValuePair <string, string>("RowsPerPage", NumberRowOfPage.ToString()),
            }
                                                    );

            COutputValue pageinfo = new COutputValue();

            CCostMethod[] list = service.GetCostMethodList(InputValue, ref pageinfo);
            StringBuilder ret  = new StringBuilder();

            try
            {
                string format = "\"ID\":\"{0}\", \"Code\":\"{1}\", \"Name\":\"{2}\"";

                ret.Append("{");
                ret.AppendFormat("\"currpage\":\"{0}\",\"totalpages\":\"{1}\",\"totalrecords\":\"{2}\",\"invdata\":[", currPage, pageinfo.TotalPage, pageinfo.TotalRow);
                for (int i = 0; i < list.Length; i++)
                {
                    string item = string.Format(format, list[i].ID, list[i].MethodID, list[i].MethodName);
                    ret.Append("{" + item + "}");
                    if (i < list.Length - 1)
                    {
                        ret.Append(",");
                    }
                }
                ret.Append("]}");
            }
            catch (Exception)
            {
            }
            return(ret.ToString());
        }