Anda di halaman 1dari 4

using using using using using using using using using

System; System.Collections.Generic; System.ComponentModel; System.Data; System.Drawing; System.Linq; System.Text; System.Windows.Forms; System.Data.Odbc;

namespace Empleados { public partial class mantempleados : Form { OdbcConnection cnn = new OdbcConnection("Dsn=orclB;uid=hr;pwd=hr"); OdbcCommand comm1 = new OdbcCommand(); public mantempleados() { InitializeComponent(); } private void eMPLOYEESBindingNavigatorSaveItem_Click(object sender, EventArgs e) { this.Validate(); this.eMPLOYEESBindingSource.EndEdit(); this.tableAdapterManager.UpdateAll(this.dataSet1); }

private void frmempleados_Load(object sender, EventArgs e) { // TODO: esta lnea de cdigo carga datos en la tabla 'dataSet1.JOB_HISTORY' Puede moverla o quitarla segn sea necesario. this.jOB_HISTORYTableAdapter.Fill(this.dataSet1.JOB_HISTORY); // TODO: esta lnea de cdigo carga datos en la tabla 'dataSet1.DEPARTMENTS' Puede moverla o quitarla segn sea necesario. this.dEPARTMENTSTableAdapter.Fill(this.dataSet1.DEPARTMENTS); // TODO: esta lnea de cdigo carga datos en la tabla 'dataSet1.JOBS' Puede moverla o quitarla segn sea necesario. this.jOBSTableAdapter.Fill(this.dataSet1.JOBS); // TODO: esta lnea de cdigo carga datos en la tabla 'dataSet1.EMPLOYEES' Puede moverla o quitarla segn sea necesario. //this.eMPLOYEESTableAdapter.Fill(this.dataSet1.EMPLOYEES); this.eMPLOYEESTableAdapter.FillBy1(this.dataSet1.EMPLOYEES); }

private void btnprimero_Click(object sender, EventArgs e) { this.eMPLOYEESBindingSource.MoveFirst(); this.btnprimero.Enabled = false; this.btnanterior.Enabled = false; this.btnultimo.Enabled = true; this.btnsiguiente.Enabled = true; } private void btnanterior_Click(object sender, EventArgs e) { this.eMPLOYEESBindingSource.MovePrevious(); if (this.eMPLOYEESBindingSource.Position == 0) { this.btnprimero.Enabled = false; this.btnanterior.Enabled = false; this.btnultimo.Enabled = true; this.btnsiguiente.Enabled = true; } if (this.eMPLOYEESBindingSource.Count > 1 && this.eMPLOYEESBindingSource.Position != 0) { this.btnultimo.Enabled = true; this.btnsiguiente.Enabled = true; } }

private void btnsiguiente_Click(object sender, EventArgs e) { this.eMPLOYEESBindingSource.MoveNext(); if (this.eMPLOYEESBindingSource.Position + 1 == this.eMPLOYEESBindingSource.Count) { this.btnsiguiente.Enabled = false; this.btnultimo.Enabled = false; this.btnprimero.Enabled = true; this.btnanterior.Enabled = true; }

if (this.eMPLOYEESBindingSource.Count > 1 && this.eMPLOYEESBindingSource.Position + 1 != this.eMPLOYEESBindingSource.Count) { this.btnprimero.Enabled = true; this.btnanterior.Enabled = true; } }

private void btnultimo_Click(object sender, EventArgs e) { this.eMPLOYEESBindingSource.MoveLast(); this.btnsiguiente.Enabled = false; this.btnultimo.Enabled = false; this.btnprimero.Enabled = true; this.btnanterior.Enabled = true; }

private void btnnuevo_Click(object sender, EventArgs e) { this.btnanadir.Enabled = true; this.btnnuevo.Enabled = false; this.btncancelar.Enabled = true; this.btneliminar.Enabled = false; this.btnmodificar.Enabled = false; this.eMAILTextBox.Enabled = true; this.hIRE_DATEDateTimePicker.Enabled = true; this.jOB_TITLEComboBox.Enabled = true; this.dEPARTMENT_NAMEComboBox.Enabled = true; this.eMPLOYEESBindingSource.AddNew(); if (eMPLOYEESBindingSource.Count > 1) { this.btnprimero.Enabled = true; this.btnanterior.Enabled = true; } cnn.Open(); OdbcCommand com = new OdbcCommand("select EMPLOYEE_ID from EMPLOYEES ORDER BY EMPLOYEE_ID DESC", cnn); OdbcDataReader lee = com.ExecuteReader(); if (lee.Read()) { eMPLOYEE_IDTextBox.Text = (int.Parse(lee[0].ToString()) + 1) + ""; } else { eMPLOYEE_IDTextBox.Text = "1"; } cnn.Close(); this.eMAILTextBox.Enabled = false; this.hIRE_DATEDateTimePicker.Enabled = false; this.jOB_TITLEComboBox.Enabled = false; this.dEPARTMENT_NAMEComboBox.Enabled = false; }

private void btnanadir_Click(object sender, EventArgs e) { try { string j1 = this.jOB_IDTextBox1.Text; this.jOB_IDTextBox.Text = j1; string d1 = this.dEPARTMENT_IDTextBox1.Text; this.dEPARTMENT_IDTextBox.Text = d1; this.eMPLOYEESBindingSource.EndEdit(); this.eMPLOYEESTableAdapter.Update(this.dataSet1.EMPLOYEES); MessageBox.Show("EL registro fue aadido correctamente", "Guardado"); this.btnnuevo.Enabled = true; this.btnanadir.Enabled = false; this.btncancelar.Enabled = false; this.btneliminar.Enabled = true; this.btnmodificar.Enabled = true; } catch (System.Data.NoNullAllowedException) { MessageBox.Show("Algunos de los campos estan incompletos", "Datos Incompletos"); } } private void btnsalir_Click(object sender, EventArgs e) { this.Dispose(); } } }

Anda mungkin juga menyukai