예제 #1
0
        // STEP 6
        private void btnSupDelete_Click(object sender, EventArgs e)
        {
            Supplier sup = new Supplier();


            sup = (Supplier)comboSupId.SelectedValue;


            SupplierDB.DeleteSupplier(sup);
            //MessageBox.Show(sup.SupName.ToString() + " has been successfully deleted from the database.");
            List <Supplier> suppliers = SupplierDB.GetSuppliers();

            comboSupId.DataSource    = suppliers;
            comboSupId.DisplayMember = "SupplierId";
        }
예제 #2
0
        // STEP 7
        private void comboSupId_SelectedIndexChanged(object sender, EventArgs e)
        {
            List <Supplier> sups = new List <Supplier>();

            sups = SupplierDB.GetSuppliers();
            Supplier sup = (Supplier)comboSupId.SelectedItem;

            //sups.Add(sup);
            dataGridViewSup.DataSource = sups;

            List <Supplier> suppliers = SupplierDB.GetSuppliers();

            txtSupName.Text = suppliers[Convert.ToInt32(comboSupId.SelectedIndex)].SupName;

            supold.SupName = txtSupName.Text.ToString();
        }
예제 #3
0
 // STEP 3
 public void GetSuppliers()
 {
     try
     {
         //fill list with database suppliers and populate combobox with the value
         suppliers                = SupplierDB.GetSuppliers();
         comboSupId.DataSource    = suppliers;
         comboSupId.DisplayMember = "SupName";
         comboSupId.ValueMember   = "SupplierId";
     }
     //catch any database exceptions
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, ex.GetType().ToString());
     }
 }
예제 #4
0
        // ***********
        // * STEP 0C *
        // ***********

        private void Form1_Load(object sender, EventArgs e)
        {
            //// Mike
            tabselection();

            // Justin
            List <Product> products = ProductDB.GetProducts();

            comboProdId.DataSource    = products;
            comboProdId.DisplayMember = "ProductId";

            // Ayi
            List <Supplier> suppliers = SupplierDB.GetSuppliers();

            comboSupId.DataSource    = suppliers;
            comboSupId.DisplayMember = "SupplierId";
        }
예제 #5
0
        // STEP 5
        private void btnSupUpdate_Click(object sender, EventArgs e)
        {
            if (Validator.IsPresent(txtSupName))
            {
                Supplier supnew = new Supplier();

                supold         = (Supplier)comboSupId.SelectedItem;
                supnew.SupName = txtSupName.Text.ToString();

                SupplierDB.UpdateSupplier(supold, supnew);

                MessageBox.Show(supold.SupName.ToString() + " has been successfully updated in the database.");
                List <Supplier> suppliers = SupplierDB.GetSuppliers();
                comboSupId.DataSource    = suppliers;
                comboSupId.DisplayMember = "SupplierId";
            }
        }
예제 #6
0
        // STEP 4
        private void btnSupAdd_Click(object sender, EventArgs e)
        {
            Supplier sup = new Supplier();

            if (Validator.IsPresent(txtNewSupId) && Validator.IsInteger(txtNewSupId) && Validator.IsPresent(txtSupName))
            {
                sup.SupplierId = Convert.ToInt32(txtNewSupId.Text);
                sup.SupName    = txtSupName.Text.ToString();

                SupplierDB.AddSupplier(sup);
                MessageBox.Show(sup.SupName.ToString() + " has been successfully added to the database.");
                List <Supplier> suppliers = SupplierDB.GetSuppliers();
                comboSupId.DataSource    = suppliers;
                comboSupId.DisplayMember = "SupplierId";
            }
            else
            {
            }
        }
예제 #7
0
 // STEP 2
 public void GetSupplier(int supplierId)
 {
     Supplier suppliers = SupplierDB.GetSupplier(supplierId);
 }