public void Insert(int folio, string cuenta, string nombre, float calificacion) { try { e_calificaciones cal = new e_calificaciones { folio = folio, cuenta = cuenta, nombre = nombre, calificacion = calificacion }; new cn_calificaciones().Insertar(cal); Console.Write("Calificacion Registrada"); } catch { Console.Write("No se pudo registrar la calificacion"); } /*string constr = ConfigurationManager.ConnectionStrings["constr"].ConnectionString; * using (SqlConnection con = new SqlConnection(constr)) * { * using (SqlCommand cmd = new SqlCommand("INSERT INTO Customers (Name, Country) VALUES (@Name, @Country)")) * { * cmd.Parameters.AddWithValue("@Name", name); * cmd.Parameters.AddWithValue("@Country", country); * cmd.Connection = con; * con.Open(); * cmd.ExecuteNonQuery(); * con.Close(); * } * }*/ }
//metodo para insertar un folio de extraordinarios public int Insertar_extra(e_calificaciones cal) { try { using (this.contexto = new DataClassesTrayectoriaDataContext()) { return(contexto.ins_calificacion_extra(cal.folio, cal.cuenta, cal.nombre, cal.calificacion)); } } catch (Exception error) { throw error; } }
//metodo para guardar cada una de las calificaciones en el datagridview private void GuardarCaificaciones() { string[] datos = new string[3]; e_calificaciones cal = new e_calificaciones(); cal.folio = int.Parse(txt_folio.Text); try { for (int i = 0; i < dgvAlumnos.Items.Count - 1; i++) { for (int j = 0; j < dgvAlumnos.Columns.Count - 3; j++) { //loop throught cell DataGridCell cell = GetCell(i, j); TextBlock tb = cell.Content as TextBlock; //MessageBox.Show(tb.Text); //cachamos los valores de las celdas datos[j] = tb.Text; } if (datos[2] != "") { cal.cuenta = datos[0]; cal.nombre = datos[1]; cal.calificacion = double.Parse(datos[2]); //insertamos en la base de datos new cn_calificaciones().Insertar_extra(cal); } } //limpiamos los textbox txt_folio.Text = ""; txt_cohorte.Text = ""; txt_periodo.Text = ""; txt_grupo.Text = ""; txt_fecha.Text = ""; //combo_carrera.SelectedIndex = -1; //combo_materia.SelectedIndex = -1; //combo_profesor.SelectedIndex = -1; dgvAlumnos.ItemsSource = null; dgvAlumnos.Items.Clear(); dgvAlumnos.Items.Refresh(); //dgvAlumnos. } catch (Exception e) { MessageBox.Show(e.Message); } }