コード例 #1
0
ファイル: Aspirante.cs プロジェクト: DiegoHuesos/c-
        public String alta(Aspirante a)
        {
            String res = "";
            int    i;

            try {
                SqlConnection con = Conexion.agregarConexion();
                SqlCommand    cmd = new SqlCommand("SELECT top(1) idAspirante FROM aspirantes order by idAspirante DESC;");
                SqlDataReader rd  = cmd.ExecuteReader();
                if (rd.Read())
                {
                    i = rd.GetInt32(0) + 1;
                    rd.Close();
                    SqlCommand cmd2 = new SqlCommand(String.Format("INSERT INTO aspirantes VALUES({0}, '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', {7}, {8});", i, a.nombre, a.appellidoPaterno, a.apellidoMaterno, a.sexo, a.fechaNac, a.correo, a.grado, a.programa), con);
                    cmd2.ExecuteNonQuery();
                }
                else
                {
                    i = rd.GetInt32(0) + 1;
                    rd.Close();
                    SqlCommand cmd2 = new SqlCommand(String.Format("INSERT INTO aspirantes VALUES({0}, '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', {7}, {8});", 1, a.nombre, a.appellidoPaterno, a.apellidoMaterno, a.sexo, a.fechaNac, a.correo, a.grado, a.programa), con);
                    cmd2.ExecuteNonQuery();
                }
            } catch (Exception ex) { res = "alta no exitosa " + ex.Message; }
            return(res);
        }
コード例 #2
0
        public String alta(Aspirante a)
        {
            String res = "";
            int i = 0;
            try
            {
                SqlConnection con = Conexion.agregarConexion();
                SqlCommand cmd = new SqlCommand("select max(idAspirante) from aspirantes", con);
                SqlDataReader rd = cmd.ExecuteReader();
                if (rd.Read())
                {
                    i = rd.GetInt32(0) + 1;
                    rd.Close();
                    SqlCommand cmd2 = new SqlCommand(String.Format("insert into aspirantes values ({0}, '{1}','{2}','{3}','{4}','{5}','{6}',{7},{8})",i,a.nombre,a.apellidoPaterno,apellidoMaterno,a.sexo,a.correo,a.fecghaNac,a.grado,a.programas), con);
                }
                else
                {
                    rd.Close();
                    SqlCommand cmd2 = new SqlCommand(String.Format("insert into aspirantes values ({0}, '{1}','{2}','{3}','{4}','{5}','{6}',{7},{8})", 0, a.nombre, a.apellidoPaterno, apellidoMaterno, a.sexo, a.correo, a.fecghaNac, a.grado, a.programas), con);
                }
                res = "alta exitosa";
                con.Close();
            }catch(Exception ex)
            {
                MessageBox.Show("Alta no exitosa " + ex);
                res = "alta no exitosa";
            }

            return res;
        }
コード例 #3
0
        public String alta(Aspirante a)
        {
            String res = "";
            int    i;

            try {
                SqlConnection con = Conexion.agregarConexion();
                SqlCommand    cmd = new SqlCommand("select top(1) idAspirante from aspirantes order by idAspirante des", con);
                SqlDataReader rd  = cmd.ExecuteReader();
                if (rd.Read())
                {
                    i = rd.GetInt32(0) + 1;
                    rd.Close();
                    SqlCommand cmd2 = new SqlCommand(String.Format("insert into aspirantes values ({0}, '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', {7}, {8}) ", i, a.nombre, a.apellidoPaterno, a.apellidoMaterno, a.sexo, a.fechaNac, a.correo, a.grado, a.programa), con);
                    cmd2.ExecuteNonQuery();
                }
                else
                {
                    rd.Close();
                    SqlCommand cmd2 = new SqlCommand(String.Format("insert into aspirantes values ({0}, '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', {7}, {8}) ", 1, a.nombre, a.apellidoPaterno, a.apellidoMaterno, a.sexo, a.fechaNac, a.correo, a.grado, a.programa), con);
                    cmd2.ExecuteNonQuery();
                }
                res = "alata exitosa";
                con.Close();
            }catch (Exception ex) {
                res = "alta no exitosa" + ex.Message;
            }
            return(res);
        }
コード例 #4
0
 private void bAlta_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         Aspirante a = new Aspirante(tbNombre.Text, tbApellidoPaterno.Text, tbApellidoMaterno.Text, tbSexo.Text, tbCorreo.Text, int.Parse(cbGrado.SelectedItem.ToString()), int.Parse(cbPrograma.SelectedItem.ToString()), tbFechaDeNacimiento.Text);
         a.alta(a);
         MessageBox.Show("Alta exitosa");
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error: " + ex.Message);;
     }
 }
コード例 #5
0
        private void bGenerar_Click(object sender, RoutedEventArgs e)
        {
            Aspirante a = new Aspirante();

            MessageBox.Show(a.generaReporte(dGReporte, cbProgramas));
        }
コード例 #6
0
        private void bAceptar_Click(object sender, RoutedEventArgs e)
        {
            Aspirante a = new Aspirante();

            MessageBox.Show(/*modifica*/);
        }
コード例 #7
0
        private void bAlta_Click(object sender, RoutedEventArgs e)
        {
            Aspirante a = new Aspirante(tbNombre.Text, tbApellidoPaterno.Text, tbApellidoMaterno.Text, tbSexo.Text, tbFechaDeNacimiento.Text, tbCorreo.Text, (int)cbGrado.SelectedItem, (int)cbPrograma.SelectedIndex);

            MessageBox.Show(a.alta(a));
        }
コード例 #8
0
        private void bAceptar_Click(object sender, RoutedEventArgs e)
        {
            Aspirante a = new Aspirante();

            MessageBox.Show(a.modifica(cbProgramas.SelectedIndex, cbAspirantes.SelectedItem.ToString()));
        }
コード例 #9
0
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     Conexion.llenarComboProgramas(cbProgramas);
     Aspirante.llenarComboNombres(cbAspirantes);
 }