Ejemplo n.º 1
0
        private void button3_Click(object sender, EventArgs e)
        {
            Dictionary <string, int> DiasDeCurso = clase.RetriveDays(profesor);
            AllDayMinClass           resp        = new AllDayMinClass();

            foreach (var dia in DiasDeCurso)
            {
                DayMinClase diaSpecific = new DayMinClase(dia.Key, dia.Value, dateTimePicker1.Value.Month);
                MessageBox.Show(dia.Key);
                MessageBox.Show(dia.Value.ToString());

                resp.add(diaSpecific);
                foreach (var diar in resp.dias)
                {
                    foreach (var sarasas in diar.Dias)
                    {
                        MessageBox.Show(sarasas.ToString());
                    }
                }
            }
        }
Ejemplo n.º 2
0
        //HACER EL IMPRIME TODAS LAS LISTAS DE TODAS LAS CLASES
        private void button3_Click_2(object sender, EventArgs e)
        {
            var    mes       = dateTimePicker1.Value.Month;
            string monthName = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(mes);

            string direccion = string.Empty;
            FolderBrowserDialog folderBrowser = new FolderBrowserDialog();
            DialogResult        result        = folderBrowser.ShowDialog();

            if (result == DialogResult.OK)
            {
                direccion = folderBrowser.SelectedPath;
            }
            if (MessageBox.Show("Desea Imprimir la Lista de Alumnos de Todas las Clases de " + monthName + "?", "Confirmar", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                foreach (var profesor in profesores)
                {
                    Clase auxClase = new Clase();
                    auxClase.Profesor = profesor;
                    auxClase.getClases(profesor);
                    foreach (var clase in auxClase.Clases)
                    {
                        string save = DateTime.Now.ToString("yyyy ") + monthName + " " + clase + " " + profesor;
                        auxClase.getAlumnoForList(profesor, clase);

                        object            misValue = System.Reflection.Missing.Value;
                        Excel.Application xlApp    = new Excel.Application();
                        Excel.Workbook    xlWorkbook;
                        Excel._Worksheet  xlWorksheet;
                        if (!System.IO.File.Exists(save))
                        {
                            xlWorkbook  = xlApp.Workbooks.Add(misValue);
                            xlWorksheet = (Excel.Worksheet)xlWorkbook.Worksheets.get_Item(1);
                            Excel.Range xlRange  = xlWorksheet.UsedRange;
                            int         rowCount = xlRange.Rows.Count;

                            //Titulos Grandes
                            xlRange.Cells[2, "A"] = "Profesor: " + profesor;
                            xlRange.Cells[2, "C"] = "Curso: " + clase;
                            xlRange.Cells[1, "H"] = DateTime.Now.ToString("yyyy ") + monthName;

                            //Titulos Lista
                            xlRange.Cells[4, "B"] = "Nombre y Apellido";
                            xlRange.Cells[4, "C"] = "Pago";



                            Dictionary <string, int> DiasDeCurso = auxClase.RetriveDays(profesor);

                            string         First = string.Empty;
                            AllDayMinClass resp  = new AllDayMinClass();
                            foreach (var dia in DiasDeCurso)
                            {
                                DayMinClase diaSpecific = new DayMinClase(dia.Key, dia.Value, dateTimePicker1.Value.Month);
                                resp.add(diaSpecific);
                            }
                            int start    = 8;
                            int cantDias = resp.getWholeDays();
                            while (resp.Any())
                            {
                                int         amountBefore = start;
                                DayMinClase aux          = resp.getMin();
                                start += aux.CantidadDeClasesPorDia;
                                foreach (var specificDay in aux.Dias)
                                {
                                    xlRange.Cells[3, amountBefore] = aux.Day;
                                    xlRange.Cells[4, amountBefore] = specificDay;

                                    /*xlWorksheet.Range[xlWorksheet.Cells[4, (letter + amountBefore)], xlWorksheet.Cells[4, (letter + amountBefore + aux.CantidadDeClasesPorDia)]].Merge();
                                     */
                                    amountBefore += cantDias;
                                }
                            }

                            int countAlumnos = 1;
                            int place        = countAlumnos + 4;

                            foreach (var alumno in auxClase.Alumnos)
                            {
                                xlRange.Cells[place, "A"] = countAlumnos.ToString();
                                xlRange.Cells[place, "B"] = alumno;
                                place++;
                                countAlumnos++;
                            }

                            xlRange.Cells[place + 5, "A"] = "Cantidad Total de Alumnos";
                            xlRange.Cells[place + 6, "A"] = "Firma del Profesor";

                            xlWorksheet.Range[xlWorksheet.Cells[4, "C"], xlWorksheet.Cells[4, "G"]].Merge();
                            xlWorksheet.Range[xlWorksheet.Cells[place + 5, "A"], xlWorksheet.Cells[place + 5, "G"]].Merge();
                            xlWorksheet.Range[xlWorksheet.Cells[place + 6, "A"], xlWorksheet.Cells[place + 6, "G"]].Merge();

                            xlWorksheet.Range[xlWorksheet.Cells[1, "A"], xlWorksheet.Cells[3, "B"]].Merge();
                            xlWorksheet.Range[xlWorksheet.Cells[1, "C"], xlWorksheet.Cells[3, "G"]].Merge();


                            xlWorksheet.Columns[2].ColumnWidth = 20;
                            for (var i = 3; i < 35; i++)
                            {
                                if (i < 8)
                                {
                                    xlWorksheet.Columns[i].ColumnWidth = 5;
                                }
                                else
                                {
                                    xlWorksheet.Columns[i].ColumnWidth = 3.5;
                                }
                            }



                            /*
                             * xlWorksheet.Range[xlWorksheet.Cells[place + 5, "A"], xlWorksheet.Cells[3, "G"]].Merge();
                             * xlWorksheet.Range[xlWorksheet.Cells[place + 6, "A"], xlWorksheet.Cells[3, "G"]].Merge();*/



                            /*xlWorksheet.Range[xlWorksheet.Cells[1, "H"], xlWorksheet.Cells[1, 8 + resp.getTotalDays()]].Merge();
                             * xlWorksheet.Range[xlWorksheet.Cells[1, "H"], xlWorksheet.Cells[1, 8 + resp.getTotalDays()]].Font.Bold = true;
                             * xlWorksheet.Range[xlWorksheet.Cells[2, "C"], xlWorksheet.Cells[2, "G"]].Merge();
                             *
                             * xlWorksheet.Range[xlWorksheet.Cells[2, "C"], xlWorksheet.Cells[2, "D"]].Merge();
                             * xlWorksheet.Range[xlWorksheet.Cells[4, "A"], xlWorksheet.Cells[place + 6, resp.getTotalDays()]].Borders.Weight = Excel.XlBorderWeight.xlMedium;
                             * xlWorksheet.Range[xlWorksheet.Cells[1, "H"], xlWorksheet.Cells[place + 6, resp.getTotalDays()]].Borders.Weight = Excel.XlBorderWeight.xlMedium;
                             */

                            xlWorkbook.SaveAs(direccion + "\\" + save + ".xlsx");
                            xlWorkbook.Close();
                            xlApp.Quit();

                            Marshal.ReleaseComObject(xlWorksheet);
                            Marshal.ReleaseComObject(xlWorkbook);
                            Marshal.ReleaseComObject(xlApp);
                        }
                    }
                }
            }
        }