Exemple #1
0
        private void btnModificar_Click(object sender, EventArgs e)
        {
            try
            {
                SuppliersDataContext db = new SuppliersDataContext();

                if (txtID.Text != null)
                {
                    var proveedor = (from prov in db.Suppliers
                                     where prov.SupplierID == Int32.Parse(txtID.Text)
                                     select prov).Single();

                    proveedor.CompanyName  = txtNombreCompania.Text;
                    proveedor.ContactName  = txtNombreContacto.Text;
                    proveedor.ContactTitle = txtTituloContacto.Text;
                    proveedor.Address      = txtDireccion.Text;
                    proveedor.City         = txtCiudad.Text;
                    proveedor.Region       = txtRegion.Text;
                    proveedor.PostalCode   = txtCodigoPostal.Text;
                    proveedor.Country      = txtPais.Text;
                    proveedor.Phone        = txtTelefono.Text;
                    proveedor.Fax          = txtFax.Text;
                    proveedor.HomePage     = txtPaginaInicio.Text;
                    db.SubmitChanges();
                    mostrarTabla();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.StackTrace);
            }
        }
Exemple #2
0
        private void btnInsertar_Click(object sender, EventArgs e)
        {
            try
            {
                Supplier proveedor = new Supplier();
                proveedor.SupplierID   = Int32.Parse(txtID.Text);
                proveedor.CompanyName  = txtNombreCompania.Text;
                proveedor.ContactName  = txtNombreContacto.Text;
                proveedor.ContactTitle = txtTituloContacto.Text;
                proveedor.Address      = txtDireccion.Text;
                proveedor.City         = txtCiudad.Text;
                proveedor.Region       = txtRegion.Text;
                proveedor.PostalCode   = txtCodigoPostal.Text;
                proveedor.Country      = txtPais.Text;
                proveedor.Phone        = txtTelefono.Text;
                proveedor.Fax          = txtFax.Text;
                proveedor.HomePage     = txtPaginaInicio.Text;

                SuppliersDataContext db = new SuppliersDataContext();
                db.Suppliers.InsertOnSubmit(proveedor);
                db.SubmitChanges();
                mostrarTabla();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.StackTrace);
            }
        }
Exemple #3
0
 public void mostrarTabla()
 {
     try
     {
         SuppliersDataContext db = new SuppliersDataContext();
         var proveedores         = from prov in db.Suppliers
                                   select prov;
         dgvProveedores.DataSource = proveedores;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.StackTrace);
     }
 }
Exemple #4
0
 private void btnBuscar_Click(object sender, EventArgs e)
 {
     try
     {
         SuppliersDataContext db = new SuppliersDataContext();
         if (txtBuscarXNombre.Text != null)
         {
             var proveedores = from prov in db.Suppliers
                               where prov.CompanyName == txtBuscarXNombre.Text
                               select prov;
             dgvProveedores.DataSource = proveedores;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.StackTrace);
     }
 }
Exemple #5
0
        private void btnEliminar_Click(object sender, EventArgs e)
        {
            try
            {
                SuppliersDataContext db = new SuppliersDataContext();

                if (txtID.Text != null)
                {
                    var proveedor = (from prov in db.Suppliers
                                     where prov.SupplierID == Int32.Parse(txtID.Text)
                                     select prov).Single();

                    db.Suppliers.DeleteOnSubmit(proveedor);
                    db.SubmitChanges();
                    mostrarTabla();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.StackTrace);
            }
        }