Пример #1
0
        private void SupplierListDoubleClick(object sender, EventArgs e)
        {
            var supplier = new Supplier();

            supplier.vSupplierEditMode = SupplierEditMode.Edit;
            var supplierName = (string)supplierList.Items[supplierList.SelectedIndex];
            var vSupplier = GetSupplierByName(ListSupplier, supplierName);
            supplier.Supp = vSupplier;
            if (supplier.ShowDialog() == DialogResult.OK)
            {
                ListSupplier.Remove(vSupplier);
                ListSupplier.Add(supplier.Supp);

                supplierList.Items.Clear();
                for(int i=0;i<ListSupplier.Count;i++)
                {
                    supplierList.Items.Add(ListSupplier[i].Name);
                }
                if (supplierList.Items.Count > 0)
                    supplierList.SelectedIndex = 0;

            }
        }
Пример #2
0
        private void BtnAddSupplierClick(object sender, EventArgs e)
        {
            var supplier = new Supplier();
            supplier.vSupplierEditMode = SupplierEditMode.Add;

            if (supplier.ShowDialog() == DialogResult.OK)
            {
                ListSupplier.Add(supplier.Supp);
                supplierList.Items.Clear();
                for(int i=0; i<ListSupplier.Count; i++)
                {
                    supplierList.Items.Add(ListSupplier[i].Name);
                }

            }

            if (supplierList.Items.Count > 0 && supplierList.SelectedIndex == -1)
                supplierList.SelectedIndex = 0;
        }