Beispiel #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(pricetextbox.Text) || comboBox1.Text == "")
            {
                MessageBox.Show("Make sure to fill Type, supplier_name, Price");
                return;
            }



            string p = pricetextbox.Text;
            double result;

            if (!Double.TryParse(p, out result))
            {
                MessageBox.Show("Please enter a proper price");
                return;
            }


            float price = (float)Convert.ToDouble(p);


            controllerObj.AddProduct(comboBox2.Text, price);
            string pid = Convert.ToString(controllerObj.GetProductID());

            DataTable dt = controllerObj.SelectBranches();

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                string branch = dt.Rows[i][0].ToString();
                controllerObj.InsertProductinBranchHas(pid, branch);
                controllerObj.InsertProductinBranchSold(pid, branch);
            }


            if (comboBox1.Text == "Motorcycle")
            {
                Motorcycle m = new Motorcycle();
                m.Show();
            }

            else if (comboBox1.Text == "Sparepart")
            {
                new SpareParts().Show();
            }

            else if (comboBox1.Text == "Accessory")
            {
                new Accessories().Show();
            }
        }