Пример #1
0
 private void GuardarButton_Click(object sender, EventArgs e)
 {
     try
     {
         if (accion == "nuevo")
         {
             if (Consultas.devolverUnEntero("select count(NumDiplomado) as n from Diplomados where NumDiplomado = " + NumeroDiplomadoTextBox.Text + "") != 0)
             {
                 MessageBox.Show("El numero de Diplomado Ya esta registrado en la Base de Datos", "Elige Otro Numero de Diplomado", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 return;
             }
             Consultas.HacerConsulta("insert into Diplomados (NumDiplomado, NombreDiplomado) values (" + Convert.ToInt32(NumeroDiplomadoTextBox.Text) + ",'" + NombreDiplomadoTextBox.Text + "')");
             Consultas.comando.ExecuteNonQuery();
             llenartabla();
         }
         else
         {
             Consultas.HacerConsulta("update Diplomados set NombreDiplomado = '" + NombreDiplomadoTextBox.Text + "' where NumDiplomado = " + NumeroDiplomadoTextBox.Text + "");
             Consultas.comando.ExecuteNonQuery();
             llenartabla();
         }
         JuegoBotones();
         panelDatos.Enabled    = false;
         dataGridView1.Enabled = true;
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error al guardar en Registrar Diplomados......" + ex);
     }
 }
Пример #2
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (textBox3.Text == "")
            {
                MessageBox.Show("El valor Pagado no puede estar en blanco");
                return;
            }

            if (MessageBox.Show("Esta seguro que la persona con cedula " + dataGridView1.CurrentRow.Cells[0].Value.ToString() + " ha pagado el diplomado?", "¿ Esta seguro ?", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK)
            {
                return;
            }

            int    idPersona = 0, idDiplomado = 0, idDiplo_Cursos = 0;
            string codigoAsesor = "";

            if (dataGridView1.Rows.Count > 0)
            {
                if (dataGridView1.CurrentRow.Cells[0].Value.ToString() == "" || dataGridView1.CurrentRow.Cells[1].Value.ToString() == "" || dataGridView1.CurrentRow.Cells[2].Value.ToString() == "")
                {
                    MessageBox.Show("alguno de los datos esta incompleto");
                    return;
                }
                idPersona   = Consultas.devolverUnEntero("select IdPersonaRegistrada as n from Persona_Registrada where Identificacion = '" + dataGridView1.CurrentRow.Cells[0].Value.ToString() + "'");
                idDiplomado = Consultas.devolverUnEntero("select NumDiplomado as n from Diplomados where NombreDiplomado = '" + dataGridView1.CurrentRow.Cells[2].Value.ToString() + "'");
            }

            else
            {
                MessageBox.Show("No se encuentran estudiantes para el pago");
                return;
            }
            Consultas.HacerConsulta("select * from Diplo_Cursos where IdDiplomado = " + idDiplomado + " and IdPersonaRegistrada = " + idPersona + "");
            Consultas.lector = Consultas.comando.ExecuteReader();
            while (Consultas.lector.Read())
            {
                codigoAsesor   = Consultas.lector["CodAsesor"].ToString();
                idDiplo_Cursos = Convert.ToInt32(Consultas.lector["IdDiplo_Cursos"].ToString());
            }

            int    contarPersonaRegistrada = Consultas.devolverUnEntero("select count(*) as n from Diplo_Cursos where IdPersonaRegistrada = " + Consultas.DevolverUnString("select IdPersonaRegistrada as n from Persona_Registrada where Identificacion = '" + dataGridView1.CurrentRow.Cells[0].Value.ToString() + "'") + "");
            double comisionAsesor          = (contarPersonaRegistrada == 1) ? primeraVenta : SegundaVenta;

            if (codigoAsesor == "")
            {
                Consultas.HacerConsulta("Insert into Diplomado_Pagado (IdDiplomado,IdPersonaRegistrada,FechaPagoAsesor,Observacion,ValorDiplomado) values (" + idDiplomado + "," + idPersona + ",'" + DateTime.Now.ToString("yyyy-MM-dd") + "','" + textBox2.Text + "'," + textBox3.Text + ")");
                Consultas.comando.ExecuteNonQuery();
            }
            else
            {
                Consultas.HacerConsulta("Insert into Diplomado_Pagado (IdDiplomado,IdPersonaRegistrada,CodigoAsesor,FechaPagoAsesor,Observacion,ValorDiplomado,ComisionAsesor) values (" + idDiplomado + "," + idPersona + "," + codigoAsesor + ",'" + DateTime.Now.ToString("yyyy-MM-dd") + "','" + textBox2.Text + "'," + textBox3.Text + "," + comisionAsesor + ")");
                Consultas.comando.ExecuteNonQuery();
            }
            Consultas.HacerConsulta("Update Diplo_Cursos SET Pagado = 'true' where IdDiplo_Cursos = " + idDiplo_Cursos + "");
            Consultas.comando.ExecuteNonQuery();
            dataGridView1.DataSource = Consultas.devolverTabla("SELECT dbo.Persona_Registrada.Identificacion, CONCAT (dbo.Persona_Registrada.PNombre,' ',dbo.Persona_Registrada.SNombre,' ',dbo.Persona_Registrada.PApellido,' ',dbo.Persona_Registrada.SApellido) as NombreCompleto , dbo.Diplomados.NombreDiplomado FROM  dbo.Diplo_Cursos INNER JOIN                          dbo.Diplomados ON dbo.Diplo_Cursos.IdDiplomado = dbo.Diplomados.NumDiplomado INNER JOIN                          dbo.Persona_Registrada ON dbo.Diplo_Cursos.IdPersonaRegistrada = dbo.Persona_Registrada.IdPersonaRegistrada WHERE        (dbo.Diplo_Cursos.Pagado = 'False')");
            limpiar();
        }
Пример #3
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("¿ Desea Guardar los Cambios ?", "GUARDAR", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
     {
         if (Consultas.devolverUnEntero("select count(*) as n from configurar") > 0)
         {
             Consultas.HacerConsulta("update configurar set RangoPago = " + textBoxRangoPago.Text + ", ValorDiplomado=" + textBoxValorDiplomado.Text + ", primeraVenta=" + textBoxComisionPrimeraVez.Text + ", SegundaVenta=" + textBoxComisionMasDeUnaVenta.Text + "");
             Consultas.comando.ExecuteNonQuery();
         }
         else
         {
             Consultas.HacerConsulta("insert into configurar (RangoPago,ValorDiplomado,primeraVenta, SegundaVenta) values (" + textBoxRangoPago.Text + ", " + textBoxValorDiplomado.Text + ", " + textBoxComisionPrimeraVez.Text + "," + textBoxComisionMasDeUnaVenta.Text + ")");
             Consultas.comando.ExecuteNonQuery();
         }
     }
     this.Close();
 }
Пример #4
0
        public void NewOrUpdate(string boton)
        {
            NuevoButton.Enabled    = false;
            GuardarButton.Enabled  = true;
            CancelarButton.Enabled = true;
            EditarButton.Enabled   = false;
            EliminarButton.Enabled = false;
            BuscarButton.Enabled   = false;

            if (boton == "nuevo")
            {
                accion = "nuevo";
                panelDatos2.Enabled = true;
                panelDatos3.Enabled = true;
                LimpiarCampos();
                Boolean log = true;
                string  cod = "";
                while (log)
                {
                    log = true;
                    cod = generarNumero();
                    if (Consultas.devolverUnEntero("select count(*) as n from Asesores where CodAsesor = " + cod + "") > 0)
                    {
                        log = true;
                    }
                    else
                    {
                        log = false;
                    }
                }
                CodigoAsesorTextBox.Text = cod;
            }
            else
            {
                accion = "editar";
                panelDatos2.Enabled         = true;
                panelDatos3.Enabled         = true;
                CodigoAsesorTextBox.Enabled = false;
            }
        }
Пример #5
0
        private void GuardarButton_Click(object sender, EventArgs e)
        {
            try
            {
                //Se validan los campos
                if (!validarCampos())
                {
                    return;
                }
                if (accion == "nuevo")
                {
                    if (Consultas.devolverUnEntero("select count(Identificacion) as n from Persona_Registrada where Identificacion = " + IdentificacionTextBox.Text + "") != 0)
                    {
                        MessageBox.Show("la cedula Ya se encuentra Registrada en la Base de Datos", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    Consultas.HacerConsulta("insert into Persona_Registrada (genero,PNombre,SNombre,PApellido,SApellido,Identificacion,Pais,Ciudad,Direccion,Telefono,Correo,Estado) values ('" + GeneroComboBox.Text + "','" + PrimerNombreTextBox.Text + "','" + SegundoNombreTextBox.Text + "','" + PrimerApellidoTextBox.Text + "','" + SegundoApellidoTextBox.Text + "','" + IdentificacionTextBox.Text + "','" + PaisTextBox.Text + "','" + CiudadTextBox.Text + "','" + DireccionTextBox.Text + "','" + celular1TextBox.Text + "','" + CorreoTextBox.Text + "','" + EstadoComboBox.Text + "');");
                    Consultas.comando.ExecuteNonQuery();
                    MessageBox.Show("Se ha Creado El Asesor Correctamente", "Felicitaciones", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    Consultas.HacerConsulta("update Persona_Registrada set genero = '" + GeneroComboBox.Text + "', PNombre = '" + PrimerNombreTextBox.Text + "', SNombre = '" + SegundoNombreTextBox.Text + "', PApellido = '" + PrimerApellidoTextBox.Text + "', SApellido = '" + SegundoApellidoTextBox.Text + "', Pais = '" + PaisTextBox.Text + "', Ciudad = '" + CiudadTextBox.Text + "', Direccion = '" + DireccionTextBox.Text + "', Telefono = '" + celular1TextBox.Text + "', Correo = '" + CorreoTextBox.Text + "', Estado = '" + EstadoComboBox.Text + "' where  Identificacion = '" + IdentificacionTextBox.Text + "'");
                    Consultas.comando.ExecuteNonQuery();
                    MessageBox.Show("Se ha Modificado El Asesor Correctamente", "Felicitaciones", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }

                panelDatos2.Enabled = false;
                panelDatos3.Enabled = false;
                CancelarButton_Click(sender, e);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error al guardar en Registrar Asesores......" + ex);
            }
        }
Пример #6
0
        private void CertificarButton_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("¿ Esta seguro que el estudiante " + dataGridView1.CurrentRow.Cells[4].Value.ToString() + " con la cedula " + dataGridView1.CurrentRow.Cells[3].Value.ToString() + " se Certificó ?", "ATENCION", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
            {
                try
                {
                    string NombreEstudiante    = dataGridView1.CurrentRow.Cells[4].Value.ToString();
                    string cedulaEstudiante    = dataGridView1.CurrentRow.Cells[3].Value.ToString();
                    string DiplomadoEstudiante = dataGridView1.CurrentRow.Cells[5].Value.ToString();
                    string idDiploPagado       = dataGridView1.CurrentRow.Cells[0].Value.ToString();

                    Consultas.HacerConsulta("update Diplomado_pagado set Estado = 'Certificado' , FechaEstado='" + DateTime.Now.ToString("yyyy-MM-dd") + "' where IdDiploPagado = " + idDiploPagado + "");
                    Consultas.comando.ExecuteNonQuery();

                    int UltimoNumActa = Consultas.devolverUnEntero("select Max(NumConsecutivo) as n from LibroActa");
                    if (UltimoNumActa == 0)
                    {
                        UltimoNumActa = Consultas.devolverUnEntero("select UltimoRegistro as n from UltimoRegistro") + 1;
                    }
                    else
                    {
                        UltimoNumActa++;
                    }

                    string NumActa = "DI" + Convert.ToDateTime(Consultas.DevolverUnString("select FechaEstado as n from Diplomado_pagado where IdDiploPagado = '" + idDiploPagado + "'")).ToString("ddMMyyyy") + UltimoNumActa;

                    int ultimoIdActa = Consultas.InsertDevovliendoId("insert into LibroActa (IdPersonaRegistrada,IdDiplomado,FechaCreated,NumConsecutivo,NumActa) "
                                                                     + "values (" + dataGridView1.CurrentRow.Cells[2].Value.ToString() + "," + dataGridView1.CurrentRow.Cells[1].Value.ToString() + ",'" + DateTime.Now.ToString("yyyy-MM-dd") + "',1,'" + NumActa + "')");

                    Consultas.HacerConsulta("update LibroActa set NumConsecutivo = " + (UltimoNumActa) + " where IdLibroActa = " + ultimoIdActa);
                    Consultas.comando.ExecuteNonQuery();

                    Consultas.HacerConsulta("update Diplomado_pagado set IdLibroActa = " + ultimoIdActa + " where IdDiploPagado = " + idDiploPagado);
                    Consultas.comando.ExecuteNonQuery();

                    ReportParameter NombreCompleto = new ReportParameter("NombreCompleto", NombreEstudiante.ToUpper().Trim());
                    ReportParameter Cedula         = new ReportParameter("Cedula", cedulaEstudiante.ToString());
                    //ReportParameter NumeroActa = new ReportParameter("NumeroActa", " DI2018070180".ToUpper().Trim());
                    ReportParameter NumeroActa = new ReportParameter("NumeroActa", NumActa.ToUpper().Trim());
                    //ReportParameter Diplomado = new ReportParameter("Diplomado", " INCLUSION EDUCATIVA EN LOS AMBIENTES DE APRENDIZAJE ".ToUpper().Trim());
                    ReportParameter Diplomado = new ReportParameter("Diplomado", DiplomadoEstudiante.ToUpper().Trim());

                    string Mes   = MonthName(DateTime.Now.Month);
                    string dia   = DateTime.Now.ToString("dd");
                    string año   = DateTime.Now.ToString("yyyy");
                    string fecha = Mes + " " + dia + " del " + año;

                    ReportParameter Fecha = new ReportParameter("Fecha", fecha.Trim());
                    this.reportViewer1.LocalReport.SetParameters(new ReportParameter[] { NombreCompleto, Cedula, NumeroActa, Diplomado, Fecha });

                    this.reportViewer1.RefreshReport();

                    byte[] pdfContent = reportViewer1.LocalReport.Render("PDF");

                    string path = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\Diplomas_Grupo_Colombiano";

                    if (!Directory.Exists(path))
                    {
                        DirectoryInfo di = Directory.CreateDirectory(path);
                    }
                    // Generar el archivo PDF
                    string pdfPath = path + @"\" + cedulaEstudiante + "-" + NumActa + ".pdf";
                    System.IO.FileStream pdfFile = new System.IO.FileStream(pdfPath, System.IO.FileMode.Create);
                    pdfFile.Write(pdfContent, 0, pdfContent.Length);
                    pdfFile.Close();

                    CargarTabla();
                    notifyIcon1.Visible = true;
                    notifyIcon1.ShowBalloonTip(400);
                }
                catch (Exception)
                {
                    throw;
                }
            }
        }