private void btningresar_Click(object sender, EventArgs e) { try { if (dataGridView1.RowCount > 0) { DialogResult mensaje = MessageBox.Show("¿Ya ha revisado la informacion antes de Guardarla?", "SGA", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (mensaje == DialogResult.OK) { EplanClase pc = new EplanClase(); foreach (DataGridViewRow datos in dataGridView1.Rows) { pc.Asignatura.AsignaturaId = Convert.ToInt32(datos.Cells[0].Value); pc.Grado.GradoId = Convert.ToInt32(datos.Cells[2].Value); NPlanClase n = new NPlanClase(); n.IngresarPlanClase(pc); } MessageBox.Show("Plan de Clase Ingresado con exito", "SGA", MessageBoxButtons.OK, MessageBoxIcon.Information); Limpiar(); CargarPlanClase(); } } else { MessageBox.Show("No hay registro que guardar", "SGA", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception ex) { throw ex; } }
public List <EplanClase> ListaPlanClase() { try { comando = new SqlCommand("ListaPlandeClase", conexion); comando.CommandType = CommandType.StoredProcedure; conexion.Open(); List <EplanClase> lista = new List <EplanClase>(); SqlDataReader leer = comando.ExecuteReader(); while (leer.Read()) { EplanClase pc = new EplanClase(); pc.PlanClaseID = (int)leer[0]; pc.Asignatura.AsignaturaId = (int)leer[1]; pc.Asignatura.Asignatura = leer[2].ToString(); pc.Grado.GradoId = (int)leer[3]; pc.Grado.Grado = leer[4].ToString(); pc.CicloEscolar.ciclo = (int)leer[5]; lista.Add(pc); } leer.Close(); conexion.Close(); conexion.Dispose(); return(lista); } catch (Exception ex) { throw ex; } }
public void IngresarPlanClase(EplanClase pc) { try { DPlanClase d = new DPlanClase(); d.IngresarPlanClase(pc); } catch (Exception ex) { throw ex; } }
public void IngresarPlanClase(EplanClase pc) { try { comando = new SqlCommand("IngresarPlanClase"); comando.CommandType = CommandType.StoredProcedure; comando.Parameters.AddWithValue("@AsignaturaId", pc.Asignatura.AsignaturaId); comando.Parameters.AddWithValue("@GradoId", pc.Grado.GradoId); comando.Connection = conexion; conexion.Open(); comando.ExecuteNonQuery(); conexion.Close(); conexion.Dispose(); } catch (Exception ex) { throw ex; } }