Exemple #1
0
        private void btn_Update_Click(object sender, EventArgs e)
        {
            Item food = new Item();

            food.Food_ID   = tbx_ID.Text;
            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 uri     = "";
            IFood  foodbll = (IFood)Activator.GetObject(typeof(IFood), uri);

            if (foodbll.Update_Food(food))
            {
                dataGridView.DataSource = foodbll.Load_Item();
                MessageBox.Show("Complete", "Result", MessageBoxButtons.OK);
            }
            else
            {
                MessageBox.Show("Fail", "Result", MessageBoxButtons.OK);
            }
        }
Exemple #2
0
        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);
            }
        }
Exemple #3
0
        private void btn_Delete_Click(object sender, EventArgs e)
        {
            Item food = new Item();

            food.Food_ID = tbx_ID.Text;
            DialogResult dialogResult = MessageBox.Show("Do you want to delete this food?", "Warning!", MessageBoxButtons.YesNo);

            String uri     = "";
            IFood  foodbll = (IFood)Activator.GetObject(typeof(IFood), uri);

            if (dialogResult == DialogResult.Yes)
            {
                if (foodbll.Delete_Food(food))
                {
                    dataGridView.DataSource = foodbll.Load_Item();
                    MessageBox.Show("Delete complete", "Result", MessageBoxButtons.OK);
                }
            }
            else if (dialogResult == DialogResult.No)
            {
                return;
            }
        }