public void actualizargrilla() { try { dataGridView1.DataSource = FactorCN.GetFactores(); } catch { MessageBox.Show("ERROR EN EL ACCESO A LA BASE DE DATOS"); } }
private void button4_Click(object sender, EventArgs e) { if (textBox4.Text.Length > 0) { try { FactorCN.deleteFactor(Int32.Parse(textBox4.Text)); MessageBox.Show("Factor eliminado correctamente"); actualizargrilla(); } catch { MessageBox.Show("ERROR EN EL ACCESO A LA BASE DE DATOS"); } vaciarEntradas(); } }
private void button2_Click(object sender, EventArgs e) { if ((textBox1.Text.Length > 6) && (textBox2.Text.Length > 5) && (textBox3.Text.Length > 6)) { Factor fact = new Factor(); fact.nombre = textBox1.Text; fact.estado = textBox2.Text; fact.detalle = textBox3.Text; try { FactorCN.CreateFactor(fact); MessageBox.Show("Factor " + fact.nombre + " dado de alta correctamente"); actualizargrilla(); } catch { MessageBox.Show("ERROR DE ACCESO A BASE DE DATOS"); } vaciarEntradas(); } }
private void button3_Click(object sender, EventArgs e) { if ((textBox1.Text.Length > 6) && ((textBox4.Text.Length) > 0) && (textBox2.Text.Length > 6) && (textBox3.Text.Length > 6)) { Factor fact = new Factor(); fact.nombre = textBox1.Text; fact.estado = textBox2.Text; fact.detalle = textBox3.Text; fact.idFactor = Int32.Parse(textBox4.Text); try { FactorCN.UpdateFactor(fact); MessageBox.Show("Factor " + fact.nombre + " actualizado correctamente"); actualizargrilla(); } catch { MessageBox.Show("ERROR DE ACCESO A LA BASE DE DATOS"); } vaciarEntradas(); } }