Example #1
0
        protected void lkFoto_Click(object sender, EventArgs e)
        {
            LinkButton drp = (LinkButton)sender;

            GridViewRow gv = (GridViewRow)drp.NamingContainer;

            int index = gv.RowIndex;

            LinkButton lkFoto      = (LinkButton)gvDenuList.Rows[index].FindControl("lkFoto");
            int        id_denuncia = Convert.ToInt32(gvDenuList.Rows[index].Cells[0].Text);

            id_denu.Value = id_denuncia.ToString();
            Models.Denuncias denuncia = DenunciasDAO.GetDenunciaByID(id_denuncia);
            Equip            equip    = EquipDAO.GetEquipByID(denuncia.id_equip);
            string           jpg      = "/Content/Imagens/Denuncias/" + equip.descri + "_" + denuncia.data_denuncia.ToString("MM-dd-yyyy") + ".jpg";

            if (File.Exists(Server.MapPath(jpg)))
            {
                imgFoto.ImageUrl = jpg;
            }
            else
            {
                imgFoto.ImageUrl = "../../Content/Imagens/ImgNotFound.png";
            }
            tbxComentarios.Text = denuncia.comentarios;
            MPE_Foto.Show();
        }
Example #2
0
        protected void gvDenuList_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                Models.Denuncias denuncia = DenunciasDAO.GetDenunciaByID(Convert.ToInt32(e.Row.Cells[0].Text));
                if (denuncia.prioridade == 'A')
                {
                    ((DropDownList)e.Row.FindControl("ddlPrioridade")).SelectedValue = "1";
                    ((DropDownList)e.Row.FindControl("ddlPrioridade")).ForeColor     = System.Drawing.Color.Red;
                }
                else if (denuncia.prioridade == 'M')
                {
                    ((DropDownList)e.Row.FindControl("ddlPrioridade")).SelectedValue = "2";
                    ((DropDownList)e.Row.FindControl("ddlPrioridade")).ForeColor     = System.Drawing.Color.Orange;
                }
                else if (denuncia.prioridade == 'B')
                {
                    ((DropDownList)e.Row.FindControl("ddlPrioridade")).SelectedValue = "3";
                    ((DropDownList)e.Row.FindControl("ddlPrioridade")).ForeColor     = System.Drawing.Color.Green;
                }
                else
                {
                    ((DropDownList)e.Row.FindControl("ddlPrioridade")).SelectedValue = "4";
                }

                if (denuncia.estado == 'V')
                {
                    ((DropDownList)e.Row.FindControl("ddlEstado")).SelectedValue = "1";
                    ((DropDownList)e.Row.FindControl("ddlEstado")).ForeColor     = System.Drawing.Color.Red;
                }
                else if (denuncia.estado == 'P')
                {
                    ((DropDownList)e.Row.FindControl("ddlEstado")).SelectedValue = "2";
                    ((DropDownList)e.Row.FindControl("ddlEstado")).ForeColor     = System.Drawing.Color.Orange;
                }
                else if (denuncia.estado == 'R')
                {
                    ((DropDownList)e.Row.FindControl("ddlEstado")).SelectedValue = "3";
                    ((DropDownList)e.Row.FindControl("ddlEstado")).ForeColor     = System.Drawing.Color.Green;
                }

                Equip  equip   = EquipDAO.GetEquipByID(denuncia.id_equip);
                User   user    = UserDAO.GetUserByID(denuncia.id_user);
                Button btEquip = (Button)e.Row.FindControl("btEquip");
                btEquip.Text = equip.descri;
                Button btUser = (Button)e.Row.FindControl("btUser");
                btUser.Text = user.Username;
            }
        }
