public void comprobar_calif2() { if (comboBox2.SelectedItem != null) { //MessageBox.Show("" + f + ""); // OBTENGO CLAVE MATERIA comando = new MySqlCommand(string.Format("select clave_materia from materia where (nombre_materia = '" + comboBox2.SelectedItem + "' and grado_grupo = '" + comboBox1.SelectedItem + "');"), Conexion.conectar()); MySqlDataReader read = comando.ExecuteReader(); read.Read(); clave_mat = read[0].ToString();//clave materia // MessageBox.Show("" + clave_mat + ""); read.Close(); //VERIFICO SI LA CLAVE MATERIA CON LA CURP CORRESPONDIENTE ESTÁ DENTRO DE LA TABLA CALIFICACIONES comando = new MySqlCommand(string.Format("select calif_materia from calificacion where(curp_alumno = '" + curp.Trim() + "' and mes_calificacion = '" + cb_periodo.SelectedItem + "' and clave_materia ='" + clave_mat.Trim() + "');"), Conexion.conectar()); read = comando.ExecuteReader(); while (read.Read()) { a++; } if (a > 0) { read.Close(); MessageBox.Show("ALUMNO YA CUENTA CON CALIFICACIÓN EN PERIODO SELECCIONADO DE ESTA MATERIA", "SELECCIONE OTRA MATERIA", MessageBoxButtons.OK, MessageBoxIcon.Error); a = 0; c = comboBox2.SelectedIndex; } else { //HABILITA LOS CONTROLS PARA INGRESAR LA CALIFICACION Y GUARDAR comboBox2.Enabled = false; cb_entero.Enabled = true; cb_decimal.Enabled = true; GUARDAR.Enabled = true; f = -1; } } }
public void comprobar_calif() { int seleccion_cbperiodo = cb_periodo.SelectedIndex - 1; //OBTENGO CURP comando = new MySqlCommand(string.Format("select * from alumno where (nombre_alumno = '" + tb_nombre.Text + "' and ap_pat_alumno = '" + tb_apP.Text + "' and ap_mat_alumno = '" + tb_apM.Text + "');"), Conexion.conectar()); MySqlDataReader read = comando.ExecuteReader(); read.Read(); curp = read[0].ToString();//obtengo curp read.Close(); //OBTENGO LAS VECES QUE ESTÁ REGISTRADO DENTRO DE LA TABLA CALIFICACIONES, SI ES = A EL # DE MATERIAS, YA COMPLETO SU REGISTRO comando = new MySqlCommand(string.Format("select count(curp_alumno) from calificacion where (curp_alumno = '" + curp + "' and mes_calificacion = '" + cb_periodo.SelectedItem + "' );"), Conexion.conectar()); read = comando.ExecuteReader(); read.Read(); veces_regis = read[0].ToString();//verifico cuantas veces está registrado //MessageBox.Show("" + materias_exis + "cantidad de materia", "" + veces_regis + "veces registrado"); aux2 = Convert.ToDouble(veces_regis); read.Close(); //OBTENGO LAS VECES QUE ESTÁ REGISTRADO DENTRO DE LA TABLA CALIFICACIONES, SI ES = A EL # DE MATERIAS, YA COMPLETO SU REGISTRO EN EL MES ANTERIOR DEL SELECCIONADO if (cb_periodo.SelectedIndex != 0) { comando = new MySqlCommand(string.Format("select count(curp_alumno) from calificacion where (curp_alumno = '" + curp + "' and mes_calificacion = '" + cb_periodo.Items[cb_periodo.SelectedIndex - 1] + "' );"), Conexion.conectar()); read = comando.ExecuteReader(); read.Read(); veces_regis_ante = read[0].ToString();//verifico cuantas veces está registrado del mes pasado aux3 = Convert.ToDouble(veces_regis_ante); // MessageBox.Show("" + aux3 + "", ""+materias_exis+ "cantidad de veces registrado en periodo anterior"); read.Close(); } if (materias_exis == aux2) { MessageBox.Show("ALUMNO YA COMPLETO TODOS SUS REGISTROS EN EL PERIODO SELECCIONADO"); d = cb_periodo.SelectedIndex; respuesta = true; if (MessageBox.Show("¿DESEA REGISTRAR EN OTRO PERIODO?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { cb_periodo.Enabled = true; } else { LIMPIAR_REI(); } } else { if (cb_periodo.SelectedIndex == 1) { if (materias_exis_sep == aux3) { f = 1; comboBox2.Enabled = true; cb_periodo.Enabled = false; } else { MessageBox.Show("ALUMNO NO HA COMPLETADO TODOS SUS REGISTROS EN EL PERIODO ANTERIOR"); d = cb_periodo.SelectedIndex; respuesta = true; if (MessageBox.Show("¿DESEA REGISTRAR EN OTRO PERIODO?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { cb_periodo.Enabled = true; } else { LIMPIAR_REI(); } } } else { if (cb_periodo.SelectedIndex != 0 && cb_periodo.SelectedIndex != 1) { if (materias_exis == aux3) { f = 1; comboBox2.Enabled = true; cb_periodo.Enabled = false; } else { MessageBox.Show("ALUMNO NO HA COMPLETADO TODOS SUS REGISTROS EN EL PERIODO ANTERIOR"); d = cb_periodo.SelectedIndex; respuesta = true; if (MessageBox.Show("¿DESEA REGISTRAR EN OTRO PERIODO?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { cb_periodo.Enabled = true; } else { LIMPIAR_REI(); } } } else { f = 1; comboBox2.Enabled = true; cb_periodo.Enabled = false; } } } }
}//COMBOBOX DE MATERIAS private void GUARDAR_Click(object sender, EventArgs e) { if (c == comboBox2.SelectedIndex) { MessageBox.Show("CAMBIE A OTRA MATERIA"); } else { aux = cb_entero.SelectedItem.ToString() + "." + cb_decimal.SelectedItem.ToString(); //CONCATENO LA CALIFICACION calif = Convert.ToDouble(aux); // MessageBox.Show("" + calif + ""); try { comando = new MySqlCommand(String.Format("INSERT INTO calificacion (calif_materia,mes_calificacion,clave_materia,curp_alumno) values ('{0}','{1}','{2}','{3}')", calif, cb_periodo.SelectedItem, clave_mat.Trim(), curp), Conexion.conectar()); comando.ExecuteNonQuery(); /*comboBox2.SelectedItem = null; * cb_periodo.SelectedItem = null;*/ MessageBox.Show("REGISTRADO CON EXITO", "REGISTRADO", MessageBoxButtons.OK, MessageBoxIcon.Information); //BUSQUEDA SI EL ALUMNO YA CUMPLIO CON TODAS SUS CALIFICACIONES REGISTRADAS comando = new MySqlCommand(string.Format("select count(curp_alumno) from calificacion where (curp_alumno = '" + curp + "' and mes_calificacion = '" + cb_periodo.SelectedItem + "' );"), Conexion.conectar()); MySqlDataReader read = comando.ExecuteReader(); read.Read(); veces_regis = read[0].ToString();//verifico cuantas veces está registrado // MessageBox.Show("" + materias_exis + "", "" + veces_regis + ""); aux2 = Convert.ToDouble(veces_regis); read.Close(); if (materias_exis == aux2) { MessageBox.Show("ALUMNO YA COMPLETO TODOS SUS REGISTROS EN EL PERIODO SELECCIONADO"); LIMPIAR_REI(); } else { if (MessageBox.Show("¿DESEA SEGUIR CALIFICANDO ALUMNO?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { f = -1;//variable para que hasta que se seleccione un elemento de las materias se compruebe si ya tiene una calificacion seleccionada //habilita los controles para seguir calificando comboBox2.SelectedItem = null; comboBox2.Enabled = true; cb_entero.Enabled = false; cb_decimal.Enabled = false; cb_decimal.SelectedIndex = 0; cb_entero.SelectedIndex = 0; cb_decimal.Enabled = false; } else { LIMPIAR_REI(); } } } catch (Exception) { MessageBox.Show("ERROR AL REGISTRAR CALIFICACIÓN", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
public static string obtenermes(string crp) { int concurrencia = 0; string[] meses = new string[] { "Diag", "Sept", "Octu", "Novi", "Dici", "Ener", "Febr", "Marz", "Abri", "Mayo", "Juni" }; for (int i = 0; i < 11; i++) { MySqlCommand consulta = new MySqlCommand(string.Format("SELECT COUNT(*) from calificacion where mes_calificacion='{0}' and curp_alumno='{1}';", meses[i], crp), Conexion.conectar()); concurrencia = Convert.ToInt16(consulta.ExecuteScalar()); if (concurrencia == 0) { return(meses[i]); } } return("1"); }
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { comboBox2.SelectedIndex = -1; comboBox2.Items.Clear(); MySqlDataAdapter grupo = new MySqlDataAdapter("Select curp_alumno,ap_pat_alumno,ap_mat_alumno,nombre_alumno from alumno where grado_grupo='" + comboBox1.SelectedItem.ToString() + "';", Conexion.conectar()); DataTable tabla = new DataTable(); grupo.Fill(tabla); dataGridView1.DataSource = tabla; }
private void pictureBox1_Click(object sender, EventArgs e) { try { if (comboBox1.SelectedItem.ToString() == "3" && comboBox2.SelectedItem.ToString() != "Diag") { ciclo = 12; calificaciones[0] = Cb_Val1_ent.SelectedItem.ToString() + "." + CB_Val1_dec.SelectedItem.ToString(); calificaciones[1] = Cb_Val2_ent.SelectedItem.ToString() + "." + CB_Val2_dec.SelectedItem.ToString(); calificaciones[2] = Cb_Val3_ent.SelectedItem.ToString() + "." + CB_Val3_dec.SelectedItem.ToString(); calificaciones[3] = Cb_Val4_ent.SelectedItem.ToString() + "." + CB_Val4_dec.SelectedItem.ToString(); calificaciones[4] = Cb_Val5_ent.SelectedItem.ToString() + "." + CB_Val5_dec.SelectedItem.ToString(); calificaciones[5] = Cb_Val6_ent.SelectedItem.ToString() + "." + CB_Val6_dec.SelectedItem.ToString(); calificaciones[6] = Cb_Val7_ent.SelectedItem.ToString() + "." + CB_Val7_dec.SelectedItem.ToString(); calificaciones[7] = Cb_Val8_ent.SelectedItem.ToString() + "." + CB_Val8_dec.SelectedItem.ToString(); calificaciones[8] = Cb_Val9_ent.SelectedItem.ToString() + "." + CB_Val9_dec.SelectedItem.ToString(); calificaciones[9] = Cb_Val10_ent.SelectedItem.ToString() + "." + CB_Val10_dec.SelectedItem.ToString(); calificaciones[10] = Cb_Val11_ent.SelectedItem.ToString() + "." + CB_Val11_dec.SelectedItem.ToString(); calificaciones[11] = Cb_Val12_ent.SelectedItem.ToString() + "." + CB_Val12_dec.SelectedItem.ToString(); } if (comboBox1.SelectedItem.ToString() == "3" && comboBox2.SelectedItem.ToString() == "Diag") { ciclo = 7; calificaciones[0] = Cb_Val1_ent.SelectedItem.ToString() + "." + CB_Val1_dec.SelectedItem.ToString(); calificaciones[1] = Cb_Val2_ent.SelectedItem.ToString() + "." + CB_Val2_dec.SelectedItem.ToString(); calificaciones[2] = Cb_Val3_ent.SelectedItem.ToString() + "." + CB_Val3_dec.SelectedItem.ToString(); calificaciones[3] = Cb_Val4_ent.SelectedItem.ToString() + "." + CB_Val4_dec.SelectedItem.ToString(); calificaciones[4] = Cb_Val5_ent.SelectedItem.ToString() + "." + CB_Val5_dec.SelectedItem.ToString(); calificaciones[5] = Cb_Val6_ent.SelectedItem.ToString() + "." + CB_Val6_dec.SelectedItem.ToString(); calificaciones[6] = Cb_Val7_ent.SelectedItem.ToString() + "." + CB_Val7_dec.SelectedItem.ToString(); } if ((comboBox1.SelectedItem.ToString() == "1" || comboBox1.SelectedItem.ToString() == "2") && comboBox2.SelectedItem.ToString() != "Diag") { ciclo = 11; calificaciones[0] = Cb_Val1_ent.SelectedItem.ToString() + "." + CB_Val1_dec.SelectedItem.ToString(); calificaciones[1] = Cb_Val2_ent.SelectedItem.ToString() + "." + CB_Val2_dec.SelectedItem.ToString(); calificaciones[2] = Cb_Val3_ent.SelectedItem.ToString() + "." + CB_Val3_dec.SelectedItem.ToString(); calificaciones[3] = Cb_Val4_ent.SelectedItem.ToString() + "." + CB_Val4_dec.SelectedItem.ToString(); calificaciones[4] = Cb_Val5_ent.SelectedItem.ToString() + "." + CB_Val5_dec.SelectedItem.ToString(); calificaciones[5] = Cb_Val6_ent.SelectedItem.ToString() + "." + CB_Val6_dec.SelectedItem.ToString(); calificaciones[6] = Cb_Val7_ent.SelectedItem.ToString() + "." + CB_Val7_dec.SelectedItem.ToString(); calificaciones[7] = Cb_Val8_ent.SelectedItem.ToString() + "." + CB_Val8_dec.SelectedItem.ToString(); calificaciones[8] = Cb_Val9_ent.SelectedItem.ToString() + "." + CB_Val9_dec.SelectedItem.ToString(); calificaciones[9] = Cb_Val10_ent.SelectedItem.ToString() + "." + CB_Val10_dec.SelectedItem.ToString(); calificaciones[10] = Cb_Val11_ent.SelectedItem.ToString() + "." + CB_Val11_dec.SelectedItem.ToString(); } if ((comboBox1.SelectedItem.ToString() == "1" || comboBox1.SelectedItem.ToString() == "2") && comboBox2.SelectedItem.ToString() == "Diag") { ciclo = 6; calificaciones[0] = Cb_Val1_ent.SelectedItem.ToString() + "." + CB_Val1_dec.SelectedItem.ToString(); calificaciones[1] = Cb_Val2_ent.SelectedItem.ToString() + "." + CB_Val2_dec.SelectedItem.ToString(); calificaciones[2] = Cb_Val3_ent.SelectedItem.ToString() + "." + CB_Val3_dec.SelectedItem.ToString(); calificaciones[3] = Cb_Val4_ent.SelectedItem.ToString() + "." + CB_Val4_dec.SelectedItem.ToString(); calificaciones[4] = Cb_Val5_ent.SelectedItem.ToString() + "." + CB_Val5_dec.SelectedItem.ToString(); calificaciones[5] = Cb_Val6_ent.SelectedItem.ToString() + "." + CB_Val6_dec.SelectedItem.ToString(); } if ((comboBox1.SelectedItem.ToString() == "4" || comboBox1.SelectedItem.ToString() == "5" || comboBox1.SelectedItem.ToString() == "6") && comboBox2.SelectedItem.ToString() == "Diag") { ciclo = 8; calificaciones[0] = Cb_Val1_ent.SelectedItem.ToString() + "." + CB_Val1_dec.SelectedItem.ToString(); calificaciones[1] = Cb_Val2_ent.SelectedItem.ToString() + "." + CB_Val2_dec.SelectedItem.ToString(); calificaciones[2] = Cb_Val3_ent.SelectedItem.ToString() + "." + CB_Val3_dec.SelectedItem.ToString(); calificaciones[3] = Cb_Val4_ent.SelectedItem.ToString() + "." + CB_Val4_dec.SelectedItem.ToString(); calificaciones[4] = Cb_Val5_ent.SelectedItem.ToString() + "." + CB_Val5_dec.SelectedItem.ToString(); calificaciones[5] = Cb_Val6_ent.SelectedItem.ToString() + "." + CB_Val6_dec.SelectedItem.ToString(); calificaciones[6] = Cb_Val7_ent.SelectedItem.ToString() + "." + CB_Val7_dec.SelectedItem.ToString(); calificaciones[7] = Cb_Val8_ent.SelectedItem.ToString() + "." + CB_Val8_dec.SelectedItem.ToString(); } if ((comboBox1.SelectedItem.ToString() == "4" || comboBox1.SelectedItem.ToString() == "5" || comboBox1.SelectedItem.ToString() == "6") && comboBox2.SelectedItem.ToString() != "Diag") { ciclo = 13; calificaciones[0] = Cb_Val1_ent.SelectedItem.ToString() + "." + CB_Val1_dec.SelectedItem.ToString(); calificaciones[1] = Cb_Val2_ent.SelectedItem.ToString() + "." + CB_Val2_dec.SelectedItem.ToString(); calificaciones[2] = Cb_Val3_ent.SelectedItem.ToString() + "." + CB_Val3_dec.SelectedItem.ToString(); calificaciones[3] = Cb_Val4_ent.SelectedItem.ToString() + "." + CB_Val4_dec.SelectedItem.ToString(); calificaciones[4] = Cb_Val5_ent.SelectedItem.ToString() + "." + CB_Val5_dec.SelectedItem.ToString(); calificaciones[5] = Cb_Val6_ent.SelectedItem.ToString() + "." + CB_Val6_dec.SelectedItem.ToString(); calificaciones[6] = Cb_Val7_ent.SelectedItem.ToString() + "." + CB_Val7_dec.SelectedItem.ToString(); calificaciones[7] = Cb_Val8_ent.SelectedItem.ToString() + "." + CB_Val8_dec.SelectedItem.ToString(); calificaciones[8] = Cb_Val9_ent.SelectedItem.ToString() + "." + CB_Val9_dec.SelectedItem.ToString(); calificaciones[9] = Cb_Val10_ent.SelectedItem.ToString() + "." + CB_Val10_dec.SelectedItem.ToString(); calificaciones[10] = Cb_Val11_ent.SelectedItem.ToString() + "." + CB_Val11_dec.SelectedItem.ToString(); calificaciones[11] = Cb_Val12_ent.SelectedItem.ToString() + "." + CB_Val12_dec.SelectedItem.ToString(); calificaciones[12] = Cb_Val13_ent.SelectedItem.ToString() + "." + CB_Val13_dec.SelectedItem.ToString(); } if (comboBox1.SelectedItem.ToString() == "1") { m[0] = "EDA-1-SEP"; m[1] = "EDF-1-SEP"; m[2] = "ENS-1-SEP"; m[3] = "ESP-1-SEP"; m[4] = "FCE-1-SEP"; m[5] = "MAT-1-SEP"; m[6] = "CLE-1-EXT"; m[7] = "DIS-1-EXT"; m[8] = "PUN-1-EXT"; m[9] = "TAR-1-EXT"; m[10] = "UYA-1-EXT"; } else if (comboBox1.SelectedItem.ToString() == "2") { m[0] = "EDA-2-SEP"; m[1] = "EDF-2-SEP"; m[2] = "ENS-2-SEP"; m[3] = "ESP-2-SEP"; m[4] = "FCE-2-SEP"; m[5] = "MAT-2-SEP"; m[6] = "DIS-2-EXT"; m[7] = "ORT-2-EXT"; m[8] = "PAR-2-EXT"; m[9] = "TAR-2-EXT"; m[10] = "UYA-2-EXT"; } else if (comboBox1.SelectedItem.ToString() == "3") { m[0] = "CIN-3-SEP"; m[1] = "EDA-3-SEP"; m[2] = "EDF-3-SEP"; m[3] = "EDV-3-SEP"; m[4] = "ESP-3-SEP"; m[5] = "FCE-3-SEP"; m[6] = "MAT-3-SEP"; m[7] = "CLE-3-EXT"; m[8] = "DIS-3-EXT"; m[9] = "ORT-3-EXT"; m[10] = "TAR-3-EXT"; m[11] = "UYA-3-EXT"; } else if (comboBox1.SelectedItem.ToString() == "4") { m[0] = "CIN-4-SEP"; m[1] = "EDA-4-SEP"; m[2] = "EDF-4-SEP"; m[3] = "ESP-4-SEP"; m[4] = "FCE-4-SEP"; m[5] = "GEO-4-SEP"; m[6] = "HIS-4-SEP"; m[7] = "MAT-4-SEP"; m[8] = "CLE-4-EXT"; m[9] = "DIS-4-EXT"; m[10] = "ORT-4-EXT"; m[11] = "PAR-4-EXT"; m[12] = "TAR-4-EXT"; } else if (comboBox1.SelectedItem.ToString() == "5") { m[0] = "CIN-5-SEP"; m[1] = "EDA-5-SEP"; m[2] = "EDF-5-SEP"; m[3] = "ESP-5-SEP"; m[4] = "FCE-5-SEP"; m[5] = "GEO-5-SEP"; m[6] = "HIS-5-SEP"; m[7] = "MAT-5-SEP"; m[8] = "CLE-5-EXT"; m[9] = "ORT-5-EXT"; m[10] = "PAR-5-EXT"; m[11] = "TAR-5-EXT"; m[12] = "TRA-5-EXT"; } else if (comboBox1.SelectedItem.ToString() == "6") { m[0] = "CIN-6-SEP"; m[1] = "EDA-6-SEP"; m[2] = "EDF-6-SEP"; m[3] = "ESP-6-SEP"; m[4] = "FCE-6-SEP"; m[5] = "GEO-6-SEP"; m[6] = "HIS-6-SEP"; m[7] = "MAT-6-SEP"; m[8] = "CLE-6-EXT"; m[9] = "ORT-6-EXT"; m[10] = "PAR-6-EXT"; m[11] = "TAR-6-EXT"; m[12] = "UYA-6-EXT"; } MySqlCommand nombre = new MySqlCommand(string.Format("select ap_pat_alumno,ap_mat_alumno,nombre_alumno from alumno where curp_alumno='{0}';", curp), Conexion.conectar()); MySqlDataReader le = nombre.ExecuteReader(); string ap = "", am = "", nom = ""; while (le.Read()) { ap = le.GetString(0); am = le.GetString(1); nom = le.GetString(2); } le.Close(); dat = ap + " " + am + " " + nom; for (int i = 0; i < ciclo; i++) { MySqlCommand com = new MySqlCommand(string.Format("insert into calificacion values('{0}','{1}','{2}','{3}');", calificaciones[i], mesact, m[i], curp), Conexion.conectar()); com.ExecuteNonQuery(); Conexion.cerrar(); } mm = comboBox2.SelectedItem.ToString(); grado = comboBox1.SelectedItem.ToString(); if (mm == "Diag") { pr = 0; } if (mm == "Sept") { pr = 1; } if (mm == "Octu") { pr = 2; } if (mm == "Novi") { pr = 3; } if (mm == "Dici") { pr = 4; } if (mm == "Ener") { pr = 5; } if (mm == "Febr") { pr = 6; } if (mm == "Marz") { pr = 7; } if (mm == "Abri") { pr = 8; } if (mm == "Mayo") { pr = 9; } if (mm == "Juni") { pr = 10; } calif.pdf1ro(); comboBox2.Items.Clear(); mesact = obtenermes(curp); if (mesact == "1") { MessageBox.Show("El alumno ya ha sido evaluado en su totalidad", "Evaluación completa", MessageBoxButtons.OK, MessageBoxIcon.Information); comboBox2.Items.Add("FINALIZADO"); comboBox2.SelectedIndex = 0; } else { comboBox2.Items.Add(mesact); comboBox2.SelectedIndex = 0; } System.Diagnostics.Process proc = new System.Diagnostics.Process(); proc.StartInfo.FileName = boletas.nuevo; proc.Start(); proc.Close(); limpiar(); } catch (Exception) { MessageBox.Show("Ha ocurrido un Error", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }