Example #1
0
 private void modificarToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         String         rfc     = dataGridViewCreditos.CurrentRow.Cells[1].Value.ToString();
         CreditoAlumno  credito = control.consultarCreditoAlumno(rfc);
         CreditoAlumnos fa      = new CreditoAlumnos(credito, false);
         fa.FormClosed += new FormClosedEventHandler(form_Closed);
         fa.Show();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Example #2
0
 private void consultarCredito()
 {
     try
     {
         String         rfc     = dataGridViewCreditos.CurrentRow.Cells[1].Value.ToString();
         CreditoAlumno  credito = control.consultarCreditoAlumno(rfc);
         CreditoAlumnos fa      = new CreditoAlumnos(credito, true);
         fa.FormClosed += new FormClosedEventHandler(form_Closed);
         fa.Show();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Example #3
0
 private bool agregarCredito()
 {
     if (validarCampos())
     {
         cmbIDPrograma.SelectedIndex = cmbPrograma.SelectedIndex;
         cmbIDAlumno.SelectedIndex   = cmbAlumno.SelectedIndex;
         CreditoAlumno c = new CreditoAlumno();
         c.alumno = cmbIDAlumno.SelectedItem.ToString();
         c.cantidadMensualidad  = Convert.ToDouble(numMensualidad.Value);
         c.cantidadMeses        = Convert.ToInt32(numCantidad.Value);
         c.observaciones        = txtObservaciones.Text;
         c.cantidadAbonoCredito = varaux1;
         c.cantidadAbonoMensual = varaux2;
         c.estado = "Aprobado";
         if (modificacion)
         {
             c.alumno = cmbIDAlumno.SelectedItem.ToString();
             if (control.actualizarCredito(c))
             {
                 DocumentosWord word = new DocumentosWord(c);
                 return(true);
             }
             else
             {
                 throw new Exception("Error al actualizar los datos del credito");
             }
         }
         else
         {
             if (control.agregarCreditoAlumno(c))
             {
                 DocumentosWord word = new DocumentosWord(c);
                 return(true);
             }
             else
             {
                 throw new Exception("Error al agregar el credito");
             }
         }
     }
     else
     {
         MessageBox.Show("No deje ningun campo vacio");
     }
     return(false);
 }
Example #4
0
        public CreditoAlumnos(CreditoAlumno c, bool consultar)
        {
            InitializeComponent();
            control = ControlIicaps.getInstance();
            List <String> auxPrograma   = new List <string>();
            List <String> auxIDPrograma = new List <string>();
            List <String> auxAlumno     = new List <string>();
            List <String> auxIDAlumno   = new List <string>();

            lblFecha.Text = DateTime.Now.ToShortDateString();
            foreach (Programa p in control.obtenerProgramas())
            {
                auxPrograma.Add(p.Nombre);
                auxIDPrograma.Add(p.Codigo.ToString());
            }
            cmbIDPrograma.Items.AddRange(auxIDPrograma.ToArray());
            cmbPrograma.Items.AddRange(auxPrograma.ToArray());
            numCantidad.Enabled = false;
            if (c != null)
            {
                modificacion = true;
                cmbIDPrograma.SelectedItem = control.obtenerProgramaAlumno(c.alumno);
                cmbPrograma.SelectedIndex  = cmbIDPrograma.SelectedIndex;
                cmbIDAlumno.SelectedItem   = c.alumno;
                cmbAlumno.SelectedIndex    = cmbIDAlumno.SelectedIndex;
                numMensualidad.Value       = Convert.ToDecimal(c.cantidadMensualidad);
                numCantidad.Value          = c.cantidadMeses;
                txtObservaciones.Text      = c.observaciones;
                if (consultar)
                {
                    cmbPrograma.Enabled      = false;
                    cmbAlumno.Enabled        = false;
                    numMensualidad.Enabled   = false;
                    txtObservaciones.Enabled = false;
                    btnCalcular.Enabled      = false;
                }
            }
        }
Example #5
0
 private void darDeBajaToolStripMenuItem_Click(object sender, EventArgs e)
 {
     String         rfc     = dataGridViewCreditos.CurrentRow.Cells[1].Value.ToString();
     CreditoAlumno  credito = control.consultarCreditoAlumno(rfc);
     DocumentosWord word    = new DocumentosWord(credito);
 }
Example #6
0
        public DocumentosWord(CreditoAlumno credito)
        {
            control = ControlIicaps.getInstance();
            Microsoft.Office.Interop.Word.Application word = new Microsoft.Office.Interop.Word.Application();
            //Quitar animacion y visibilidad mientras se crea y edita
            word.ShowAnimation = false;
            word.Visible       = false;
            //Missing para rellenar parametros de creacion
            object missing = System.Reflection.Missing.Value;

            //Creacion del documento
            Microsoft.Office.Interop.Word.Document documento = word.Documents.Add(ref missing, ref missing, ref missing);
            //Agregar encabezado
            foreach (Microsoft.Office.Interop.Word.Section section in documento.Sections)
            {
                //Encabezado y configuracion
                Microsoft.Office.Interop.Word.Range headerRange = section.Headers[Microsoft.Office.Interop.Word.WdHeaderFooterIndex.wdHeaderFooterPrimary].Range;
                headerRange.Fields.Add(headerRange, Microsoft.Office.Interop.Word.WdFieldType.wdFieldPage);
                headerRange.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                HeaderFooter header = section.Headers[WdHeaderFooterIndex.wdHeaderFooterPrimary];
                header.Range.ParagraphFormat.SpaceAfter = 0;
                if (File.Exists(imgHeader1))
                {
                    header.Shapes.AddPicture(imgHeader1);
                }
            }
            //Agregar pie de pagina
            foreach (Microsoft.Office.Interop.Word.Section wordSection in documento.Sections)
            {
                //Pie de pagina y configuracion
                Microsoft.Office.Interop.Word.Range footerRange = wordSection.Footers[Microsoft.Office.Interop.Word.WdHeaderFooterIndex.wdHeaderFooterPrimary].Range;
                footerRange.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                HeaderFooter footer = wordSection.Footers[WdHeaderFooterIndex.wdHeaderFooterPrimary];
                footer.Range.ParagraphFormat.SpaceAfter = 50;
                if (File.Exists(imgFooter1))
                {
                    footer.Shapes.AddPicture(imgFooter1);
                }
            }
            //Agregar parrafo de texto con estilo de titulo 1
            Microsoft.Office.Interop.Word.Paragraph parra1 = documento.Content.Paragraphs.Add(ref missing);
            object styleHeading1 = "Título 1";

            parra1.Range.set_Style(ref styleHeading1);
            parra1.Range.Font.Color = WdColor.wdColorDarkGreen;
            parra1.Range.Font.Bold  = 1;
            parra1.Range.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphCenter;
            parra1.Range.Text = Environment.NewLine + Environment.NewLine + "CONTRATO DE CRÉDITO EDUCATIVO";
            parra1.Range.InsertParagraphAfter();
            //Parrafos restantes del documento
            Microsoft.Office.Interop.Word.Paragraph parra2 = documento.Content.Paragraphs.Add(ref missing);
            object style1 = "Normal";

            parra2.Range.set_Style(ref style1);
            parra2.Range.Font.Size  = 13;
            parra2.Format.Alignment = WdParagraphAlignment.wdAlignParagraphRight;
            //parra1.Range.Text = "Recibo de documentos para: " + control.obtenerProgramaAlumno(doc.alumno);
            parra2.Range.Text = "Los Mochis Sinaloa, " + DateTime.Now.ToLongDateString();
            parra2.Range.InsertParagraphAfter();
            Microsoft.Office.Interop.Word.Paragraph parra3 = documento.Content.Paragraphs.Add(ref missing);
            parra3.Range.set_Style(ref style1);
            parra3.Range.Font.Size = 12;
            parra3.Alignment       = WdParagraphAlignment.wdAlignParagraphJustify;
            parra3.Range.Text      = "Por medio de la presente autorizo la solicitud de crédito educativo a él(la) alumno(a) " + control.obtenerNombreAlumno(credito.alumno) +
                                     ", inscrita actualmente en el programa " + control.obtenerNombrePrograma(control.obtenerProgramaAlumno(credito.alumno)) + ".";
            parra3.Range.InsertParagraphAfter();
            Microsoft.Office.Interop.Word.Paragraph parra4 = documento.Content.Paragraphs.Add(ref missing);
            parra4.Range.set_Style(ref style1);
            parra4.Range.Font.Size = 12;
            parra4.Alignment       = WdParagraphAlignment.wdAlignParagraphJustify;
            parra4.Range.Text      = "Dicho crédito consistirá en pagar una colegiatura de $" + credito.cantidadMensualidad +
                                     " ($" + credito.cantidadAbonoMensual + " colegiatura + $" + credito.cantidadAbonoCredito + " costo del crédito) durante " + credito.cantidadMeses + " meses.";
            parra4.Range.InsertParagraphAfter();
            Microsoft.Office.Interop.Word.Paragraph parra5 = documento.Content.Paragraphs.Add(ref missing);
            parra5.Range.set_Style(ref style1);
            parra5.Range.Font.Size = 12;
            parra5.Alignment       = WdParagraphAlignment.wdAlignParagraphJustify;
            parra5.Range.Text      = "TERMINOS Y CONDICIONES." + Environment.NewLine +
                                     " Con base en el Art. 6  del reglamento de pagos del Instituto de Investigación, Capacitación y Psicoterapia " +
                                     "el alumno que cuenta con el crédito educativo pagará la cantidad que indique el documento: ´´CONTRATO DE CREDITO EDUCATIVO´´ " +
                                     "firmado por el Director de la institución y sellado." + Environment.NewLine +
                                     " El crédito necesita ser autorizado por el director de la institución. Este será vigente cuando el " +
                                     "cumplimiento del pago sea puntual, es decir, del día primero al último del mes que corresponde la mensualidad." + Environment.NewLine +
                                     "Si el tiempo de puntualidad del pago se ve vencido, el CREDITO EDUCATIVO quedará anulado, siendo necesario liquidar " +
                                     "la diferencia del total de las mensualidades que el alumno pagó con el crédito educativo para ingresar de nuevo a los " +
                                     "módulos programados del programa en el que está inscrito." + Environment.NewLine +
                                     "Cualquier prórroga deberá ser solicitada durante el mes vigente del pago en el departamento de " +
                                     "Administración Escolar del Instituto, y esta necesita ser solicitada y autorizada por escrito." + Environment.NewLine;
            parra5.Range.InsertParagraphAfter();
            //var ptable = documento.Paragraphs.Add();
            //ptable.Format.SpaceAfter = 10f;
            //Microsoft.Office.Interop.Word.Table table1 = documento.Tables.Add(parra5.Range, 3, 3, ref missing, ref missing);
            //int r, c;
            //for (r = 0; r < 3; r++)
            //{
            //    for (c = 0; c < 3; c++)
            //    {
            //        if (r == 0 && c == 0 || r == 0 && c == 2)
            //            table1.Cell(r, c).Range.Text = "__________________________________";
            //        if (r == 1 && c == 0)
            //            table1.Cell(r, c).Range.Text = "Jesús Mario Mancillas Peñuelas";
            //        if (r == 1 && c == 2)
            //            table1.Cell(r, c).Range.Text = control.obtenerNombreAlumno(credito.alumno);
            //        if (r == 2 && c == 0)
            //            table1.Cell(r, c).Range.Text = "Director";
            //        if (r == 1 && c == 2)
            //            table1.Cell(r, c).Range.Text = "Alumno(a)";
            //    }
            //}
            //table1.Columns[0].Width = word.InchesToPoints(2);
            //table1.Columns[1].Width = word.InchesToPoints(1);
            //table1.Columns[2].Width = word.InchesToPoints(2);
            //table1.AllowAutoFit = true;
            Microsoft.Office.Interop.Word.Paragraph parra6 = documento.Content.Paragraphs.Add(ref missing);
            parra6.Range.set_Style(ref style1);
            parra6.Range.Font.Size = 12;
            parra6.Alignment       = WdParagraphAlignment.wdAlignParagraphCenter;
            parra6.Range.Text      = "______________________________           ______________________________" + Environment.NewLine +
                                     "Jesús Mario Mancillas Peñuelas           " + control.obtenerNombreAlumno(credito.alumno) + Environment.NewLine +
                                     "           Director                                 Alumno" + Environment.NewLine;
            parra6.Range.InsertParagraphAfter();
            //Hacemos visible el documento
            word.Visible = true;
            //Guardamos el documento
            string path     = Directory.GetCurrentDirectory() + @"\Documentos";
            object filename = Directory.GetCurrentDirectory() + @"\Documentos\ContratoCreditoEducativo" + credito.alumno;

            // comprobar si el fichero ya existe
            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            documento.SaveAs2(ref filename);
            //documento.Close(ref missing, ref missing, ref missing);
            //documento = null;
            //word.Quit(ref missing, ref missing, ref missing);
            //word = null;
            MessageBox.Show("¡Contrato de crédito educativo creado exitosamente!");
        }