Example #3
0
        protected void btSimDenu_Click(object sender, EventArgs e)
        {
            User user = UserDAO.GetUserByEmail(Session["email"].ToString());

            Models.Denuncias denu = new Models.Denuncias()
            {
                id_equip   = Convert.ToInt32(id_equip.Value),
                prioridade = 'N',
                estado     = 'V',
                id_user    = user.id_User,
                problema   = tbxProb.Text
            };
            int returncode = DenunciasDAO.InsertDenu(denu);

            MPE_Denu.Hide();
            if (returncode == -1)
            {
                String str = "<script>alertify.error('Inserção feita sem sucesso!');</script>";
                Page.ClientScript.RegisterStartupScript(this.GetType(), "Script", str, false);
                lbErro.Text = "Ja existe uma denuncia com este problema neste equipamento que ainda não se encontra resolvida.";
                MPE_Erro.Show();
            }
            else
            {
                if (fluFoto.HasFile == true)
                {
                    Equip  equip = EquipDAO.GetEquipByID(denu.id_equip);
                    String path  = equip.descri + "_" + DateTime.Now.ToString("MM-dd-yyyy") + ".jpg";
                    fluFoto.PostedFile.SaveAs(Server.MapPath("~/Content/Imagens/Denuncias/") + path);
                }
                else
                {
                    imgFoto.ImageUrl = "../../Content/Imagens/ImgNotFound.png";
                }

                String str = "<script>alertify.success('Inserção feita com sucesso!');</script>";
                Page.ClientScript.RegisterStartupScript(this.GetType(), "Script", str, false);
            }

            btSimDenu.CausesValidation = false;
            rfvProb.Enabled            = false;
            DataBindGridDenu();
        }
Example #4
0
        protected void lkQrCode_Click(object sender, EventArgs e)
        {
            LinkButton drp = (LinkButton)sender;

            GridViewRow gv = (GridViewRow)drp.NamingContainer;

            int index = gv.RowIndex;

            LinkButton lkQrCode    = (LinkButton)gvDenuList.Rows[index].FindControl("lkQrCode");
            int        id_denuncia = Convert.ToInt32(gvDenuList.Rows[index].Cells[0].Text);

            MPE_QrCode.Show();
            Models.Denuncias denuncia    = DenunciasDAO.GetDenunciaByID(id_denuncia);
            Equip            equip       = EquipDAO.GetEquipByID(denuncia.id_equip);
            string           code        = "Equipamento : " + equip.descri + "\nProblema : " + denuncia.problema;
            QRCodeGenerator  qrGenerator = new QRCodeGenerator();
            QRCodeData       qrCodeData  = qrGenerator.CreateQrCode(code, QRCodeGenerator.ECCLevel.Q);

            System.Web.UI.WebControls.Image imgBarCode = new System.Web.UI.WebControls.Image();
            QRCode qrCode = new QRCode(qrCodeData);

            imgBarCode.Height = 150;
            imgBarCode.Width  = 150;
            using (Bitmap bitMap = qrCode.GetGraphic(20))
            {
                using (MemoryStream ms = new MemoryStream())
                {
                    String path = AppDomain.CurrentDomain.BaseDirectory;
                    bitMap.Save(path + "Content\\Imagens\\qrcode.png", System.Drawing.Imaging.ImageFormat.Png);
                    bitMap.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
                    byte[] byteImage = ms.ToArray();
                    imgBarCode.ImageUrl = "data:image/png;base64," + Convert.ToBase64String(byteImage);
                }

                PlaceHolder1.Controls.Add(imgBarCode);
            }
        }
Example #5
0
        protected void btSimRe_Click(object sender, EventArgs e)
        {
            bool a = false, b = false;

            for (int i = 0; i < gvDenuList.Rows.Count; i++)
            {
                Models.Denuncias denuncia = DenunciasDAO.GetDenunciaByID(Convert.ToInt32(gvDenuList.DataKeys[i].Value));
                if (((CheckBox)gvDenuList.Rows[i].FindControl("chbxEliminar")).Checked)
                {
                    a = true;

                    int id_denuncia = denuncia.id_denuncia;

                    User  user  = UserDAO.GetUserByID(denuncia.id_user);
                    Equip equip = EquipDAO.GetEquipByID(denuncia.id_equip);
                    try
                    {
                        using (var client = new WebClient())
                            using (client.OpenRead("http://google.com/generate_204"))
                                b = true;
                    }
                    catch
                    {
                        b = false;
                    }
                    if (b == true)
                    {
                        MailMessage mailMessage = new MailMessage();
                        mailMessage.From = new MailAddress("*****@*****.**");
                        mailMessage.To.Add(user.Email);
                        mailMessage.Subject    = "Cancelamento de uma denuncia.";
                        mailMessage.Body       = "<h3>G.E.T</h3><br/>Vimos por este meio informar que a sua denuncia do seguinte equipamento : " + equip.descri + "<br/>Foi removida. <br/>Para mais informações contacte um administrador.";
                        mailMessage.IsBodyHtml = true;

                        SmtpClient smtpClient = new SmtpClient("smtp.gmail.com", 587);
                        smtpClient.EnableSsl             = true;
                        smtpClient.DeliveryMethod        = SmtpDeliveryMethod.Network;
                        smtpClient.UseDefaultCredentials = false;
                        smtpClient.Credentials           = new System.Net.NetworkCredential("*****@*****.**", "teste123456");
                        smtpClient.Send(mailMessage);
                    }
                    else
                    {
                        String str = "<script>alertify.error('Sem ligação! Email não enviado.');</script>";
                        Page.ClientScript.RegisterStartupScript(this.GetType(), "Script", str, false);
                    }


                    DenunciasDAO.RemoveDenuncia(id_denuncia);
                    continue;
                }
            }
            MPE_Rem.Hide();
            if (a == true)
            {
                DataBindGrid();
                String str = "<script>alertify.success('Remoção feita com sucesso!');</script>";
                Page.ClientScript.RegisterStartupScript(this.GetType(), "Script", str, false);
            }
            else
            {
                DataBindGrid();
                String str = "<script>alertify.error('Não há nada para remover!');</script>";
                Page.ClientScript.RegisterStartupScript(this.GetType(), "Script", str, false);
            }
        }
Example #6
0
        protected void btSimEstado_Click(object sender, EventArgs e)
        {
            bool b = false;
            char est;

            Models.Denuncias denuncia = DenunciasDAO.GetDenunciaByID(Convert.ToInt32(id_denu.Value));
            if (estado.Value == "1")
            {
                est = 'V';
            }
            else if (estado.Value == "2")
            {
                est = 'P';
                EquipDAO.UpdateEquipDisp(Convert.ToInt32(denuncia.id_equip), Convert.ToBoolean(0));
            }
            else
            {
                est = 'R';
            }
            int returncode = DenunciasDAO.UpdateDenuEstado(Convert.ToInt32(id_denu.Value), est);

            MPE_Estado.Hide();
            if (returncode == -1)
            {
                String str = "<script>alertify.error('Alteração feita sem sucesso!');</script>";
                Page.ClientScript.RegisterStartupScript(this.GetType(), "Script", str, false);
            }
            else
            {
                User   user  = UserDAO.GetUserByID(denuncia.id_user);
                Equip  equip = EquipDAO.GetEquipByID(denuncia.id_equip);
                string esta;
                if (est == 'V')
                {
                    esta = "Por ver";
                }
                else if (est == 'P')
                {
                    esta = "Por resolver";
                }
                else
                {
                    esta = "Resolvida";
                }

                try
                {
                    using (var client = new WebClient())
                        using (client.OpenRead("http://google.com/generate_204"))
                            b = true;
                }
                catch
                {
                    b = false;
                }
                if (b == true)
                {
                    MailMessage mailMessage = new MailMessage();
                    mailMessage.From = new MailAddress("*****@*****.**");
                    mailMessage.To.Add(user.Email);
                    mailMessage.Subject    = "Alteração do estado de uma denuncia.";
                    mailMessage.Body       = "<h3>G.E.T</h3><br/>Vimos por este meio informar que o estado da sua denuncia do seguinte equipamento: " + equip.descri + "<br/>Foi alterado para: " + esta + ".<br/>Para mais informações contacte um administrador.";
                    mailMessage.IsBodyHtml = true;

                    SmtpClient smtpClient = new SmtpClient("smtp.gmail.com", 587);
                    smtpClient.EnableSsl             = true;
                    smtpClient.DeliveryMethod        = SmtpDeliveryMethod.Network;
                    smtpClient.UseDefaultCredentials = false;
                    smtpClient.Credentials           = new System.Net.NetworkCredential("*****@*****.**", "teste123456");
                    smtpClient.Send(mailMessage);
                }
                else
                {
                    String str1 = "<script>alertify.error('Sem ligação! Email não enviado.');</script>";
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "Script", str1, false);
                }
                DataBindGrid();
                String str = "<script>alertify.success('Alteração feita com sucesso!');</script>";
                Page.ClientScript.RegisterStartupScript(this.GetType(), "Script", str, false);
            }
        }