Esempio n. 1
0
        public void loadSuppliers()
        {
            clsDBSupplier dbSupplier = new clsDBSupplier();
            List<clsSupplier> suppliers = dbSupplier.SupplierList();

            Int32 Index = 0;
            
            lstSupplier.Items.Clear();
            while (Index < suppliers.Count)
            {
                clsSupplier supplier = suppliers[Index];

                ListViewItem NewItem = new ListViewItem();
                NewItem.Text = supplier.Name;
                NewItem.SubItems.Add(supplier.Address);
                NewItem.SubItems.Add(supplier.Town);
                NewItem.SubItems.Add(supplier.Postcode);
                NewItem.SubItems.Add(supplier.ContactName);
                NewItem.SubItems.Add(supplier.ContactNumber);
              
                NewItem.Tag = supplier;
                lstSupplier.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
                lstSupplier.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
                lstSupplier.Items.Add(NewItem); //Add the item to ListView

                Index++; //move the index to the next record
            }
        }
Esempio n. 2
0
        private void btnDelete_Click(object sender, EventArgs e)
        {

            if (lstSupplier.SelectedItems.Count > 0)
            {
                ListViewItem selectedItem = lstSupplier.SelectedItems[0];
                clsSupplier supplier = (clsSupplier)selectedItem.Tag;
                // Display a message box asking users if they
                // want to delete the selected Supplier.
                if (MessageBox.Show("Are you sure to Delete this Supplier " + supplier.Name + "?", "Delete Supplier",
                    MessageBoxButtons.YesNo, MessageBoxIcon.Question)
                      == DialogResult.Yes)
                {
                    // code for deleting the record goes here
                    clsDBSupplier dbSupplier = new clsDBSupplier();
                    dbSupplier.DeleteSupplier(supplier.ID);
                    loadSuppliers();
                }
            }
        }
Esempio n. 3
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (isValid())
            {
                clsSupplier supplier = new clsSupplier();
                supplier.Name          = txtSupplierName.Text;
                supplier.Address       = txtAddress.Text;
                supplier.Town          = txtTown.Text;
                supplier.Postcode      = txtPostCode.Text;
                supplier.ContactName   = txtContactName.Text;
                supplier.ContactNumber = txtContactNo.Text;

                clsDBSupplier fbs   = new clsDBSupplier();
                Int32         added = 0;
                if (txtID.Text.Length > 0)
                {
                    supplier.ID = Convert.ToInt32(txtID.Text);
                    added       = fbs.UpdateSupplier(supplier);
                }
                else
                {
                    added = fbs.InsertSupplier(supplier);
                }

                if (added > 0)
                {
                    frmListSupplier.loadSuppliers();
                    Close();
                }
                else
                {
                    txtErrorMessage.Text    = "Could not added Supplier.";
                    txtErrorMessage.Visible = true;
                }
            }
            else
            {
                txtErrorMessage.Text    = "Specify valid values";
                txtErrorMessage.Visible = true;
            }
        }
        public void loadSuppliers(clsProductRecord productRecord)
        {
            clsDBSupplier      dbSupplier = new clsDBSupplier();
            List <clsSupplier> suppliers  = dbSupplier.SupplierList();

            Int32 Index = 0;

            cmbSupplierName.DisplayMember = "Name";
            cmbSupplierName.ValueMember   = "ID";
            cmbSupplierName.Items.Clear();
            while (Index < suppliers.Count)
            {
                clsSupplier supplier = suppliers[Index];
                cmbSupplierName.Items.Add(supplier); //add the supplier to the list
                if (productRecord != null && (productRecord.SupplierId == supplier.ID))
                {
                    cmbSupplierName.SelectedItem = supplier;
                }

                Index++; //move the index to the next record
            }
        }