private void btn_NewItem_Click(object sender, EventArgs e) { Item food = new Item(); food.Name_Food = tbx_Name.Text; food.Detail = tbx_Detail.Text; food.Price = Int32.Parse(tbx_Price.Text); food.Quantity = Int32.Parse(tbx_Qualntity.Text); food.Seller_ID = tbx_Seller.Text; food.Unit = cmb_Unit.SelectedItem.ToString(); String host = txtHost.Text.Trim(); String port = txtPort.Text.Trim(); String protocol = ""; if (cmbProtocol.SelectedIndex == 0) // tcp { protocol = "tcp"; } else if (cmbProtocol.SelectedIndex == 1) // http { protocol = "http"; } String uri = protocol + "://" + host + ":" + port + "/FoodBLL"; IFood foodbll = (IFood)Activator.GetObject(typeof(IFood), uri); if (foodbll.Add_new(food)) { dataGridView.DataSource = foodbll.Load_Item(); MessageBox.Show("Complete", "Result", MessageBoxButtons.OK); } else { MessageBox.Show("Fail", "Result", MessageBoxButtons.OK); } }