예제 #1
0
        }//btnSaveProduct_Click

        protected void btnLoadDataService_Click(object sender, EventArgs e)
        {
            WebService1 obj = new WebService1();

            string dataJson = obj.GetItemAll();         //return json

            string xml = obj.GetItemByCode("ITEM_003"); //retuen xml

            if (xml != "")
            {
                StringReader txtReader = new StringReader(xml);

                XmlSerializer xmlSerializer = new XmlSerializer(typeof(Item));
                Item          data          = (Item)xmlSerializer.Deserialize(txtReader);
            }

            if (dataJson != "")
            {
                List <Item> item_data = JsonConvert.DeserializeObject <List <Item> >(dataJson);

                if (item_data != null && item_data.Count > 0)
                {
                    foreach (Item item in item_data)
                    {
                        ItemDal dal = new ItemDal();
                        dal.StockInsert(item);

                        this.Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "myscript", "Message_Show('Upload Success')", true);

                        GetListItem();

                        btnLoadDataService.Enabled = false;
                    }
                }
            }
        }