private void button1_Click(object sender, EventArgs e) { conexion cn = new conexion(); bool respuesta = true; if (validarEB()) { respuesta = cn.NoExistenciasA(Convert.ToString(textBoxIdAlumnoReingreso.Text)); ErrorEB.Clear(); if (respuesta != true) { string año2 = dateTimePickerReingreso.Text; DataClasses1DataContext db = new DataClasses1DataContext(); int codigo = Convert.ToInt32(textBoxIdAlumnoReingreso.Text); conexion xl = new conexion(); SqlConnection conn = new SqlConnection("Data Source=localhost\\SQLEXPRESS;Initial Catalog=Inst_JoseCelilioValle;Integrated Security=True"); conn.Open(); string comando = string.Format("select count(a.codigo_alumno) from [dbo].[Alumno] a inner join [dbo].[grado_alumno] b on a.codigo_alumno = b.codigo_alumno inner join [dbo].[Periodos_Grado] c on b.codigo_periodoGrado = c.codigo_periodoGrado inner join [dbo].[Grado] d on c.codigo_grado= d.codigo_grado inner join [dbo].[Seccion] e on c.codigo_seccion = e.codigo_seccion where c.codigo_grado = {0} AND c.codigo_seccion = {1}", comboBoxGrado2.SelectedIndex + 1, comboBoxSeccion2.SelectedIndex + 1); SqlCommand cmd = new SqlCommand(comando, conn); Int32 count = (Int32)cmd.ExecuteScalar(); conn.Close(); if (count <= 30) { string actualizar = "materiaRetrasada ='" + textBoxRetrasadaReingreso.Text + "',materiaTPA ='" + textBoxTPAreingreso + "', instituto_procedencia ='" + textBoxProcedenciaReingreso.Text + "'"; if (cn.actualizar("Alumno", actualizar, "id_alumno=" + textBoxIdAlumnoReingreso.Text)) { MessageBox.Show("Datos Actualizados", "Mensaje", MessageBoxButtons.OK); } else { MessageBox.Show("Error al actualizar el Registro", "Mensaje", MessageBoxButtons.OK); } if (comboBoxGrado2.Text == "1er grado") { textBoxGrado2.Clear(); textBoxGrado2.Text = "1"; } if (comboBoxGrado2.Text == "2do grado") { textBoxGrado2.Clear(); textBoxGrado2.Text = "2"; } if (comboBoxGrado2.Text == "3er grado") { textBoxGrado2.Clear(); textBoxGrado2.Text = "3"; } if (comboBoxGrado2.Text == "4to grado") { textBoxGrado2.Clear(); textBoxGrado2.Text = "4"; } if (comboBoxGrado2.Text == "5to grado") { textBoxGrado2.Clear(); textBoxGrado2.Text = "5"; } if (comboBoxGrado2.Text == "6to grado") { textBoxGrado2.Clear(); textBoxGrado2.Text = "6"; } if (comboBoxGrado2.Text == "7mo grado") { textBoxGrado2.Clear(); textBoxGrado2.Text = "7"; } if (comboBoxGrado2.Text == "8vo grado") { textBoxGrado2.Clear(); textBoxGrado2.Text = "8"; } if (comboBoxGrado2.Text == "9no grado") { textBoxGrado2.Clear(); textBoxGrado2.Text = "9"; } if (comboBoxGrado2.Text == "10mo grado") { textBoxGrado2.Clear(); textBoxGrado2.Text = "10"; } if (comboBoxGrado2.Text == "11vo grado") { textBoxGrado2.Clear(); textBoxGrado2.Text = "11"; } int grado2; grado2 = Int32.Parse(textBoxGrado2.Text); if (comboBoxSeccion2.Text == "A") { textBoxSeccion2.Clear(); textBoxSeccion2.Text = "1"; } if (comboBoxSeccion2.Text == "B") { textBoxSeccion2.Clear(); textBoxSeccion2.Text = "2"; } if (comboBoxSeccion2.Text == "C") { textBoxSeccion2.Clear(); textBoxSeccion2.Text = "3"; } int seccion2; seccion2 = Int32.Parse(textBoxSeccion2.Text); if (comboBoxGrado2.Text == "1er grado" && comboBoxSeccion2.Text == "A") { textBoxGrado2.Clear(); textBoxAula2.Text = "1"; } if (comboBoxGrado2.Text == "1er grado" && comboBoxSeccion2.Text == "B") { textBoxGrado2.Clear(); textBoxAula2.Text = "2"; } if (comboBoxGrado2.Text == "1er grado" && comboBoxSeccion2.Text == "C") { textBoxGrado2.Clear(); textBoxAula2.Text = "3"; } if (comboBoxGrado2.Text == "2do grado" && comboBoxSeccion2.Text == "A") { textBoxGrado2.Clear(); textBoxAula2.Text = "4"; } if (comboBoxGrado2.Text == "2do grado" && comboBoxSeccion2.Text == "B") { textBoxGrado2.Clear(); textBoxAula2.Text = "5"; } if (comboBoxGrado2.Text == "2do grado" && comboBoxSeccion2.Text == "C") { textBoxGrado2.Clear(); textBoxAula2.Text = "6"; } if (comboBoxGrado2.Text == "3er grado" && comboBoxSeccion2.Text == "A") { textBoxGrado2.Clear(); textBoxAula2.Text = "7"; } if (comboBoxGrado2.Text == "3er grado" && comboBoxSeccion2.Text == "B") { textBoxGrado2.Clear(); textBoxAula2.Text = "8"; } if (comboBoxGrado2.Text == "3er grado" && comboBoxSeccion2.Text == "C") { textBoxGrado2.Clear(); textBoxAula2.Text = "9"; } if (comboBoxGrado2.Text == "4to grado" && comboBoxSeccion2.Text == "A") { textBoxGrado2.Clear(); textBoxAula2.Text = "10"; } if (comboBoxGrado2.Text == "4to grado" && comboBoxSeccion2.Text == "B") { textBoxGrado2.Clear(); textBoxAula2.Text = "11"; } if (comboBoxGrado2.Text == "4to grado" && comboBoxSeccion2.Text == "C") { textBoxGrado2.Clear(); textBoxAula2.Text = "12"; } if (comboBoxGrado2.Text == "5to grado" && comboBoxSeccion2.Text == "A") { textBoxGrado2.Clear(); textBoxAula2.Text = "13"; } if (comboBoxGrado2.Text == "5to grado" && comboBoxSeccion2.Text == "B") { textBoxGrado2.Clear(); textBoxAula2.Text = "14"; } if (comboBoxGrado2.Text == "5to grado" && comboBoxSeccion2.Text == "C") { textBoxGrado2.Clear(); textBoxAula2.Text = "15"; } if (comboBoxGrado2.Text == "6to grado" && comboBoxSeccion2.Text == "A") { textBoxGrado2.Clear(); textBoxAula2.Text = "16"; } if (comboBoxGrado2.Text == "6to grado" && comboBoxSeccion2.Text == "B") { textBoxGrado2.Clear(); textBoxAula2.Text = "17"; } if (comboBoxGrado2.Text == "6to grado" && comboBoxSeccion2.Text == "C") { textBoxGrado2.Clear(); textBoxAula2.Text = "18"; } if (comboBoxGrado2.Text == "7mo grado" && comboBoxSeccion2.Text == "A") { textBoxGrado2.Clear(); textBoxAula2.Text = "19"; } if (comboBoxGrado2.Text == "7mo grado" && comboBoxSeccion2.Text == "B") { textBoxGrado2.Clear(); textBoxAula2.Text = "20"; } if (comboBoxGrado2.Text == "7mo grado" && comboBoxSeccion2.Text == "C") { textBoxGrado2.Clear(); textBoxAula2.Text = "21"; } if (comboBoxGrado2.Text == "8vo grado" && comboBoxSeccion2.Text == "A") { textBoxGrado2.Clear(); textBoxAula2.Text = "22"; } if (comboBoxGrado2.Text == "8vo grado" && comboBoxSeccion2.Text == "B") { textBoxGrado2.Clear(); textBoxAula2.Text = "23"; } if (comboBoxGrado2.Text == "8vo grado" && comboBoxSeccion2.Text == "C") { textBoxGrado2.Clear(); textBoxAula2.Text = "24"; } if (comboBoxGrado2.Text == "9no grado" && comboBoxSeccion2.Text == "A") { textBoxGrado2.Clear(); textBoxAula2.Text = "25"; } if (comboBoxGrado2.Text == "9no grado" && comboBoxSeccion2.Text == "B") { textBoxGrado2.Clear(); textBoxAula2.Text = "26"; } if (comboBoxGrado2.Text == "9no grado" && comboBoxSeccion2.Text == "C") { textBoxGrado2.Clear(); textBoxAula2.Text = "27"; } if (comboBoxGrado2.Text == "10mo grado" && comboBoxSeccion2.Text == "A") { textBoxGrado2.Clear(); textBoxAula2.Text = "28"; } if (comboBoxGrado2.Text == "10mo grado" && comboBoxSeccion2.Text == "B") { textBoxGrado2.Clear(); textBoxAula2.Text = "29"; } if (comboBoxGrado2.Text == "10mo grado" && comboBoxSeccion2.Text == "C") { textBoxGrado2.Clear(); textBoxAula2.Text = "30"; } if (comboBoxGrado2.Text == "11vo grado" && comboBoxSeccion2.Text == "A") { textBoxGrado2.Clear(); textBoxAula2.Text = "31"; } if (comboBoxGrado2.Text == "11vo grado" && comboBoxSeccion2.Text == "B") { textBoxGrado2.Clear(); textBoxAula2.Text = "32"; } if (comboBoxGrado2.Text == "11vo grado" && comboBoxSeccion2.Text == "C") { textBoxGrado2.Clear(); textBoxAula2.Text = "33"; } int aula2; aula2 = Int32.Parse(textBoxAula2.Text); db.ingresarPeriodosGrados(dateTimePickerReingreso.Text, grado2, seccion2, aula2); db.insertarGradoAlumno(); MessageBox.Show("Datos Guardados correctamente", "Mensaje", MessageBoxButtons.OK); } else { MessageBox.Show("Seccion ya tiene 30 alumnos"); } } else { MessageBox.Show("El id NO Existe", "Mensaje", MessageBoxButtons.OK); } } }
private void button1_Click(object sender, EventArgs e) { DataClasses1DataContext db = new DataClasses1DataContext(); conexion cn = new conexion(); bool respuesta = true; bool respuesta2 = true; bool respuesta3 = true; if (validarEB()) { respuesta = cn.ExistenciasB(int.Parse(textBox2.Text)); respuesta2 = cn.ExistenciasNB(int.Parse(textBoxNumeroBusE.Text)); respuesta3 = cn.ExistenciasPB(Convert.ToString(textBoxPlacaBusE.Text)); if (respuesta3 != true) { if (respuesta2 != true) { if (respuesta != true) { if (textBox2.Text == " ") { MessageBox.Show("Debe seleccionar un Chofer"); } else { int num; int num2; num = int.Parse(textBoxNumeroBusE.Text); num2 = int.Parse(textBox2.Text); db.insertarruta(textBoxDescripcioE.Text); db.insertarbuses(1, null, num2, num, textBoxPlacaBusE.Text); MessageBox.Show("la ruta se guardo"); cn.consulta("select * from Buses", "Buses"); dataGridAgrarR.DataSource = cn.ds.Tables["Buses"]; } } else { MessageBox.Show("Este Chofer ya tiene Ruta Asignada", "Mensaje", MessageBoxButtons.OK); } } else { MessageBox.Show("Este Numero de Bus ya esta Asignado", "Mensaje", MessageBoxButtons.OK); textBoxNumeroBusE.Clear(); textBoxNumeroBusE.Focus(); } } else { MessageBox.Show("Esta placa ya Existe", "Mensaje", MessageBoxButtons.OK); textBoxPlacaBusE.Clear(); textBoxPlacaBusE.Focus(); } } }