private void dgvEmpleado_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) { string sexo = ""; if (e.RowIndex != -1) { if (dgvEmpleado.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString().Equals("Crear cuenta")) { frmUsuario frmUser = new frmUsuario(); int idempplead = Convert.ToInt32(dgvEmpleado.Rows[e.RowIndex].Cells[1].Value.ToString()); var user = NUsusario.BuscarUsuarioIdEmpleado(idempplead); if (user.Rows.Count > 0) { if (idempplead == Convert.ToInt32(user.Rows[0]["idempleado"].ToString())) { MessageBox.Show("ya tiene una cuenta"); } else { frmUser.Show(); var tabla = NEmpleado.BuscarEmpleadoId(idempplead); frmUsuario.MiFormUsuario._idEmpleado = int.Parse(tabla.Rows[0]["idempleado"].ToString()); frmUsuario.MiFormUsuario.txtUsuario.Text = tabla.Rows[0]["correo"].ToString(); } } else { frmUser.Show(); var tabla = NEmpleado.BuscarEmpleadoId(idempplead); frmUsuario.MiFormUsuario._idEmpleado = int.Parse(tabla.Rows[0]["idempleado"].ToString()); frmUsuario.MiFormUsuario.txtUsuario.Text = tabla.Rows[0]["correo"].ToString(); } } if (dgvEmpleado.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString().Equals("Editar")) { int idEmpleado = Convert.ToInt32(dgvEmpleado.Rows[e.RowIndex].Cells[1].Value.ToString()); frmEmpleado frmEmpleado = new frmEmpleado(); frmEmpleado.Show(); var tabla = NEmpleado.BuscarEmpleadoId(idEmpleado); frmEmpleado.MiFormEmpleado.txtNombres.Text = tabla.Rows[0]["nombres"].ToString(); frmEmpleado.MiFormEmpleado.txtApellidos.Text = tabla.Rows[0]["apellidos"].ToString(); frmEmpleado.MiFormEmpleado.txtDni.Text = tabla.Rows[0]["dni"].ToString(); sexo = tabla.Rows[0]["sexo"].ToString(); if (sexo == "M") { frmEmpleado.MiFormEmpleado.cboSexo.SelectedItem = "Masculino"; } else { frmEmpleado.MiFormEmpleado.cboSexo.SelectedItem = "Femenino"; } frmEmpleado.MiFormEmpleado.txtTelefono.Text = tabla.Rows[0]["telefono"].ToString(); frmEmpleado.MiFormEmpleado.txtCorreo.Text = tabla.Rows[0]["correo"].ToString(); frmEmpleado.MiFormEmpleado.txtDireccion.Text = tabla.Rows[0]["direccion"].ToString(); frmEmpleado.MiFormEmpleado.cboArea.SelectedValue = tabla.Rows[0]["idarea"].ToString(); byte[] img = (byte[])tabla.Rows[0]["foto"]; var ms = new MemoryStream(img); frmEmpleado.MiFormEmpleado.pbFoto.Image = Image.FromStream(ms); frmEmpleado.MiFormEmpleado.idEmpleado = idEmpleado; frmEmpleado.MiFormEmpleado._IsNew = false; frmEmpleado.MiFormEmpleado.cboArea.Enabled = true; } if (dgvEmpleado.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString().Equals("Eliminar")) { int idempplead = Convert.ToInt32(dgvEmpleado.Rows[e.RowIndex].Cells[1].Value.ToString()); DialogResult rspta = MessageBox.Show("Desea Eliminar", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation); if (DialogResult.Yes == rspta) { var rpta = NEmpleado.EliminarEmpleado(idempplead); if (rpta == "Ok") { MessageBox.Show(rpta + "---Elimado"); dgvEmpleado.Rows.RemoveAt(e.RowIndex); NEmpleado objEmpleado = new NEmpleado(); objEmpleado.ListadoDgv(dgvEmpleado); } else { MessageBox.Show("error"); } } } if (dgvEmpleado.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString().Equals("Ver")) { int idEmpleado = Convert.ToInt32(dgvEmpleado.Rows[e.RowIndex].Cells[1].Value.ToString()); frmPerfil perfil = new frmPerfil(); perfil.Show(); var tabla = NEmpleado.BuscarEmpleadoId(idEmpleado); sexo = tabla.Rows[0]["sexo"].ToString(); if (sexo == "M") { sexo = "Masculino"; } else { sexo = "Femenino"; } frmPerfil.MiFormPerfil.listDatos.Items.Add("Nombre: " + tabla.Rows[0]["nombres"].ToString()); frmPerfil.MiFormPerfil.listDatos.Items.Add(""); frmPerfil.MiFormPerfil.listDatos.Items.Add("Apellidos: " + tabla.Rows[0]["apellidos"].ToString()); frmPerfil.MiFormPerfil.listDatos.Items.Add(""); frmPerfil.MiFormPerfil.listDatos.Items.Add("Dni: " + tabla.Rows[0]["dni"].ToString()); frmPerfil.MiFormPerfil.listDatos.Items.Add(""); frmPerfil.MiFormPerfil.listDatos.Items.Add("Sexo: " + sexo); frmPerfil.MiFormPerfil.listDatos.Items.Add(""); frmPerfil.MiFormPerfil.listDatos.Items.Add("Teléfono: " + tabla.Rows[0]["telefono"].ToString()); frmPerfil.MiFormPerfil.listDatos.Items.Add(""); frmPerfil.MiFormPerfil.listDatos.Items.Add("Correo: " + tabla.Rows[0]["correo"].ToString()); frmPerfil.MiFormPerfil.listDatos.Items.Add(""); frmPerfil.MiFormPerfil.listDatos.Items.Add("Dirección: " + tabla.Rows[0]["direccion"].ToString()); frmPerfil.MiFormPerfil.listDatos.Items.Add(""); frmPerfil.MiFormPerfil.listDatos.Items.Add("Area: " + tabla.Rows[0]["area"].ToString()); byte[] img = (byte[])tabla.Rows[0]["foto"]; var ms = new MemoryStream(img); frmPerfil.MiFormPerfil.pbFoto.Image = Image.FromStream(ms); frmPerfil.MiFormPerfil.lblTitulo.Text = "Datos Empleado"; } } }
private void dgvMascota_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) { if (e.RowIndex != -1) { if (dgvMascota.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString().Equals("Editar")) { int idmascota = Convert.ToInt32(dgvMascota.Rows[e.RowIndex].Cells[1].Value.ToString()); frmMascota fMascota = new frmMascota(); fMascota.Show(); var tabla = NMascota.BuscarMascotaId(idmascota); frmMascota.MiFormMascota.txtCodigo.Text = tabla.Rows[0]["codigo"].ToString(); frmMascota.MiFormMascota.txtCliente.Text = tabla.Rows[0]["nombres"].ToString() + " " + tabla.Rows[0]["apellidos"].ToString(); frmMascota.MiFormMascota.txtNombre.Text = tabla.Rows[0]["nombre"].ToString(); frmMascota.MiFormMascota.txtEdad.Text = tabla.Rows[0]["edad"].ToString(); frmMascota.MiFormMascota.txtPeso.Text = tabla.Rows[0]["peso"].ToString(); frmMascota.MiFormMascota.cboSexo.SelectedItem = tabla.Rows[0]["sexo"].ToString(); frmMascota.MiFormMascota.cboEspecie.SelectedValue = tabla.Rows[0]["idespecie"].ToString(); frmMascota.MiFormMascota.cboRaza.SelectedValue = tabla.Rows[0]["idraza"].ToString(); frmMascota.MiFormMascota.txtDescripcion.Text = tabla.Rows[0]["descripcion"].ToString(); byte[] img = (byte[])tabla.Rows[0]["imagen"]; var ms = new MemoryStream(img); frmMascota.MiFormMascota.pbFoto.Image = Image.FromStream(ms); frmMascota.MiFormMascota._idMascota = idmascota; frmMascota.MiFormMascota._idCliente = Convert.ToInt32(tabla.Rows[0]["idcliente"].ToString()); /* frmMascota.MiFormMascota._idRaza = Convert.ToInt32(tabla.Rows[0]["idraza"].ToString());*/ frmMascota.MiFormMascota.txtCodigo.Visible = true; frmMascota.MiFormMascota.label1.Visible = true; frmMascota.MiFormMascota._IsNew = false; frmMascota.MiFormMascota.txtBuscar.Enabled = false; frmMascota.MiFormMascota.cboEspecie.Enabled = false; frmMascota.MiFormMascota.cboRaza.Enabled = false; frmMascota.MiFormMascota.cboSexo.Enabled = false; } if (dgvMascota.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString().Equals("Eliminar")) { int idmascota = Convert.ToInt32(dgvMascota.Rows[e.RowIndex].Cells[1].Value.ToString()); DialogResult rspta = MessageBox.Show("Desea Eliminar", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation); if (DialogResult.Yes == rspta) { var rpta = NMascota.EliminarMascota(idmascota); if (rpta == "Ok") { MessageBox.Show(rpta + "---Elimado"); dgvMascota.Rows.RemoveAt(e.RowIndex); NMascota objMascota = new NMascota(); objMascota.ListadoDgv(dgvMascota); dgvMascota.Refresh(); } else { MessageBox.Show("error"); } } } if (dgvMascota.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString().Equals("Ver")) { int idmascota = Convert.ToInt32(dgvMascota.Rows[e.RowIndex].Cells[1].Value.ToString()); frmPerfil perfil = new frmPerfil(); perfil.Show(); var tabla = NMascota.BuscarMascotaId(idmascota); frmPerfil.MiFormPerfil.listDatos.Items.Add("Nombre: " + tabla.Rows[0]["nombres"].ToString()); frmPerfil.MiFormPerfil.listDatos.Items.Add(""); frmPerfil.MiFormPerfil.listDatos.Items.Add("Apellidos: " + tabla.Rows[0]["apellidos"].ToString()); frmPerfil.MiFormPerfil.listDatos.Items.Add(""); frmPerfil.MiFormPerfil.listDatos.Items.Add("Telefono: " + tabla.Rows[0]["telefono"].ToString()); frmPerfil.MiFormPerfil.listDatos.Items.Add(""); frmPerfil.MiFormPerfil.listDatos.Items.Add("Codigo: " + tabla.Rows[0]["codigo"].ToString()); frmPerfil.MiFormPerfil.listDatos.Items.Add(""); frmPerfil.MiFormPerfil.listDatos.Items.Add("Nombre: " + tabla.Rows[0]["nombre"].ToString()); frmPerfil.MiFormPerfil.listDatos.Items.Add(""); frmPerfil.MiFormPerfil.listDatos.Items.Add("Edad: " + tabla.Rows[0]["edad"].ToString()); frmPerfil.MiFormPerfil.listDatos.Items.Add(""); frmPerfil.MiFormPerfil.listDatos.Items.Add("Peso: " + tabla.Rows[0]["peso"].ToString()); frmPerfil.MiFormPerfil.listDatos.Items.Add(""); frmPerfil.MiFormPerfil.listDatos.Items.Add("Especie: " + tabla.Rows[0]["especie"].ToString()); frmPerfil.MiFormPerfil.listDatos.Items.Add(""); frmPerfil.MiFormPerfil.listDatos.Items.Add("Raza: " + tabla.Rows[0]["raza"].ToString()); byte[] img = (byte[])tabla.Rows[0]["imagen"]; var ms = new MemoryStream(img); frmPerfil.MiFormPerfil.pbFoto.Image = Image.FromStream(ms); frmPerfil.MiFormPerfil.lblTitulo.Text = "Datos Dueño - Mascota"; } } }
private void dgvCliente_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) { string sexo = ""; if (e.RowIndex != -1) { if (dgvCliente.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString().Equals("Editar")) { int idCliente = Convert.ToInt32(dgvCliente.Rows[e.RowIndex].Cells[1].Value.ToString()); frmCliente frmCliente = new frmCliente(); frmCliente.Show(); var tabla = NCliente.BuscarClienteId(idCliente); frmCliente.MiFormCliente.txtNombres.Text = tabla.Rows[0]["nombres"].ToString(); frmCliente.MiFormCliente.txtApellidos.Text = tabla.Rows[0]["apellidos"].ToString(); frmCliente.MiFormCliente.txtDni.Text = tabla.Rows[0]["dni"].ToString(); sexo = tabla.Rows[0]["sexo"].ToString(); if (sexo == "M") { frmCliente.MiFormCliente.cboSexo.SelectedItem = "Masculino"; } else { frmCliente.MiFormCliente.cboSexo.SelectedItem = "Femenino"; } frmCliente.MiFormCliente.txtTelefono.Text = tabla.Rows[0]["telefono"].ToString(); frmCliente.MiFormCliente.txtCorreo.Text = tabla.Rows[0]["correo"].ToString(); frmCliente.MiFormCliente.txtDireccion.Text = tabla.Rows[0]["direccion"].ToString(); byte[] img = (byte[])tabla.Rows[0]["foto"]; var ms = new MemoryStream(img); frmCliente.MiFormCliente.pbFoto.Image = Image.FromStream(ms); frmCliente.MiFormCliente.idCliente = idCliente; frmCliente.MiFormCliente._IsNew = false; } if (dgvCliente.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString().Equals("Eliminar")) { int idclient = Convert.ToInt32(dgvCliente.Rows[e.RowIndex].Cells[1].Value.ToString()); DialogResult rspta = MessageBox.Show("Desea Eliminar", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation); if (DialogResult.Yes == rspta) { var rpta = NCliente.EliminarCliente(idclient); if (rpta == "Ok") { MessageBox.Show(rpta + "---Elimado"); dgvCliente.Rows.RemoveAt(e.RowIndex); NCliente objCliente = new NCliente(); objCliente.ListadoDgv(dgvCliente); dgvCliente.Refresh(); } else { MessageBox.Show("error"); } } } if (dgvCliente.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString().Equals("Ver")) { int idCliente = Convert.ToInt32(dgvCliente.Rows[e.RowIndex].Cells[1].Value.ToString()); frmPerfil perfil = new frmPerfil(); perfil.Show(); var tabla = NCliente.BuscarClienteId(idCliente); if (tabla.Rows.Count > 0) { sexo = tabla.Rows[0]["sexo"].ToString(); if (sexo == "M") { sexo = "Masculino"; } else { sexo = "Femenino"; } frmPerfil.MiFormPerfil.listDatos.Items.Add("Nombre: " + tabla.Rows[0]["nombres"].ToString()); frmPerfil.MiFormPerfil.listDatos.Items.Add(""); frmPerfil.MiFormPerfil.listDatos.Items.Add("Apellidos: " + tabla.Rows[0]["apellidos"].ToString()); frmPerfil.MiFormPerfil.listDatos.Items.Add(""); frmPerfil.MiFormPerfil.listDatos.Items.Add("Dni: " + tabla.Rows[0]["dni"].ToString()); frmPerfil.MiFormPerfil.listDatos.Items.Add(""); frmPerfil.MiFormPerfil.listDatos.Items.Add("Sexo: " + sexo); frmPerfil.MiFormPerfil.listDatos.Items.Add(""); frmPerfil.MiFormPerfil.listDatos.Items.Add("Teléfono: " + tabla.Rows[0]["telefono"].ToString()); frmPerfil.MiFormPerfil.listDatos.Items.Add(""); frmPerfil.MiFormPerfil.listDatos.Items.Add("Correo: " + tabla.Rows[0]["correo"].ToString()); frmPerfil.MiFormPerfil.listDatos.Items.Add(""); frmPerfil.MiFormPerfil.listDatos.Items.Add("Dirección: " + tabla.Rows[0]["direccion"].ToString()); byte[] img = (byte[])tabla.Rows[0]["foto"]; var ms = new MemoryStream(img); frmPerfil.MiFormPerfil.pbFoto.Image = Image.FromStream(ms); frmPerfil.MiFormPerfil.lblTitulo.Text = "Datos Cliente"; } } } }
private void dgvUsuario_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) { string sexo = ""; if (e.RowIndex != -1) { if (dgvUsuario.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString().Equals("Activar") || dgvUsuario.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString().Equals("Desactivar")) { try { string estado = dgvUsuario.Rows[e.RowIndex].Cells[7].Value.ToString(); int iduser = Convert.ToInt32(dgvUsuario.Rows[e.RowIndex].Cells[1].Value.ToString()); NUsusario objUser = new NUsusario(); if (NUsusario.ActualizarEstadoUsuario(estado.Equals("Desactivar") ? 0 : 1, iduser)) { objUser.ListadoDgv(dgvUsuario); } else { MessageBox.Show("Error al controlar el estado"); } } catch (Exception ex) { MessageBox.Show(ex.Message); throw; } } if (dgvUsuario.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString().Equals("Editar")) { int idUser = Convert.ToInt32(dgvUsuario.Rows[e.RowIndex].Cells[1].Value.ToString()); frmUsuario frmUser = new frmUsuario(); frmUser.Show(); var tabla = NUsusario.BuscarUsuarioId(idUser); frmUsuario.MiFormUsuario._isNew = false; frmUsuario.MiFormUsuario._idUsuario = idUser; frmUsuario.MiFormUsuario.txtUsuario.Text = tabla.Rows[0]["username"].ToString(); frmUsuario.MiFormUsuario.txtPassword.Text = tabla.Rows[0]["pasword"].ToString(); frmUsuario.MiFormUsuario.cboTipo.SelectedItem = tabla.Rows[0]["tipo"].ToString(); frmUsuario.MiFormUsuario._idEmpleado = int.Parse(tabla.Rows[0]["idempleado"].ToString()); dgvUsuario.Refresh(); } if (dgvUsuario.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString().Equals("Eliminar")) { int iduser = Convert.ToInt32(dgvUsuario.Rows[e.RowIndex].Cells[1].Value.ToString()); DialogResult rspta = MessageBox.Show("Desea Eliminar", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation); if (DialogResult.Yes == rspta) { var rpta = NUsusario.EliminarUsuario(iduser); if (rpta == "Ok") { MessageBox.Show(rpta + "---Elimado"); dgvUsuario.Rows.RemoveAt(e.RowIndex); NUsusario objUser = new NUsusario(); objUser.ListadoDgv(dgvUsuario); } else { MessageBox.Show("error"); } } } if (dgvUsuario.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString().Equals("Ver")) { //DialogResult rspta = MessageBox.Show("Desea Desencripar la contraseña", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation); // if (DialogResult.Yes == rspta) // { int idUser = Convert.ToInt32(dgvUsuario.Rows[e.RowIndex].Cells[1].Value.ToString()); frmPerfil perfil = new frmPerfil(); perfil.Show(); var tabla = NUsusario.BuscarUsuarioId(idUser); sexo = tabla.Rows[0]["sexo"].ToString(); if (sexo == "M") { sexo = "Masculino"; } else { sexo = "Femenino"; } frmPerfil.MiFormPerfil.listDatos.Items.Add("Nombre: " + tabla.Rows[0]["nombres"].ToString()); frmPerfil.MiFormPerfil.listDatos.Items.Add(""); frmPerfil.MiFormPerfil.listDatos.Items.Add("Apellidos: " + tabla.Rows[0]["apellidos"].ToString()); frmPerfil.MiFormPerfil.listDatos.Items.Add(""); frmPerfil.MiFormPerfil.listDatos.Items.Add("Dni: " + tabla.Rows[0]["dni"].ToString()); frmPerfil.MiFormPerfil.listDatos.Items.Add(""); frmPerfil.MiFormPerfil.listDatos.Items.Add("Sexo: " + sexo); frmPerfil.MiFormPerfil.listDatos.Items.Add(""); frmPerfil.MiFormPerfil.listDatos.Items.Add("Teléfono: " + tabla.Rows[0]["telefono"].ToString()); frmPerfil.MiFormPerfil.listDatos.Items.Add(""); frmPerfil.MiFormPerfil.listDatos.Items.Add("Correo: " + tabla.Rows[0]["correo"].ToString()); frmPerfil.MiFormPerfil.listDatos.Items.Add(""); frmPerfil.MiFormPerfil.listDatos.Items.Add("Dirección: " + tabla.Rows[0]["direccion"].ToString()); frmPerfil.MiFormPerfil.listDatos.Items.Add(""); frmPerfil.MiFormPerfil.listDatos.Items.Add("Usuario: " + tabla.Rows[0]["username"].ToString()); frmPerfil.MiFormPerfil.listDatos.Items.Add(""); frmPerfil.MiFormPerfil.listDatos.Items.Add("Password: "******"pasword"].ToString()); frmPerfil.MiFormPerfil.listDatos.Items.Add(""); frmPerfil.MiFormPerfil.listDatos.Items.Add("TipoUser: "******"tipo"].ToString()); string captura = tabla.Rows[0]["estado"].ToString(); frmPerfil.MiFormPerfil.lblEstadoUser.Visible = true; if (captura == "1") { frmPerfil.MiFormPerfil.lblEstadoUser.Text = "Activo"; frmPerfil.MiFormPerfil.lblEstadoUser.ForeColor = Color.Green; } else { frmPerfil.MiFormPerfil.lblEstadoUser.Text = "Inactivo"; frmPerfil.MiFormPerfil.lblEstadoUser.ForeColor = Color.Red; } byte[] img = (byte[])tabla.Rows[0]["foto"]; var ms = new MemoryStream(img); frmPerfil.MiFormPerfil.pbFoto.Image = Image.FromStream(ms); frmPerfil.MiFormPerfil.lblTitulo.Text = "Datos Usuario"; //} } } }
private void frmPerfil_FormClosed(object sender, FormClosedEventArgs e) { _miFormPerfil = null; }