Example #1
0
        public static int ValidarNombre(string Nom_Materiaa)
        {
            AccesoDatos aq      = new AccesoDatos();
            SqlCommand  comando = new SqlCommand();

            try
            {
                comando = DatosSP.MateriasValidar(Nom_Materiaa);
                aq.ConfigurarProcedure(ref comando, "VerificarMateria");
                //MessageBox.Show("Nombre Valido");
                comando.Connection = aq.ObtenerConexion();
                SqlDataReader reader = comando.ExecuteReader();
                while (reader.Read())
                {
                    return(int.Parse(reader[0].ToString()));
                }

                return(-100);
            }
            catch (Exception ex)
            {
                // MessageBox.Show("Nombre Invalido");
                //MessageBox.Show(ex.ToString());
                return(-100);
            }
        }
Example #2
0
        private void button2_Click(object sender, EventArgs e)
        {
            Preinscripciones.Confirmacion conf = new Preinscripciones.Confirmacion();
            int registros_ok = 0;

            if (conf.ShowDialog() == DialogResult.OK)
            {
                AccesoDatos aq = new AccesoDatos();

                SqlCommand comando = new SqlCommand();



                for (int i = 0; i < dataGridView1.Rows.Count; i++)
                {
                    try {
                        comando = DatosSP.Preinscriptos(int.Parse(dataGridView1.Rows[i].Cells[10].Value.ToString()), "MAYO 2018", "0",
                                                        dataGridView1.Rows[i].Cells[8].Value.ToString(), dataGridView1.Rows[i].Cells[7].Value.ToString(),
                                                        dataGridView1.Rows[i].Cells[12].Value.ToString(), dataGridView1.Rows[i].Cells[11].Value.ToString(),
                                                        0, dataGridView1.Rows[i].Cells[6].Value.ToString(), dataGridView1.Rows[i].Cells[5].Value.ToString()
                                                        );


                        aq.EjecutarProcedimientoAlmacenado(comando, "CargaPreinscripto");
                        registros_ok++;
                    }
                    catch (Exception ex) {
                        //  MessageBox.Show(ex.ToString());
                    }
                }

                MessageBox.Show("Registros cargados correctamente: " + registros_ok);
            }
        }
Example #3
0
        private void btn_Modificar_M_Click(object sender, EventArgs e)
        {
            if (bloqueado == 0)
            {
                bloqueado = 1;
                read();
            }
            else
            {
                AccesoDatos aq      = new AccesoDatos();
                SqlCommand  comando = new SqlCommand();

                try
                {
                    float   foo = float.Parse(txb_PRECIO_M.Text.Replace(".", ","));
                    decimal bar = Convert.ToDecimal(foo);
                    bar = Math.Round(bar, 2);
                    txb_PRECIO_M.Text = bar.ToString();
                    // MessageBox.Show(txb_PRECIO_M.Text);
                    comando = DatosSP.MateriasCarga(txb_ID_M.Text, txb_NOMBRE_M.Text, txb_PRECIO_M.Text
                                                    , int.Parse(n1.Value.ToString()), int.Parse(n2.Value.ToString()), int.Parse(n3.Value.ToString()));

                    aq.EjecutarProcedimientoAlmacenado(comando, "MateriaModificacion");
                    cargarGrid();
                    MessageBox.Show("Materia modificada correctamente.");
                    bloqueado = 0;
                    read();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }
        }
Example #4
0
        private void btn_Modificar_M_Click(object sender, EventArgs e)
        {
            AccesoDatos aq      = new AccesoDatos();
            SqlCommand  comando = new SqlCommand();

            try
            {
                if (ValidarNombre(txb_NOMBRE_M.Text) == 1)
                {
                    comando = DatosSP.Materias(txb_ID_M.Text, txb_NOMBRE_M.Text);
                    aq.EjecutarProcedimientoAlmacenado(comando, "MateriaModificacionNombre");
                }
                else
                {
                    MessageBox.Show("Nombre Materia Repetido");
                }

                comando = DatosSP.Materias2(txb_ID_M.Text, txb_PRECIO_M.Text);
                aq.EjecutarProcedimientoAlmacenado(comando, "MateriaModificacionPrecio");
                cargarGrid();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Example #5
0
        private void bt_Aceptar_Click(object sender, EventArgs e)
        {
            if (Tabla == 1)
            {
                DateTime fecha = new DateTime();
                fecha         = DateTime.Today;
                tb_Fecha.Text = fecha.ToString();


                AccesoDatos aq      = new AccesoDatos();
                DataSet     ds      = new DataSet();
                SqlCommand  comando = new SqlCommand();

                string codcurso = "";

                codcurso = "select CodCurso from Cursos where actual =1";
                AccesoDatos aff = new AccesoDatos();
                aff.cargaTabla("5:35AM..", codcurso, ref ds);

                codcurso = ds.Tables["5:35AM.."].Rows[0][0].ToString();
                //  MessageBox.Show(codcurso);



                comando = DatosSP.Inscriptos(int.Parse(tb_DNI.Text), textBox2.Text, textBox1.Text, codcurso, tb_Email.Text, tb_Telefono.Text, cb_activo.Checked
                                             , cb_analitico.Checked,
                                             cb_cuil.Checked, cb_Dni.Checked, cb_4x4.Checked, cb_ConstanciaTrabajo.Checked, fecha, tb_Observaciones.Text);
                aq.EjecutarProcedimientoAlmacenado(comando, "ModificarInscripto");
                MessageBox.Show("Alumno modificado correctamente");
                this.Close();
            }
            else
            {
                AccesoDatos aq      = new AccesoDatos();
                DataSet     ds      = new DataSet();
                SqlCommand  comando = new SqlCommand();

                DateTime fecha = new DateTime();
                fecha         = DateTime.Today;
                tb_Fecha.Text = fecha.ToString();


                comando = DatosSP.Inscriptos(int.Parse(tb_DNI.Text), textBox2.Text, textBox1.Text, tb_CodCurso.Text, tb_Email.Text, tb_Telefono.Text, cb_activo.Checked
                                             , cb_analitico.Checked,
                                             cb_cuil.Checked, cb_Dni.Checked, cb_4x4.Checked, cb_ConstanciaTrabajo.Checked, fecha, tb_Observaciones.Text);
                aq.EjecutarProcedimientoAlmacenado(comando, "CargaInscripto");
                MessageBox.Show("Alumno Inscripto correctamente");
                this.Close();
            }
        }
Example #6
0
        private void btn_Modificar_E_Click(object sender, EventArgs e)
        {
            AccesoDatos aq      = new AccesoDatos();
            SqlCommand  comando = new SqlCommand();

            try
            {
                int numero = int.Parse(numericUpDown1.Value.ToString());
                comando = DatosSP.Especialidades(txb_NOMBRE_E.Text, txb_ID_E.Text, numero);
                aq.EjecutarProcedimientoAlmacenado(comando, "EspecialidadModificar");
                cargarGrid();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Example #7
0
        private void btn_altaEspecialidad_Click_1(object sender, EventArgs e)
        {
            AccesoDatos aq      = new AccesoDatos();
            SqlCommand  comando = new SqlCommand();

            try
            {
                if (DatosEspecialidad(txb_NombreE.Text, numericUpDown1.Text) == true)
                {
                    string IDConseguido;
                    int    id = ObtenerID();

                    IDConseguido = "00" + id.ToString();
                    comando      = DatosSP.EspecialidadCarga(IDConseguido, txb_NombreE.Text, numericUpDown1.Text);
                    aq.EjecutarProcedimientoAlmacenado(comando, "CrearEspecialidad");
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Example #8
0
        private void btn_altaMateria_Click(object sender, EventArgs e)
        {
            AccesoDatos aq      = new AccesoDatos();
            SqlCommand  comando = new SqlCommand();

            try
            {
                if (DatosMateria(txb_NombreM.Text, txb_PrecioM.Text) == true)
                {
                    string IDConseguido;
                    int    id = ObtenerID();

                    IDConseguido = "00" + id.ToString();
                    comando      = DatosSP.MateriasCarga(IDConseguido, txb_NombreM.Text, txb_PrecioM.Text);
                    aq.EjecutarProcedimientoAlmacenado(comando, "CrearMateria");
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Example #9
0
        private void btn_altaMateria_Click(object sender, EventArgs e)
        {
            AccesoDatos aq      = new AccesoDatos();
            SqlCommand  comando = new SqlCommand();

            try
            {
                if (DatosMateria(txb_NombreM.Text, txb_PrecioM.Text) == true)
                {
                    string IDConseguido;
                    int    id = ObtenerID() + 1;

                    IDConseguido = "00" + id.ToString();
                    // MessageBox.Show(IDConseguido);
                    string  doble    = txb_PrecioM.Text;
                    decimal doblesss = Convert.ToDecimal(doble);
                    int     number   = Decimal.ToInt32(doblesss);


                    if (number > 0)
                    {
                        comando = DatosSP.MateriasCarga(IDConseguido, txb_NombreM.Text, number.ToString(), int.Parse(n1.Value.ToString()), int.Parse(n2.Value.ToString()), int.Parse(textBox1.Text));
                        aq.EjecutarProcedimientoAlmacenado(comando, "CrearMateria");
                        MessageBox.Show("Materia creada correctamente");
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("Tiene que ser un numero positivo.");
                    }
                }
            }
            catch (Exception ex)
            {
                //MessageBox.Show("Ingrese un numero correcto");
            }
        }
Example #10
0
        public void revisargrid(DataGridView dq)
        {
            AccesoDatos aq = new AccesoDatos();

            for (int i = 0; i < dq.Rows.Count; i++)
            {
                // dni    MessageBox.Show(  dq.Rows[i].Cells[10].Value.ToString());
                SqlCommand comando = new SqlCommand();
                try {
                    DatosSP.Preinscriptos_DNI(ref comando, dq.Rows[i].Cells[10].Value.ToString());



                    aq.ConfigurarProcedure(ref comando, "VerificarPreinscripto");
                    comando.Connection = aq.ObtenerConexion();

                    SqlDataReader reader = comando.ExecuteReader();

                    while (reader.Read())
                    {
                        //  MessageBox.Show( reader[0].ToString());

                        if (reader[0].ToString() == "1")
                        {
                            // pintar de verde porque fue encontrado..
                            dataGridView1.Rows[i].DefaultCellStyle.BackColor = System.Drawing.Color.Green;
                        }
                        else
                        {
                            dataGridView1.Rows[i].DefaultCellStyle.BackColor = System.Drawing.Color.Red;
                        }
                    }
                }
                catch (Exception) { }
            }
        }
Example #11
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (MEDUSA == true)
            {
                try
                {
                    Preinscripciones.Confirmacion conf = new Preinscripciones.Confirmacion();
                    int registros_ok = 0;
                    if (conf.ShowDialog() == DialogResult.OK)
                    {
                        AccesoDatos aq = new AccesoDatos();

                        SqlCommand comando = new SqlCommand();



                        SqlCommand  comando2 = new SqlCommand();
                        AccesoDatos aq2      = new AccesoDatos();
                        string      codcurso = "";

                        aq2.ConfigurarProcedure(ref comando, "ExistenciaCurso");
                        comando.Connection = aq.ObtenerConexion();

                        SqlDataReader reader = comando.ExecuteReader();

                        while (reader.Read())
                        {
                            if (reader[0].ToString() != "-1")
                            {
                                bool asd = false;
                                // MessageBox.Show(comboBox1.Items[comboBox1.SelectedIndex].ToString());

                                //    MessageBox.Show(comboBox1.Text);

                                if (textBox1.Text != "")
                                {
                                    asd = true;
                                    if (asd == true)
                                    {
                                        //      MessageBox.Show(reader[0].ToString());
                                        codcurso = reader[0].ToString();

                                        for (int i = 0; i < dataGridView1.Rows.Count; i++)
                                        {
                                            try
                                            {
                                                comando = DatosSP.Preinscriptos(int.Parse(dataGridView1.Rows[i].Cells[10].Value.ToString()), codcurso, "0",
                                                                                dataGridView1.Rows[i].Cells[8].Value.ToString(), dataGridView1.Rows[i].Cells[7].Value.ToString(),
                                                                                dataGridView1.Rows[i].Cells[20].Value.ToString(), dataGridView1.Rows[i].Cells[19].Value.ToString(),
                                                                                dataGridView1.Rows[i].Cells[6].Value.ToString(), dataGridView1.Rows[i].Cells[5].Value.ToString(),
                                                                                codespe(textBox1.Text)
                                                                                );


                                                aq.EjecutarProcedimientoAlmacenado(comando, "CargaPreinscripto");
                                                registros_ok++;
                                                dataGridView1.Rows[i].DefaultCellStyle.BackColor = System.Drawing.Color.Green;
                                            }
                                            catch (Exception ex)
                                            {
                                            }
                                        }

                                        MessageBox.Show("Registros cargados correctamente: " + registros_ok);
                                    }
                                    else
                                    {
                                        MessageBox.Show("Esa especialidad no existe.");
                                    }
                                }
                                else
                                {
                                    MessageBox.Show("Tiene que seleccionar una especialidad.");
                                }
                            }
                            else
                            {
                                MessageBox.Show("No hay un curso que sea el actual, antes de cargar preinscriptos favor de crear curso actual.");
                            }
                        }
                    }
                }
                catch (Exception ex) {
                    //  MessageBox.Show(ex.ToString());
                }
            }
            else
            {
                MessageBox.Show("Recuerde que tiene que cargar antes el excel.");
            }
        }
Example #12
0
        private void button1_Click(object sender, EventArgs e)
        {
            bool   guardar = true;
            string b       = "\n";
            string error   = "No se pudo crear el curso por los siguientes errores:" + b;

            int cont = 0;

            try {
                try {
                    if (verificarcombo(comboBox1.SelectedItem.ToString(), comboBox1) == -1)
                    {
                        cont++;
                        guardar = false;
                        error  += cont + ") " + "Especialidad inexistente." + b;
                    }
                } catch (Exception) {
                    cont++;
                    guardar = false;
                    error  += cont + ") " + "Especialidad inexistente." + b;
                }

                try
                {
                    if (verificarcombo(comboBox2.SelectedItem.ToString(), comboBox2) == -1)
                    {
                        cont++;
                        guardar = false;
                        error  += cont + ") " + "Porfavor seleccione un valor de la lista." + b;
                    }
                } catch (Exception)
                {
                    cont++;
                    guardar = false;
                    error  += cont + ") " + "Porfavor seleccione un valor de la lista." + b;
                }



                if (textBox2.Text == "")
                {
                    cont++;
                    guardar = false;
                    error  += cont + ") " + "El curso deberia tener un nombre o idenficador." + b;
                }

                if (numericUpDown1.Value <= 0)
                {
                    cont++;
                    guardar = false;
                    error  += cont + ") " + "La cantidad maxima de alumnos no puede ser <=0" + b;
                }

                if (listBox1.Items.Count <= 0)
                {
                    cont++;
                    guardar = false;
                    error  += cont + ") " + "El curso debe tener por lo menos alguna materia cargada" + b;
                }

                //  MessageBox.Show(dateTimePicker1.Value.ToShortDateString());

                DateTime f1 = new DateTime();
                DateTime f2 = new DateTime();
                f1 = DateTime.Parse(dateTimePicker1.Value.ToShortDateString());
                f2 = DateTime.Parse(dateTimePicker2.Value.ToShortDateString());
                if (f1 >= f2)
                {
                    cont++;
                    guardar = false;
                    error  += cont + ") " + "La fecha de finalizacion del curso debe ser menor a la del inicio." + b;
                }
            }
            catch (Exception ex) {
                MessageBox.Show(ex.ToString());
            }

            if (guardar == true)
            {
                string consulta = "";
                try
                {
                    consulta = "Update Cursos set actual = 0 where actual = 1";
                    aq.cargaTabla("ActualCambio", consulta, ref ds);

                    //orden carga en bd

                    //armado de nombre del curso.



                    //insert into Cursos select 001,'20/08/2017','20/08/2017','Mayo2018',7,150,1
                    consulta = "insert into Cursos select " + textBox1.Text + ",'" + dateTimePicker1.Value.ToShortDateString() + "','" + dateTimePicker2.Value.ToShortDateString() + "','" + textBox2.Text + "'," + int.Parse(comboBox2.SelectedItem.ToString()) + "," + numericUpDown1.Value + ",";
                    if (checkBox1.Checked == true)
                    {
                        consulta += "1";
                    }
                    else
                    {
                        consulta += "0";
                    }
                    //aq.cargaTabla("Espe", consulta, ref ds);
                    //  MessageBox.Show(consulta);
                    aq.cargaTabla("Cursos0", consulta, ref ds);
                    //3 especialidades x cursos

                    DatosSP.EspecialidadNombre(ref comando, comboBox1.SelectedItem.ToString());

                    string aux = aq.Reader_Procedure(comando, "EncontrarEspecialidad");
                    if (aux != "error")
                    {
                        consulta = "insert into especialidadesxCursos select '" + textBox1.Text + "','" + aux + "'";

                        aq.cargaTabla("espexcursos", consulta, ref ds);
                    }

                    //4 materias xcursos
                    consulta = "select nombre,Codespecialidad from especialidades";
                    aq.cargaTabla("CodEspe", consulta, ref ds);

                    for (int i = 0; i < tam; i++)
                    {
                        consulta = "insert into MateriasxCurso select '" + cod[i] + "','" + textBox1.Text + "','";

                        for (int x = 0; x < ds.Tables["CodEspe"].Rows.Count; x++)
                        {
                            if (ds.Tables["CodEspe"].Rows[x][0].ToString() == comboBox1.SelectedItem.ToString())
                            {
                                consulta += ds.Tables["CodEspe"].Rows[x][1].ToString() + "'";
                            }
                        }

                        aq.cargaTabla("Materiasxcurso" + i, consulta, ref ds);
                    }

                    MessageBox.Show("Curso Creado.");
                    this.Close();
                }
                catch (Exception ex) { MessageBox.Show(ex.ToString()); }
            }
            else
            {
                MessageBox.Show(error);
            }
        }
Example #13
0
        private void bt_Aceptar_Click(object sender, EventArgs e)
        {
            try {
                int.Parse(tb_DNI.Text);
                if (tb_DNI.Text != string.Empty)
                {
                    if (listBox1.SelectedIndex >= 0)
                    {
                        switch (listBox1.Items[listBox1.SelectedIndex].ToString())
                        {
                        case "Comprobante de alumno regular.":
                            listBox1.SelectedIndex = 0;
                            analitico = true;

                            break;

                        case "Comprobante de Titulo en tramite.":
                            listBox1.SelectedIndex = 1;
                            analitico = true;

                            break;

                        case "Comprobante de Titulo legalizado.":
                            listBox1.SelectedIndex = 2;
                            analitico = true;


                            break;

                        case "No trajo comprobante.":
                            listBox1.SelectedIndex = 3;
                            analitico = false;

                            break;

                        case "vencido.":

                            break;

                        default:
                            listBox1.SelectedIndex = 3;
                            analitico = false;
                            break;
                        }



                        if (Tabla == 1)
                        {
                            fecha = DateTime.Parse(tb_Fecha.Text);

                            tb_Fecha.Text = fecha.ToString();


                            AccesoDatos aq = new AccesoDatos();

                            SqlCommand comando = new SqlCommand();

                            string codcurso = "";
                            try
                            {
                                codcurso = "select CodCurso from Cursos where actual =1";
                                AccesoDatos aff = new AccesoDatos();
                                aff.cargaTabla("5:35AM..", codcurso, ref ds);

                                codcurso = ds.Tables["5:35AM.."].Rows[0][0].ToString();
                            }
                            catch (Exception)
                            {
                                MessageBox.Show("No hay curso asignado como el actual");
                            }



                            try
                            {
                                comando = DatosSP.Inscriptos(ds.Tables["TablaSelecionado"].Rows[0][0].ToString(), int.Parse(tb_DNI.Text), textBox2.Text, textBox1.Text, codcurso, tb_Email.Text, tb_Telefono.Text, true
                                                             , analitico, cb_cuil.Checked, cb_Dni.Checked, cb_4x4.Checked, cb_ConstanciaTrabajo.Checked, fecha, tb_Observaciones.Text,
                                                             listBox1.Items[listBox1.SelectedIndex].ToString(), cb_naci.Checked, codespe(textBox3.Text));
                                aq.EjecutarProcedimientoAlmacenado(comando, "ModificarInscripto");

                                if (CursarCursoActual.Checked == true)
                                {
                                    string  asd = "select COUNT(legajo) from AlumnosxMateriasxCursos where legajo=" + saberlegajo(tb_DNI.Text) + "and codcurso=" + codcurso;
                                    DataSet dt  = new DataSet();
                                    aq.cargaTabla("queseyo222", asd, ref dt);
                                    if (dt.Tables["queseyo222"].Rows[0][0].ToString() == "0")
                                    {
                                        CargaCursoAcutal();
                                    }
                                }
                                MessageBox.Show("Alumno modificado correctamente");

                                apagar(1);
                                //this.Close();
                            }
                            catch (Exception ex)
                            {
                                //     az(ex.ToString());
                            }
                        }
                        else
                        {
                            AccesoDatos aq = new AccesoDatos();

                            SqlCommand comando = new SqlCommand();

                            DateTime fecha = new DateTime();
                            fecha         = DateTime.Today;
                            tb_Fecha.Text = fecha.ToString();
                            string codcurso = "";
                            int    error    = 0;
                            try
                            {
                                codcurso = "select CodCurso from Cursos where actual =1";
                                AccesoDatos aff = new AccesoDatos();
                                aff.cargaTabla("5:35AM..", codcurso, ref ds);

                                codcurso = ds.Tables["5:35AM.."].Rows[0][0].ToString();
                                error    = 1;

                                comando = DatosSP.Inscriptos(ds.Tables["TablaSelecionado"].Rows[0][0].ToString(), int.Parse(tb_DNI.Text), textBox2.Text, textBox1.Text, codcurso, tb_Email.Text, tb_Telefono.Text, true
                                                             , analitico,
                                                             cb_cuil.Checked, cb_Dni.Checked, cb_4x4.Checked, cb_ConstanciaTrabajo.Checked, fecha, tb_Observaciones.Text,
                                                             listBox1.Items[listBox1.SelectedIndex].ToString(), cb_naci.Checked, codespe(textBox3.Text));
                                // aq.EjecutarProcedimientoAlmacenado(comando, "ModificarInscripto");
                                aq.EjecutarProcedimientoAlmacenado(comando, "CargaInscripto");

                                if (CursarCursoActual.Checked == true)
                                {
                                    string  asd = "select COUNT(legajo) from AlumnosxMateriasxCursos where legajo=" + saberlegajo(tb_DNI.Text);
                                    DataSet dt  = new DataSet();
                                    aq.cargaTabla("queseyo222", asd, ref dt);
                                    if (dt.Tables["queseyo222"].Rows[0][0].ToString() == "0")
                                    {
                                        CargaCursoAcutal();
                                    }
                                }


                                MessageBox.Show("Alumno Inscripto correctamente.");
                                apagar(1);

                                //  this.Close();
                            }
                            catch (Exception ex)
                            {
                                if (error == 0)
                                {
                                    MessageBox.Show("No hay un curso asignado como el actual.");
                                }
                                else
                                {
                                    MessageBox.Show(ex.ToString());
                                }
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("Debe seleccionar un comprobante.");
                        textBox4.Visible = true;
                    }
                }
                else
                {
                    az("El campo DNI esta mal.");
                }
            }
            catch (Exception ex) {
                //     az(ex.ToString());
            }
        }