private void Initialize()
        {
            _db = new InvoiceProjectContext();
            _selectedCustomer      = null;
            _selectedProduct       = null;
            _invoiceDetail         = new HashSet <InvoiceDetail>();
            _selectedInvoiceDetail = null;

            dataGridView1.DataSource = _invoiceDetail;

            InvoiceDetail invoice = _db.InvoiceDetails.ToList().LastOrDefault();

            _invoiceID        = invoice == null ? 1 : invoice.InvoiceID;
            lblInvoiceID.Text = _invoiceID.ToString();

            cmbProductName.DisplayMember = "ProductName";
            cmbProductName.ValueMember   = "ProductID";
            cmbProductName.DataSource    = _db.Products.ToList();

            cmbCity.DisplayMember = "CityName";
            cmbCity.ValueMember   = "CityID";
            cmbCity.DataSource    = _db.Cities.ToList();
            cmbCity.Enabled       = false;

            cmbCounty.DisplayMember = "CountyName";
            cmbCounty.ValueMember   = "CountyID";
            cmbCounty.DataSource    = _db.Counties.ToList();
            cmbCounty.Enabled       = false;

            cmbCustomer.DisplayMember = "CompanyName";
            cmbCustomer.ValueMember   = "CustomerID";
            cmbCustomer.DataSource    = _db.Customers.ToList();
        }
Beispiel #2
0
        private void Initialize()
        {
            _db = new InvoiceProjectContext();
            selectedCustomer = null;
            _invoiceHeader   = new List <InvoiceHeader>();

            cmbCity.DisplayMember = "CityName";
            cmbCity.ValueMember   = "CityID";
            cmbCity.DataSource    = _db.Cities.ToList();
        }