private void Form_Load(object sender, EventArgs e) { DataTable suppliersTable = new SuppliersDAO().EnumerateSuppliers(); lbSuppliers.Items.Clear(); foreach (DataRow row in suppliersTable.Rows) { lbSuppliers.Items.Add(new Supplier(row).Name); } }
private void GetSuppliers() { SuppliersDAO oDAO = new SuppliersDAO(); proveedores = oDAO.RetrieveAll(); if (proveedores != null) { if (proveedores.Count != 0) { proveedorCmBox.DisplayMember = "CompanyName"; proveedorCmBox.ValueMember = "SupplierID"; proveedorCmBox.DataSource = (from c in proveedores select new { c.SupplierID, c.CompanyName }).ToList(); } } }
private void GetProveedores() { try { SuppliersDAO oDAO = new SuppliersDAO(); proveedores = oDAO.RetrieveAll(); var tmpProveedores = (from prov in proveedores select new { Compañia = prov.CompanyName, Contacto = prov.ContactName, TitContacto = prov.ContactTitle, Direccion = prov.Address, Ciudad = prov.City, CodigoPostal = prov.PostalCode, Pais = prov.Country, Telefono = prov.Phone }).ToList(); dgvDatos.DataSource = null; dgvDatos.DataSource = tmpProveedores; } catch (Exception e) { MessageBox.Show(e.Message, "MyStoreDesktop"); } }
private void AgregarBtn_Click(object sender, EventArgs e) { try { Regex match = new Regex(@"^[A-Z]+[a-zA-Z0-9''-'\s]*$"); if (match.IsMatch(proveedorTxt.Text)) { bool band; SuppliersDAO oDAO = new SuppliersDAO(); if (AgregarBtn.Text.Equals("Agregar")) { proveedor = new Suppliers(); PasarObjeto(); band = oDAO.Create(proveedor); } else { PasarObjeto(); band = oDAO.Update(proveedor); } if (band) { GetProveedores(); LimpiarControles(); } } else { MessageBox.Show("No se permiten los siguientes aspectos:\n" + "Proveedor" + " vacío,\nCapitalización,\nNo empezar con un número,\nMáximo a 40 caracteres."); } } catch (Exception ex) { MessageBox.Show("Error al agregar al proveedor: " + ex.Message, "My Store Desktop", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// Initialize the supplier tab /// </summary> private void InitializeSupplierTab() { SuppliersDAO lwDataAccess = new SuppliersDAO(); DataTable suppliersTable = lwDataAccess.EnumerateSuppliers(); // Add these to our combo box foreach (DataRow row in suppliersTable.Rows) { this.cbSuppliers.Items.Add(new Supplier(row)); } // Select the 'current' supplier or the first if none int index = 0; if (_applicationLicense.SupplierID > 1) { index = cbSuppliers.FindStringExact(_applicationLicense.SupplierName); } if (index == -1) { index = 0; } cbSuppliers.SelectedIndex = index; }