예제 #1
0
 private void button6_Click_1(object sender, EventArgs e)
 {
     try
     {
         List <Vendor> vendorList = new List <Vendor>();
         vendorList = VendorDB.GetVendor();
         MessageBox.Show("You have " + vendorList.Count.ToString() + " vendors");
         dataGridView1.DataSource = vendorList;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
예제 #2
0
        private void button2_Click_2(object sender, EventArgs e)
        {
            if (textBox1.Text.Trim() == String.Empty)
            {
                MessageBox.Show("Please enter a Vendor ID to find.");
                textBox2.Focus();
                return;
            }

            Vendor objVendor = VendorDB.GetVendor(Convert.ToInt32(textBox1.Text.Trim()));

            //Step 2: Validate to make sure the Customer object is not null.
            if (objVendor != null)
            {
                //Populate the UI with the object values
                textBox2.Text = objVendor.VendorName;
                //make Customer ID field read-only to be used for updating and deleting records demo
                textBox1.ReadOnly = true;
            }
            else
            {
                MessageBox.Show("Vendor ID " + textBox1.Text.Trim() + " not found in database.", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }