private void cargartablanotas() { String conexion = "Data Source=HANS-PC\\SQLEXPRESS2; Initial Catalog=universidad; integrated security=True"; SqlConnection cn = new SqlConnection(conexion); String consulta = "select Distinct e.nombre_estudiante, e.apellido, e.Id_estudiante, n.Nota, a.nombre, c.grupo from asignatura a, curso c, matricula m, estudiante e, Nota n where e.Id_estudiante=m.estudiante_id_estudiante and m.curso_id_curso=c.Id_curso and c.asignatura_id_asignatura=a.Id_asignatura and e.Id_estudiante=n.Id_estudiante"; SqlDataAdapter da = new SqlDataAdapter(consulta, cn); DataTable dt = new DataTable(); cn.Open(); int registro = da.Fill(dt); cn.Close(); GridNotas.DataSource = dt; GridNotas.DataBind(); }
private void bt_GerarPlanilha_Click(object sender, EventArgs e) { switch (Metodo) { case 1: //MAN-2164: Consulta de Titulos a Receber break; case 2: //MAN-2164: Consulta de Titulos a Pagar break; case 3: //MAN-2368: Consulta de Notas GridNotas notas = new GridNotas(); notas.ArqExcel = tb_PatchPadrao.Text; notas.CodCenCus = CodCenCus; notas.GeraCab = GeraCab; notas.IDConex = IdConex; notas.PastaUser = PastaUser; notas.PatchXml = PatchXML; notas.NomeRelat = "Grid Consulta de Notas"; notas.GeraPlanilha(); break; } //Verifica se Pode Abrir a Planilha. try { Excel.Application xlApp = new Excel.Application(); Excel.Workbook xlWorkBook; // = new Excel.Workbook(); Excel.Worksheet xlWorkSheet = new Excel.Worksheet(); xlWorkBook = xlApp.Workbooks.Open(tb_PatchPadrao.Text); xlApp.Visible = true; } catch (Exception) { MessageBox.Show("Não foi possível abrir a planilha Automáticamente!!! Deseja ver o Arquivo na Pasta?", "Controller ERP"); } }