private void Button2_Click(object sender, EventArgs e) { bindingSource1.EndEdit(); int ed = context.SaveChanges(); string id = textBox2.Text; var result = context.ProductNews .Where(p => p.product_id == id) .First(); //RestClient client2 = new RestClient("http://www.csmsu.net"); //RestRequest request2 = new RestRequest("/APDServiceRest/api/Product/" + result.product_id + "/8"); ; //var resultGet = client2.Execute<List<getProduct>>(request2, Method.GET); RestClient client = new RestClient("http://www.csmsu.net"); RestRequest request = new RestRequest("/APDServiceRest/api/Product"); putToService insertP = new putToService(); insertP.productid = textBox2.Text; insertP.productname = textBox3.Text; insertP.productdetail = textBox4.Text; string str = textBox6.Text; while (str.Contains(",")) { int inx = textBox6.Text.IndexOf(','); str = textBox6.Text.Remove(inx, 1); } insertP.productprice = str; insertP.productimgurl = result.product_pic; insertP.shopid = 8; request.AddObject(insertP); var result2 = client.Execute(request, Method.PUT); //MessageBox.Show("Img = "+ converted); if (ed > 0 && result2.ResponseStatus == ResponseStatus.Completed) { MessageBox.Show("แก้ไขข้อมูลสินค้าเรียบร้อยแล้ว"); pro.updateDataSorce(); this.Close(); } }
private void Button3_Click(object sender, EventArgs e) { pro.updateDataSorce(); this.Close(); }