Documentos de Académico
Documentos de Profesional
Documentos de Cultura
En este manual se muestra el diseño de las tablas, las vistas y el código que fué escrito en el lenguage “C‐Sharp”,
este tiene conexiones con el manejador de base de datos relacional MySQL por medio del conector “mysql‐connector‐
net‐6.6.7” y “MySQL ODBC 5.3 ANSI driver”, así como con Crystal Reports por medio de “CRRuntime_64bit_13_0_18 ” y
“CRRuntime_32bit_13_0_18 ”. Se incluye también una referencia de una tercera parte a un generador de campos del
tipo combobox con múltiple columnas llamado “MultiColumnComboSuggestionBox”.
TABLAS
Las tablas creadas para la aplicación son las siguientes:
‐ Alumnos
Esta contiene la información referente al alumno y la estructura se muestra en la gráfica siguiente:
‐ Calificaciones
Esta contiene todas las calificaciones que el alumno ha adquirido en el curso o cursos que haya tomado en el centro
de lenguas, esta tabla solo puede ser modificada por el administrador del sistema. La estructura se muestra en la
siguiente gráfica:
‐ Calificacionesmaestros
Esta es una tabla temporal donde se almacenan los alumnos de cada grupo antes de que los maestros les asignen
una calificación al finalizar el curso, esta tabla tiene que ser alimentada por el administrador con los datos de los
grupos poco antes de finalizar cada periodo, después los maestros ingresan las calificaciones y por último sera
procesadas por medio del menú principal (Calificaciones – Extraer)
‐ Carreras
En esta tabla es alimentada por el administrador del sistema con la informacion de los datos de las carreras que
sirven como referencia en el registro de los recibos de pago y en los datos personales de los alumnos.
‐ Flags
Esta tabla es indispensable para validar los grupos en la captura de calificaciones de los maestros, esta debe de ser
alimentada por el administrador del sistema poco antes del final del periodo con los grupos que fueron dados de
alta en este.
‐ Grupo
Esta tabla es alimentada por el administrador del sistema antes de iniciar el periodo de inscripciones con los grupos
que se van a ofrecer.
‐ Maestro
Esta tabla es alimentada por el administrador del sistema y contiene los datos de los maestros que imparten los
cursos de inglés.
‐ Niveles
Esta tabla es alimentada por el administrador del sistema y sirve de referencia al momento de la inscripción de los
alumnos que presentan examen de ubicación.
‐ Periodos
Esta tabla sirve de referencia para que las aplicaciones solo muestren referencias de los grupos relevantes al periodo
en el que se esta trabajando.
‐ Recibos
Esta tabla contiene los registros de todos los recibos que se ingresan a la base de datos, es alimentada por la
aplicación y es la más importante del sistema.
‐ Tipos
Esta tabla es alimentada por el administrador del sistema y es una referencia a los tipos de alumnos que se manejan
en este.
VISTAS
A continuación se muestran las vistas que son utilizadas con la aplicación, todas estas vistas se encuentran en la
base de datos MySQL.
Adeudoalumnos
SELECT DISTINCT
`alumnosingles_be`.`recibos`.`no_control` AS `no_control`,
`alumnosingles_be`.`recibos`.`clave_grupo` AS `clave_grupo`,
`alumnosingles_be`.`recibos`.`tipo` AS `tipo`,
SUM(`alumnosingles_be`.`recibos`.`cantidad`) AS `CantidadAbonada`
FROM
`alumnosingles_be`.`recibos`
GROUP BY `alumnosingles_be`.`recibos`.`no_control` , `alumnosingles_be`.`recibos`.`clave_grupo` ,
`alumnosingles_be`.`recibos`.`tipo`
HAVING (((`alumnosingles_be`.`recibos`.`tipo` = 'Interno')
AND (SUM(`alumnosingles_be`.`recibos`.`cantidad`) < 900)
AND (RIGHT(`alumnosingles_be`.`recibos`.`clave_grupo`,
2) <> '00')
AND (RIGHT(`alumnosingles_be`.`recibos`.`clave_grupo`,
2) <> '99'))
OR ((`alumnosingles_be`.`recibos`.`tipo` = 'Externo')
AND (SUM(`alumnosingles_be`.`recibos`.`cantidad`) < 2300)
AND (RIGHT(`alumnosingles_be`.`recibos`.`clave_grupo`,
2) <> '00')
AND (RIGHT(`alumnosingles_be`.`recibos`.`clave_grupo`,
2) <> '99'))
OR ((`alumnosingles_be`.`recibos`.`tipo` = 'SEP/Maestria')
AND (SUM(`alumnosingles_be`.`recibos`.`cantidad`) < 1150)
AND (RIGHT(`alumnosingles_be`.`recibos`.`clave_grupo`,
2) <> '00')
AND (RIGHT(`alumnosingles_be`.`recibos`.`clave_grupo`,
2) <> '99'))
OR ((`alumnosingles_be`.`recibos`.`tipo` = 'Tit/2daVez')
AND (SUM(`alumnosingles_be`.`recibos`.`cantidad`) < 1100)
AND (RIGHT(`alumnosingles_be`.`recibos`.`clave_grupo`,
2) <> '00')
AND (RIGHT(`alumnosingles_be`.`recibos`.`clave_grupo`,
2) <> '99'))
OR ((`alumnosingles_be`.`recibos`.`tipo` = 'Tit/Esp')
AND (SUM(`alumnosingles_be`.`recibos`.`cantidad`) < 2000)
AND (RIGHT(`alumnosingles_be`.`recibos`.`clave_grupo`,
2) <> '00')
AND (RIGHT(`alumnosingles_be`.`recibos`.`clave_grupo`,
2) <> '99')))
ORDER BY `alumnosingles_be`.`recibos`.`no_control`
‐ adeudosalumnos1
SELECT
`recibos‐no_control‐query`.`no_control` AS `no_control`,
`recibos‐no_control‐query`.`clave_grupo` AS `clave_grupo`,
`adeudoalumnos`.`tipo` AS `tipo`,
`adeudoalumnos`.`clave_grupo` AS `GrupoAdeudo`,
`adeudoalumnos`.`CantidadAbonada` AS `CantidadAbonada`,
CONCAT(`alumnosingles_be`.`alumnos`.`apellido_pat`,
' ',
`alumnosingles_be`.`alumnos`.`apellido_mat`,
' ',
`alumnosingles_be`.`alumnos`.`nombre`) AS `NombreAlumno`,
CONCAT(`alumnosingles_be`.`grupo`.`nivel`,
' ',
`alumnosingles_be`.`grupo`.`horario_dias`,
' ',
`alumnosingles_be`.`grupo`.`horario_hrs`) AS `Nivel`,
CONCAT(`alumnosingles_be`.`grupo`.`periodo`,
' ',
`alumnosingles_be`.`grupo`.`año`) AS `Periodo`
FROM
(((`alumnosingles_be`.`recibos‐no_control‐query`
JOIN `alumnosingles_be`.`adeudoalumnos` ON ((`recibos‐no_control‐query`.`no_control` =
`adeudoalumnos`.`no_control`)))
JOIN `alumnosingles_be`.`alumnos` ON ((`recibos‐no_control‐query`.`no_control` =
`alumnosingles_be`.`alumnos`.`no_control`)))
JOIN `alumnosingles_be`.`grupo` ON ((`recibos‐no_control‐query`.`clave_grupo` =
`alumnosingles_be`.`grupo`.`clave_grupo`)))
WHERE
((RIGHT(`recibos‐no_control‐query`.`clave_grupo`,
2) <> '00')
AND (RIGHT(`recibos‐no_control‐query`.`clave_grupo`,
2) <> '99'))
‐ adeudosalumnos2
SELECT
`adeudoalumnos`.`no_control` AS `no_control`,
SUM(`adeudoalumnos`.`CantidadAbonada`) AS `Debe`
FROM
`alumnosingles_be`.`adeudoalumnos`
GROUP BY `adeudoalumnos`.`no_control`
‐ alumnoscantidadtipo1
SELECT
`alumnosingles_be`.`recibos`.`clave_grupo` AS `clave_grupo`,
`alumnosingles_be`.`recibos`.`tipo` AS `tipo`,
SUM(`alumnosingles_be`.`recibos`.`cantidad`) AS `CantTotal`
FROM
`alumnosingles_be`.`recibos`
GROUP BY `alumnosingles_be`.`recibos`.`clave_grupo` , `alumnosingles_be`.`recibos`.`tipo`
‐ alumnoscantidadtipo2
SELECT
`alumnosingles_be`.`recibos`.`clave_grupo` AS `clave_grupo`,
`alumnosingles_be`.`recibos`.`tipo` AS `tipo`,
COUNT(`alumnosingles_be`.`recibos`.`clave_grupo`) AS `CantAlumnos`
FROM
`alumnosingles_be`.`recibos`
GROUP BY `alumnosingles_be`.`recibos`.`clave_grupo` , `alumnosingles_be`.`recibos`.`tipo`
‐ alumnoscantidadtipo3
SELECT
`alumnoscantidadtipo1`.`clave_grupo` AS `clave_grupo`,
`alumnoscantidadtipo1`.`tipo` AS `tipo`,
`alumnoscantidadtipo1`.`CantTotal` AS `CantTotal`,
`alumnoscantidadtipo2`.`CantAlumnos` AS `CantAlumnos`,
CONCAT(`alumnosingles_be`.`grupo`.`nivel`,
' ',
`alumnosingles_be`.`grupo`.`horario_dias`,
' ',
`alumnosingles_be`.`grupo`.`horario_hrs`,
' ',
`alumnoscantidadtipo1`.`clave_grupo`) AS `GrupoNivel`
FROM
((`alumnosingles_be`.`alumnoscantidadtipo1`
JOIN `alumnosingles_be`.`alumnoscantidadtipo2` ON (((`alumnoscantidadtipo1`.`clave_grupo` =
`alumnoscantidadtipo2`.`clave_grupo`)
AND (`alumnoscantidadtipo1`.`tipo` = `alumnoscantidadtipo2`.`tipo`))))
JOIN `alumnosingles_be`.`grupo` ON ((`alumnoscantidadtipo1`.`clave_grupo` =
`alumnosingles_be`.`grupo`.`clave_grupo`)))
‐ alumnospasados
SELECT
`alumnosingles_be`.`calificaciones`.`clave_grupo` AS `clave_grupo`,
`alumnosingles_be`.`grupo`.`nivel` AS `nivel`,
`alumnosingles_be`.`calificaciones`.`no_control` AS `no_control`,
`alumnosingles_be`.`calificaciones`.`calificacion_final` AS `calificacion_final`,
CONCAT_WS(' ',
`alumnosingles_be`.`alumnos`.`apellido_pat`,
`alumnosingles_be`.`alumnos`.`apellido_mat`,
`alumnosingles_be`.`alumnos`.`nombre`) AS `NombreAlumno`,
CONCAT_WS(' ',
`alumnosingles_be`.`maestro`.`mtapellido_pat`,
`alumnosingles_be`.`maestro`.`mtapellido_mat`,
`alumnosingles_be`.`maestro`.`mtnombre`) AS `NombreMaestro`
FROM
(((`alumnosingles_be`.`calificaciones`
JOIN `alumnosingles_be`.`grupo` ON ((`alumnosingles_be`.`calificaciones`.`clave_grupo` =
`alumnosingles_be`.`grupo`.`clave_grupo`)))
JOIN `alumnosingles_be`.`maestro` ON ((`alumnosingles_be`.`grupo`.`RFC_maestro` =
`alumnosingles_be`.`maestro`.`RFC_maestro`)))
LEFT JOIN `alumnosingles_be`.`alumnos` ON ((`alumnosingles_be`.`calificaciones`.`no_control` =
`alumnosingles_be`.`alumnos`.`no_control`)))
WHERE
((`alumnosingles_be`.`calificaciones`.`calificacion_final` >= 80)
AND (`alumnosingles_be`.`calificaciones`.`clave_grupo` LIKE 'GSD2015%'))
‐ Calificacionesadeudos
SELECT
`alumnosingles_be`.`calificaciones`.`clave_grupo` AS `clave_grupo`,
`alumnosingles_be`.`calificaciones`.`no_control` AS `no_control`,
`alumnosingles_be`.`calificaciones`.`conversacion` AS `conversacion`,
`alumnosingles_be`.`calificaciones`.`lectura_y_comprension` AS `lectura_y_comprension`,
`alumnosingles_be`.`calificaciones`.`estructura_gramatical` AS `estructura_gramatical`,
`alumnosingles_be`.`calificaciones`.`habilidad_en_el_idioma` AS `habilidad_en_el_idioma`,
`alumnosingles_be`.`calificaciones`.`participacion` AS `participacion`,
`alumnosingles_be`.`calificaciones`.`asistencia` AS `asistencia`,
`alumnosingles_be`.`calificaciones`.`puntualidad` AS `puntualidad`,
`alumnosingles_be`.`calificaciones`.`calificacion_final` AS `calificacion_final`,
`alumnosingles_be`.`calificaciones`.`id` AS `id`,
`adeudosalumnos2`.`Debe` AS `Debe`
FROM
(`alumnosingles_be`.`calificaciones`
LEFT JOIN `alumnosingles_be`.`adeudosalumnos2` ON ((`alumnosingles_be`.`calificaciones`.`no_control` =
`adeudosalumnos2`.`no_control`)))
‐ calmas01
SELECT DISTINCT
`alumnosingles_be`.`calificacionesmaestros`.`clave_grupo` AS `clave_grupo`,
CONCAT(`alumnosingles_be`.`maestro`.`mtapellido_pat`,
' ',
`alumnosingles_be`.`maestro`.`mtapellido_mat`,
' ',
`alumnosingles_be`.`maestro`.`mtnombre`) AS `NombreMaestro`,
`alumnosingles_be`.`grupo`.`nivel` AS `nivel`,
`alumnosingles_be`.`grupo`.`horario_hrs` AS `horario_hrs`,
`alumnosingles_be`.`grupo`.`horario_dias` AS `horario_dias`,
`alumnosingles_be`.`grupo`.`periodo` AS `periodo`,
`alumnosingles_be`.`grupo`.`año` AS `año`
FROM
((`alumnosingles_be`.`calificacionesmaestros`
JOIN `alumnosingles_be`.`grupo` ON ((`alumnosingles_be`.`calificacionesmaestros`.`clave_grupo` =
`alumnosingles_be`.`grupo`.`clave_grupo`)))
JOIN `alumnosingles_be`.`maestro` ON ((`alumnosingles_be`.`grupo`.`RFC_maestro` =
`alumnosingles_be`.`maestro`.`RFC_maestro`)))
‐ calmas02
SELECT
`alumnosingles_be`.`calificacionesmaestros`.`clave_grupo` AS `clave_grupo`,
CONCAT(`alumnosingles_be`.`alumnos`.`apellido_pat`,
' ',
`alumnosingles_be`.`alumnos`.`apellido_mat`,
' ',
`alumnosingles_be`.`alumnos`.`nombre`) AS `NombreAlumno`,
`alumnosingles_be`.`calificacionesmaestros`.`no_control` AS `no_control`,
`alumnosingles_be`.`alumnos`.`carrera` AS `carrera`,
`alumnosingles_be`.`calificacionesmaestros`.`conversacion` AS `conversacion`,
`alumnosingles_be`.`calificacionesmaestros`.`lectura_y_comprension` AS `lectura_y_comprension`,
`alumnosingles_be`.`calificacionesmaestros`.`estructura_gramatical` AS `estructura_gramatical`,
`alumnosingles_be`.`calificacionesmaestros`.`habilidad_en_el_idioma` AS `habilidad_en_el_idioma`,
`alumnosingles_be`.`calificacionesmaestros`.`participacion` AS `participacion`,
`alumnosingles_be`.`calificacionesmaestros`.`asistencia` AS `asistencia`,
`alumnosingles_be`.`calificacionesmaestros`.`puntualidad` AS `puntualidad`,
`alumnosingles_be`.`calificacionesmaestros`.`calificacion_final` AS `calificacion_final`
FROM
(`alumnosingles_be`.`calificacionesmaestros`
JOIN `alumnosingles_be`.`alumnos` ON ((`alumnosingles_be`.`calificacionesmaestros`.`no_control` =
`alumnosingles_be`.`alumnos`.`no_control`)))
‐ cantidadengrupos
SELECT
`recibos‐no_control‐query`.`clave_grupo` AS `clave_grupo`,
COUNT(`recibos‐no_control‐query`.`clave_grupo`) AS `Cant`
FROM
`alumnosingles_be`.`recibos‐no_control‐query`
GROUP BY `recibos‐no_control‐query`.`clave_grupo`
‐ cantidadengrupos2
(SELECT DISTINCT
`recibos‐no_control‐query`.`clave_grupo` AS `clave_grupo`,
SUM(`recibos‐no_control‐query`.`Sum Of cantidad`) AS `Sum Of Sum Of cantidad`,
COUNT(0) AS `Count Of Recibos‐no_control‐Query`
FROM
`alumnosingles_be`.`recibos‐no_control‐query`
GROUP BY `recibos‐no_control‐query`.`clave_grupo`)
‐ estadisticasgenero
SELECT
`recibos‐no_control‐query`.`clave_grupo` AS `clave_grupo`,
`recibos‐no_control‐query`.`no_control` AS `no_control`,
`alumnosingles_be`.`grupo`.`nivel` AS `nivel`,
`alumnosingles_be`.`alumnos`.`carrera` AS `carrera`,
`alumnosingles_be`.`alumnos`.`genero` AS `genero`
FROM
((`alumnosingles_be`.`recibos‐no_control‐query`
JOIN `alumnosingles_be`.`grupo` ON ((`recibos‐no_control‐query`.`clave_grupo` =
`alumnosingles_be`.`grupo`.`clave_grupo`)))
JOIN `alumnosingles_be`.`alumnos` ON ((`recibos‐no_control‐query`.`no_control` =
`alumnosingles_be`.`alumnos`.`no_control`)))
WHERE
((RIGHT(`recibos‐no_control‐query`.`clave_grupo`,
2) <> '00')
AND (RIGHT(`recibos‐no_control‐query`.`clave_grupo`,
2) <> '99'))
‐ pagos
SELECT DISTINCT
`alumnosingles_be`.`recibos`.`no_control` AS `no_control`,
`alumnosingles_be`.`recibos`.`clave_grupo` AS `clave_grupo`,
`alumnosingles_be`.`recibos`.`tipo` AS `tipo`,
SUM(`alumnosingles_be`.`recibos`.`cantidad`) AS `Cantidad`,
CONCAT(`alumnosingles_be`.`grupo`.`nivel`,
' ',
`alumnosingles_be`.`grupo`.`horario_dias`,
' ',
`alumnosingles_be`.`grupo`.`horario_hrs`) AS `Nivel`,
CONCAT(`alumnosingles_be`.`grupo`.`periodo`,
' ',
`alumnosingles_be`.`grupo`.`año`) AS `Periodo`
FROM
((`alumnosingles_be`.`alumnos`
JOIN `alumnosingles_be`.`recibos` ON ((`alumnosingles_be`.`alumnos`.`no_control` =
`alumnosingles_be`.`recibos`.`no_control`)))
JOIN `alumnosingles_be`.`grupo` ON ((`alumnosingles_be`.`recibos`.`clave_grupo` =
`alumnosingles_be`.`grupo`.`clave_grupo`)))
GROUP BY `alumnosingles_be`.`recibos`.`no_control` , `alumnosingles_be`.`recibos`.`clave_grupo` ,
`alumnosingles_be`.`grupo`.`nivel` , `alumnosingles_be`.`grupo`.`horario_dias` ,
`alumnosingles_be`.`grupo`.`horario_hrs` , `alumnosingles_be`.`grupo`.`periodo` , `alumnosingles_be`.`grupo`.`año`
‐ periodocarrera
SELECT
`recibos‐no_control‐query`.`no_control` AS `no_control`,
`recibos‐no_control‐query`.`clave_grupo` AS `clave_grupo`,
CONCAT_WS(' ',
`alumnosingles_be`.`alumnos`.`apellido_pat`,
`alumnosingles_be`.`alumnos`.`apellido_mat`,
`alumnosingles_be`.`alumnos`.`nombre`) AS `NombreAlumno`,
`alumnosingles_be`.`alumnos`.`carrera` AS `carrera`,
`alumnosingles_be`.`grupo`.`nivel` AS `Nivel`,
CONCAT_WS(' ',
`alumnosingles_be`.`grupo`.`periodo`,
`alumnosingles_be`.`grupo`.`año`) AS `Periodo`
FROM
((`alumnosingles_be`.`recibos‐no_control‐query`
JOIN `alumnosingles_be`.`alumnos` ON ((`recibos‐no_control‐query`.`no_control` =
`alumnosingles_be`.`alumnos`.`no_control`)))
JOIN `alumnosingles_be`.`grupo` ON ((`recibos‐no_control‐query`.`clave_grupo` =
`alumnosingles_be`.`grupo`.`clave_grupo`)))
WHERE
((NOT ((`alumnosingles_be`.`grupo`.`clave_grupo` LIKE '%00')))
AND (NOT ((`alumnosingles_be`.`grupo`.`clave_grupo` LIKE '%99'))))
‐ reciboscontrolclave
SELECT
CONCAT(`alumnosingles_be`.`recibos`.`no_control`,
`alumnosingles_be`.`recibos`.`clave_grupo`) AS `ControlClave`
FROM
`alumnosingles_be`.`recibos`
ORDER BY CONCAT(`alumnosingles_be`.`recibos`.`no_control`,
`alumnosingles_be`.`recibos`.`clave_grupo`)
‐ recibos‐no_control‐query
SELECT DISTINCT
`alumnosingles_be`.`recibos`.`no_control` AS `no_control`,
`alumnosingles_be`.`recibos`.`clave_grupo` AS `clave_grupo`,
SUM(`alumnosingles_be`.`recibos`.`cantidad`) AS `Sum Of cantidad`
FROM
(`alumnosingles_be`.`alumnos`
JOIN `alumnosingles_be`.`recibos` ON ((`alumnosingles_be`.`alumnos`.`no_control` =
`alumnosingles_be`.`recibos`.`no_control`)))
GROUP BY `alumnosingles_be`.`recibos`.`no_control` , `alumnosingles_be`.`recibos`.`clave_grupo`
CODIGO
Los c[odigos de todos los procesos para la aplicación se muestran a continuación:
‐ DBConnnect
Código que contiene todas las conexiones que se hacen entre la aplicación y el manejador de datos MySQL, este es
llamado dentro de los mismos procesos mediante el llamado a procedimiento.
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using System.IO;
using MySql.Data.MySqlClient;
using System.Data;
namespace AlumnosIngles
{
class DBConnect
{
private MySqlConnection connection;
private string server;
private string database;
private string uid;
private string password;
//Constructor
public DBConnect()
{
Initialize();
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
//Initialize values
private void Initialize()
{
server = "10.13.50.101";
database = "alumnosingles_be";
uid = "CentroIdiomas01";
password = "CenLen01!!";
string connectionString;
connectionString = "SERVER=" + server + ";" +
"DATABASE=" + database + ";" +
"UID=" + uid + ";" +
"PASSWORD=" + password + ";";
connection = new MySqlConnection(connectionString);
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
//open connection to database
private bool OpenConnection()
{
try
{
connection.Open();
return true;
}
catch (MySqlException ex)
{
switch (ex.Number)
{
case 0:
MessageBox.Show("Can't Connect with Server");
break;
case 1045:
MessageBox.Show("Invalid username/password, please try again");
break;
}
return false;
}
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
//Close connection
private bool CloseConnection()
{
try
{
connection.Close();
return true;
}
catch (MySqlException ex)
{
MessageBox.Show(ex.Message);
return false;
}
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
//Buscar alumno en tabla Alumnos
public bool BuscarAlumno(string strNoControl)
{
string query = "SELECT * FROM alumnos WHERE no_control='" + strNoControl + "'";
bool Alumno = false;
//Open connection
if (this.OpenConnection() == true)
{
//Create Command
MySqlCommand cmd = new MySqlCommand(query, connection);
//Create a data reader and Execute the command
MySqlDataReader dataReader = cmd.ExecuteReader();
if (dataReader.HasRows)
{
Alumno= true;
}
//close Data Reader
dataReader.Close();
//close Connection
this.CloseConnection();
}
return Alumno;
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
//Buscar Carrera
public bool BuscarCarrera(string strCarrera)
{
string query = "SELECT * FROM carreras WHERE BINARY carreras='" + strCarrera + "'";
bool Carrera = false;
//Open connection
if (this.OpenConnection() == true)
{
//Create Command
MySqlCommand cmd = new MySqlCommand(query, connection);
//Create a data reader and Execute the command
MySqlDataReader dataReader = cmd.ExecuteReader();
if (dataReader.HasRows)
{
Carrera = true;
}
else
{
MessageBox.Show("La Carrera no Existe");
}
//close Data Reader
dataReader.Close();
//close Connection
this.CloseConnection();
}
return Carrera;
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
//Buscar Recibo
public bool BuscarRecibo(string strRecibo)
{
string query = "SELECT * FROM recibos WHERE no_recibo='" + strRecibo + "'";
bool Recibo = false;
//Open connection
if (this.OpenConnection() == true)
{
//Create Command
MySqlCommand cmd = new MySqlCommand(query, connection);
//Create a data reader and Execute the command
MySqlDataReader dataReader = cmd.ExecuteReader();
if (dataReader.HasRows)
{
MessageBox.Show("El Recibo Ya Existe");
Recibo = true;
}
else
{
//MessageBox.Show("El Recibo No Existe");
}
//close Data Reader
dataReader.Close();
//close Connection
this.CloseConnection();
}
return Recibo;
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
//Buscar Grupo
public bool BuscarGrupo(string strGrupo)
{
string query = "SELECT * FROM grupo WHERE BINARY clave_grupo='" + strGrupo + "'";
bool Grupo = true;
//Open connection
if (this.OpenConnection() == true)
{
//Create Command
MySqlCommand cmd = new MySqlCommand(query, connection);
//Create a data reader and Execute the command
MySqlDataReader dataReader = cmd.ExecuteReader();
if (dataReader.HasRows)
{
Grupo = false;
}
else
{
MessageBox.Show("El Grupo no Existe");
}
//close Data Reader
dataReader.Close();
//close Connection
this.CloseConnection();
}
return Grupo;
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
//Buscar Nivel
public bool BuscarNivel(string strNivel)
{
string query = "SELECT * FROM niveles WHERE BINARY nivel='" + strNivel + "'";
bool Nivel = false;
//Open connection
if (this.OpenConnection() == true)
{
MySqlCommand cmd = new MySqlCommand(query, connection);
MySqlDataReader dataReader = cmd.ExecuteReader();
if (dataReader.HasRows)
{
Nivel = true;
}
else
{
MessageBox.Show("El Nivel no Existe");
}
//close Data Reader
dataReader.Close();
//close Connection
this.CloseConnection();
}
return Nivel;
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
//Buscar Tipo
public bool BuscarTipo(string strTipo)
{
string query = "SELECT * FROM tipos WHERE BINARY tipo='" + strTipo + "'";
bool Tipo = false;
//Open connection
if (this.OpenConnection() == true)
{
MySqlCommand cmd = new MySqlCommand(query, connection);
MySqlDataReader dataReader = cmd.ExecuteReader();
if (dataReader.HasRows)
{
//MessageBox.Show(dataReader["tipo"].ToString());
Tipo = true;
}
else
{
MessageBox.Show("El Tipo no Existe");
}
//close Data Reader
dataReader.Close();
//close Connection
this.CloseConnection();
}
return Tipo;
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
//Buscar Periodo
public bool BuscarPeriodo(string strPeriodo)
{
string query = "SELECT * FROM periodos WHERE periodo='" + strPeriodo + "'";
bool bolPeriodo = false;
//Open connection
if (this.OpenConnection() == true)
{
//Create Command
MySqlCommand cmd = new MySqlCommand(query, connection);
//Create a data reader and Execute the command
MySqlDataReader dataReader = cmd.ExecuteReader();
if (dataReader.HasRows)
{
//MessageBox.Show("Si Existe el Periodo");
bolPeriodo = true;
}
else
{
MessageBox.Show("No Existe el Periodo");
}
//close Data Reader
dataReader.Close();
//close Connection
this.CloseConnection();
}
return bolPeriodo;
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
//Buscar Grupo Calificaciones Maestros
public bool BuscarCalificacionesMaestro(string strGrupo)
{
string query = "SELECT DISTINCT clave_grupo FROM alumnosingles_be.calificacionesmaestros where
clave_grupo='" + strGrupo + "'";
bool Grupo = false;
//Open connection
if (this.OpenConnection() == true)
{
//Create Command
MySqlCommand cmd = new MySqlCommand(query, connection);
//Create a data reader and Execute the command
MySqlDataReader dataReader = cmd.ExecuteReader();
if (dataReader.HasRows)
{
Grupo = true;
}
else
{
MessageBox.Show("El Grupo No Existe");
}
//close Data Reader
dataReader.Close();
//close Connection
this.CloseConnection();
}
return Grupo;
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
public string BuscarCantidadEnGrupos(string Grupo)
{
string query = "SELECT * FROM cantidadengrupos WHERE clave_grupo='" + Grupo + "'";
string Cantidad = "";
int RowCount = 0;
//Open connection
if (this.OpenConnection() == true)
{
//Create Command
MySqlCommand cmd = new MySqlCommand(query, connection);
//Create a data reader and Execute the command
MySqlDataReader dataReader = cmd.ExecuteReader();
//Read the data and store them in the list
while (dataReader.Read())
{
RowCount++;
Cantidad = dataReader["Cant"].ToString();
}
//MessageBox.Show(RowCount.ToString());
//MessageBox.Show(Cantidad.ToString());
//close Data Reader
dataReader.Close();
//close Connection
this.CloseConnection();
//return list to be displayed
}
return Cantidad;
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
public bool BuscarBoletasIndividuales(string strGrupo, string strNoControl)
{
string query = "SELECT * FROM calificaciones WHERE clave_grupo = '" + strGrupo + "' AND no_control = '" +
strNoControl + "'";
bool bolBoleta = false;
//Open connection
if (this.OpenConnection() == true)
{
//Create Command
MySqlCommand cmd = new MySqlCommand(query, connection);
//Create a data reader and Execute the command
MySqlDataReader dataReader = cmd.ExecuteReader();
if (dataReader.HasRows)
{
//MessageBox.Show("El Numero de Control Si Existe");
bolBoleta = true;
}
else
{
//MessageBox.Show("El Numero de Control No Existe");
}
//close Data Reader
dataReader.Close();
//close Connection
this.CloseConnection();
}
return bolBoleta;
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
// Check if the student is in the group
public bool AlumnoGrupo(string NoControl, string Grupo)
{
//Search if student is already in the group
bool Existe = false;
string query = "SELECT * FROM alumnosingles_be.recibos WHERE no_control='" +
NoControl +"' AND clave_grupo='" + Grupo +"'";
// string query = "SELECT * FROM recibos WHERE no_control = '" + NoControl + "'";
if (this.OpenConnection() == true)
{
MySqlCommand cmd = new MySqlCommand(query, connection);
MySqlDataReader dataReader = cmd.ExecuteReader();
if (dataReader.HasRows)
{
//MessageBox.Show("Si Existe el Grupo para El Alumno");
Existe = true;
}
else
{
//MessageBox.Show("El Alumno No Esta en el Grupo");
}
dataReader.Close();
}
this.CloseConnection();
return Existe;
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
// Check if there is space available in the group
public bool GrupoDisponible(string strGrupo)
{
bool Lleno = false;
int QtyRecibos = 0;
int QtyGrupo = 0;
//Open connection
if (this.OpenConnection() == true)
{
string queryRecibos = "SELECT * FROM alumnosingles_be.cantidadengrupos WHERE clave_grupo='" +
strGrupo + "'";
MySqlCommand cmdRecibos = new MySqlCommand(queryRecibos, connection);
MySqlDataReader dataReaderRecibos = cmdRecibos.ExecuteReader();
if (dataReaderRecibos.HasRows)
{
dataReaderRecibos.Read();
QtyRecibos = Convert.ToInt32(dataReaderRecibos["Cant"].ToString());
}
dataReaderRecibos.Close();
string queryGrupo = "SELECT * FROM grupo WHERE (clave_grupo = '" + strGrupo + "')";
MySqlCommand cmdGrupo = new MySqlCommand(queryGrupo, connection);
MySqlDataReader dataReaderGrupo = cmdGrupo.ExecuteReader();
dataReaderGrupo.Read();
QtyGrupo = Convert.ToInt32(dataReaderGrupo["cupo_alumnos"].ToString());
dataReaderGrupo.Close();
if (QtyRecibos >= QtyGrupo)
{
MessageBox.Show("El Grupo Esta LLeno");
Lleno = true;
}
}
//close Connection
this.CloseConnection();
return Lleno;
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
//Load Recibos DataGrid
public List<string>[] LoadGrid(string NoControl)
{
string query = "SELECT * FROM recibos WHERE (no_control = '" + NoControl + "')";
//Create a list to store the result
List<string>[] list = new List<string>[6];
list[0] = new List<string>(); //no_control
list[1] = new List<string>(); //clave_grupo
list[2] = new List<string>(); //tipo
list[3] = new List<string>(); //cantidad
list[4] = new List<string>(); //examenubicacion
list[5] = new List<string>(); //no_recibo
//Open connection
if (this.OpenConnection() == true)
{
//Create Command
MySqlCommand cmd = new MySqlCommand(query, connection);
//Create a data reader and Execute the command
MySqlDataReader dataReader = cmd.ExecuteReader();
//Read the data and store them in the list
while (dataReader.Read())
{
list[0].Add(dataReader["no_control"] + "");
list[1].Add(dataReader["no_recibo"] + "");
list[2].Add(dataReader["clave_grupo"] + "");
list[3].Add(dataReader["tipo"] + "");
list[4].Add(dataReader["cantidad"] + "");
list[5].Add(dataReader["examenubicacion"] + "");
}
//close Data Reader
dataReader.Close();
//close Connection
this.CloseConnection();
//return list to be displayed
return list;
}
else
{
return list;
}
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
public void AlumnoInsert(List<string> list)
{
//MessageBox.Show("Insert Values in Alumnos table");
string query = "INSERT INTO alumnos (no_control, nombre, apellido_pat, apellido_mat, carrera, genero)" +
"VALUES('" + list[0] + "', '" + list[2] + "', '" + list[1] + "', '" + list[8] +
"', '" + list[9] + "', '" + list[3] + "')";
//open connection
if (this.OpenConnection() == true)
{
//create command and assign the query and connection from the constructor
MySqlCommand cmd = new MySqlCommand(query, connection);
//Execute command
cmd.ExecuteNonQuery();
//close connection
this.CloseConnection();
}
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
public void AlumnoUpdate(List<string> list)
{
//MessageBox.Show("Insert Values in Alumnos table");
string query = "UPDATE alumnos SET nombre='" + list[2] + "', apellido_pat='" + list[1] + "', " +
"apellido_mat='" + list[4] + "', carrera='" + list[5] + "', genero='" + list[3] + "' " +
"WHERE no_control='" + list[0] + "'";
if (this.OpenConnection() == true)
{
MySqlCommand cmd = new MySqlCommand(query, connection);
cmd.ExecuteNonQuery();
this.CloseConnection();
}
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
public void ReciboInsert(List<string> list)
{
//MessageBox.Show("Insert Values in Recibos table");
string DateNow = DateTime.Now.ToString("yyyy‐MM‐dd HH:mm:ss"); //DateTime.Now.ToString("yyyy‐
MM‐dd");
string query = "INSERT INTO recibos (no_control, no_recibo, clave_grupo, tipo, cantidad, examenubicacion)" +
"VALUES('" + list[0] + "', '" + list[4] + "', '" + list[5] + "', '" + list[6] +
"', '" + list[7] + "', '" + list[10] + "')";
//open connection
if (this.OpenConnection() == true)
{
//create command and assign the query and connection from the constructor
MySqlCommand cmd = new MySqlCommand(query, connection);
//Execute command
cmd.ExecuteNonQuery();
//close connection
this.CloseConnection();
}
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
//Buscar alumno en tabla AdeudoAlumnos
public bool Adeudos
(string strNoControl)
{
string query = "SELECT * FROM adeudoalumnos WHERE no_control='" + strNoControl + "'";
bool Adeudo = false;
//Open connection
if (this.OpenConnection() == true)
{
//Create Command
MySqlCommand cmd = new MySqlCommand(query, connection);
//Create a data reader and Execute the command
MySqlDataReader dataReader = cmd.ExecuteReader();
if (dataReader.HasRows)
{
Adeudo = true;
}
//close Data Reader
dataReader.Close();
//close Connection
this.CloseConnection();
}
return Adeudo;
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
//Load Recibos DataGrid
public DataSet AdeudosDataGrid(string strNoControl)
{
DataSet DS = null;
if (this.OpenConnection() == true)
{
string query = "SELECT adeudoalumnos.no_control, " +
"CONCAT(alumnos.apellido_pat, ' ', alumnos.apellido_mat, ' ', alumnos.nombre) AS Nombre, " +
"alumnos.carrera, adeudoalumnos.tipo, adeudoalumnos.clave_grupo, " +
"CONCAT(grupo.nivel, ' ', grupo.horario_dias, ' ', grupo.horario_hrs) AS Horario, " +
"adeudoalumnos.CantidadAbonada " +
"FROM adeudoalumnos " +
"INNER JOIN alumnos ON adeudoalumnos.no_control = alumnos.no_control " +
"INNER JOIN grupo ON adeudoalumnos.clave_grupo = grupo.clave_grupo " +
"WHERE (adeudoalumnos.no_control = '" + strNoControl + "')";
MySqlDataAdapter mySqlDataAdapter = new MySqlDataAdapter(query, connection);
DS = new DataSet();
mySqlDataAdapter.Fill(DS);
//close Connection
this.CloseConnection();
}
//return list to be displayed
return DS;
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
//Load Alumnos data to modify
public DataSet ModificarAlumno(string strNoControl)
{
DataSet DS = null;
if (this.OpenConnection() == true)
{
string query = "SELECT * FROM alumnos WHERE no_control='" + strNoControl + "'";
MySqlDataAdapter mySqlDataAdapter = new MySqlDataAdapter(query, connection);
DS = new DataSet();
mySqlDataAdapter.Fill(DS);
//close Connection
this.CloseConnection();
}
//return list to be displayed
return DS;
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
//Load Alumnos data to modify
public DataSet ModificarRecibo(string strNoControl)
{
DataSet DS = null;
if (this.OpenConnection() == true)
{
string query = "SELECT recibos.no_control, recibos.no_recibo, recibos.clave_grupo, recibos.tipo, " +
"recibos.cantidad, recibos.examenubicacion, alumnos.apellido_pat, alumnos.apellido_mat, " +
"alumnos.nombre, alumnos.carrera, grupo.nivel, grupo.horario_dias, grupo.horario_hrs " +
"FROM recibos " +
"INNER JOIN alumnos ON recibos.no_control = alumnos.no_control " +
"INNER JOIN grupo ON recibos.clave_grupo = grupo.clave_grupo " +
"WHERE (recibos.no_control = '" + strNoControl + "')";
MySqlDataAdapter mySqlDataAdapter = new MySqlDataAdapter(query, connection);
DS = new DataSet();
mySqlDataAdapter.Fill(DS);
//close Connection
this.CloseConnection();
}
//return list to be displayed
return DS;
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
public void ModificarRecibosUpdate(string strGrupo, string strTipo, string strCantidad, string
strExamenUbicacion, string NoRecibo)
{
//MessageBox.Show(id + " " + modulo + " " + participacion.ToString());
string query = "UPDATE recibos SET clave_grupo='" + strGrupo + "', tipo='" + strTipo +
"', cantidad='" + strCantidad + "', examenubicacion='" + strExamenUbicacion +
"' WHERE no_recibo='" + NoRecibo + "'";
//Open connection
if (this.OpenConnection() == true)
{
//create mysql command
MySqlCommand cmd = new MySqlCommand();
//Assign the query using CommandText
cmd.CommandText = query;
//Assign the connection using Connection
cmd.Connection = connection;
//Execute query
cmd.ExecuteNonQuery();
}
//close connection
this.CloseConnection();
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
//Load Recibos DataGrid
public DataSet DatosAlumnos(string strNoControl)
{
DataSet DS = null;
if (this.OpenConnection() == true)
{
string query = "SELECT * FROM alumnos WHERE no_control = '" + strNoControl + "'";
MySqlDataAdapter mySqlDataAdapter = new MySqlDataAdapter(query, connection);
DS = new DataSet();
mySqlDataAdapter.Fill(DS);
//close Connection
this.CloseConnection();
}
//return list to be displayed
return DS;
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
//Load Recibos DataGrid
public DataSet LoadGridCantidadEnGrupos(string strPeriodo)
{
DataSet DS = null;
if (this.OpenConnection() == true)
{
string query = "SELECT grupo.clave_grupo, grupo.nivel AS Nivel, grupo.horario_dias AS Dias,
grupo.horario_hrs AS Hrs, " +
"grupo.cupo_alumnos AS Cupo, cantidadengrupos.Cant, grupo.salon, " +
"CONCAT_WS(' ', maestro.mtapellido_pat, maestro.mtapellido_mat, maestro.mtnombre) AS
NombreMaestro " +
"FROM alumnosingles_be.grupo " +
"LEFT JOIN maestro ON grupo.RFC_maestro = maestro.RFC_maestro " +
"LEFT JOIN cantidadengrupos ON grupo.clave_grupo = cantidadengrupos.clave_grupo " +
"WHERE(grupo.clave_grupo LIKE '" + strPeriodo + "' AND NOT(grupo.clave_grupo LIKE '%00') " +
"AND NOT(grupo.clave_grupo LIKE '%99'))";
MySqlDataAdapter mySqlDataAdapter = new MySqlDataAdapter(query, connection);
DS = new DataSet();
mySqlDataAdapter.Fill(DS);
//close Connection
this.CloseConnection();
}
//return list to be displayed
return DS;
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
//Load Alumnos Grid
public DataSet LoadGridAlumnos(string strCampo, string strDato)
{
DataSet DS = null;
if (this.OpenConnection() == true)
{
string query = "SELECT no_control, nombre, apellido_pat, apellido_mat, carrera, genero " +
"FROM alumnosingles_be.alumnos " +
"WHERE " + strCampo + " LIKE '" + strDato + "%'" +
"ORDER BY " + strCampo;
MySqlDataAdapter mySqlDataAdapter = new MySqlDataAdapter(query, connection);
DS = new DataSet();
mySqlDataAdapter.Fill(DS);
//close Connection
this.CloseConnection();
}
//return list to be displayed
return DS;
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
public MySqlDataAdapter DropDown(string strSelect)
{
string strQuery = "";
switch (strSelect)
{
case "Alumnos":
strQuery = "SELECT alumnos.no_control, CONCAT_WS(' ',alumnos.apellido_pat,alumnos.apellido_mat," +
"alumnos.nombre) As NombreAlumno " +
"FROM alumnosingles_be.alumnos";
break;
case "Carreras":
strQuery = "SELECT * FROM carreras ORDER BY carreras";
break;
case "Periodos":
strQuery = "SELECT * FROM periodos ORDER BY ID DESC";
break;
case "Grupos":
strQuery = "SELECT grupo.clave_grupo, grupo.nivel, grupo.horario_dias, grupo.horario_hrs,
cantidadengrupos.Cant, " +
"CONCAT_WS(' ', maestro.mtapellido_pat,maestro.mtapellido_mat, maestro.mtnombre) AS
NombreMaestro " +
"FROM alumnosingles_be.grupo " +
"LEFT JOIN alumnosingles_be.maestro ON grupo.RFC_maestro = maestro.RFC_maestro " +
"LEFT JOIN alumnosingles_be.cantidadengrupos ON grupo.clave_grupo =
cantidadengrupos.clave_grupo " +
"WHERE grupo.clave_grupo LIKE '" + GlobalVars.GlobalPeriodo + "'";
break;
case "Niveles":
strQuery = "SELECT * FROM niveles ORDER BY nivel";
break;
case "Tipos":
strQuery = "SELECT * FROM tipos ORDER BY tipo";
break;
case "Cardexes":
strQuery = "SELECT DISTINCT calificaciones.no_control, " +
"CONCAT_WS(' ',alumnos.apellido_pat,alumnos.apellido_mat,alumnos.nombre) AS
NombreAlumno " +
"FROM calificaciones " +
"INNER JOIN alumnos ON alumnos.no_control = calificaciones.no_control " +
"ORDER BY calificaciones.no_control";
break;
case "ExtraerCalificaciones":
strQuery = "SELECT DISTINCT calificacionesmaestros.clave_grupo, " +
"CONCAT_WS(' ',grupo.nivel,grupo.horario_dias,grupo.horario_hrs) AS Nivel, " +
"CONCAT_WS(' ',maestro.mtapellido_pat,maestro.mtapellido_mat,maestro.mtnombre) AS
NombreMaestro " +
"FROM calificacionesmaestros " +
"INNER JOIN grupo ON calificacionesmaestros.clave_grupo = grupo.clave_grupo " +
"LEFT JOIN maestro ON grupo.RFC_maestro = maestro.RFC_maestro " +
"ORDER BY Nivel";
break;
case "Calificaciones":
strQuery = "SELECT DISTINCT calificaciones.clave_grupo, " +
"CONCAT_WS(' ',grupo.nivel,grupo.horario_dias,grupo.horario_hrs) AS Nivel, " +
"CONCAT_WS(' ',maestro.mtapellido_pat,maestro.mtapellido_mat,maestro.mtnombre) AS
NombreMaestro " +
"FROM alumnosingles_be.calificaciones " +
"INNER JOIN alumnosingles_be.grupo ON calificaciones.clave_grupo = grupo.clave_grupo " +
"LEFT JOIN alumnosingles_be.maestro ON grupo.RFC_maestro = maestro.RFC_maestro " +
"WHERE grupo.clave_grupo LIKE '" + GlobalVars.GlobalPeriodo + "'" +
"GROUP BY calificaciones.clave_grupo";
break;
case "BoletasIndividuales":
strQuery = "SELECT calificaciones.no_control, calificaciones.clave_grupo, " +
"CONCAT_WS(' ',grupo.nivel,grupo.horario_dias,grupo.horario_hrs) AS Nivel, " +
"CONCAT_WS(' ',alumnos.apellido_pat,alumnos.apellido_mat,alumnos.nombre) AS
NombreAlumno " +
"FROM calificaciones " +
"INNER JOIN alumnos ON calificaciones.no_control = alumnos.no_control " +
"INNER JOIN grupo ON calificaciones.clave_grupo = grupo.clave_grupo " +
"ORDER BY calificaciones.no_control";
break;
default:
break;
}
//MessageBox.Show(strQuery);
MySqlCommand command;
MySqlDataAdapter adapter = null;
if (this.OpenConnection() == true)
{
command = new MySqlCommand(strQuery, connection);
adapter = new MySqlDataAdapter(command);
//close Connection
this.CloseConnection();
}
//return list to be displayed
return adapter;
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
//Load Cardex DataGrid
public DataSet CardexDataGrid(string strNoControl)
{
DataSet DS = null;
if (this.OpenConnection() == true)
{
string query = "SELECT grupo.nivel, calificaciones.calificacion_final, " +
"calificaciones.conversacion, calificaciones.lectura_y_comprension,
calificaciones.estructura_gramatical, " +
"calificaciones.habilidad_en_el_idioma, calificaciones.participacion, calificaciones.asistencia, " +
"calificaciones.puntualidad, grupo.periodo, grupo.año, calificaciones.clave_grupo, " +
"CONCAT (maestro.mtapellido_pat, ' ',maestro.mtapellido_mat, ' ', maestro.mtnombre) AS
NombreMaestro " +
"FROM calificaciones INNER JOIN grupo ON calificaciones.clave_grupo = grupo.clave_grupo " +
"LEFT JOIN maestro ON grupo.RFC_maestro = maestro.RFC_maestro " +
"WHERE (calificaciones.no_control = '" + strNoControl + "')";
MySqlDataAdapter mySqlDataAdapter = new MySqlDataAdapter(query, connection);
DS = new DataSet();
mySqlDataAdapter.Fill(DS);
//close Connection
this.CloseConnection();
}
//return list to be displayed
return DS;
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
//Buscar alumno en tabla de Calificaciones
public bool BuscarAlumnoCalificaciones(string strNoControl)
{
string query = "SELECT * FROM calificaciones WHERE no_control='" + strNoControl + "'";
bool AlumnoCalificaciones = false;
//Open connection
if (this.OpenConnection() == true)
{
//Create Command
MySqlCommand cmd = new MySqlCommand(query, connection);
//Create a data reader and Execute the command
MySqlDataReader dataReader = cmd.ExecuteReader();
if (dataReader.HasRows)
{
AlumnoCalificaciones = true;
}
//close Data Reader
dataReader.Close();
//close Connection
this.CloseConnection();
}
return AlumnoCalificaciones;
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
public void InsertDeleteCalificacionesMaestro(string strGrupo)
{
string InsertQuery = "INSERT INTO alumnosingles_be.calificaciones (clave_grupo, no_control, conversacion, "
+
"lectura_y_comprension, estructura_gramatical, habilidad_en_el_idioma, participacion, " +
"asistencia, puntualidad, calificacion_final) " +
"SELECT clave_grupo, no_control, conversacion, lectura_y_comprension, estructura_gramatical, " +
"habilidad_en_el_idioma, participacion, asistencia, puntualidad, calificacion_final " +
"FROM alumnosingles_be.calificacionesmaestros " +
"WHERE clave_grupo='" + strGrupo + "'";
string DeleteQuery = "DELETE FROM alumnosingles_be.calificacionesmaestros WHERE clave_grupo = '" +
strGrupo + "'";
//open connection
if (this.OpenConnection() == true)
{
MySqlCommand cmdInsert = new MySqlCommand(InsertQuery, connection);
cmdInsert.ExecuteNonQuery();
MySqlCommand cmdDelete = new MySqlCommand(DeleteQuery, connection);
cmdDelete.ExecuteNonQuery();
this.CloseConnection();
}
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
public void StorePassword(string strRFC, byte[] bytPassword)
{
//MessageBox.Show(id + " " + modulo + " " + participacion.ToString());
string query = "UPDATE alumnosingles_be.maestro1 SET Password='" + bytPassword +
"' WHERE RFC_maestro='" + strRFC + "'";
//Open connection
if (this.OpenConnection() == true)
{
//create mysql command
MySqlCommand cmd = new MySqlCommand();
//Assign the query using CommandText
cmd.CommandText = query;
//Assign the connection using Connection
cmd.Connection = connection;
//Execute query
cmd.ExecuteNonQuery();
}
//close connection
this.CloseConnection();
////MessageBox.Show("Insert Values in Alumnos table");
//string query = "INSERT INTO alumnosingles.maestro1 (Password)" +
// "VALUES('" + list[0] + "', '" + list[2] + "', '" + list[1] + "', '" + list[8] +
// "', '" + list[9] + "', '" + list[3] + "')";
////open connection
//if (this.OpenConnection() == true)
//{
// //create command and assign the query and connection from the constructor
// MySqlCommand cmd = new MySqlCommand(query, connection);
// //Execute command
// cmd.ExecuteNonQuery();
// //close connection
// this.CloseConnection();
//}
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
public byte[] CheckPassword(string strRFC)
{
//string query = "SELECT Password FROM alumnosingles_be.maestro1 WHERE RFC_maestro='" + strRFC + "'";
byte[] PasswordStored = null;
////Open connection
if (this.OpenConnection() == true)
{
// //Create Command
// MySqlCommand cmd = new MySqlCommand(query, connection);
// //Create a data reader and Execute the command
// MySqlDataReader dataReader = cmd.ExecuteReader();
// if (dataReader.HasRows)
// {
// MessageBox.Show("It has rows");
string query1 = "SELECT Password FROM alumnosingles_be.maestro1 WHERE RFC_maestro='" + strRFC +
"'";
MySqlCommand cmdPassword = new MySqlCommand(query1, connection);
MySqlDataReader dataReaderPassword = cmdPassword.ExecuteReader();
// if (dataReaderPassword.HasRows)
// {
dataReaderPassword.Read();
// byte[] temp=dataReaderPassword["Password"];
// MessageBox.Show(temp.ToString());
// // PasswordStored = Convert.ToByte[](dataReaderPassword["Password"]);
// }
// dataReaderPassword.Close();
// }
// //close Data Reader
// dataReader.Close();
// //close Connection
this.CloseConnection();
}
return PasswordStored;
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
public bool GrupoAbierto(string strGrupo)
{
string query = "SELECT * FROM alumnosingles_be.flags WHERE clave_grupo='" + strGrupo + "'";
bool GrupoAbierto = false;
if (this.OpenConnection() == true)
{
MySqlCommand cmd = new MySqlCommand(query, connection);
MySqlDataReader dataReader = cmd.ExecuteReader();
if (dataReader.HasRows)
{
int intStatus = 0;
dataReader.Read();
intStatus = Convert.ToInt32(dataReader["status"].ToString());
if (intStatus == 1)
{
GrupoAbierto = true;
}
}
dataReader.Close();
this.CloseConnection();
}
return GrupoAbierto;
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
public DataSet Becas(string strSelect)
{
string strQuery = "";
string strType = "";
switch (strSelect)
{
case "Rober Bocsh":
strType = "21%";
break;
case "Mascareñas":
strType = "22%";
break;
case "Rosario Castellanos":
strType = "23%";
break;
case "Deportes":
strType = "24%";
break;
case "Becas":
strType = "25%";
break;
case "Rosario Campos":
strType = "26%";
break;
default:
strType = "";
break;
}
strQuery = "SELECT no_recibo AS Recibo FROM alumnosingles_be.recibos WHERE no_recibo like '" + strType +
"' ORDER BY no_recibo DESC";
DataSet DS = null;
if (this.OpenConnection() == true)
{
MySqlDataAdapter mySqlDataAdapter = new MySqlDataAdapter(strQuery, connection);
DS = new DataSet();
mySqlDataAdapter.Fill(DS);
//close Connection
this.CloseConnection();
}
//return list to be displayed
return DS;
}
//=========================================================================================
}
}
‐ frmAdeudos
Código que se ejecuta al momento del registro de nuevos recibos, abre una ventana que muestra si el alumno que
se está inscribiendo tiene algún adeudo con el centro de lenguas. Se ejecuta automáticamente en el proceso
frmAlumnos o frmRecibos.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace AlumnosIngles
{
public partial class frmAdeudos : Form
{
DBConnect newDBConnect = new DBConnect();
public frmAdeudos()
{
InitializeComponent();
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
// Through Constructor
public frmAdeudos(string strTextBox)
{
InitializeComponent();
lblNoControl.Text=strTextBox;
AdeudosShow();
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
// Show student debt
private void AdeudosShow()
{
//MessageBox.Show("Adeudos Show");
DataSet Datos;
int ColNumber;
string strCantidad = "";
int intAdeudo;
string strTipo = "";
Datos = newDBConnect.AdeudosDataGrid(lblNoControl.Text.ToString());
//dgvAdeudos.DataSource = Datos.Tables[0];
DataTable DataTable = new DataTable();
DataTable = Datos.Tables[0];
this.lblNoControl.Text = DataTable.Rows[0]["no_control"].ToString();
this.lblNombre.Text = DataTable.Rows[0]["Nombre"].ToString();
this.lblCarrera.Text = DataTable.Rows[0]["Carrera"].ToString();
dgvAdeudos.Rows.Clear();
// Load datagrid with data
foreach (DataTable table in Datos.Tables)
{
foreach (DataRow row in table.Rows)
{
ColNumber = 0;
int RowNumber = dgvAdeudos.Rows.Add();
foreach (DataColumn column in table.Columns)
{
if (column.ToString() == "tipo" || column.ToString() == "clave_grupo" ||
column.ToString() == "Horario" || column.ToString() == "CantidadAbonada")
{
if (ColNumber == 3)
{
dgvAdeudos.Rows[RowNumber].Cells[ColNumber].Value = Int32.Parse(row[column].ToString());
}
else
{
dgvAdeudos.Rows[RowNumber].Cells[ColNumber].Value = row[column].ToString();
}
ColNumber++;
}
}
strTipo = dgvAdeudos.Rows[RowNumber].Cells[0].Value.ToString();
strCantidad = dgvAdeudos.Rows[RowNumber].Cells[3].Value.ToString();
intAdeudo = AlumnoTipo(strTipo, strCantidad);
dgvAdeudos.Rows[RowNumber].Cells[ColNumber].Value = intAdeudo;
}
}
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private int AlumnoTipo(string Tipo, string Cantidad)
{
int numVal = Int32.Parse(Cantidad);
switch (Tipo)
{
case "Interno":
numVal = 900 ‐ numVal;
break;
case "Externo":
numVal = 2300 ‐ numVal;
break;
case "Descuento":
numVal = 1150 ‐ numVal;
break;
case "Tit/Esp":
numVal = 2000 ‐ numVal;
break;
case "Tit/2daVez":
numVal = 1100 ‐ numVal;
break;
case "SEP/Maestria":
numVal = 1150 ‐ numVal;
break;
case "Tit/Esp C":
numVal = 3000 ‐ numVal;
break;
default:
break;
}
return numVal;
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void frmAdeudos_KeyPress(object sender, KeyPressEventArgs e)
{
//MessageBox.Show("KeyPress");
//MessageBox.Show(e.KeyChar.ToString());
//MessageBox.Show(Convert.ToChar((char)27).ToString());
if (e.KeyChar == (char)27) this.Close();
}
//=========================================================================================
}
}
‐ frmAlumnos
Código que registra los datos para los alumnos nuevos en la tabla alumnos, además registra el registra el recibo con
el cual se da de alta el alumno n el sistema, esta se ejecuta en el menú principal en la opción ALUMNOS/AGREGAR.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MySql.Data.MySqlClient;
namespace AlumnosIngles
{
public partial class frmAlumnos : Form
{
DBConnect newDBConnect = new DBConnect();
public frmAlumnos()
{
InitializeComponent();
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void Alumnos_Load(object sender, EventArgs e)
{
//MessageBox.Show("Load Alumnos Form");
MySqlDataAdapter GruposDA;
DataTable GruposDT = new DataTable();
GruposDA = newDBConnect.DropDown("Grupos");
GruposDA.Fill(GruposDT);
cmbGrupo.Data = GruposDT;
cmbGrupo.ViewColumn = 0;
MySqlDataAdapter CarreralDA;
DataTable CarreraDT = new DataTable();
CarreralDA = newDBConnect.DropDown("Carreras");
CarreralDA.Fill(CarreraDT);
cmbCarrera.DataSource = CarreraDT;
cmbCarrera.DisplayMember = "carreras";
cmbCarrera.ValueMember = "carreras";
MySqlDataAdapter NivelDA;
DataTable NivelDT = new DataTable();
NivelDA = newDBConnect.DropDown("Niveles");
NivelDA.Fill(NivelDT);
cmbNivel.DataSource = NivelDT;
cmbNivel.DisplayMember = "Nivel";
cmbNivel.ValueMember = "Nivel";
MySqlDataAdapter TipoDA;
DataTable TipoDT = new DataTable();
TipoDA = newDBConnect.DropDown("Tipos");
TipoDA.Fill(TipoDT);
cmbTipo.DataSource = TipoDT;
cmbTipo.DisplayMember = "tipo";
cmbTipo.ValueMember = "tipo";
cmbNoControl.SelectedIndex = ‐1;
cmbCarrera.SelectedIndex = ‐1;
cmbRecibo.SelectedIndex = ‐1;
cmbGrupo.SelectedIndex = ‐1;
cmbNivel.SelectedIndex = ‐1;
cmbTipo.SelectedIndex = ‐1;
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
//Advance next tab index if return is pressed
private void GeneralKeyPress(object sender, KeyPressEventArgs e)
{
e.KeyChar = Char.ToUpper(e.KeyChar);
if (e.KeyChar == Convert.ToChar(Keys.Return))
{
SendKeys.Send("{TAB}");
}
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
// Validating Alumno
private void cmbNoControl_Validating(object sender, CancelEventArgs e)
{
//MessageBox.Show("Validating No Control");
bool BuscarAlumno;
BuscarAlumno = newDBConnect.BuscarAlumno(cmbNoControl.Text.ToString());
if (BuscarAlumno)
{
MessageBox.Show("El Alumno ya Existe");
e.Cancel = true;
}
else
{
//MessageBox.Show("No Existe");
}
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
// Validating Genero
private void cmbGenero_Validating(object sender, CancelEventArgs e)
{
//MessageBox.Show("Validating Genero");
string Genero = cmbGenero.Text.ToString();
if (Genero == "F" || Genero == "M" || Genero == "")
{
//MessageBox.Show("Correcto");
}
else
{
MessageBox.Show("Solo F o M");
e.Cancel = true;
}
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
// Validating Carrera
private void cmbCarrera_Validating(object sender, CancelEventArgs e)
{
//MessageBox.Show("Validating Carrera");
bool bolCarrera;
if (cmbCarrera.Text.ToString() != "")
{
bolCarrera = newDBConnect.BuscarCarrera(cmbCarrera.Text.ToString());
if (bolCarrera)
{
//MessageBox.Show("Existe Carrera");
}
else
{
//MessageBox.Show("La Carrera No Existe");
e.Cancel = true;
}
}
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
// Validating Recibo
private void cmbRecibo_Validating(object sender, CancelEventArgs e)
{
//MessageBox.Show("Validating No Control");
bool Recibo;
Recibo = newDBConnect.BuscarRecibo(cmbRecibo.Text.ToString());
if (Recibo)
{
//MessageBox.Show("El Recibo ya Existe");
e.Cancel = true;
}
else
{
//MessageBox.Show("No Existe el Recibo");
}
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
// Validating Group
private void cmbGrupo_Validating(object sender, CancelEventArgs e)
{
string strGrupo = cmbGrupo.Text.ToString();
if (strGrupo == "")
{
//MessageBox.Show("El Campo Esta Vacio");
}
else
{
bool Grupo;
Grupo = newDBConnect.BuscarGrupo(strGrupo);
if (Grupo)
{
//MessageBox.Show("El grupo no Existe");
e.Cancel = true;
}
else
{
if (strGrupo.Substring(7, 2).ToString() == "00")
{
//MessageBox.Show("Examen de Ubicacion");
cmbNivel.Focus();
}
else
{
bool GrupoLleno;
GrupoLleno = newDBConnect.GrupoDisponible(strGrupo);
if (GrupoLleno)
{
//MessageBox.Show("EL Grupo Esta Lleno");
e.Cancel = true;
}
else
{
cmbTipo.Focus();
}
}
}
}
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void cmbNivel_Validating(object sender, CancelEventArgs e)
{
//MessageBox.Show("Validating Nivel");
bool Nivel;
if (cmbNivel.Text.ToString() != "")
{
Nivel = newDBConnect.BuscarNivel(cmbNivel.Text.ToString());
if (Nivel)
{
//MessageBox.Show("El Nivel ya Existe");
}
else
{
//MessageBox.Show("No Existe el Nivel");
e.Cancel = true;
}
}
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void btnGuardarDatos_Click(object sender, EventArgs e)
{
//MessageBox.Show("Guardar datos Click");
List<string> list = new List<string>();
list.Add(cmbNoControl.Text.ToString()); // 0 No. de Control
list.Add(txbApellidoPat.Text.ToString()); // 1 Apellido Paterno
list.Add(txbNombre.Text.ToString()); // 2 Nombre
list.Add(cmbGenero.Text.ToString()); // 3 Genero
list.Add(cmbRecibo.Text.ToString()); // 4 No. de Recibo
list.Add(cmbGrupo.Text.ToString()); // 5 Clave de Grupo
list.Add(cmbTipo.Text.ToString()); // 6 Tipo
list.Add(txbCantidad.Text.ToString()); // 7 Cantidad
int i=0;
foreach (string element in list)
{
if (list[i] == "")
{
MessageBox.Show("Los Campos con * Deben Contener Datos");
break;
}
i++;
}
int ListCount = list.Count;
//MessageBox.Show(i + " " + ListCount.ToString());
if (i == ListCount)
{
list.Add(txbApellidoMat.Text.ToString()); // 8 Apellido Materno
list.Add(cmbCarrera.Text.ToString()); // 9 Carrera
list.Add(cmbNivel.Text.ToString()); // 10 Nivel
newDBConnect.AlumnoInsert(list);
newDBConnect.ReciboInsert(list);
//cmbNoControl.Text = ""; // 0 No. de Control
txbApellidoPat.Text = ""; // 1 Apellido Paterno
txbNombre.Text = ""; // 2 Nombre
cmbGenero.Text = ""; // 3 Genero
cmbRecibo.Text = ""; // 4 No. de Recibo
cmbGrupo.Text = ""; // 5 Clave de Grupo
cmbTipo.Text = ""; // 6 Tipo
txbCantidad.Text = ""; // 7 Cantidad
txbApellidoMat.Text = ""; // 8 Apellido Materno
cmbCarrera.Text = ""; // 9 Carrera
cmbNivel.Text = ""; // 10 Nivel
}
cmbNoControl.Focus();
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void cmbTipo_Validating(object sender, CancelEventArgs e)
{
//MessageBox.Show("Validating Nivel");
bool Tipo;
if (cmbTipo.Text.ToString() != "")
{
Tipo = newDBConnect.BuscarTipo(cmbTipo.Text.ToString());
if (Tipo)
{
//MessageBox.Show("El Tipo ya Existe");
}
else
{
//MessageBox.Show("No Existe el Tipo");
e.Cancel = true;
}
}
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void EnterKeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == Convert.ToChar(Keys.Return))
{
SendKeys.Send("{TAB}");
}
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void btnBecas_Click(object sender, EventArgs e)
{
this.Height = 660;
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void cmbBecas_SelectedIndexChanged(object sender, EventArgs e)
{
//You can get data from the selected row out of the ColumnComboBox like this:
if (cmbBecas.SelectedIndex > ‐1)//If there is no selected index the indexer will return null
{
//cmbBecas.Text = (cmbBecas.SelectedIndex.ToString());
}
else
{
cmbBecas.Text = "";
}
DataSet Datos = null;
Datos = newDBConnect.Becas(cmbBecas.Text.ToString());
dgvBecas.DataSource = Datos.Tables[0];
DataTable RecibosDT = new DataTable();
RecibosDT = Datos.Tables[0];
if (RecibosDT.Rows.Count == 0)
{
this.cmbRecibo.Text = "00000";
}
else
{
int intReciboNo = 0;
intReciboNo = Int32.Parse(RecibosDT.Rows[0]["Recibo"].ToString()) + 1;
this.cmbRecibo.Text = intReciboNo.ToString();
}
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void pnlBecas_Leave(object sender, EventArgs e)
{
this.Height = 430;
cmbBecas.Text = "";
}
//=========================================================================================
}
}
‐ frmAlumnosGrid
Código que muestra todos los alumnos que se han ingresado en este sistema, se utiliza para localizar un número de
control, nombre, apellido, carrera o género. Se ejecuta en el menú principal en la opción ALUMNOS/ALUMNOS
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace AlumnosIngles
{
public partial class frmAlumnosGrid : Form
{
public frmAlumnosGrid()
{
InitializeComponent();
}
DBConnect newDBConnect = new DBConnect();
BindingSource AlumnosBS = new BindingSource();
DataTable AlumnosDT = new DataTable();
DataSet AlumnosDS;
string strCampo = "";
string strHeaderName = "";
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void frmAlumnosGrid_Load(object sender, EventArgs e)
{
//MessageBox.Show("frmAlumnosGrid_Load");
AlumnosDS = newDBConnect.LoadGridAlumnos("no_control", "");
//LoadGridGrupos.DataSource = Datos.Tables[0];
LoadAlumnosGrid();
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void dgvAlumnos_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
int colIndex = dgvAlumnos.Columns[e.ColumnIndex].Index;
strCampo = dgvAlumnos.Columns[colIndex].Name;
strHeaderName = dgvAlumnos.Columns[colIndex].HeaderText;
pnlDato.Visible = true;
txbHeaderText.Text = strHeaderName;
txbDato.Focus();
//MessageBox.Show("ColumnHeaderMouseClick Right Click");
//string strCampo = dgvAlumnos.Columns[colIndex].Name;
//MessageBox.Show(colIndex.ToString());
//MessageBox.Show(strCampo);
}
}
// ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void LoadAlumnosGrid()
{
int ColNumber;
AlumnosDT = AlumnosDS.Tables[0];
AlumnosBS.DataSource = AlumnosDS.Tables[0];
AlumnosbindingNavigator.BindingSource = AlumnosBS;
//dgvGrupos.DataSource = BS;
dgvAlumnos.Rows.Clear();
// For each table in the DataSet, show in datagrid
foreach (DataTable table in AlumnosDS.Tables)
{
foreach (DataRow AlumnosDR in table.Rows)
{
ColNumber = 0;
int RowNumber = dgvAlumnos.Rows.Add();
foreach (DataColumn AlumnosDC in table.Columns)
{
dgvAlumnos.Rows[RowNumber].Cells[ColNumber].Value = AlumnosDR[AlumnosDC].ToString();
ColNumber++;
}
}
}
//int RowNumberHeader = 1;
//foreach (DataGridViewRow row in dgvAlumnos.Rows)
//{
// if (row.IsNewRow) continue;
// row.HeaderCell.Value = "" + RowNumberHeader;
// RowNumberHeader++;
//}
//dgvAlumnos.RowHeadersWidth = 60;
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void txbDato_KeyPress(object sender, KeyPressEventArgs e)
{
e.KeyChar = Char.ToUpper(e.KeyChar);
if (e.KeyChar == Convert.ToChar(Keys.Return))
{
SendKeys.Send("{TAB}");
}
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void txbDato_Validating(string strCampo)
{
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void txbDato_Validating(object sender, CancelEventArgs e)
{
string strDato = txbDato.Text.ToString();
AlumnosDS = newDBConnect.LoadGridAlumnos(strCampo, strDato);
LoadAlumnosGrid();
pnlDato.Visible = false;
}
//_________________________________________________________________________________________
}
}
‐ frmAlumnosGrupos
Código que abre una ventana donde se muestra la cantidad de grupos ofrecidos para un periodo seleccionado, así
como el numero de alumnos registrados y el cupo total del grupo. Se ejecuta en el menú principal en la opción
GRUPOS/CANTIDAD POR PERIODOS.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MySql.Data.MySqlClient;
namespace AlumnosEnGrupos
{
public partial class AlumnosGrupos : Form
{
DBConnect newDBConnect = new DBConnect();
BindingSource BS = new BindingSource();
DataTable GrupoDT = new DataTable();
DataSet GrupoDS;
public AlumnosGrupos()
{
InitializeComponent();
}
// ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void GeneralKeyPress(object sender, KeyPressEventArgs e)
{
e.KeyChar = Char.ToUpper(e.KeyChar);
if (e.KeyChar == Convert.ToChar(Keys.Return))
{
SendKeys.Send("{TAB}");
}
}
// ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void btnCargarDatos_Click(object sender, EventArgs e)
{
int ColNumber;
GrupoDS = newDBConnect.LoadGridGrupos(cmbPeriodo.SelectedValue.ToString() + "%");
//LoadGridGrupos.DataSource = Datos.Tables[0];
GrupoDT = GrupoDS.Tables[0];
BS.DataSource = GrupoDS.Tables[0];
bindingNavigator1.BindingSource = BS;
dgvGrupos.Rows.Clear();
foreach (DataTable table in GrupoDS.Tables)
{
foreach (DataRow GrupoDR in table.Rows)
{
ColNumber = 0;
int RowNumber = dgvGrupos.Rows.Add();
foreach (DataColumn GrupoDC in table.Columns)
{
dgvGrupos.Rows[RowNumber].Cells[ColNumber].Value = GrupoDR[GrupoDC].ToString();
ColNumber++;
}
}
}
int RowNumberHeader = 1;
foreach (DataGridViewRow row in dgvGrupos.Rows)
{
if (row.IsNewRow) continue;
row.HeaderCell.Value = "" + RowNumberHeader;
RowNumberHeader++;
}
dgvGrupos.RowHeadersWidth = 50;
timer1.Enabled = true;
}
// ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void btnActualizar_Click(object sender, EventArgs e)
{
Color clrColor = Color.White;
int RowTot = dgvGrupos.Rows.Count ‐ 1;
List<string> lstCantGrupos=null;
for (int RowNum = 0; RowNum <= RowTot; RowNum++)
{
string Grupo = dgvGrupos.Rows[RowNum].Cells[0].Value.ToString();
lstCantGrupos = newDBConnect.UpdateCant(Grupo);
//MessageBox.Show(dgvGrupos.Rows[RowNum].Cells[4].Value.ToString());
if (lstCantGrupos[1] != "0")
{
dgvGrupos.Rows[RowNum].Cells[4].Value = lstCantGrupos[1];
}
else
{
lstCantGrupos[1] = dgvGrupos.Rows[RowNum].Cells[4].Value.ToString();
}
dgvGrupos.Rows[RowNum].Cells[5].Value = lstCantGrupos[0];
int intCupo = int.Parse(lstCantGrupos[1]);
int intCant = int.Parse(lstCantGrupos[0]);
if (intCant >= intCupo)
{
clrColor = Color.Red;
}
else
{
if (intCant >= intCupo ‐ 5)
{
clrColor = Color.Yellow;
}
else
{
clrColor = Color.Lavender;
}
}
for (int i = 0; i <= int.Parse(dgvGrupos.ColumnCount.ToString()) ‐ 1; i++)
{
dgvGrupos.Rows[RowNum].Cells[i].Style.BackColor = clrColor;
}
//MessageBox.Show(RowNum.ToString());
}
}
// ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void dgvGrupos_SortCompare(object sender, DataGridViewSortCompareEventArgs e)
{
//MessageBox.Show("dgvGrupos_SortCompare");
e.SortResult = System.String.Compare(
e.CellValue1.ToString(), e.CellValue2.ToString());
if (e.SortResult == 0 && e.Column.Name == "nivel")
{
string strNivel1 = dgvGrupos.Rows[e.RowIndex1].Cells["nivel"].Value.ToString() +
dgvGrupos.Rows[e.RowIndex1].Cells["dias"].Value.ToString() +
dgvGrupos.Rows[e.RowIndex1].Cells["hora"].Value.ToString();
string strNivel2 = dgvGrupos.Rows[e.RowIndex2].Cells["nivel"].Value.ToString() +
dgvGrupos.Rows[e.RowIndex2].Cells["dias"].Value.ToString() +
dgvGrupos.Rows[e.RowIndex2].Cells["hora"].Value.ToString();
e.SortResult = System.String.Compare(strNivel1, strNivel2);
}
e.Handled = true;
}
// ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void dgvGrupos_Sorted(object sender, EventArgs e)
{
//MessageBox.Show("dgvGrupos_Sorted");
}
// ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void cmbPeriodo_Enter(object sender, EventArgs e)
{
MySqlDataAdapter PeriodosDA;
DataTable PeriodosDT = new DataTable();
PeriodosDA = newDBConnect.PeriodoDropDown();
PeriodosDA.Fill(PeriodosDT);
cmbPeriodo.DataSource = PeriodosDT;
cmbPeriodo.DisplayMember = "Descripcion";
cmbPeriodo.ValueMember = "Periodo";
cmbPeriodo.SelectedIndex = ‐1;
}
}
}
‐ frmBoletaIndividual
Código que se utiliza para la impresión de boletas de calificaciones individuales. Se ejecuta por medio en la opción
BOLETAS/INDIVIDUALES.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MySql.Data.MySqlClient;
namespace AlumnosIngles
{
public partial class frmBoletaIndividual : Form
{
DBConnect newDBConnect = new DBConnect();
public frmBoletaIndividual()
{
InitializeComponent();
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void frmBoletaIndividual_Load(object sender, EventArgs e)
{
//MessageBox.Show("frmBoletaIndividual_Load");
MySqlDataAdapter BoletasIndividualesDA;
DataTable BoletasIndividualesDT = new DataTable();
BoletasIndividualesDA = newDBConnect.DropDown("BoletasIndividuales");
BoletasIndividualesDA.Fill(BoletasIndividualesDT);
cmbNoControlGrupo.Data = BoletasIndividualesDT;
cmbNoControlGrupo.ViewColumn = 0;
cmbNoControlGrupo.Columns[1].Display = false;
cmbNoControlGrupo.SelectedIndex = ‐1;
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void cmbNoControlGrupo_Validating(object sender, CancelEventArgs e)
{
string strGrupo = "";
if (cmbNoControlGrupo["clave_grupo"] != null)
{
strGrupo = cmbNoControlGrupo["clave_grupo"].ToString();
}
if (cmbNoControlGrupo.Text.ToString() != "")
{
string strNoControl = cmbNoControlGrupo.Text.ToString();
bool bolBoleta;
bolBoleta = newDBConnect.BuscarBoletasIndividuales(strGrupo, strNoControl);
if (!bolBoleta)
{
MessageBox.Show("El Número de Control no Existe");
e.Cancel = true;
}
}
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void btnNoControlGrupo_Click(object sender, EventArgs e)
{
//MessageBox.Show("btnNoControlGrupo_Click");
if (cmbNoControlGrupo.Text == "")
{
MessageBox.Show("El Numero de Control Esta Vacio");
cmbNoControlGrupo.Focus();
}
else
{
string strNoControl = cmbNoControlGrupo.Text.ToString();
string strGrupo = cmbNoControlGrupo["clave_grupo"].ToString();
rptBoletas1.Refresh();
rptBoletas1.SetParameterValue("Grupo", strGrupo);
rptBoletas1.SetParameterValue("NoControl", strNoControl);
cryBoletaIndividual.ReportSource = rptBoletas1;
}
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void cmbNoControlGrupo_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == Convert.ToChar(Keys.Return))
{
SendKeys.Send("{TAB}");
}
}
//=========================================================================================
}
}
‐ frmBoletas
Código que se utiliza para la impresión de boletas de calificación por grupo. Se ejecuta por medio del menú principal
BOLETAS/POR GRUPO.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MySql.Data.MySqlClient;
namespace AlumnosIngles
{
public partial class frmBoletas : Form
{
DBConnect newDBConnect = new DBConnect();
public frmBoletas()
{
InitializeComponent();
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void frmBoletas_Load(object sender, EventArgs e)
{
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void cmbGrupo_Validating(object sender, CancelEventArgs e)
{
string strGrupo = "";
if (cmbGrupo.Text.ToString() != "")
{
bool bolGrupo;
strGrupo = cmbGrupo.Text.ToString();
bolGrupo = newDBConnect.BuscarGrupo(strGrupo);
if (bolGrupo)
{
//MessageBox.Show("El grupo no Existe");
e.Cancel = true;
}
else
{
rptListaCalificaciones1.Refresh();
rptListaCalificaciones1.SetParameterValue("Grupo", strGrupo);
cryListaCalificaciones.ReportSource = rptListaCalificaciones1;
rptBoletas1.Refresh();
rptBoletas1.SetParameterValue("Grupo", strGrupo);
rptBoletas1.SetParameterValue("NoControl", "*");
cryBoletas.ReportSource = rptBoletas1;
}
}
}
private void cmbGrupo_Enter(object sender, EventArgs e)
{
//MessageBox.Show("frmReporteListas_Load");
MySqlDataAdapter CalificacionesDA;
DataTable CalificacionesDT = new DataTable();
CalificacionesDA = newDBConnect.DropDown("Calificaciones");
CalificacionesDA.Fill(CalificacionesDT);
cmbGrupo.Data = CalificacionesDT;
cmbGrupo.ViewColumn = 0;
cmbGrupo.SelectedIndex = ‐1;
}
//==========================================================================================
}
}
‐ frmCalificacionesMaestro
Código que abre una ventana de captura que utilizan los maestros para la asignación de calificaciones de los
alumnos. Se ejecuta dando doble click o seleccionando y dando enter al ícono de CALIFICACIONES MAESTRO.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MySql.Data.MySqlClient;
namespace Calificaciones_Maestros
{
public partial class frmCalificacionesMaestro : Form
{
public frmCalificacionesMaestro()
{
InitializeComponent();
}
private MySqlConnection connection;
private MySqlDataAdapter CalificacionesMaestrosDA;
private DataTable CalificacionesMaestrosDT = new DataTable();
// ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void Initialize()
{
string connectionString;
connectionString = "SERVER=10.13.50.101; DATABASE=alumnosingles_be; UID=CentroIdiomas01;
PASSWORD=CenLen01!!;";
connection = new MySqlConnection(connectionString);
}
// ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void frmCalificacionesMaestro_Load(object sender, EventArgs e)
{
//MessageBox.Show("Form Load");
Initialize();
}
// ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
public MySqlDataAdapter DropDown(string strSelect)
{
string strQuery = "";
switch (strSelect)
{
case "CalificacionesMaestros":
strQuery = "SELECT DISTINCT calificacionesmaestros.clave_grupo, " +
"CONCAT_WS(' ',grupo.nivel,grupo.horario_dias,grupo.horario_hrs) AS Nivel, " +
"CONCAT_WS(' ',maestro.mtapellido_pat,maestro.mtapellido_mat,maestro.mtnombre) AS
NombreMaestro " +
"FROM alumnosingles_be.calificacionesmaestros " +
"INNER JOIN alumnosingles_be.grupo ON calificacionesmaestros.clave_grupo = grupo.clave_grupo
" +
"INNER JOIN alumnosingles_be.maestro ON grupo.RFC_maestro = maestro.RFC_maestro " +
"ORDER BY Nivel";
break;
default:
break;
}
MySqlCommand cmd;
MySqlDataAdapter DA = null;
connection.Open();
cmd = new MySqlCommand(strQuery, connection);
DA = new MySqlDataAdapter(cmd);
connection.Close();
return DA;
}
// ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void DropDownLoad()
{
CalificacionesMaestrosDT.Clear();
CalificacionesMaestrosDA = DropDown("CalificacionesMaestros");
CalificacionesMaestrosDA.Fill(CalificacionesMaestrosDT);
cmbGrupo.Data = CalificacionesMaestrosDT;
cmbGrupo.ViewColumn = 0;
}
// ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void cmbGrupo_Enter(object sender, EventArgs e)
{
crystalReportViewer1.Visible = false;
DropDownLoad();
}
// ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void cmbGrupo_Validating(object sender, CancelEventArgs e)
{
//MessageBox.Show("cmbGrupo_Validating");
string strGrupo=cmbGrupo.Text.ToString();
bool bolGrupo=false;
bolGrupo=BuscarGrupo(strGrupo);
if (strGrupo != "")
{
if (!bolGrupo)
{
MessageBox.Show("El Grupo No Existe");
e.Cancel = true;
}
}
}
// ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void cmbGrupo_Validated(object sender, EventArgs e)
{
//MessageBox.Show("Grupo Validating");
}
// ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
public DataSet CalificacionesMaestro(string strGrupo)
{
DataSet DS = null;
connection.Open();
string query = "SELECT * FROM alumnosingles_be.calmas02 WHERE clave_grupo='" + strGrupo + "' ORDER BY
NombreAlumno";
MySqlDataAdapter mySqlDataAdapter = new MySqlDataAdapter(query, connection);
DS = new DataSet();
mySqlDataAdapter.Fill(DS);
connection.Close();
return DS;
}
// ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
//Buscar Grupo
public bool BuscarGrupo(string strGrupo)
{
string query = "SELECT DISTINCT clave_grupo FROM calificacionesmaestros WHERE (clave_grupo = '" +
strGrupo + "')";
bool bolGrupo = false;
connection.Open();
MySqlCommand cmd = new MySqlCommand(query, connection);
MySqlDataReader dataReader = cmd.ExecuteReader();
if (dataReader.HasRows)
{
bolGrupo = true;
}
else
{
//MessageBox.Show("El Grupo no Existe");
}
dataReader.Close();
connection.Close();
return bolGrupo;
}
// ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
public void Update(int Campo, string Grupo, string NoControl, string Valor)
{
string campo = "";
switch (Campo)
{
case 4:
campo = "conversacion";
break;
case 5:
campo = "lectura_y_comprension";
break;
case 6:
campo = "estructura_gramatical";
break;
case 7:
campo = "habilidad_en_el_idioma";
break;
case 8:
campo = "participacion";
break;
case 9:
campo = "asistencia";
break;
case 10:
campo = "puntualidad";
break;
case 11:
campo = "calificacion_final";
break;
default:
break;
}
//MessageBox.Show(id + " " + modulo + " " + participacion.ToString());
string query = "UPDATE calificacionesmaestros SET " + campo + "=" + Valor + " WHERE no_control=" +
NoControl;
connection.Open();
MySqlCommand cmd = new MySqlCommand();
cmd.CommandText = query;
cmd.Connection = connection;
cmd.ExecuteNonQuery();
connection.Close();
}
// ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void dgvCalificacionesMaestros_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
{
//MessageBox.Show("Validating");
int ColNum = dgvCalificacionesMaestros.CurrentCell.ColumnIndex;
int RowNum = dgvCalificacionesMaestros.CurrentCell.RowIndex;
//MessageBox.Show(dgvCalificaciones.Rows[RowNum].Cells[ColNum].Value.ToString());
string CellValue = e.FormattedValue.ToString();
if (CellValue != "")
{
string Grupo = dgvCalificacionesMaestros.Rows[RowNum].Cells[0].Value.ToString();
string NoControl = dgvCalificacionesMaestros.Rows[RowNum].Cells[2].Value.ToString();
if (ColNum > 3 && ColNum < 11)
{
int CellValueInt = Convert.ToInt32(CellValue);
if (CellValueInt < 0 || CellValueInt > 5)
{
e.Cancel = true;
MessageBox.Show("El Valor Debe De Ser Entre 0 y 5");
}
else
{
Update(ColNum, Grupo, NoControl, CellValue);
}
}
if (ColNum == 11)
{
int CellValueInt = Convert.ToInt32(CellValue);
if (CellValueInt < 0 || CellValueInt > 100)
{
e.Cancel = true;
MessageBox.Show("El Valor Debe De Ser Entre 0 y 100");
}
else
{
Update(ColNum, Grupo, NoControl, CellValue);
}
}
}
}
// ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void btnImprimirLista_Click(object sender, EventArgs e)
{
//MessageBox.Show("cmbGrupo_Validating");
string strGrupo=cmbGrupo.Text.ToString();
bool bolGrupo=false;
bolGrupo=BuscarGrupo(strGrupo);
if (strGrupo != "")
{
if (bolGrupo)
{
crystalReportViewer1.Visible = true;
rptCalificacionesMaestros1.Refresh();
rptCalificacionesMaestros1.SetParameterValue("Grupo", cmbGrupo.Text.ToString());
crystalReportViewer1.ReportSource = rptCalificacionesMaestros1;
}
else
{
MessageBox.Show("El Grupo No Existe");
//e.Cancel = true;
}
}
}
// ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void btnVerGrupo_Click(object sender, EventArgs e)
{
cmbGrupo.Enabled = false;
string strStatus = "1";
UpdateStatus(strStatus);
int ColNumber = 0;
int RowNumber = 0;
string strGrupo = cmbGrupo.Text.ToString();
DataSet CalificacionesMaestroDS = CalificacionesMaestro(cmbGrupo.Text.ToString());
BindingSource CalificacionesMaestrosBS = new BindingSource();
CalificacionesMaestrosBS.DataSource = CalificacionesMaestroDS.Tables[0];
string query = "SELECT CONCAT_WS(' ',grupo.nivel, grupo.horario_dias, grupo.horario_hrs) AS Nivel, " +
"CONCAT_WS(' ',maestro.mtapellido_pat, maestro.mtapellido_mat, maestro.mtnombre)AS
NombreMaestro, " +
"CONCAT_WS(' ', grupo.periodo, grupo.año) AS Periodo " +
"FROM grupo INNER JOIN maestro ON grupo.RFC_maestro = maestro.RFC_maestro " +
"WHERE (grupo.clave_grupo = '" + strGrupo + "')";
MySqlCommand command = new MySqlCommand(query, connection);
connection.Open();
MySqlDataReader MaestroGrupoDR = command.ExecuteReader();
while (MaestroGrupoDR.Read())
{
txbNombreMaestro.Text = MaestroGrupoDR["NombreMaestro"].ToString();
txbNivel.Text = MaestroGrupoDR["Nivel"].ToString();
txbPeriodo.Text = MaestroGrupoDR["Periodo"].ToString();
}
connection.Close();
dgvCalificacionesMaestros.Rows.Clear();
foreach (DataTable table in CalificacionesMaestroDS.Tables)
{
foreach (DataRow row in table.Rows)
{
ColNumber = 0;
RowNumber = dgvCalificacionesMaestros.Rows.Add();
foreach (DataColumn column in table.Columns)
{
dgvCalificacionesMaestros.Rows[RowNumber].Cells[ColNumber].Value = row[column].ToString();
ColNumber++;
}
}
}
int RowNumberHeader = 1;
foreach (DataGridViewRow row in dgvCalificacionesMaestros.Rows)
{
if (row.IsNewRow) continue;
row.HeaderCell.Value = "" + RowNumberHeader;
RowNumberHeader++;
}
dgvCalificacionesMaestros.RowHeadersWidth = 50;
bindingNavigator1.BindingSource = CalificacionesMaestrosBS;
}
// ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void UpdateStatus(string strStatus)
{
string query = "UPDATE alumnosingles_be.flags SET status='" + strStatus + "' WHERE clave_grupo='" +
cmbGrupo.Text + "'";
connection.Open();
MySqlCommand cmd = new MySqlCommand();
cmd.CommandText = query;
cmd.Connection = connection;
cmd.ExecuteNonQuery();
connection.Close();
}
// ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void btnCerrarGrupo_Click(object sender, EventArgs e)
{
string strStatus = "0";
UpdateStatus(strStatus);
txbNombreMaestro.Text = "";
txbNivel.Text = "";
txbPeriodo.Text = "";
cmbGrupo.Enabled = true;
dgvCalificacionesMaestros.Rows.Clear();
}
// ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void frmCalificacionesMaestro_FormClosed(object sender, FormClosedEventArgs e)
{
//MessageBox.Show("Form Closed");
string strStatus = "0";
UpdateStatus(strStatus);
}
//
_______________________________________________________________________________________________
_
}
}
‐ frmCantidadEnGrupos
Código que muestra una ventana con los grupos que existen para el periodo especificado, el horario, la capacidad y
el total de alumnos inscritos. Se ejecuta en el menú principal en la opción GRUPOS/CANTIDAD POR PERIODO.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MySql.Data.MySqlClient;
namespace AlumnosIngles
{
public partial class frmCantidadEnGrupos : Form
{
DBConnect newDBConnect = new DBConnect();
public frmCantidadEnGrupos()
{
InitializeComponent();
}
private void btnCargarDatos_Click(object sender, EventArgs e)
{
DataSet GrupoDS;
int ColNumber;
GrupoDS = newDBConnect.LoadGridCantidadEnGrupos(cmbPeriodo.SelectedValue.ToString() + "%");
//LoadGridGrupos.DataSource = Datos.Tables[0];
BindingSource BS = new BindingSource();
DataTable GrupoDT = new DataTable();
GrupoDT = GrupoDS.Tables[0];
BS.DataSource = GrupoDS.Tables[0];
bindingNavigator1.BindingSource = BS;
//dgvGrupos.DataSource = BS;
dgvGrupos.Rows.Clear();
// For each table in the DataSet, show in datagrid
foreach (DataTable table in GrupoDS.Tables)
{
foreach (DataRow row in table.Rows)
{
ColNumber = 0;
int RowNumber = dgvGrupos.Rows.Add();
foreach (DataColumn column in table.Columns)
{
dgvGrupos.Rows[RowNumber].Cells[ColNumber].Value = row[column].ToString();
ColNumber++;
}
}
}
//timer1.Enabled = true;
}
private void btnActualizar_Click(object sender, EventArgs e)
{
string Cant = "";
int RowTot = dgvGrupos.Rows.Count ‐ 1;
for (int RowNum = 0; RowNum <= RowTot; RowNum++)
{
string Grupo = dgvGrupos.Rows[RowNum].Cells[0].Value.ToString();
DBConnect newBuscar = new DBConnect();
Cant = newBuscar.BuscarCantidadEnGrupos(Grupo);
if (Cant == "")
{
Cant = "0";
}
dgvGrupos.Rows[RowNum].Cells[5].Value = Cant;
//MessageBox.Show(RowNum.ToString());
}
}
private void frmCantidadEnGrupos_Load(object sender, EventArgs e)
{
MySqlDataAdapter Datos;
DataTable table = new DataTable();
Datos = newDBConnect.DropDown("Periodos");
Datos.Fill(table);
cmbPeriodo.DataSource = table;
cmbPeriodo.DisplayMember = "Descripcion";
cmbPeriodo.ValueMember = "Periodo";
cmbPeriodo.Text = GlobalVars.GlobalPeriodoDesc;
this.dgvGrupos.RowsDefaultCellStyle.BackColor = Color.Bisque;
this.dgvGrupos.AlternatingRowsDefaultCellStyle.BackColor = Color.Beige;
}
private void dgvGrupos_SortCompare(object sender, DataGridViewSortCompareEventArgs e)
{
//MessageBox.Show("dgvGrupos_SortCompare");
e.SortResult = System.String.Compare(
e.CellValue1.ToString(), e.CellValue2.ToString());
if (e.SortResult == 0 && e.Column.Name == "nivel")
{
string strNivel1 = dgvGrupos.Rows[e.RowIndex1].Cells["nivel"].Value.ToString() +
dgvGrupos.Rows[e.RowIndex1].Cells["dias"].Value.ToString() +
dgvGrupos.Rows[e.RowIndex1].Cells["hora"].Value.ToString();
string strNivel2 = dgvGrupos.Rows[e.RowIndex2].Cells["nivel"].Value.ToString() +
dgvGrupos.Rows[e.RowIndex2].Cells["dias"].Value.ToString() +
dgvGrupos.Rows[e.RowIndex2].Cells["hora"].Value.ToString();
e.SortResult = System.String.Compare(strNivel1, strNivel2);
}
e.Handled = true;
}
//_________________________________________________________________________________________
}
}
‐ frmCardex
Código que muestra la información de calificaciones del alumno, además muestra el periodo en el que tomó el curso
o los cursos, el grupo y el maestro que impartió en dicho grupo.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MySql.Data.MySqlClient;
namespace AlumnosIngles
{
public partial class frmCardex : Form
{
DBConnect newDBConnect = new DBConnect();
public frmCardex()
{
InitializeComponent();
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void frmCardex_Load(object sender, EventArgs e)
{
MySqlDataAdapter CardexDA;
DataTable TableCardex = new DataTable();
CardexDA = newDBConnect.DropDown("Cardexes");
CardexDA.Fill(TableCardex);
cmbNoControl.Data = TableCardex;
cmbNoControl.ViewColumn = 0;
cmbNoControl.SelectedIndex = ‐1;
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void btnCardex_Click(object sender, EventArgs e)
{
//MessageBox.Show("CLick Button Cardex");
DataSet DSAlumno = null;
DataSet DSCalificaciones = null;
int ColNumber;
bool bolAlumnoCalificaciones = false;
bolAlumnoCalificaciones = newDBConnect.BuscarAlumnoCalificaciones(cmbNoControl.Text.ToString());
if (bolAlumnoCalificaciones)
{
//MessageBox.Show("Si tiene datos");
dgvCardex.Visible = true;
dgvCardex.Height = 110;
DSCalificaciones = newDBConnect.CardexDataGrid(cmbNoControl.Text.ToString());
DSAlumno = newDBConnect.DatosAlumnos(cmbNoControl.Text.ToString());
DataTable DTAlumno = new DataTable();
DTAlumno = DSAlumno.Tables[0];
this.txbNombre.Text = DTAlumno.Rows[0]["apellido_pat"].ToString() + " " +
DTAlumno.Rows[0]["apellido_mat"].ToString() + " " +
DTAlumno.Rows[0]["nombre"].ToString();
this.txbCarrera.Text = DTAlumno.Rows[0]["carrera"].ToString();
dgvCardex.Rows.Clear();
DataTable DTCalificaciones = new DataTable();
DTCalificaciones = DSCalificaciones.Tables[0];
// Load datagrid with data
foreach (DataTable table in DSCalificaciones.Tables)
{
foreach (DataRow row in table.Rows)
{
ColNumber = 0;
int RowNumber = dgvCardex.Rows.Add();
foreach (DataColumn column in table.Columns)
{
dgvCardex.Rows[RowNumber].Cells[ColNumber].Value = row[column].ToString();
ColNumber++;
}
}
}
}
else
{
MessageBox.Show("No Hay Calificaciones Para Este Alumno");
}
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void cmbNoControl_Enter(object sender, EventArgs e)
{
dgvCardex.Visible = false;
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void cmbNoControl_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == Convert.ToChar(Keys.Return))
{
SendKeys.Send("{TAB}");
}
}
}
}
‐ frmChecador
Código que ejecuta la ventana de checador de los maestros. Se ejecuta dando doble click o seleccionando y dando
enter en el ícono del CHECADOR.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.IO;
using System.Windows.Forms;
using Checador;
using MySql.Data.MySqlClient;
namespace Checador
{
public partial class frmChecador : Form
{
public frmChecador()
{
InitializeComponent();
}
DBConnect newDBConnect = new DBConnect();
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void frmChecador_Load(object sender, EventArgs e)
{
string sMonth = DateTime.Now.ToString("MM");
switch (sMonth)
{
case "01":
pic00.Visible = true;
break;
case "02":
pic01.Visible = true;
break;
case "03":
pic02.Visible = true;
break;
case "04":
pic03.Visible = true;
break;
case "05":
pic04.Visible = true;
break;
default:
break;
}
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void cmbMaestro_Enter(object sender, EventArgs e)
{
MySqlDataAdapter MaestroDD;
DataTable MaestroDT = new DataTable();
MaestroDD = newDBConnect.DropDown();
MaestroDD.Fill(MaestroDT);
cmbMaestro.DataSource = MaestroDT;
cmbMaestro.DisplayMember = "Maestro";
cmbMaestro.ValueMember = "RFC";
cmbMaestro.SelectedIndex = ‐1;
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void btnEntrada_Click(object sender, EventArgs e)
{
if (cmbMaestro.SelectedValue == null)
{
MessageBox.Show("El Nombre de Usuario no Existe");
}
else
{
newDBConnect.Checar(cmbMaestro.SelectedValue.ToString(), txbPassword.Text.ToString(), "E");
cmbMaestro.Text = "";
txbPassword.Text = "";
}
cmbMaestro.Focus();
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void btnSalida_Click(object sender, EventArgs e)
{
if (cmbMaestro.SelectedValue == null)
{
MessageBox.Show("El Nombre de Usuario no Existe");
}
else
{
newDBConnect.Checar(cmbMaestro.SelectedValue.ToString(), txbPassword.Text.ToString(), "S");
cmbMaestro.Text = "";
txbPassword.Text = "";
cmbMaestro.Focus();
}
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void lblHora_Click(object sender, EventArgs e)
{
lblHora.Text = DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss");
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void rtbInfo_TextChanged(object sender, EventArgs e)
{
string strInfo = File.ReadAllText(@"\\10.13.50.101\BackEnd\Info.txt");
//strInfo = string.Format(strInfo);
//MessageBox.Show(strInfo);
rtbInfo.Text = strInfo;
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void frmChecador_DoubleClick(object sender, EventArgs e)
{
MessageBox.Show("frmChecador_DoubleClick");
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void pnlPassword_Click(object sender, EventArgs e)
{
if (ModifierKeys == Keys.Control)
{
if (newDBConnect.PasswordCreateForm(txbPassword.Text))
{
cmbMaestro.Text = "";
txbPassword.Text = "";
cmbMaestro.Focus();
var newPassword = new frmPasswordCreate();
Enabled = false;
newPassword.ShowDialog(this);
Enabled = true;
}
}
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void GeneralKeyPressSmall(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == Convert.ToChar(Keys.Return))
{
SendKeys.Send("{TAB}");
}
}
private void btn01_Click(object sender, EventArgs e)
{
pic01.Visible = true;
pic02.Visible = false;
pic03.Visible = false;
pic04.Visible = false;
pic00.Visible = false;
}
private void btn02_Click(object sender, EventArgs e)
{
pic01.Visible = false;
pic02.Visible = true;
pic03.Visible = false;
pic04.Visible = false;
pic00.Visible = false;
}
private void btn03_Click(object sender, EventArgs e)
{
pic01.Visible = false;
pic02.Visible = false;
pic03.Visible = true;
pic04.Visible = false;
pic00.Visible = false;
}
private void btn04_Click(object sender, EventArgs e)
{
pic01.Visible = false;
pic02.Visible = false;
pic03.Visible = false;
pic04.Visible = true;
pic00.Visible = false;
}
//_________________________________________________________________________________________
}
}
‐ frmCursosAdeudos
Código que muestra los adeudos que tiene cada alumno. Se ejecuta en el menú principal en la opción
ALUMNOS/CURSOS Y ADEUDOS
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MySql.Data.MySqlClient;
namespace RecibosxAlumno
{
public partial class frmCursosAdeudos : Form
{
//
_______________________________________________________________________________________________
_______
public frmCursosAdeudos()
{
InitializeComponent();
}
// ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void Form1_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'alumnosingles_beDataSet.alumnos1' table. You can move, or
remove it, as needed.
this.alumnos1TableAdapter.Fill(this.alumnosingles_beDataSet.alumnos1);
DBConnect newDBConnect = new DBConnect();
MySqlDataAdapter AlumnosDD;
DataTable AlumnosDT = new DataTable();
AlumnosDD = newDBConnect.DropDown();
AlumnosDD.Fill(AlumnosDT);
cmbNoControl.Data = AlumnosDT;
cmbNoControl.ViewColumn = 0;
cmbNoControl.SelectedIndex = ‐1;
}
// ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void button1_Click(object sender, EventArgs e)
{
string strTipo = "";
string strCantidad = "";
string strGrupo = "";
string strNoControl = "";
string strCal = "";
List<string> BuscarAlumno = null;
DataSet Datos;
DBConnect newDBConnect = new DBConnect();
BuscarAlumno = newDBConnect.BuscarAlumno(cmbNoControl.Text.ToString());
if (BuscarAlumno != null)
{
int ColNumber = 0;
cmbNombre.Text = (BuscarAlumno[1] + " " + BuscarAlumno[2] + " " + BuscarAlumno[0]);
cmbCarrera.Text = BuscarAlumno[3];
Datos = newDBConnect.LoadGrid(cmbNoControl.Text.ToString());
dgvPagos.Rows.Clear();
// For each table in the DataSet, show in datagrid
foreach (DataTable table in Datos.Tables)
{
foreach (DataRow row in table.Rows)
{
int RowNumber = dgvPagos.Rows.Add();
foreach (DataColumn column in table.Columns)
{
if (ColNumber == 3)
{
dgvPagos.Rows[RowNumber].Cells[ColNumber].Value = Int32.Parse(row[column].ToString());
}
else
{
dgvPagos.Rows[RowNumber].Cells[ColNumber].Value = row[column].ToString();
}
ColNumber++;
}
strNoControl = dgvPagos.Rows[RowNumber].Cells[0].Value.ToString();
strGrupo = dgvPagos.Rows[RowNumber].Cells[1].Value.ToString();
DBConnect newCalificaciones = new DBConnect();
strCal = newCalificaciones.Calificaciones(strNoControl, strGrupo);
dgvPagos.Rows[RowNumber].Cells[ColNumber].Value = strCal;
ColNumber++;
int GrupoLength = strGrupo.Length;
strGrupo = strGrupo.Substring((GrupoLength ‐ 2), 2);
strTipo = dgvPagos.Rows[RowNumber].Cells[2].Value.ToString();
if (strGrupo != "00" && strGrupo != "99" && strTipo != "Beca")
{
int intDebe;
strCantidad = dgvPagos.Rows[RowNumber].Cells[3].Value.ToString();
intDebe = AlumnoTipo(strTipo, strCantidad);
dgvPagos.Rows[RowNumber].Cells[ColNumber].Value = intDebe;
}
else
{
dgvPagos.Rows[RowNumber].Cells[ColNumber].Value = 0;
}
ColNumber = 0;
}
}
SendKeys.Send("{TAB}");
}
else
{
MessageBox.Show("El Alumno no Tiene Recibos");
}
}
// ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private int AlumnoTipo(string Tipo, string Cantidad)
{
int numVal = Int32.Parse(Cantidad);
switch (Tipo)
{
case "Interno":
numVal = 900 ‐ numVal;
break;
case "Externo":
numVal = 2300 ‐ numVal;
break;
case "Descuento":
numVal = 1150 ‐ numVal;
break;
case "Tit/Esp":
numVal = 2000 ‐ numVal;
break;
case "Tit/2daVez":
numVal = 1100 ‐ numVal;
break;
case "SEP/Maestria":
numVal = 1150 ‐ numVal;
break;
case "Tit/Esp C":
numVal = 3000 ‐ numVal;
break;
default:
break;
}
return numVal;
}
// ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
//Advance next tab index if return is pressed
private void GeneralKeyPress(object sender, KeyPressEventArgs e)
{
//e.KeyChar = Char.ToUpper(e.KeyChar);
if (e.KeyChar == Convert.ToChar(Keys.Return))
{
SendKeys.Send("{TAB}");
}
}
// ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
//
_______________________________________________________________________________________________
_____________
}
}
‐ frmExtraerCalificaciones
Código que se utiliza para el movimiento de las calificaciones capturadas por el maestro en la tabla
calificacionesmaestro a la tabla calificaciones. Se ejecuta por medio del menú principal en la opción
CALIFICACIONES/EXTRAER.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MySql.Data.MySqlClient;
namespace AlumnosIngles
{
public partial class frmExtraerCalificaciones : Form
{
DBConnect newDBConnect = new DBConnect();
public frmExtraerCalificaciones()
{
InitializeComponent();
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void cmbGrupo_Validating(object sender, CancelEventArgs e)
{
//MessageBox.Show("Validating");
bool bolGrupo;
string strGrupo = cmbGrupo.Text.ToString();
if (strGrupo != "")
{
bolGrupo = newDBConnect.BuscarCalificacionesMaestro(strGrupo);
if (bolGrupo)
{
//MessageBox.Show("El Periodo Si Existe");
}
else
{
//MessageBox.Show("El Periodo No Existe");
e.Cancel = true;
}
}
else
{
this.Close();
}
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void cmbGrupo_KeyPress(object sender, KeyPressEventArgs e)
{
//MessageBox.Show("KeyPress Event");
e.KeyChar = Char.ToUpper(e.KeyChar);
if (e.KeyChar == Convert.ToChar(Keys.Return))
{
//MessageBox.Show("Return Pressed");
SendKeys.Send("{TAB}");
}
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void btnExtraer_Click(object sender, EventArgs e)
{
if (cmbGrupo.Text != "")
{
bool bolGrupoAbierto = true;
bolGrupoAbierto = newDBConnect.GrupoAbierto(cmbGrupo.Text);
if (bolGrupoAbierto)
{
MessageBox.Show("Hay que Cerrar el Grupo Antes de Extraer Las Calificaciones");
}
else
{
//string strCG = "";
//DataRow dr;
string Grupo = cmbGrupo.Text.ToString();
string MessageBoxTitle = "Extracion de Grupo";
string MessageBoxContent = "La Extraccion Solo se Hace Una Vez";
DialogResult dialogResult = MessageBox.Show(MessageBoxContent, MessageBoxTitle,
MessageBoxButtons.YesNo);
if (dialogResult == DialogResult.Yes)
{
newDBConnect.InsertDeleteCalificacionesMaestro(cmbGrupo.Text);
//for (int i = CalificacionesDT.Rows.Count ‐ 1; i >= 0; i‐‐)
//{
// dr = CalificacionesDT.Rows[i];
// strCG = dr["clave_grupo"].ToString();
// if (strCG == Grupo)
// {
// CalificacionesDT.Rows.Remove(dr);
// MessageBox.Show("Operacion Exitosa");
// cmbGrupo.Text = "";
// }
//}
MessageBox.Show("Operacion Exitosa");
}
else if (dialogResult == DialogResult.No)
{
//do something else
MessageBox.Show("Operacion Cancelada");
}
}
}
else
{
MessageBox.Show("El Campo de Grupo esta Vacio");
cmbGrupo.Focus();
}
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void cmbGrupo_SelectedIndexChanged(object sender, EventArgs e)
{
if (cmbGrupo.SelectedIndex > ‐1)//If there is no selected index the indexer will return null
{
lblNombreMaestro.Text = cmbGrupo["NombreMaestro"].ToString();
lblNivel.Text = cmbGrupo["Nivel"].ToString();
lblGrupo.Text = cmbGrupo["clave_grupo"].ToString();
}
}
private void cmbGrupo_Enter(object sender, EventArgs e)
{
MySqlDataAdapter Datos = new MySqlDataAdapter();
DataTable CalificacionesDT = new DataTable();
Datos = newDBConnect.DropDown("ExtraerCalificaciones");
Datos.Fill(CalificacionesDT);
cmbGrupo.Data = CalificacionesDT;
cmbGrupo.ViewColumn = 0;
cmbGrupo.SelectedIndex = ‐1;
}
//_________________________________________________________________________________________
}
}
‐ frmMenu
Código que muestra el menú principal, se ejecuta dando doble click o seleccionando el icono de la aplicación y
presionando enter.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Windows.Forms;
using MySql.Data.MySqlClient;
using AlumnosIngles;
namespace AlumnosIngles
{
public partial class frmMenu : Form
{
DBConnect newDBConnect = new DBConnect();
public frmMenu()
{
InitializeComponent();
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void toolStripTextBox1_Click(object sender, EventArgs e)
{
var newAlumnos = new frmAlumnos();
Enabled = false;
newAlumnos.Show(this);
Enabled = true;
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void toolStripMenuItem2_Click(object sender, EventArgs e)
{
var newRecibos = new frmRecibos();
Enabled = false;
newRecibos.Show(this);
Enabled = true;
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void modificarToolStripMenuItem_Click(object sender, EventArgs e)
{
var newModificarAlumno = new frmModificarAlumno();
Enabled = false;
newModificarAlumno.ShowDialog(this);
Enabled = true;
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void cantidadPorPeriodoToolStripMenuItem_Click(object sender, EventArgs e)
{
//frmCantidadEnGrupos frm = new frmCantidadEnGrupos();
//frm.Show();
//var newCantidadEnGrupos = new frmCantidadEnGrupos();
//Enabled = false;
//newCantidadEnGrupos.ShowDialog(this);
//Enabled = true;
// Open the file "example.txt".
// ... It must be in the same directory as the .exe file.
Process.Start("AlumnosEnGrupos.EXE");
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void frmMenu_Load(object sender, EventArgs e)
{
var childForm = new frmPeriodo();
Enabled = false;
childForm.ShowDialog(this);
Enabled = true;
MySqlDataAdapter Datos;
DataTable table = new DataTable();
Datos = newDBConnect.DropDown("Periodos");
Datos.Fill(table);
cmbPeriodo.DataSource = table;
cmbPeriodo.DisplayMember = "Descripcion";
cmbPeriodo.ValueMember = "Periodo";
cmbPeriodo.Text = GlobalVars.GlobalPeriodoDesc;
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void cmbPeriodo_SelectedIndexChanged(object sender, EventArgs e)
{
GlobalVars.GlobalPeriodo = cmbPeriodo.SelectedValue.ToString();
//MessageBox.Show(GlobalVars.GlobalPeriodo);
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void modificarToolStripMenuItem1_Click(object sender, EventArgs e)
{
//MessageBox.Show("Modificar Recibos");
var newModificarRecibo = new frmModificarRecibo();
Enabled = false;
newModificarRecibo.ShowDialog(this);
Enabled = true;
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void porGrupoToolStripMenuItem_Click(object sender, EventArgs e)
{
//MessageBox.Show("Boletas Por Grupo");
var newBoletas = new frmBoletas();
Enabled = false;
newBoletas.ShowDialog(this);
Enabled = true;
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void individualesToolStripMenuItem_Click(object sender, EventArgs e)
{
//MessageBox.Show("Boletas Individuales");
var newBoletaIndividual = new frmBoletaIndividual();
Enabled = false;
newBoletaIndividual.ShowDialog(this);
Enabled = true;
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void pagareToolStripMenuItem_Click(object sender, EventArgs e)
{
//MessageBox.Show("Reporte Pagare");
var newfrmReporteDeudores = new frmReporteDeudores();
Enabled = false;
newfrmReporteDeudores.ShowDialog(this);
Enabled = true;
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void cantidadYTipoDeAlumnosToolStripMenuItem_Click(object sender, EventArgs e)
{
//MessageBox.Show("Reporte Cantidad y Tipo de Alumno");
var newfrmAlumnosCantidadTipo = new frmReporteAlumnosCantidadTipo();
Enabled = false;
newfrmAlumnosCantidadTipo.ShowDialog(this);
Enabled = true;
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void cantidadGruposToolStripMenuItem_Click(object sender, EventArgs e)
{
//MessageBox.Show("Reporte Cantidad en Grupos");
var newReporteGrupos = new frmReporteGrupos();
Enabled = false;
newReporteGrupos.ShowDialog(this);
Enabled = true;
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void alumnosEnGruposToolStripMenuItem_Click(object sender, EventArgs e)
{
//MessageBox.Show("Reporte Alumnos en Grupos");
var newfrmReporteGrupos = new frmReporteGrupos();
Enabled = false;
newfrmReporteGrupos.ShowDialog(this);
Enabled = true;
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void agregarToolStripMenuItem_Click(object sender, EventArgs e)
{
MessageBox.Show("Agregar Calificaciones");
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void extraerToolStripMenuItem_Click(object sender, EventArgs e)
{
//MessageBox.Show("Extraer Calificaciones");
var newExtraerCalificaciones = new frmExtraerCalificaciones();
Enabled = false;
newExtraerCalificaciones.ShowDialog(this);
Enabled = true;
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void listasToolStripMenuItem_Click(object sender, EventArgs e)
{
//MessageBox.Show("Listas");
var newReporteListas = new frmReporteListas();
Enabled = false;
newReporteListas.Show(this);
Enabled = true;
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void cursosToolStripMenuItem1_Click(object sender, EventArgs e)
{
//MessageBox.Show("Cursos");
Process.Start("RecibosxAlumno.EXE");
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void cardexToolStripMenuItem_Click(object sender, EventArgs e)
{
//MessageBox.Show("Cardex");
var newCardex = new frmCardex();
Enabled = false;
newCardex.ShowDialog(this);
Enabled = true;
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void estadisticasDeGeneroToolStripMenuItem_Click(object sender, EventArgs e)
{
//MessageBox.Show("Estadisticas de Genero");
var newfrmReporteEstadisticasGenero = new frmReporteEstadisticasGenero();
Enabled = false;
newfrmReporteEstadisticasGenero.ShowDialog(this);
Enabled = true;
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void alumnosToolStripMenuItem_Click(object sender, EventArgs e)
{
//MessageBox.Show("Alumnos grid");
var newfrmAlumnosGrid = new frmAlumnosGrid();
Enabled = false;
newfrmAlumnosGrid.ShowDialog(this);
Enabled = true;
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void periodoCarreraToolStripMenuItem_Click(object sender, EventArgs e)
{
//MessageBox.Show("Reporte Periodo Carrera");
var newfrmReportePeriodoCarrera = new frmReportePeriodoCarrera();
Enabled = false;
newfrmReportePeriodoCarrera.ShowDialog(this);
Enabled = true;
}
private void gruposToolStripMenuItem1_Click(object sender, EventArgs e)
{
//MessageBox.Show("Reporte Periodo Carrera");
var newfrmCantidadEnGrupos = new frmCantidadEnGrupos();
Enabled = false;
newfrmCantidadEnGrupos.Show(this);
Enabled = true;
}
//_________________________________________________________________________________________
}
}
‐ frmModificarRecibo
Código que muestra la ventana para modificar datos como grupo, tipo, cantidad y/o examen de ubicación. Se
ejecuta en el menú principal en la opción RECIBOS/MODIFICAR.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MySql.Data.MySqlClient;
namespace AlumnosIngles
{
public partial class frmModificarRecibo : Form
{
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
DBConnect newDBConnect = new DBConnect();
public frmModificarRecibo()
{
InitializeComponent();
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void frmModificarRecibos_Load(object sender, EventArgs e)
{
MySqlDataAdapter AlumnosDA;
DataTable AlumnosDT = new DataTable();
AlumnosDA = newDBConnect.DropDown("Alumnos");
AlumnosDA.Fill(AlumnosDT);
cmbNoControl.Data = AlumnosDT;
cmbNoControl.ViewColumn = 0;
cmbNoControl.SelectedIndex = ‐1;
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
//Advance next tab index if return is pressed
private void GeneralKeyPress(object sender, KeyPressEventArgs e)
{
e.KeyChar = Char.ToUpper(e.KeyChar);
if (e.KeyChar == Convert.ToChar(Keys.Return))
{
SendKeys.Send("{TAB}");
}
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void cmbNoControl_Validating(object sender, CancelEventArgs e)
{
//MessageBox.Show("No Control Validating");
bool Alumno;
if (cmbNoControl.Text != "")
{
Alumno = newDBConnect.BuscarAlumno(cmbNoControl.Text.ToString());
if (!Alumno)
{
MessageBox.Show("El Alumno No Existe");
e.Cancel = true;
}
else
{
LoadItemsGrid();
}
}
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void LoadItemsGrid()
{
DataSet Datos;
int ColNumber = 0;
int RowNumber = 0;
int DSColNumber = 0;
Datos = newDBConnect.ModificarRecibo(cmbNoControl.Text.ToString());
if (Datos == null)
{
MessageBox.Show("No Hay Reccibos Para Este Alumno");
}
else
{
DataTable RecibosDT = new DataTable();
RecibosDT = Datos.Tables[0];
//this.cmbNoControl.Enabled = false;
this.txbApellido.Text = (RecibosDT.Rows[0]["apellido_pat"].ToString() + " " +
RecibosDT.Rows[0]["apellido_mat"].ToString());
this.txbNombre.Text = RecibosDT.Rows[0]["nombre"].ToString();
this.txbCarrera.Text = RecibosDT.Rows[0]["carrera"].ToString();
//dgvModificarRecibos.DataSource = Datos.Tables[0];
string strNivel;
// For each table in the DataSet, show in datagrid
dgvModificarRecibos.Rows.Clear();
foreach (DataTable table in Datos.Tables)
{
foreach (DataRow row in table.Rows)
{
ColNumber = 0;
strNivel = null;
RowNumber = dgvModificarRecibos.Rows.Add();
foreach (DataColumn column in table.Columns)
{
DSColNumber = column.Ordinal;
switch (DSColNumber)
{
case 1:
case 2:
case 3:
case 5:
dgvModificarRecibos.Rows[RowNumber].Cells[ColNumber].Value = row[column].ToString();
ColNumber++;
break;
case 4:
dgvModificarRecibos.Rows[RowNumber].Cells[ColNumber].Value =
Int32.Parse(row[column].ToString());
ColNumber++;
break;
case 10:
case 11:
case 12:
strNivel = strNivel + " " + row[column].ToString();
ColNumber++;
break;
case 13:
break;
default:
break;
}
}
dgvModificarRecibos.Rows[RowNumber].Cells[5].Value = strNivel;
}
}
RecibosDT.Dispose();
}
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void dgvModificarRecibos_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
{
//MessageBox.Show("Validating");
int intColNum = dgvModificarRecibos.CurrentCell.ColumnIndex;
int intRowNum = dgvModificarRecibos.CurrentCell.RowIndex;
string strCellValue = e.FormattedValue.ToString();
if (strCellValue != "")
{
if (intColNum > 0 && intColNum < 5)
{
string strNoRecibo = dgvModificarRecibos.Rows[intRowNum].Cells[0].Value.ToString();
//MessageBox.Show(intColNum.ToString() + " " + intRowNum.ToString() + " " + strCellValue);
switch (intColNum)
{
case 1:
strCellValue = strCellValue.ToUpper();
if (strCellValue == "")
{
MessageBox.Show("El Campo Debe de Contener La Clave del Campo");
}
else
{
bool bolGrupo;
bolGrupo = newDBConnect.BuscarGrupo(strCellValue);
if (bolGrupo)
{
MessageBox.Show("El Grupo no Existe");
e.Cancel = true;
}
else
{
if (strCellValue.Substring(7, 2) == "00" || strCellValue.Substring(7, 2) == "99")
{
//MessageBox.Show("Examen de Ubicacion o Bonificacion");
//newDBConnect.ModificarRecibosUpdate(intColNum, strNoRecibo, strCellValue);
}
else
{
bool bolAlumnoGrupo;
bolAlumnoGrupo = newDBConnect.AlumnoGrupo(cmbNoControl.Text.ToString(),
strCellValue);
if (bolAlumnoGrupo)
{
//MessageBox.Show("EL Alumno Ya Esta en el Grupo");
//newDBConnect.ModificarRecibosUpdate(intColNum, strNoRecibo, strCellValue);
}
else
{
bool bolGrupoLleno;
bolGrupoLleno = newDBConnect.GrupoDisponible(strCellValue);
if (bolGrupoLleno)
{
MessageBox.Show("EL Grupo Esta Lleno");
e.Cancel = true;
}
else
{
//MessageBox.Show("Si Hay Cupo en el Grupo");
//newDBConnect.ModificarRecibosUpdate(intColNum, strNoRecibo, strCellValue);
}
}
}
}
}
break;
case 2:
//MessageBox.Show("Tipo");
bool bolTipo = newDBConnect.BuscarTipo(strCellValue);
if (bolTipo)
{
//MessageBox.Show("Si existe el Tipo");
//newDBConnect.ModificarRecibosUpdate(intColNum, strNoRecibo, strCellValue);
}
else
{
//MessageBox.Show("EL Tipo No Existe");
e.Cancel = true;
}
break;
case 3:
if (strCellValue.Substring(0, 1) == "$")
{
int intValor = strCellValue.Length;
strCellValue = strCellValue.Substring(1, intValor ‐ 1);
}
int n;
bool isNumeric = int.TryParse(strCellValue, out n);
if (isNumeric)
{
//newDBConnect.ModificarRecibosUpdate(intColNum, strNoRecibo, strCellValue);
}
else
{
MessageBox.Show("Tiene que Introducer un Valor Numerico");
e.Cancel = true;
}
break;
case 4:
//MessageBox.Show("Validating Nivel");
bool bolNivel = newDBConnect.BuscarNivel(strCellValue);
if (bolNivel)
{
//MessageBox.Show("Si existe el Nivel");
//strCellValue = strCellValue.ToUpper();
//newDBConnect.ModificarRecibosUpdate(intColNum, strNoRecibo, strCellValue);
}
else
{
MessageBox.Show("EL Nivel No Existe");
e.Cancel = true;
}
break;
default:
break;
}
}
}
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void dgvModificarRecibos_KeyPress(object sender, KeyPressEventArgs e)
{
MessageBox.Show("Keypress Function");
//e.KeyChar = Char.ToUpper(e.KeyChar);
}
private void dgvModificarRecibos_CellValueChanged(object sender, DataGridViewCellEventArgs e)
{
//MessageBox.Show("Cell Value Change");
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void dgvModificarRecibos_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
int intColNum = dgvModificarRecibos.CurrentCell.ColumnIndex;
int intRowNum = dgvModificarRecibos.CurrentCell.RowIndex;
if (intColNum == 6)
{
//MessageBox.Show("Column=" + Convert.ToString(intColNum) + " Row=" +
Convert.ToString(intRowNum));
MySqlDataAdapter GruposDA;
DataTable GruposDT = new DataTable();
GruposDA = newDBConnect.DropDown("Grupos");
GruposDA.Fill(GruposDT);
cmbGrupo.Data = GruposDT;
cmbGrupo.ViewColumn = 0;
cmbGrupo.SelectedIndex = ‐1;
MySqlDataAdapter NivelDA;
DataTable NivelDT = new DataTable();
NivelDA = newDBConnect.DropDown("Niveles");
NivelDA.Fill(NivelDT);
cmbExamenUbicacion.DataSource = NivelDT;
cmbExamenUbicacion.DisplayMember = "Nivel";
cmbExamenUbicacion.ValueMember = "Nivel";
cmbExamenUbicacion.SelectedIndex = ‐1;
MySqlDataAdapter TipoDA;
DataTable TipoDT = new DataTable();
TipoDA = newDBConnect.DropDown("Tipos");
TipoDA.Fill(TipoDT);
cmbTipo.DataSource = TipoDT;
cmbTipo.DisplayMember = "tipo";
cmbTipo.ValueMember = "tipo";
cmbTipo.SelectedIndex = ‐1;
txbNoRecibo.Text = dgvModificarRecibos.Rows[intRowNum].Cells[0].Value.ToString();
cmbGrupo.Text = dgvModificarRecibos.Rows[intRowNum].Cells[1].Value.ToString();
cmbTipo.Text = dgvModificarRecibos.Rows[intRowNum].Cells[2].Value.ToString();
txbCantidad.Text = dgvModificarRecibos.Rows[intRowNum].Cells[3].Value.ToString();
cmbExamenUbicacion.Text = dgvModificarRecibos.Rows[intRowNum].Cells[4].Value.ToString();
pnlRecibo.Visible = true;
}
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void btnVerRecibo_Click(object sender, EventArgs e)
{
//cmbGrupo.Text = cmbNoControl.Text.ToString();
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void cmbNoControl_Enter(object sender, EventArgs e)
{
pnlRecibo.Visible = false;
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void cmbGrupo_Validating(object sender, CancelEventArgs e)
{
string strGrupo = cmbGrupo.Text.ToString();
if (strGrupo == "")
{
MessageBox.Show("El Campo Esta Vacio");
e.Cancel = true;
}
else
{
bool bolGrupo;
bolGrupo = newDBConnect.BuscarGrupo(strGrupo);
if (bolGrupo)
{
//MessageBox.Show("El grupo no Existe");
e.Cancel = true;
}
else
{
if (strGrupo.Substring(7, 2).ToString() == "00")
{
//MessageBox.Show("Examen de Ubicacion");
}
else
{
bool bolAlumnoGrupo;
bolAlumnoGrupo = newDBConnect.AlumnoGrupo(cmbNoControl.Text.ToString(), strGrupo);
if (bolAlumnoGrupo)
{
//MessageBox.Show("EL Alumno Ya Esta en el Grupo");
}
else
{
bool bolGrupoLleno;
bolGrupoLleno = newDBConnect.GrupoDisponible(strGrupo);
if (bolGrupoLleno)
{
//MessageBox.Show("EL Grupo Esta Lleno");
e.Cancel = true;
}
else
{
//MessageBox.Show("Si Hay Cupo en el Grupo");
}
}
}
}
}
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void cmbTipo_Validating(object sender, CancelEventArgs e)
{
//MessageBox.Show("Validating Nivel");
bool Tipo;
if (cmbTipo.Text.ToString() != "")
{
Tipo = newDBConnect.BuscarTipo(cmbTipo.Text.ToString());
if (Tipo)
{
//MessageBox.Show("El Tipo ya Existe");
}
else
{
//MessageBox.Show("No Existe el Tipo");
e.Cancel = true;
}
}
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void cmbExamenUbicacion_Validating(object sender, CancelEventArgs e)
{
//MessageBox.Show("Validating Nivel");
bool ExamenUbicacion;
if (cmbExamenUbicacion.Text.ToString() != "")
{
ExamenUbicacion = newDBConnect.BuscarNivel(cmbExamenUbicacion.Text.ToString());
if (ExamenUbicacion)
{
//MessageBox.Show("El Nivel ya Existe");
}
else
{
//MessageBox.Show("No Existe el Nivel");
e.Cancel = true;
}
}
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void BtnGuardarDatos_Click(object sender, EventArgs e)
{
string strGrupo = cmbGrupo.Text.ToString();
string strTipo = cmbTipo.Text.ToString();
string strCantidad = txbCantidad.Text.ToString();
string strExamenUbicacion = cmbExamenUbicacion.Text.ToString();
string strNoRecibo = txbNoRecibo.Text.ToString();
newDBConnect.ModificarRecibosUpdate(strGrupo, strTipo, strCantidad, strExamenUbicacion, strNoRecibo);
cmbNoControl.Focus();
LoadItemsGrid();
}
//=========================================================================================
}
}
‐ frmPasswordCreate
Código que muestra una ventana en la que se puede asignar la clave de acceso a los maestros para que puedan usar
el checador. Se ejecuta en la ventana del checador introduciendo el numero “14582367” en la clave de acceso,
presionar “Ctrl” y dando click en la esquina superior izquierda de la ventana del checador.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Checador
{
public partial class frmPasswordCreate : Form
{
public frmPasswordCreate()
{
InitializeComponent();
}
DBConnect newDBConnect = new DBConnect();
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void txbUser_Validating(object sender, CancelEventArgs e)
{
string strNombreMaestro = newDBConnect.UserExist(txbUser.Text);
if (strNombreMaestro == "" && txbUser.Text != "")
{
MessageBox.Show("El Usuario No Existe");
e.Cancel = true;
}
else
{
lblNombreMaestro.Text = strNombreMaestro;
}
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void btnSave_Click(object sender, EventArgs e)
{
string strPasswordHash = "";
if (txbPassword.Text == txbConfirmPassword.Text)
{
strPasswordHash = Hashing.ComputeHash(txbPassword.Text, Supported_HA.SHA256, null);
newDBConnect.PasswordUpdate(txbUser.Text, strPasswordHash);
this.Close();
}
else
{
MessageBox.Show("La Clave de Acceso y la Confirmacion no Coinciden");
}
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void GeneralKeyPress(object sender, KeyPressEventArgs e)
{
e.KeyChar = Char.ToUpper(e.KeyChar);
if (e.KeyChar == Convert.ToChar(Keys.Return))
{
SendKeys.Send("{TAB}");
}
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void GeneralKeyPressSmall(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == Convert.ToChar(Keys.Return))
{
SendKeys.Send("{TAB}");
}
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void btnCancel_Click(object sender, EventArgs e)
{
this.Close();
}
//=========================================================================================
}
}
‐ frmPeriodo
Código que muestra una ventana en la que se pide el periodo en el que se desea que trabaje la aplicación, se ejecuta
al momento de llamar al menú principal.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MySql.Data.MySqlClient;
namespace AlumnosIngles
{
public partial class frmPeriodo : Form
{
DBConnect newDBConnect = new DBConnect();
public frmPeriodo()
{
InitializeComponent();
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void btnPeriodo_Click(object sender, EventArgs e)
{
//MessageBox.Show(cmbPeriodo.SelectedValue.ToString());
GlobalVars.GlobalPeriodo = cmbPeriodo.SelectedValue.ToString();
GlobalVars.GlobalPeriodoDesc = cmbPeriodo.Text.ToString();
this.Close();
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void cmbPeriodo_Enter(object sender, EventArgs e)
{
MySqlDataAdapter PeriodosDA;
DataTable PeriodosDT = new DataTable();
PeriodosDA = newDBConnect.DropDown("Periodos");
PeriodosDA.Fill(PeriodosDT);
cmbPeriodo.DataSource = PeriodosDT;
cmbPeriodo.DisplayMember = "Descripcion";
cmbPeriodo.ValueMember = "Periodo";
cmbPeriodo.SelectedIndex = ‐1;
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void cmbPeriodo_Validating(object sender, CancelEventArgs e)
{
if(cmbPeriodo.Text == "" || cmbPeriodo.Text == null)
{
MessageBox.Show("Debe de Seleccionar un Periodo");
e.Cancel = true;
}
}
}
}
‐ frmRecibos
Código que registra los datos en la tabla de recibos. Se ejecuta por medio del menú principal en la opción
RECIBOS/AGREGAR.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MySql.Data.MySqlClient;
namespace AlumnosIngles
{
public partial class frmRecibos : Form
{
DBConnect newDBConnect = new DBConnect();
public frmRecibos()
{
InitializeComponent();
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void alumnosBindingNavigatorSaveItem_Click(object sender, EventArgs e)
{
this.Validate();
}
// ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void frmRecibos_Load(object sender, EventArgs e)
{
//MessageBox.Show("Load Recibos");
MySqlDataAdapter NivelDA;
DataTable NivelDT = new DataTable();
NivelDA = newDBConnect.DropDown("Niveles");
NivelDA.Fill(NivelDT);
cmbNivel.DataSource = NivelDT;
cmbNivel.DisplayMember = "Nivel";
cmbNivel.ValueMember = "Nivel";
MySqlDataAdapter TipoDA;
DataTable TipoDT = new DataTable();
TipoDA = newDBConnect.DropDown("Tipos");
TipoDA.Fill(TipoDT);
cmbTipo.DataSource = TipoDT;
cmbTipo.DisplayMember = "tipo";
cmbTipo.ValueMember = "tipo";
txbApellidoPat.Text = "";
txbApellidoMat.Text = "";
txbNombre.Text = "";
txbCarrera.Text = "";
cmbNoControl.SelectedIndex = ‐1;
cmbGrupo.SelectedIndex = ‐1;
cmbNivel.SelectedIndex = ‐1;
cmbTipo.SelectedIndex = ‐1;
}
// ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
//Advance next tab index if return is pressed
private void GeneralKeyPress(object sender, KeyPressEventArgs e)
{
//MessageBox.Show("Gereal Key Pressed");
e.KeyChar = Char.ToUpper(e.KeyChar);
if (e.KeyChar == Convert.ToChar(Keys.Return))
{
//MessageBox.Show("Return Pressed");
SendKeys.Send("{TAB}");
}
}
// ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void cmbNoControl_Leave(object sender, EventArgs e)
{
//MessageBox.Show("Leave No Control");
}
// ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void cmbNoControl_Validating(object sender, CancelEventArgs e)
{
//MessageBox.Show("Validating No Control");
bool BuscarAlumno;
bool Adeudo;
if (cmbNoControl.Text.ToString() != "")
{
BuscarAlumno = newDBConnect.BuscarAlumno(cmbNoControl.Text.ToString());
if (BuscarAlumno)
{
//MessageBox.Show("El Alumno ya Existe");
Adeudo = newDBConnect.Adeudos(cmbNoControl.Text.ToString());
if (Adeudo)
{
MessageBox.Show("El Alumno tiene adeudo");
// Through Constructor
frmAdeudos frm = new frmAdeudos(cmbNoControl.Text);
Enabled = false;
frm.ShowDialog(this);
Enabled = true;
}
}
else
{
MessageBox.Show("El Alumno No Existe");
e.Cancel = true;
}
}
}
// ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void cmbNoRecibo_Validating(object sender, CancelEventArgs e)
{
//MessageBox.Show("Validating No Control");
bool Recibo;
Recibo = newDBConnect.BuscarRecibo(cmbRecibo.Text.ToString());
if (Recibo)
{
//MessageBox.Show("El Recibo ya Existe");
e.Cancel = true;
}
else
{
//MessageBox.Show("No Existe el Recibo");
}
}
// ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void cmbGrupo_Validating(object sender, CancelEventArgs e)
{
string strGrupo = cmbGrupo.Text.ToString();
if (strGrupo == "")
{
//MessageBox.Show("El Campo Esta Vacio");
}
else
{
bool bolGrupo;
bolGrupo = newDBConnect.BuscarGrupo(strGrupo);
if (bolGrupo)
{
//MessageBox.Show("El grupo no Existe");
e.Cancel = true;
}
else
{
if (strGrupo.Substring(7, 2).ToString() == "00")
{
//MessageBox.Show("Examen de Ubicacion");
cmbNivel.Focus();
}
else
{
bool bolAlumnoGrupo;
DBConnect newDBConnect1 = new DBConnect();
bolAlumnoGrupo = newDBConnect1.AlumnoGrupo(cmbNoControl.Text.ToString(), strGrupo);
if (bolAlumnoGrupo)
{
//MessageBox.Show("EL Alumno Ya Esta en el Grupo");
cmbTipo.Focus();
}
else
{
bool bolGrupoLleno;
DBConnect newDBConnect2 = new DBConnect();
bolGrupoLleno = newDBConnect2.GrupoDisponible(strGrupo);
if (bolGrupoLleno)
{
//MessageBox.Show("EL Grupo Esta Lleno");
e.Cancel = true;
}
else
{
//MessageBox.Show("Si Hay Cupo en el Grupo");
cmbTipo.Focus();
}
}
}
}
}
}
// ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void btnGuardarDatos_Click(object sender, EventArgs e)
{
//MessageBox.Show("Guardar datos Click");
List<string> list = new List<string>();
list.Add(cmbNoControl.Text.ToString()); // 0 No. de Control
list.Add("Null"); // 1
list.Add("Null"); // 2
list.Add("Null"); // 3
list.Add(cmbRecibo.Text.ToString()); // 4 No. de Recibo
list.Add(cmbGrupo.Text.ToString()); // 5 Clave de Grupo
list.Add(cmbTipo.Text.ToString()); // 6 Tipo
list.Add(txbCantidad.Text.ToString()); // 7 Cantidad
int i=0;
foreach (string element in list)
{
if (list[i] == "")
{
MessageBox.Show("Los Campos con * Deben Contener Datos");
break;
}
i++;
}
int ListCount = list.Count;
//MessageBox.Show(i + " " + ListCount.ToString());
if (i == ListCount)
{
list.Add("Null"); // 8
list.Add("Null"); // 9
list.Add(cmbNivel.Text.ToString()); // 10 Nivel
newDBConnect.ReciboInsert(list);
//cmbNoControl.Text = ""; // 0 No. de Control
cmbRecibo.Text = ""; // 4 No. de Recibo
cmbGrupo.Text = ""; // 5 Clave de Grupo
cmbTipo.Text = ""; // 6 Tipo
txbCantidad.Text = ""; // 7 Cantidad
cmbNivel.Text = ""; // 10 Nivel
}
cmbNoControl.Focus();
}
// ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void cmbNivel_Validating(object sender, CancelEventArgs e)
{
//MessageBox.Show("Validating Nivel");
bool Nivel;
if (cmbNivel.Text.ToString() != "")
{
Nivel = newDBConnect.BuscarNivel(cmbNivel.Text.ToString());
if (Nivel)
{
//MessageBox.Show("El Nivel ya Existe");
}
else
{
//MessageBox.Show("No Existe el Nivel");
e.Cancel = true;
}
}
}
// ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void cmbTipo_Validating(object sender, CancelEventArgs e)
{
//MessageBox.Show("Validating Nivel");
bool Tipo;
if (cmbTipo.Text.ToString() != "")
{
Tipo = newDBConnect.BuscarTipo(cmbTipo.Text.ToString());
if (Tipo)
{
//MessageBox.Show("El Tipo ya Existe");
}
else
{
//MessageBox.Show("No Existe el Tipo");
e.Cancel = true;
}
}
}
// ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void cmbNoControl_Validated(object sender, EventArgs e)
{
//MessageBox.Show("Validated No Control");
List<string>[] list;
DataSet Datos = null;
list = newDBConnect.LoadGrid(cmbNoControl.Text.ToString());
//MessageBox.Show(list[0].Count.ToString());
Datos = newDBConnect.DatosAlumnos(cmbNoControl.Text.ToString());
if (Datos.Tables.Count != 0 && cmbNoControl.Text.ToString() != "")
{
//MessageBox.Show("Si tiene datos");
DataTable DataTable = new DataTable();
DataTable = Datos.Tables[0];
this.txbApellidoPat.Text = DataTable.Rows[0]["apellido_pat"].ToString();
this.txbApellidoMat.Text = DataTable.Rows[0]["apellido_mat"].ToString();
this.txbNombre.Text = DataTable.Rows[0]["nombre"].ToString();
this.txbCarrera.Text = DataTable.Rows[0]["carrera"].ToString();
}
else
{
//MessageBox.Show("No tiene datos");
}
dgvRecibosAlumno.Rows.Clear();
for (int i = 0; i < list[0].Count; i++)
{
int number = dgvRecibosAlumno.Rows.Add();
dgvRecibosAlumno.Rows[number].Cells[0].Value = list[0][i];
dgvRecibosAlumno.Rows[number].Cells[1].Value = list[1][i];
dgvRecibosAlumno.Rows[number].Cells[2].Value = list[2][i];
dgvRecibosAlumno.Rows[number].Cells[3].Value = list[3][i];
dgvRecibosAlumno.Rows[number].Cells[4].Value = list[4][i];
dgvRecibosAlumno.Rows[number].Cells[5].Value = list[5][i];
}
}
// ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void EnterKeyPress(object sender, KeyPressEventArgs e)
{
//MessageBox.Show("Enter Key Pressed");
if (e.KeyChar == Convert.ToChar(Keys.Return))
{
//MessageBox.Show("Return Pressed");
SendKeys.Send("{TAB}");
}
}
// ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void btnBecas_Click(object sender, EventArgs e)
{
pnlBecas.Visible = true;
}
// ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void cmbGrupo_Enter(object sender, EventArgs e)
{
MySqlDataAdapter GruposDA;
DataTable GruposDT = new DataTable();
GruposDA = newDBConnect.DropDown("Grupos");
GruposDA.Fill(GruposDT);
cmbGrupo.Data = GruposDT;
cmbGrupo.ViewColumn = 0;
}
// ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void cmbBecas_SelectedIndexChanged(object sender, EventArgs e)
{
if (cmbBecas.SelectedIndex > ‐1)//If there is no selected index the indexer will return null
{
//cmbBecas.Text = (cmbBecas.SelectedIndex.ToString());
}
else
{
cmbBecas.Text = "";
}
DataSet Datos = null;
Datos = newDBConnect.Becas(cmbBecas.Text.ToString());
dgvBecas.DataSource = Datos.Tables[0];
DataTable RecibosDT = new DataTable();
RecibosDT = Datos.Tables[0];
if (RecibosDT.Rows.Count == 0)
{
this.cmbRecibo.Text = "00000";
}
else
{
int intReciboNo = 0;
intReciboNo = Int32.Parse(RecibosDT.Rows[0]["Recibo"].ToString()) + 1;
this.cmbRecibo.Text = intReciboNo.ToString();
}
}
// ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void pnlBecas_Leave(object sender, EventArgs e)
{
pnlBecas.Visible = false;
cmbBecas.Text = "";
}
//
_____________________________________________________________________________________________
}
}
‐ frmReporteAlumnosCantidadTipo
Codigo que ejecuta el reporte de cantidad y tipo de alumnos en el periodo seleccionado. Se ejecuta en el menú
principal en la opción REPORTE/CANTIDAD Y TIPO DE ALUMNOS.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MySql.Data.MySqlClient;
namespace AlumnosIngles
{
public partial class frmReporteAlumnosCantidadTipo : Form
{
DBConnect newDBConnect = new DBConnect();
public frmReporteAlumnosCantidadTipo()
{
InitializeComponent();
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void frmReporteAlumnosCantidadTipo_Load(object sender, EventArgs e)
{
MySqlDataAdapter Datos;
DataTable table = new DataTable();
Datos = newDBConnect.DropDown("Periodos");
Datos.Fill(table);
cmbPeriodo.DataSource = table;
cmbPeriodo.DisplayMember = "Descripcion";
cmbPeriodo.ValueMember = "Periodo";
cmbPeriodo.SelectedIndex = ‐1;
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void cmbPeriodo_SelectedIndexChanged(object sender, EventArgs e)
{
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void cmbPeriodo_Validating(object sender, CancelEventArgs e)
{
//MessageBox.Show("Validating");
bool bolPeriodo;
string strPeriodo = "";
if (cmbPeriodo.SelectedValue == null)
{
strPeriodo ="";
}
else
{
strPeriodo =cmbPeriodo.SelectedValue.ToString();
}
bolPeriodo = newDBConnect.BuscarPeriodo(strPeriodo);
if (bolPeriodo)
{
//MessageBox.Show("El Periodo Si Existe");
rptReporteAlumnosCantidadTipo1.Refresh();
rptReporteAlumnosCantidadTipo1.SetParameterValue("Periodo", strPeriodo + "*");
crystalReportViewer1.ReportSource = rptReporteAlumnosCantidadTipo1;
}
else
{
//MessageBox.Show("El Periodo No Existe");
e.Cancel = true;
}
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void cmbPeriodo_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == Convert.ToChar(Keys.Return))
{
SendKeys.Send("{TAB}");
}
}
}
}
‐ frmReporteDeudores
Código que ejecuta un reporte el cual muestra los alumnos que tienen un adeudo en el centro de lenguas. Se
ejecuta en el menú principal en la opción REPORTE/PAGARE.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MySql.Data.MySqlClient;
namespace AlumnosIngles
{
public partial class frmReporteDeudores : Form
{
DBConnect newDBConnect = new DBConnect();
public frmReporteDeudores()
{
InitializeComponent();
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void cmbPeriodo_Validating(object sender, CancelEventArgs e)
{
//MessageBox.Show("Validating");
bool bolPeriodo;
string strPeriodo = "";
if (cmbPeriodo.SelectedValue == null)
{
strPeriodo = "";
}
else
{
strPeriodo = cmbPeriodo.SelectedValue.ToString();
}
bolPeriodo = newDBConnect.BuscarPeriodo(strPeriodo);
if (bolPeriodo)
{
//MessageBox.Show("El Periodo Si Existe");
rptReporteDeudores1.Refresh();
rptReporteDeudores1.SetParameterValue("Periodo", strPeriodo + "*");
crystalReportViewer1.ReportSource = rptReporteDeudores1;
}
else
{
//MessageBox.Show("El Periodo No Existe");
e.Cancel = true;
}
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void frmReporteDeudores_Load(object sender, EventArgs e)
{
MySqlDataAdapter Datos;
DataTable table = new DataTable();
Datos = newDBConnect.DropDown("Periodos");
Datos.Fill(table);
cmbPeriodo.DataSource = table;
cmbPeriodo.DisplayMember = "Descripcion";
cmbPeriodo.ValueMember = "Periodo";
cmbPeriodo.SelectedIndex = ‐1;
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void cmbPeriodo_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == Convert.ToChar(Keys.Return))
{
SendKeys.Send("{TAB}");
}
}
//_________________________________________________________________________________________
}
}
‐ frmReporteEstadisticasGenero
Codigo que ejecuta un reporte el cual muestra el total de alumnos inscritos en el periodo seleccionado sorteados
por carrera, nivel, mostrando la cantidad de hombres y mujeres es los grupos. Se ejecuta en el menú principal en la
opción REPORTE/ESTADISTICA DE GENERO .
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MySql.Data.MySqlClient;
namespace AlumnosIngles
{
public partial class frmReporteEstadisticasGenero : Form
{
DBConnect newDBConnect = new DBConnect();
public frmReporteEstadisticasGenero()
{
InitializeComponent();
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void frmReporteEstadisticasGenero_Load(object sender, EventArgs e)
{
MySqlDataAdapter Datos;
DataTable table = new DataTable();
Datos = newDBConnect.DropDown("Periodos");
Datos.Fill(table);
cmbPeriodo.DataSource = table;
cmbPeriodo.DisplayMember = "Descripcion";
cmbPeriodo.ValueMember = "Periodo";
cmbPeriodo.SelectedIndex = ‐1;
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void cmbPeriodo_Validating(object sender, CancelEventArgs e)
{
//MessageBox.Show("Validating");
bool bolPeriodo;
string strPeriodo = "";
if (cmbPeriodo.SelectedValue == null)
{
strPeriodo = "";
}
else
{
strPeriodo = cmbPeriodo.SelectedValue.ToString();
}
bolPeriodo = newDBConnect.BuscarPeriodo(strPeriodo);
if (bolPeriodo)
{
//MessageBox.Show("El Periodo Si Existe");
rptReporteEstadisticasGenero1.Refresh();
rptReporteEstadisticasGenero1.SetParameterValue("Periodo", strPeriodo + "*");
crystalReportViewer1.ReportSource = rptReporteEstadisticasGenero1;
}
else
{
//MessageBox.Show("El Periodo No Existe");
e.Cancel = true;
}
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void cmbPeriodo_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == Convert.ToChar(Keys.Return))
{
SendKeys.Send("{TAB}");
}
}
//_________________________________________________________________________________________
}
}
‐ frmReporteGrupos
Codigo que ejecuta un reporte el cual muestra la cantidad de alumnos por grupo, el nivel y el total de dinero
recibido para el periodo seleccionado. Se ejecuta en el menú principal en la opción REPORTE/CANTIDAD GRUPOS.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MySql.Data.MySqlClient;
namespace AlumnosIngles
{
public partial class frmReporteGrupos : Form
{
DBConnect newDBConnect = new DBConnect();
public frmReporteGrupos()
{
InitializeComponent();
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void frmReporteGrupos_Load(object sender, EventArgs e)
{
MySqlDataAdapter Datos;
DataTable table = new DataTable();
Datos = newDBConnect.DropDown("Periodos");
Datos.Fill(table);
cmbPeriodo.DataSource = table;
cmbPeriodo.DisplayMember = "Descripcion";
cmbPeriodo.ValueMember = "Periodo";
cmbPeriodo.SelectedIndex = ‐1;
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void cmbPeriodo_Validating(object sender, CancelEventArgs e)
{
//MessageBox.Show("Validating");
bool bolPeriodo;
string strPeriodo = "";
if (cmbPeriodo.SelectedValue == null)
{
strPeriodo = "";
}
else
{
strPeriodo = cmbPeriodo.SelectedValue.ToString();
}
bolPeriodo = newDBConnect.BuscarPeriodo(strPeriodo);
if (bolPeriodo)
{
//MessageBox.Show("El Periodo Si Existe");
rptReporteGrupos1.Refresh();
rptReporteGrupos1.SetParameterValue("Periodo", strPeriodo + "*");
crystalReportViewer1.ReportSource = rptReporteGrupos1;
}
else
{
//MessageBox.Show("El Periodo No Existe");
e.Cancel = true;
}
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void cmbPeriodo_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == Convert.ToChar(Keys.Return))
{
SendKeys.Send("{TAB}");
}
}
//_________________________________________________________________________________________
}
}
‐ frmReporteListas
Código que ejecuta un reporte el cual crea las listas del grupo seleccionado que son usadas en el salón de clase por
los maestros. Se ejecuta en el menú principal en la opción LISTAS.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MySql.Data.MySqlClient;
namespace AlumnosIngles
{
public partial class frmReporteListas : Form
{
DBConnect newDBConnect = new DBConnect();
public frmReporteListas()
{
InitializeComponent();
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void frmReporteListas_Load(object sender, EventArgs e)
{
MySqlDataAdapter GruposDA;
DataTable GrupoDT = new DataTable();
GruposDA = newDBConnect.DropDown("Grupos");
GruposDA.Fill(GrupoDT);
cmbGrupo.Data = GrupoDT;
cmbGrupo.ViewColumn = 0;
cmbGrupo.SelectedIndex = ‐1;
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void cmbGrupo_Enter(object sender, EventArgs e)
{
//rptReporteListas1.Close();
//crystalReportViewer1.ReportSource = null;
//crystalReportViewer1.Refresh();
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void cmbGrupo_Validating(object sender, CancelEventArgs e)
{
string strGrupo = "";
if (cmbGrupo.Text.ToString() != "")
{
bool bolGrupo;
strGrupo = cmbGrupo.Text.ToString();
bolGrupo = newDBConnect.BuscarGrupo(strGrupo);
if (bolGrupo)
{
//MessageBox.Show("El grupo no Existe");
e.Cancel = true;
}
else
{
rptReporteListas1.Refresh();
rptReporteListas1.SetParameterValue("Grupo", strGrupo);
crystalReportViewer1.ReportSource = rptReporteListas1;
}
}
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void cmbGrupo_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == Convert.ToChar(Keys.Return))
{
SendKeys.Send("{TAB}");
}
}
//_________________________________________________________________________________________
}
}
‐ frmReportePeriodoCarrera
Código que ejecuta un reporte que muestra el nivel en el que están inscritos los alumnos de cada carrera dentro del
periodo seleccionado. Se ejecuta en el menú principal en la opción ALUMNOS/PERIODO CARRERA.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MySql.Data.MySqlClient;
namespace AlumnosIngles
{
public partial class frmReportePeriodoCarrera : Form
{
DBConnect newDBConnect = new DBConnect();
public frmReportePeriodoCarrera()
{
InitializeComponent();
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void frmReportePeriodoCarrera_Load(object sender, EventArgs e)
{
MySqlDataAdapter PeriodosDA;
DataTable PeriodosDT = new DataTable();
PeriodosDA = newDBConnect.DropDown("Periodos");
PeriodosDA.Fill(PeriodosDT);
cmbPeriodo.DataSource = PeriodosDT;
cmbPeriodo.DisplayMember = "Descripcion";
cmbPeriodo.ValueMember = "Periodo";
cmbPeriodo.SelectedIndex = ‐1;
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void btnVerReporte_Click(object sender, EventArgs e)
{
string strPeriodo=cmbPeriodo.Text.ToString();
if (strPeriodo == "")
{
MessageBox.Show("El Campo del Periodo Esta Vacio");
cmbPeriodo.Focus();
}
else
{
rptReportePeriodoCarrera1.Refresh();
rptReportePeriodoCarrera1.SetParameterValue("Periodo", strPeriodo);
crystalReportViewer1.ReportSource = rptReportePeriodoCarrera1;
}
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void cmbPeriodo_Validating(object sender, CancelEventArgs e)
{
//MessageBox.Show("Validating");
bool bolPeriodo;
string strPeriodo = "";
if (cmbPeriodo.SelectedValue == null)
{
strPeriodo = cmbPeriodo.Text.ToString();
}
else
{
strPeriodo = cmbPeriodo.SelectedValue.ToString();
}
//MessageBox.Show(strPeriodo);
if (strPeriodo != "" )
{
bolPeriodo = newDBConnect.BuscarPeriodo(strPeriodo);
if (bolPeriodo)
{
//MessageBox.Show("El Periodo Si Existe");
}
else
{
//MessageBox.Show("El Periodo No Existe");
e.Cancel = true;
}
}
}
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
private void cmbPeriodo_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == Convert.ToChar(Keys.Return))
{
SendKeys.Send("{TAB}");
}
}
//_________________________________________________________________________________________
}
}
‐ GlobalVars
Código que crea variables de ambiente que son utilizadas por diferentes códigos. Se ejecuta al iniciar la aplicación
principal.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace AlumnosIngles
{
public static class GlobalVars
{
public const string GlobalString = "Global Fix Var";
static int _globalInt;
// Access routine for global integer variable.
public static int GlobalInt
{
get { return _globalInt; }
set { _globalInt = value; }
}
static string _globalPeriodo = "";
// Access routine for global string variable.
public static string GlobalPeriodo
{
get { return _globalPeriodo + "%"; }
set { _globalPeriodo = value; }
}
static string _globalPeriodoDesc = "";
public static string GlobalPeriodoDesc
{
get { return _globalPeriodoDesc; }
set { _globalPeriodoDesc = value; }
}
// Global static field.
public static bool GlobalBoolean;
}
}
USUARIOS Y CLAVES DE ACCESO
EL sistema no contiene usuarios y/o claves de acceso, pero existen usuarios para la base de datos en MySQL.
El usuario de MySQL es “root”, y la clave de acceso es “CleJua11”.
El usuario del enlace de la base de datos con la aplicación es “CentroIdiomas01” y la clave de acceso es
“CenLen01!!”
server = "10.13.50.101"; database = "alumnosingles_be"; uid = "CentroIdiomas01"; password = "CenLen01!!";
El usuario del reporteador que utiliza el enlace ODBC es “Reportes” y la clave de acceso es “RepIng11”.
Antes de iniciar el periodo hay que crear los grupos que se van a ofrecer, esto se hace directamente en
la tabla grupos de MySQL, el formato de los códigos de grupo es el siguiente.
GPPAAAANN donde:
G es fijo.
PP es el periodo del grupo (Feb‐May ‐> FM Jun‐Ago ‐> JA Sep‐Dic ‐>SD)
AAAA es el año del periodo
NN es el número de grupo.
Antes de finalizar los cursos hay que cargar datos en dos tablas.
1. Tabla flags con la lista de los grupos que hubo en el periodo, todos estos llevan status 0.
2. Tabla calificacionesmaestros donde se registran todos los alumnos que tomaron algún curso durante el
periodo, esta tabla es la base para las calificaciones de los maestros.