Esempio n. 1
0
        public void cargarnota(int cell, int row)
        {
            if (sabercodmateria(dataGridView1.Columns[cell].HeaderText) != "")
            {
                string     codmate = sabercodmateria(dataGridView1.Columns[cell].HeaderText);
                string     codespe = "001";
                SqlCommand comando = new SqlCommand();

                DatosSP.Notasp(ref comando, codcurso, codmate, codespe, dataGridView1.Rows[row].Cells[cell].Value.ToString(), int.Parse(dataGridView1.Rows[row].Cells[0].Value.ToString()));
                aq.ConfigurarProcedure(ref comando, "UpdateNotas2");
                comando.Connection = aq.ObtenerConexion();

                SqlDataReader reader = comando.ExecuteReader();

                while (reader.Read())
                {
                }
            }
        }
Esempio n. 2
0
        private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            int row  = dataGridView1.CurrentRow.Index;
            int cell = dataGridView1.CurrentCell.ColumnIndex;

            try
            {
                if (dataGridView1.Columns[cell].HeaderText.Contains("Parcial") == true || dataGridView1.Columns[cell].HeaderText.Contains("Recuper"))
                {
                    if (int.Parse(dataGridView1.Rows[row].Cells[cell].Value.ToString()) <= 10 &&
                        int.Parse(dataGridView1.Rows[row].Cells[cell].Value.ToString()) >= 0)
                    {
                        SqlCommand comando = new SqlCommand();
                        // MessageBox.Show(dataGridView1.Columns[cell].HeaderText);
                        DatosSP.Notasp(ref comando, codcurso, codmateria, codespe, dataGridView1.Rows[row].Cells[cell].Value.ToString(), int.Parse(dataGridView1.Rows[row].Cells[0].Value.ToString()));
                        DatosSP.Notas_tiponota(ref comando, dataGridView1.Columns[cell].HeaderText);
                        aq.ConfigurarProcedure(ref comando, "updatenotaparciales");
                        comando.Connection = aq.ObtenerConexion();

                        SqlDataReader reader = comando.ExecuteReader();

                        while (reader.Read())
                        {
                        }
                    }
                    else
                    {
                        az("Recuerde que las notas deben ser del 0 al 10, las notas que no cumplan esa regla no seran guardadas.");
                    }
                }
            }
            catch (Exception) { MessageBox.Show("Solo se permiten numeros en esa celda."); }

            bool guardarNotaf = true;

            //if (dataGridView1.Columns[cell].HeaderText.Contains("Nota Final") == true) {
            //    if (int.Parse(dataGridView1.Rows[row].Cells[cell].Value.ToString()) > 10 ||
            //    int.Parse(dataGridView1.Rows[row].Cells[cell].Value.ToString()) < 0) {
            //        guardarNotaf = false;
            //        az("Recuerde que las notas deben ser del 0 al 10, las notas que no cumplan esa regla no seran guardadas.");
            //    }
            //}
            if (dataGridView1.Columns[cell].HeaderText.Contains("Nota Final") == true)
            {
                if (dataGridView1.Rows[row].Cells[cell].Value.ToString() == "EQUIVALENCIA" ||
                    dataGridView1.Rows[row].Cells[cell].Value.ToString() == "equivalencia")

                {
                    // cargarnota(cell, row);
                    guardarNotaf = true;
                }
                else
                {
                    try {
                        if (int.Parse(dataGridView1.Rows[row].Cells[cell].Value.ToString()) <= 10 &&
                            int.Parse(dataGridView1.Rows[row].Cells[cell].Value.ToString()) >= 0)
                        {
                            //  cargarnota(cell, row);
                            guardarNotaf = true;
                        }
                        else
                        {
                            az("Recuerde que las notas van del 0 al 10");
                        }
                    } catch (Exception) {
                        az("Recuerde que las notas van del 0 al 10, o equivalencia/EQUIVALENCIA.");
                    }
                }
            }
            if (dataGridView1.Columns[cell].HeaderText == "Modalidad")
            {
                if (dataGridView1.Rows[row].Cells[cell].Value.ToString().ToUpper() != "PRESENCIAL" && dataGridView1.Rows[row].Cells[cell].Value.ToString().ToUpper() != "LIBRE")
                //|| dataGridView1.Rows[row].Cells[cell].Value.ToString() != "LIBRE")
                {
                    guardarNotaf = false;
                    az("Las modalidades tienen que ser: PRESENCIAL  o  LIBRE");
                }
                else
                {
                }
            }
            if (dataGridView1.Columns[cell].HeaderText == "Turno")
            {
                if (dataGridView1.Rows[row].Cells[cell].Value.ToString() == "NOCHE" ||
                    dataGridView1.Rows[row].Cells[cell].Value.ToString() == "MAÑANA" ||
                    dataGridView1.Rows[row].Cells[cell].Value.ToString() == "noche" ||
                    dataGridView1.Rows[row].Cells[cell].Value.ToString() == "mañana")
                {
                }
                else
                {
                    guardarNotaf = false;
                    az("El turno tiene que ser: NOCHE o MAÑANA");
                }
            }

            if (cargadedatosok == true)
            {
                if (guardarNotaf == true)
                {
                    try
                    {
                        /*
                         * if (int.Parse(dataGridView1.Rows[row].Cells[cell].Value.ToString()) <= 10 &&
                         * int.Parse(dataGridView1.Rows[row].Cells[cell].Value.ToString()) > 0)
                         * {
                         */

                        SqlCommand comando = new SqlCommand();



                        try {
                            //   int.Parse(dataGridView1.Rows[row].Cells["Legajo"].Value.ToString()),
                            DatosSP.Notas(ref comando, codcurso, codmateria, codespe,
                                          dataGridView1.Rows[row].Cells["Nota Final"].Value.ToString(),
                                          int.Parse(dataGridView1.Rows[row].Cells["Legajo"].Value.ToString()),
                                          dataGridView1.Rows[row].Cells["Modalidad"].Value.ToString(),
                                          dataGridView1.Rows[row].Cells["Turno"].Value.ToString()

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

                            SqlDataReader reader = comando.ExecuteReader();

                            while (reader.Read())
                            {
                            }
                        }
                        catch (Exception) {
                            DatosSP.Notas(ref comando, codcurso, codmateria, codespe,
                                          dataGridView1.Rows[row].Cells["Nota Final"].Value.ToString(),
                                          int.Parse(dataGridView1.Rows[row].Cells["Legajo"].Value.ToString()),
                                          dataGridView1.Rows[row].Cells["Modalidad"].Value.ToString(),
                                          dataGridView1.Rows[row].Cells["Turno"].Value.ToString()

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

                            SqlDataReader reader = comando.ExecuteReader();

                            while (reader.Read())
                            {
                            }
                        }
                    }
                    catch (Exception ex) {
                        // az(ex.ToString());
                    }
                }
            }
        }