public static string getReturnJson(string url)
        {
            StreamReader streamReader = null;
            string       Rstring      = "";

            try
            {
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
                request.Method = "GET";
                // request.Accept = "text/html, application/xhtml+xml, */*";
                request.ContentType = "application/json";
                request.Headers.Add("X-User", user);
                request.Headers.Add("X-DB", db);
                WarehouseCode warehouseCode = new WarehouseCode(warehouse);
                string        w             = JsonConvert.SerializeObject(warehouseCode);
                request.Headers.Add("x-params", w);
                WebResponse response = (WebResponse)request.GetResponse();
                streamReader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
                // XmlDocument doc = new XmlDocument();
                string s = streamReader.ReadToEnd();
                streamReader.Close();
                // doc.LoadXml(s);
                //  Rstring = JsonConvert.SerializeXmlNode(doc);
                Rstring = s;
            }
            catch (Exception ex)
            {
                LogExecute.WriteExceptionLog("GET", ex);
            }
            return(Rstring);
        }
Exemple #2
0
 public void getDefaultWarehouseInfo(string user)
 {
     try
     {
         string sql = string.Format("select s.defaultWarehouseCode as 'code',s.defaultWarehouseName as 'name'  from user_settings s where s.Code='{0}' ;", user);
         cbxWarehouse.DataSource = null;
         DataTable dt2 = DBConnect.GetDataSet(sql);
         cbxWarehouse.DataSource    = dt2;
         cbxWarehouse.DisplayMember = "name";
         cbxWarehouse.ValueMember   = "code";
     }
     catch (Exception ex)
     {
         LogExecute.WriteExceptionLog("getDefaultWarehouseInfo", ex);
     }
 }
Exemple #3
0
 public void getWarehouseInfo(string user)
 {
     try
     {
         string sql = string.Format("select count(0)  from ttx_user s where s.code='{0}'", user);
         if (DBConnect.GetDataSet(sql).Rows[0][0].ToString() != "0")
         {
             sql = string.Format(" select w.`code`,w.`name` from ttx_data_right r INNER JOIN warehouse w on r.`value`= w.`code` where r.`user`= '{0}' and r.tid = 'warehouse';", user);
             cbxWarehouse.DataSource = null;
             DataTable dt = DBConnect.GetDataSet(sql);
             cbxWarehouse.DataSource    = dt;
             cbxWarehouse.DisplayMember = "name";
             cbxWarehouse.ValueMember   = "code";
         }
     }
     catch (Exception ex) {
         LogExecute.WriteExceptionLog("getWarehouseInfo", ex);
     }
 }