private void btnAceptar_Click(object sender, EventArgs e) { if (txtRespuesta.Text=="") { MessageBox.Show("Ingrese una Respuesta"); } else { dll_conexion.Conexion cConectar = new dll_conexion.Conexion(); cConectar.cLocal(); cConectar.sqlData = new MySqlDataAdapter("Select vrespuesta from mausuario WHERE usuario='" + frmlogin.sNombre + "'", cConectar.SqlConexion); DataTable DT_dat = new DataTable(); cConectar.sqlData.Fill(DT_dat); if (DT_dat.Rows[0][0].ToString() != txtRespuesta.Text ) { Notificacion.mostrarVentana("Error", "Respuesta Incorrecta", Notificacion.Imagen.Error, 5); cConectar.SqlConexion.Close(); } else { cConectar.SqlConexion.Close(); fncRecuperarpass(); this.Hide(); } } }
// Inserta datos en BD private void btnGuardar_Click(object sender, EventArgs e) { try { if (txtNombre.Text == "") { MessageBox.Show("Llene el campo"); fncCargagrid(); } else { dll_conexion.Conexion cConectar = new dll_conexion.Conexion(); cConectar.cLocal(); cConectar.sqlCmd = new MySqlCommand("INSERT INTO madatopersonal (ndpipersonal, vnombrepersonal, vapepersonal, dfechanacimiento, vsexopersonal, vdireccionpersonal, ntelpersonal, MaPUESTOPERSONAL_ncodpuesto) VALUES ('" + txtDpi.Text + "' , '" + txtNombre.Text + "' , '" + txtApellido.Text + "' , '" + txtFechanacimiento.Text + "' , '" + cbxSexo.Text + "' , '" + txtDireccion.Text + "' , '" + txtTelefono.Text + "','" + cboxTipo.Text + "')", cConectar.SqlConexion); cConectar.sqlCmd.ExecuteNonQuery(); cConectar.SqlConexion.Close(); MessageBox.Show("Datos Insertados"); fncCargagrid(); } } catch (MySqlException) { MessageBox.Show("Error en BD"); } }
private void btnContinuar_Click(object sender, EventArgs e) { try { if (cbxLocal.Text == cbxVisitante.Text){MessageBox.Show("Error No puede competir el mismo Equipo");}else{ dll_conexion.Conexion cConectar = new dll_conexion.Conexion(); cConectar.cLocal(); cConectar.sqlData = new MySqlDataAdapter("Select ncodequipo from maequipo WHERE vnombreequipo='" + cbxLocal.Text + "'", cConectar.SqlConexion); DataTable DT_dat = new DataTable(); cConectar.sqlData.Fill(DT_dat); sidLocal = DT_dat.Rows[0][0].ToString(); cConectar.SqlConexion.Close(); cConectar.sqlData = new MySqlDataAdapter("Select ncodequipo from maequipo WHERE vnombreequipo='" + cbxVisitante.Text + "'", cConectar.SqlConexion); DataTable DT_dat2 = new DataTable(); cConectar.sqlData.Fill(DT_dat2); sidVisitante = DT_dat2.Rows[0][0].ToString(); cConectar.SqlConexion.Close(); frmPartido frmnNuevoPartidoenvivo = new frmPartido(); //frmnNuevoPartidoenvivo.MdiParent = this; // frmnNuevoPartido.WindowState = FormWindowState.Maximized; sEquipoLocal = cbxLocal.Text; sEquipoVisitante = cbxVisitante.Text; frmPartido frmnPartido = new frmPartido(); frmnPartido.MdiParent = frmmenuprincipal.ActiveForm; frmnPartido.Show(); this.Close(); } } catch (MySqlException) { MessageBox.Show("Error en BD"); } }
/* * ELIMINACION DE DE DATOS CON CONFIRMACION DE OPERACION * Dennys Choy * */ private void btnEliminar(object sender, EventArgs e) { try { if (MessageBox.Show("¿Está seguro de Eliminar este registro? Nombre del Empleado: " + txtNombre.Text, "Eliminar Registro", MessageBoxButtons.YesNo) == DialogResult.Yes) { dll_conexion.Conexion cConectar = new dll_conexion.Conexion(); cConectar.cLocal(); cConectar.sqlCmd = new MySqlCommand("DELETE FROM macompetencia where ncodcompetencia = " + lblCodigo.Text + ";", cConectar.SqlConexion); cConectar.sqlCmd.ExecuteNonQuery(); cConectar.SqlConexion.Close(); fncCargagrid(); MessageBox.Show("Registro Eliminado"); limpiar(); } else { limpiar(); } } catch { MessageBox.Show("Problema en BD"); } }
//Inserta datos en BD private void btnGuardar_Click(object sender, EventArgs e) { try { if (txtNombre.Text == "") { MessageBox.Show("Indique el Nombre del Equipo"); fncCargaGrid(); } else { dll_conexion.Conexion cConectar = new dll_conexion.Conexion(); cConectar.cLocal(); cConectar.sqlCmd = new MySqlCommand("INSERT INTO maequipo (vnombreequipo,vdescripcion) VALUES ('" + txtNombre.Text + "','" + txtDescripcion.Text + "')", cConectar.SqlConexion); cConectar.sqlCmd.ExecuteNonQuery(); cConectar.SqlConexion.Close(); fncCargaGrid(); MessageBox.Show("Datos Insertados"); limpiar(); } } catch { MessageBox.Show("Problema en BD"); } }
private void btnGuardar_Click(object sender, EventArgs e) { try { dll_conexion.Conexion cConectar = new dll_conexion.Conexion(); cConectar.cLocal(); cConectar.sqlCmd = new MySqlCommand("INSERT INTO macategoria (vnombrecategoria, nedadcategoria, vgenerocategoria, vobsecategoria) VALUES ('" + txtNombreCampeonato.Text + "', " + lstEdad.Text + " ,'" + cmbGenero.Text + "', ' " + txtObervaciones.Text + "');", cConectar.SqlConexion); MySqlDataReader MyReader2; MyReader2 = cConectar.sqlCmd.ExecuteReader(); MessageBox.Show("Datos Insertados"); fncCargagrid(); clsBloquear(); limpiar(); while(MyReader2.Read()) { } cConectar.SqlConexion.Close(); } catch(Exception ex) { MessageBox.Show(ex.Message); } }
private void cmbEquipoTarjeta_SelectedIndexChanged(object sender, EventArgs e) { try { if (cmbEquipoTarjeta.Text == eLocal.Text) { idTarjeta.Text = idLocal.Text; } else { idTarjeta.Text = idVisitante.Text; } dll_conexion.Conexion cConectar = new dll_conexion.Conexion(); cConectar.cLocal(); cConectar.sqlData = new MySqlDataAdapter("Select majugador.vnombrejugador from majugador INNER JOIN maequipo ON majugador.MaEQUIPO_ncodequipo = maequipo.ncodequipo WHERE maequipo.ncodequipo = '" + idTarjeta.Text + "';", cConectar.SqlConexion); DataTable DT_box = new DataTable(); cConectar.sqlData.Fill(DT_box); foreach (DataRow row in DT_box.Rows) { string rowz = row.ItemArray.ToString(); } DataTable DT_box2 = new DataTable(); cConectar.sqlData.Fill(DT_box2); foreach (DataRow row in DT_box.Rows) { string rowy = row.ItemArray.ToString(); } cbxJugadorTarjeta.DataSource = DT_box; cbxJugadorTarjeta.DisplayMember = "vnombrejugador"; cConectar.SqlConexion.Close(); } catch (MySqlException) { MessageBox.Show("Error en BD"); } }
private void frmrecContrasena(object sender, EventArgs e) { dll_conexion.Conexion cConectar = new dll_conexion.Conexion(); cConectar.cLocal(); cConectar.sqlData = new MySqlDataAdapter("Select vpregunta from mausuario WHERE usuario='" + frmlogin.sNombre + "'", cConectar.SqlConexion); DataTable DT_dat = new DataTable(); cConectar.sqlData.Fill(DT_dat); lblPregunta.Text = DT_dat.Rows[0][0].ToString(); cConectar.SqlConexion.Close(); }
private void fncRecuperarpass() { dll_conexion.Conexion cConectar = new dll_conexion.Conexion(); cConectar.cLocal(); cConectar.sqlData = new MySqlDataAdapter("Select vpassword from mausuario WHERE usuario='" + frmlogin.sNombre + "'", cConectar.SqlConexion); DataTable DT_dat = new DataTable(); cConectar.sqlData.Fill(DT_dat); cConectar.SqlConexion.Close(); Notificacion.mostrarVentana("Aceptado", "Respuesta Correcta\n Tú Password es: " + DT_dat.Rows[0][0].ToString(), Notificacion.Imagen.Llave, 5); }
public void fncTomaPrivilegio() { dll_conexion.Conexion cConectar = new dll_conexion.Conexion(); cConectar.cLocal(); cConectar.sqlData = new MySqlDataAdapter("Select usuario, vprivilegio from mausuario where usuario ='" + txtNombre.Text + "'", cConectar.SqlConexion); DataTable DT_dat = new DataTable(); cConectar.sqlData.Fill(DT_dat); cConectar.SqlConexion.Close(); sUsuario = DT_dat.Rows[0][0].ToString(); sPrivilegio = DT_dat.Rows[0][1].ToString(); }
private void button1_Click(object sender, EventArgs e) { dll_conexion.Conexion cConectar = new dll_conexion.Conexion(); //cConectar.cLocal(); try { if (MessageBox.Show("¿Está seguro de inscribir a " + cmbEquipo.Text + " Al siguiente campeonato: " + cmbCompetencia.Text + " ", "Confirmación de Inscripción", MessageBoxButtons.YesNo) == DialogResult.Yes) { cConectar.cLocal(); MySqlCommand cmd = new MySqlCommand("select *from trequipoencompetencia where MaCOMPETENCIA_ncodcompetencia1 = '" + lblCodigoCompetencia.Text + "' and MaEQUIPO_ncodequipo = '" + lblCodigoEquipo.Text + "';", cConectar.SqlConexion); MySqlDataReader MyReader3; MyReader3 = cmd.ExecuteReader(); if (!MyReader3.HasRows) { cConectar.SqlConexion.Close(); try { cConectar.cLocal(); cConectar.sqlCmd = new MySqlCommand("INSERT INTO trequipoencompetencia (njjugados, njganados, njperdidos, njempatados, ngolfavor, ngolcontra, npts, MaCOMPETENCIA_ncodcompetencia1, MaEQUIPO_ncodequipo) VALUES (0, 0, 0, 0, 0, 0, 0, " + lblCodigoCompetencia.Text + "," + lblCodigoEquipo.Text + ");", cConectar.SqlConexion); MySqlDataReader MyReader1; MyReader1 = cConectar.sqlCmd.ExecuteReader(); MessageBox.Show("Equipo inscrito exitosamente"); fncCargagrid(); while (MyReader1.Read()) { } cConectar.SqlConexion.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } else { cConectar.SqlConexion.Close(); MessageBox.Show("El equipo ya está inscrito"); } } else { MessageBox.Show("Error en el mensaje de verificación"); } } catch { MessageBox.Show("Problema en BD"); } }
private void Btn_Eliminar_Click(object sender, EventArgs e) { //llamada a conexion dll dll_conexion.Conexion cConectar = new dll_conexion.Conexion(); cConectar.cLocal(); //query de eliminacion segun el nombre del archivo o reporte cConectar.sqlCmd = new MySqlCommand("DELETE FROM reportes WHERE nom_reporte='" + sNombreReporteGrid + "'", cConectar.SqlConexion); cConectar.sqlCmd.ExecuteNonQuery(); cConectar.SqlConexion.Close(); Fnc_Cargagrid(); //metodo de eliminacion de archivos locales System.IO.File.Delete("C:/Reportes/" + sNombreReporteGrid); //confirmacion de eliminacion MessageBox.Show("Registro Eliminado"); }
private void btnGuardar_Click(object sender, EventArgs e) { try { dll_conexion.Conexion cConectar = new dll_conexion.Conexion(); cConectar.cLocal(); cConectar.sqlCmd = new MySqlCommand("INSERT INTO majugador (ndpijugador,vnombrejugador,vapejugador,nfechanacimiento,vsexojugador,vdireccionjugador,vtelefonojugador,MaEQUIPO_ncodequipo,foto) VALUES (" + txtDpi.Text + ",'" + txtNombre.Text + "','" + txtApellido.Text + "','" + txtEdad.Text + "','" + cbxSexo.Text + "','" + txtDireccion.Text + "','" + txtTelefono.Text + "','" + label9.Text + "','"+textBox1.Text+"');", cConectar.SqlConexion); cConectar.sqlCmd.ExecuteNonQuery(); cConectar.SqlConexion.Close(); MessageBox.Show("Datos Insertados"); fncCargagrid(); } catch(Exception ex) { MessageBox.Show(ex.Message); } }
//INSERTAR DATOS A LA TABLA CAMPEONATO private void btnGuarda_Click(object sender, EventArgs e) { try { dll_conexion.Conexion cConectar = new dll_conexion.Conexion(); cConectar.cLocal(); cConectar.sqlCmd = new MySqlCommand("INSERT INTO macompetencia (vnomcompetencia, vdescripcion, vtipocompetencia, dfechainicio, dfechafin, MaCATEGORIA_codcategoria) VALUES ('" + txtNombre.Text + "' , '" + txtDescripcion.Text + "' , '" + cmbTipoCompetencia.Text + "' , '" + dateInicio.Text + "' , '" + dateFinal.Text + "' , " + lblCategoria1.Text + " ); ", cConectar.SqlConexion); MySqlDataReader MyReader2; MyReader2 = cConectar.sqlCmd.ExecuteReader(); MessageBox.Show("Datos Insertados"); cConectar.SqlConexion.Close(); fncCargagrid(); } catch { MessageBox.Show("Error en BD"); } }
// btnloguin conexion y logueo de usuario private void btnloguin_Click(object sender, EventArgs e) { try { if (txtNombre.Text == "") { MessageBox.Show("Porfavor Ingrese un Nombre de Usuario"); } else if (txtContrasena.Text == "") { MessageBox.Show("Porfavor Ingrese su Contraseña"); } else { dll_conexion.Conexion cConectar = new dll_conexion.Conexion(); cConectar.cLocal(); cConectar.sqlCmd = new MySqlCommand("Select usuario, vprivilegio from mausuario WHERE usuario='" + txtNombre.Text + "'And vpassword ='******'", cConectar.SqlConexion); Object obj = cConectar.sqlCmd.ExecuteScalar(); if (obj == null) { Notificacion.mostrarVentana("Login", "Error: Ingrese un usuario y contraseña validos", Notificacion.Imagen.Error, 5); txtNombre.Text = ""; txtContrasena.Text = ""; cConectar.SqlConexion.Close(); } else { sNombre = txtNombre.Text; Notificacion.mostrarVentana("Loguin", "Inicio de Sesion Correcto ", Notificacion.Imagen.Llave, 5); cConectar.SqlConexion.Close(); this.Hide(); fncTomaPrivilegio(); frmmenuprincipal frmnmenu = new frmmenuprincipal(); frmnmenu.Show(); } } } catch { MessageBox.Show("Problema con la BD"); } }
private void cbmCampeonato_SelectedIndexChanged(object sender, EventArgs e) { try { dll_conexion.Conexion cConectar = new dll_conexion.Conexion(); cConectar.cLocal(); cConectar.sqlCmd = new MySqlCommand("SELECT ncodcompetencia FROM macompetencia WHERE vnomcompetencia = '" + cbmCampeonato.Text + "';", cConectar.SqlConexion); MySqlDataReader MyReader3; MyReader3 = cConectar.sqlCmd.ExecuteReader(); while (MyReader3.Read()) { lblCompetencia.Text = MyReader3.GetInt32(0).ToString(); } cConectar.SqlConexion.Close(); fncCargaEquipo(); } catch { MessageBox.Show("Problema en BD"); } }
private void cbmEquipo_SelectedIndexChanged(object sender, EventArgs e) { try { dll_conexion.Conexion cConectar = new dll_conexion.Conexion(); cConectar.cLocal(); cConectar.sqlCmd = new MySqlCommand("Select ncodequipo from maequipo where vnombreequipo = '" + cbmEquipo.Text + "';", cConectar.SqlConexion); MySqlDataReader MyReader3; MyReader3 = cConectar.sqlCmd.ExecuteReader(); while (MyReader3.Read()) { lblCodigoEquipo.Text = MyReader3.GetInt32(0).ToString(); fncCargagrid(); } cConectar.SqlConexion.Close(); } catch { MessageBox.Show("Problema en BD"); } }
private void fncCargacmb1() { try { dll_conexion.Conexion cConectar = new dll_conexion.Conexion(); cConectar.cLocal(); cConectar.sqlData = new MySqlDataAdapter("Select vnombreequipo from maequipo", cConectar.SqlConexion); DataTable DT_box = new DataTable(); cConectar.sqlData.Fill(DT_box); foreach (DataRow row in DT_box.Rows) { string rowz = row.ItemArray.ToString(); } cbmEquipo.DataSource = DT_box; cbmEquipo.DisplayMember = "vnombreequipo"; cConectar.SqlConexion.Close(); } catch { MessageBox.Show("Problema en BD, Competencia"); } }
//btnrecuperar recupera password del usuario private void btnrecupera_Click(object sender, EventArgs e) { try { if (txtNombre.Text == "") { MessageBox.Show("Porfavor Ingrese un Nombre de Usuario"); } else { dll_conexion.Conexion cConectar = new dll_conexion.Conexion(); cConectar.cLocal(); cConectar.sqlCmd = new MySqlCommand("Select usuario from mausuario WHERE usuario='" + txtNombre.Text + "'", cConectar.SqlConexion); Object obj = cConectar.sqlCmd.ExecuteScalar(); if (obj == null) { Notificacion.mostrarVentana("Error", "Usuario NO EXISTE!!!", Notificacion.Imagen.Error, 5); } else { frmreccontrasena F_ventanaP = new frmreccontrasena(); sNombre = txtNombre.Text; F_ventanaP.Show(); } cConectar.SqlConexion.Close(); } } catch { MessageBox.Show("Problema con la BD"); } }
/* * "UDPDATE" DE DE DATOS CON CONFIRMACION DE OPERACION * Dennys Choy * */ private void btnModificar(object sender, EventArgs e) { try { if (MessageBox.Show("¿Está seguro Modificar este registro? Nombre del Empleado: " + txtNombre.Text, "Modificar Registro", MessageBoxButtons.YesNo) == DialogResult.Yes) { dll_conexion.Conexion cConectar = new dll_conexion.Conexion(); cConectar.cLocal(); cConectar.sqlCmd = new MySqlCommand("UPDATE macompetencia SET vnomcompetencia = '"+ txtNombre.Text+ "', vdescripcion = '" + txtDescripcion.Text + "' , vtipocompetencia = '"+ cmbTipoCompetencia.Text +"' , dfechainicio = '"+ dateInicio.Text +"', dfechafin = '"+ dateFinal.Text + "' , MaCATEGORIA_codcategoria = "+ txtCategoria.Text +" WHERE ncodcompetencia = "+lblCodigo.Text+";" , cConectar.SqlConexion); cConectar.sqlCmd.ExecuteNonQuery(); cConectar.SqlConexion.Close(); fncCargagrid(); MessageBox.Show("Registro Modificado"); limpiar(); } else { limpiar(); } } catch { MessageBox.Show("Problema en BD"); } }
//Carga o actualiza grid void fncCargagrid() { try { dll_conexion.Conexion cConectar = new dll_conexion.Conexion(); cConectar.cLocal(); cConectar.sqlData = new MySqlDataAdapter("Select * from madatopersonal", cConectar.SqlConexion); DataTable DT_dat = new DataTable(); cConectar.sqlData.Fill(DT_dat); this.dgvEmpleado.DataSource = DT_dat; cConectar.SqlConexion.Close(); cConectar.cLocal(); cConectar.sqlData = new MySqlDataAdapter("Select * from mapuestopersonal", cConectar.SqlConexion); DataTable DT_box = new DataTable(); cConectar.sqlData.Fill(DT_box); foreach (DataRow row in DT_box.Rows) { string rowz = row.ItemArray.ToString(); } cboxTipo.DataSource = DT_box; cboxTipo.DisplayMember = "ncodpuesto"; cConectar.SqlConexion.Close(); } catch { MessageBox.Show("Problema en BD"); } }
private void txtDpi_TextChanged(object sender, EventArgs e) { dll_conexion.Conexion cConectar = new dll_conexion.Conexion(); cConectar.cLocal(); cConectar.sqlData = new MySqlDataAdapter("Select * from madatopersonal where ndpipersonal like ('" + txtDpi.Text + "%') ", cConectar.SqlConexion); DataTable DT_dat = new DataTable(); cConectar.sqlData.Fill(DT_dat); this.dgvEmpleado.DataSource = DT_dat; cConectar.SqlConexion.Close(); }
private void txtNombre_TextChanged(object sender, EventArgs e) { dll_conexion.Conexion cConectar = new dll_conexion.Conexion(); cConectar.cLocal(); cConectar.sqlData = new MySqlDataAdapter("Select * from macompetencia where vnomcompetencia like ('" + txtNombre.Text + "%') ", cConectar.SqlConexion); DataTable DT_dat = new DataTable(); cConectar.sqlData.Fill(DT_dat); this.dgvCampeonato.DataSource = DT_dat; cConectar.SqlConexion.Close(); }
private void fncCargagrid() { try { dll_conexion.Conexion cConectar = new dll_conexion.Conexion(); cConectar.cLocal(); cConectar.sqlData = new MySqlDataAdapter("Select * from macompetencia", cConectar.SqlConexion); DataTable DT_dat = new DataTable(); cConectar.sqlData.Fill(DT_dat); this.dgvCampeonato.DataSource = DT_dat; cConectar.SqlConexion.Close(); //Carga datos al combobox según categoría cConectar.cLocal(); cConectar.sqlData = new MySqlDataAdapter("select *FROM macategoria", cConectar.SqlConexion); DataTable DT_box = new DataTable(); cConectar.sqlData.Fill(DT_box); foreach (DataRow row in DT_box.Rows) { string rowz = row.ItemArray.ToString(); } cmbCategoria.DataSource = DT_box; //cboxTipo.DataSource = DT_box; //cboxTipo.DisplayMember = "ncodpuesto"; cmbCategoria.DisplayMember = "vnombrecategoria"; cConectar.SqlConexion.Close(); } catch { MessageBox.Show("Problema en BD"); } }
/* * Carga txtCategoria el codigo de categoria según seleccion de cmbCategoria * Dennys Choy * */ private void cmbCategoria_SelectedIndexChanged(object sender, EventArgs e) { try { dll_conexion.Conexion cConectar = new dll_conexion.Conexion(); cConectar.cLocal(); cConectar.sqlCmd = new MySqlCommand("SELECT codcategoria FROM macategoria WHERE vnombrecategoria = '" + cmbCategoria.Text + "';", cConectar.SqlConexion); MySqlDataReader MyReader3; MyReader3 = cConectar.sqlCmd.ExecuteReader(); while (MyReader3.Read()) { txtCategoria.Text = MyReader3.GetInt32(0).ToString(); lblCategoria1.Text = MyReader3.GetInt32(0).ToString(); } cConectar.SqlConexion.Close(); } catch { MessageBox.Show("Problema en BD"); } }
// modifica datos en BD private void btnModificar_Click(object sender, EventArgs e) { try { if (MessageBox.Show("¿Está seguro de Modificar este registro? Nombre del Empleado: " + txtNombre.Text, "Modificar Registro", MessageBoxButtons.YesNo) == DialogResult.Yes) { dll_conexion.Conexion cConectar = new dll_conexion.Conexion(); cConectar.cLocal(); cConectar.sqlCmd = new MySqlCommand("UPDATE madatopersonal SET ndpipersonal='" + txtDpi.Text + "' , vnombrepersonal='" + txtNombre.Text + "', vapepersonal='" + txtApellido.Text + "', dfechanacimiento='" + txtFechanacimiento.Text + "',vsexopersonal='" + cbxSexo.Text + "' ,vdireccionpersonal='" + txtDireccion.Text + "' ,ntelpersonal='" + txtTelefono.Text + "' WHERE coddatopersonal ='" + label9.Text + "'", cConectar.SqlConexion); cConectar.sqlCmd.ExecuteNonQuery(); cConectar.SqlConexion.Close(); fncCargagrid(); MessageBox.Show("Registro Modificado"); limpiar(); } else { limpiar(); } } catch { MessageBox.Show("Problema en BD"); } }
private void Fnc_Cargareporte() { // Cbox_Modulo.Text trae el nombre el reporte, tabla y modulo que se reporteara // string que trae la tabla para crear el reporte string Squery = "Select * from " + Cbox_Modulo.Text + ""; //LLamada a la dll de conexion dll_conexion.Conexion cConectar = new dll_conexion.Conexion(); cConectar.cLocal(); MySqlCommand comd = new MySqlCommand(Squery, cConectar.SqlConexion); //Se limpia el datasource del reporte this.Rv_Reporte.LocalReport.DataSources.Clear(); Rv_Reporte.Reset(); //Se llama el reporte que se mostrara en el reportviewer Rv_Reporte.LocalReport.ReportEmbeddedResource = "prueba1." + Cbox_Modulo.Text + ".rdlc"; //se crea el datatable que se llenara DataTable Dt_table = new DataTable(); //Se cargan los valores en dt Dt_table.Load(comd.ExecuteReader()); //Termina la conexion cConectar.SqlConexion.Close(); //Se crea una nueva llamada al reporte por medio del DataSet (se utiliza solo como referencia no conexion) ReportDataSource RprtDS_Origen = new ReportDataSource(); RprtDS_Origen.Name = "DataSet1"; RprtDS_Origen.Value = Dt_table; //Se cargan los datos al reporte this.Rv_Reporte.LocalReport.DataSources.Add(RprtDS_Origen); //Refresca el reporte this.Rv_Reporte.RefreshReport(); }
private void Fnc_Cargagrid() { //conexion por dll dll_conexion.Conexion cConectar = new dll_conexion.Conexion(); cConectar.cLocal(); //query de llamada de datos al grid cConectar.sqlData = new MySqlDataAdapter("Select nom_reporte, usuario, fecha_hora from reportes", cConectar.SqlConexion); DataTable DT_Table = new DataTable(); //Carga el grid cConectar.sqlData.Fill(DT_Table); Gv_Reporte.DataSource = DT_Table; //Se renombran los headers de las columnas Gv_Reporte.Columns[0].HeaderText = "Reporte"; Gv_Reporte.Columns[1].HeaderText = "Usuario"; Gv_Reporte.Columns[2].HeaderText = "Fecha de Creacion"; //Termina la conexion cConectar.SqlConexion.Close(); }
private void CreaReporte() { //variable que contiene el tiempo en formato para guardar en nombre del archivo STiempo = DateTime.Now.ToString("yyyyMMddhhmmss"); //String que lleva la direccion de la carpeta contenedora de los reportes string SSave; //Condicion para crear la carpeta en disco c //si existe guarda los datos //lleva la direccion, nombre, fecha y hora, y el .pdf para crear el documento SSave = "C:/Reportes/" + Cbox_Modulo.Text + "_" + STiempo + puntoreporte + ""; // crea el documento pdf byte[] Bytes = Rv_Reporte.LocalReport.Render(format: tiporeporte, deviceInfo: ""); using (FileStream stream = new FileStream(SSave, FileMode.Create)) { stream.Write(Bytes, 0, Bytes.Length); } //variable que lleva el nombre del archivo que se creo pdf.. para la inserccion en BD SNom_Reporte = "" + Cbox_Modulo.Text + "_" + STiempo + puntoreporte + ""; //conexion por dll dll_conexion.Conexion cConectar = new dll_conexion.Conexion(); cConectar.cLocal(); //query de inserccion cConectar.sqlCmd = new MySqlCommand("INSERT INTO reportes (modulo, nom_reporte, usuario, fecha_hora, id_form) VALUES ('" + IModulo + "' , '" + SNom_Reporte + "' , '" + SUsuario + "' , '" + SFecha_Hora + "' , '" + Iid_Form + "')", cConectar.SqlConexion); cConectar.sqlCmd.ExecuteNonQuery(); cConectar.SqlConexion.Close(); //mensaje de confirmacion MessageBox.Show("Reporte Creado"); //actualiza grid Fnc_Cargagrid(); }
private void fncCargagrid() { try { dll_conexion.Conexion cConectar = new dll_conexion.Conexion(); cConectar.cLocal(); //cConectar.sqlData = new MySqlDataAdapter("SELECT *FROM trequipoencompetencia WHERE MaCOMPETENCIA_ncodcompetencia1 = "+ lblCodigoCompetencia.Text +";", cConectar.SqlConexion); cConectar.sqlData = new MySqlDataAdapter("select ndpijugador, vnombrejugador, vapejugador, nfechanacimiento, vsexojugador, vdireccionjugador, vtelefonojugador from majugador where maequipo_ncodequipo = '" +lblCodigoEquipo.Text + "';", cConectar.SqlConexion); DataTable DT_dat = new DataTable(); cConectar.sqlData.Fill(DT_dat); this.dgvReporteJugador.DataSource = DT_dat; cConectar.SqlConexion.Close(); } catch { MessageBox.Show("Problema en BD, Equipo en competencia GRID"); } }