예제 #1
0
        public async void Insert_Data()
        {
            try
            {
                var datagrid = App.Current.Properties["DataGridPA"] as ObservableCollection <ProductModel>;

                selectProduct.SelectedItem = datagrid;



                //if (PRODUCT_CODE == "" || PRODUCT_CODE == null)
                //{
                //    MessageBox.Show("PRODUCT CODE Should not be blank..");
                //}

                //else if (selectProduct.DESCR == "" || selectProduct.DESCR == null)
                //{
                //    MessageBox.Show("DESCRIPTION Should not be blank..");
                //}

                //else if (selectProduct.BIN == "" || selectProduct.BIN == null)
                //{
                //    MessageBox.Show("BIN Should not be blank..");
                //}

                //else
                {
                    HttpClient client = new HttpClient();
                    client.DefaultRequestHeaders.Accept.Add(
                        new MediaTypeWithQualityHeaderValue("application/json"));
                    client.BaseAddress = new Uri(GlobalData.gblApiAdress);
                    var response = await client.PostAsJsonAsync("api/ProductAPI/AssemblyBreak/", selectProduct);

                    if (response.StatusCode.ToString() == "OK")
                    {
                        MessageBox.Show("Product Assembled Successfully");
                        //Cancel_Product();
                        ProductImage _PIMG = new ProductImage();
                        _PIMG.ShowDialog();
                    }
                }
            }

            catch
            {
            }
        }
        public async void Insert_Data()
        {
            try
            {
                if (PRODUCT_CODE == "" || PRODUCT_CODE == null)
                {
                    MessageBox.Show("PRODUCT CODE Should not be blank..");
                }

                else if (selectProduct.DESCR == "" || selectProduct.DESCR == null)
                {
                    MessageBox.Show("DESCRIPTION Should not be blank..");
                }

                else if (selectProduct.BIN == "" || selectProduct.BIN == null)
                {
                    MessageBox.Show("BIN Should not be blank..");
                }

                else
                {
                    //HttpClient client = new HttpClient();
                    //client.DefaultRequestHeaders.Accept.Add(
                    //    new MediaTypeWithQualityHeaderValue("application/json"));
                    //client.BaseAddress = new Uri(GlobalData.gblApiAdress);
                    //var response = await client.PostAsJsonAsync("api/ProductAPI/AssemblyBreak/", selectProduct);
                    //if (response.StatusCode.ToString() == "OK")
                    //{
                    MessageBox.Show("Product Assembled Successfully");
                    Cancel_Product();
                    ProductImage _PIMG = new ProductImage();
                    _PIMG.ShowDialog();


                    //}
                }
            }

            catch
            {
            }
        }