private void dataGridView_CellClick(object sender, DataGridViewCellEventArgs e) { string codigo = (string)dataGridView.CurrentRow.Cells["cod_proveedor"].Value; btnModificar.Enabled = true; btnNuevo.Enabled = true; btnGuardar.Enabled = false; btnEliminar.Enabled = true; txtNombre.Enabled = false; txtRuc.Enabled = false; txtDireccion.Enabled = false; txtEmail.Enabled = false; dateFecha.Enabled = false; txtTelefono.Enabled = false; cbCiudad.Enabled = false; pictureCodigo.Image = null; pictureEstado.Image = null; pictureNombre.Image = null; pictureDireccion.Image = null; pictureCedula.Image = null; pictureEmail.Image = null; pictureFecha.Image = null; pictureCiudad.Image = null; pictureTelefono.Image = null; chEstado.Enabled = false; using (SqlConnection conexion = Conexion.obtenerConexion()) { SqlCommand comando = new SqlCommand(string.Format("Select * from proveedor where cod_proveedor like '%{0}'", codigo), conexion); SqlDataReader reader = comando.ExecuteReader(); while (reader.Read()) { txtCodigo.Text = reader.GetString(0); txtNombre.Text = reader.GetString(1); txtRuc.Text = reader.GetString(2); txtDireccion.Text = reader.GetString(3); txtTelefono.Text = reader.GetString(4); txtEmail.Text = reader.GetString(5); string c = MetodosBD.buscarCiudad(reader.GetString(6)); cbCiudad.SelectedIndex = cbCiudad.FindString(c); bool estado2 = reader.GetBoolean(7); dateFecha.Value = Convert.ToDateTime(reader.GetString(8)); if (estado2) { chEstado.Text = "Activo"; chEstado.ForeColor = Color.Green; contador = 0; chEstado.Checked = false; btnEliminar.Enabled = true; estado = true; } else { chEstado.Text = "Inactivo"; chEstado.ForeColor = Color.Red; chEstado.Checked = true; btnEliminar.Enabled = false; contador = contador + 1; estado = true; } } conexion.Close(); } Console.Write(codigo); }
private void dataGridView_CellClick(object sender, DataGridViewCellEventArgs e) { string codigo = (string)dataGridView.CurrentRow.Cells["cod_empleado"].Value; btnModificar.Enabled = true; btnNuevo.Enabled = true; btnGuardar.Enabled = false; btnEliminar.Enabled = true; txtNombre.Enabled = false; txtApellido.Enabled = false; txtCedula.Enabled = false; dateFecha.Enabled = false; txtDireccion.Enabled = false; txtEmail.Enabled = false; txtPass.Enabled = false; btnCargarFoto.Enabled = false; txtUsuario.Enabled = false; txtTelefono.Enabled = false; cbTipoUsuario.Enabled = false; cbCiudad.Enabled = false; pictureCodigo.Image = null; pictureEstado.Image = null; pictureNombre.Image = null; pictureApellido.Image = null; pictureBox1.Image = null; pictureFecha.Image = null; pictureDireccion.Image = null; pictureCedula.Image = null; pictureEmail.Image = null; pictureUsuario.Image = null; pictureContra.Image = null; pictureFoto.Image = System.Drawing.Image.FromFile("D:\\ingenieria en sistemas\\Fernando sexto semestre\\Programacion 5\\Programas n c# 6to semestre\\ProyectoProgV\\ProyectoProgV\\Resources\\updown.png"); pictureCiudad.Image = null; pictureTipo.Image = null; pictureTelefono.Image = null; chEstado.Enabled = false; using (SqlConnection conexion = Conexion.obtenerConexion()) { SqlCommand comando = new SqlCommand(string.Format("Select * from usuario where cod_empleado like '%{0}'", codigo), conexion); SqlDataReader reader = comando.ExecuteReader(); while (reader.Read()) { txtCodigo.Text = reader.GetString(0); txtCedula.Text = reader.GetString(1); txtNombre.Text = reader.GetString(2); txtApellido.Text = reader.GetString(3); txtDireccion.Text = reader.GetString(4); txtTelefono.Text = reader.GetString(5); txtEmail.Text = reader.GetString(6); txtUsuario.Text = reader.GetString(7); txtPass.Text = reader.GetString(8); cbTipoUsuario.SelectedItem = reader.GetString(9); Direccion = reader.GetString(10); pictureBox1.ImageLocation = reader.GetString(10); string c = MetodosBD.buscarCiudad(reader.GetString(11)); cbCiudad.SelectedIndex = cbCiudad.FindString(c); bool estado2 = reader.GetBoolean(12); dateFecha.Value = Convert.ToDateTime(reader.GetString(13)); if (estado2) { chEstado.Text = "Activo"; chEstado.ForeColor = Color.Green; contador = 0; chEstado.Checked = false; btnEliminar.Enabled = true; estado = true; } else { chEstado.Text = "Inactivo"; chEstado.ForeColor = Color.Red; chEstado.Checked = true; btnEliminar.Enabled = false; contador = contador + 1; estado = true; } pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage; } conexion.Close(); } Console.Write(codigo); }