コード例 #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);
            }
        }
コード例 #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);
            }
        }
コード例 #3
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);
            }
        }