예제 #1
0
        private void butAprobarSolicutud_Click(object sender, EventArgs e)
        {
            string textoCorreo = "<b> UNIDAD DE REGENCIA</b> <br><br>Su solicitud con el consecutivo " + consecutivo + " fue aprobada.<br>";

            //Denega los articulos rojos y los regresa a la base. También escribe el correo
            if (reacDenegados.Count > 0)
            {
                textoCorreo += "Los siguientes reactivos fueron denegados;<br>";
                for (int i = 0; i < reacDenegados.Count; ++i)
                {
                    textoCorreo += "Nombre: " + dgvReactivos.Rows[reacDenegados[i]].Cells[0].Value.ToString() +
                                   "<br> Pureza: " + dgvReactivos.Rows[reacDenegados[i]].Cells[1].Value.ToString() + "<br> Motivo: " +
                                   motReacDen[i] + "<br><br>";
                    bd.denegarReactivo(consecutivo, dgvReactivos.Rows[reacDenegados[i]].Cells[0].Value.ToString(),
                                       dgvReactivos.Rows[reacDenegados[i]].Cells[1].Value.ToString());
                }
            }
            if (crisDenegados.Count > 0)
            {
                textoCorreo += "Los siguientes artículos de cristalería fueron denegados:<br>";
                for (int i = 0; i < crisDenegados.Count; ++i)
                {
                    textoCorreo += "Nombre: " + dgvCristaleria.Rows[crisDenegados[i]].Cells[0].Value.ToString() +
                                   "<br> Material: " + dgvCristaleria.Rows[crisDenegados[i]].Cells[1].Value.ToString() +
                                   "<br> Capacidad: " + dgvCristaleria.Rows[crisDenegados[i]].Cells[2].Value.ToString() + "<br> Motivo: " + motCrisDen[i] + "<br><br>";
                    bd.denegarCristaleria(consecutivo, dgvCristaleria.Rows[crisDenegados[i]].Cells[0].Value.ToString(),
                                          dgvCristaleria.Rows[crisDenegados[i]].Cells[1].Value.ToString(), dgvCristaleria.Rows[crisDenegados[i]].Cells[2].Value.ToString() +
                                          "<br>");
                }
            }

            //Se envía correo
            //System.IO.File.WriteAllLines(@"C:\Users\Jorge\Desktop\correo.txt", textoCorreo.Split('\n'));
            enviarCorreo(correoSolicitante, textoCorreo);

            //Se cambia el estado
            bd.ejecutarConsulta("update Solicitud set Estado = 'Aceptado', FechaAprobacion = GETDATE() where Id = '" + consecutivo + "'");

            //Se muestra un mensaje y se cierra la ventana
            MessageBox.Show("La solicitud ha sido aprobada correctamente", "Solicitud", MessageBoxButtons.OK, MessageBoxIcon.None);
            this.Close();
        }