Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Login
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Web.Security;
- using AzureTableLayer;
- using Microsoft.WindowsAzure;
- using Microsoft.WindowsAzure.StorageClient;
- using Microsoft.WindowsAzure.ServiceRuntime;
- namespace manager
- {
- public partial class login : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- CloudStorageAccount storageAccount = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("Conn"));
- CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
- // Retrieve a reference to a container
- CloudBlobContainer container = blobClient.GetContainerReference("fiscal");
- // Create the container if it doesn't already exist
- container.CreateIfNotExist();
- }
- protected void Button1_Click(object sender, EventArgs e)
- {
- //string hashstring = FormsAuthentication.HashPasswordForStoringInConfigFile(tbxSenha.Text, "qual a cor");
- if (FormsAuthentication.Authenticate(tbxLogin.Text, tbxSenha.Text))
- {
- string crypto = Crypto.EncryptData(tbxLogin.Text);
- Server.Transfer("main.aspx?x=" + crypto);
- return;
- }
- else
- {
- lbllogin.Text = "Login inválido";
- }
- }
- }
- }
- // Main.aspx.cs
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using AzureTableLayer;
- using Microsoft.WindowsAzure;
- using Microsoft.WindowsAzure.StorageClient;
- using Microsoft.WindowsAzure.ServiceRuntime;
- namespace manager
- {
- public partial class main : System.Web.UI.Page
- {
- public string crypto;
- protected void Page_Load(object sender, EventArgs e)
- {
- CloudStorageAccount storageAccount = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("Conn"));
- CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
- // Retrieve a reference to a container
- CloudBlobContainer container = blobClient.GetContainerReference("fiscal");
- // Create the container if it doesn't already exist
- container.CreateIfNotExist();
- }
- }
- }
- //Main.html
- <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="main.aspx.cs" Inherits="manager.main" %>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head runat="server">
- <title></title>
- </head>
- <frameset rows="65%,35%" name='frames'>
- <frame name="mapa" id="mapa" src="gmaps.aspx" />
- <frame name="grid" id="grid" src="grid.aspx?x=<%=Request["x"].ToString()%>" />
- </frameset>
- </html>
- //grid.aspx
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using Microsoft.WindowsAzure;
- using Microsoft.WindowsAzure.ServiceRuntime;
- using AzureTableLayer;
- using System.Diagnostics;
- using System.Collections;
- using System.IO;
- using System.Web.UI.HtmlControls;
- namespace manager
- {
- public partial class grid : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!Page.IsPostBack)
- {
- tbxDe.Text = DateTime.Now.AddDays(-1).ToShortDateString();
- tbxAte.Text = DateTime.Now.ToShortDateString();
- ViewState["x"] = Request["x"].ToString();
- popula();
- }
- if (!Crypto.DecryptString(ViewState["x"].ToString()).Equals("art"))
- trconc.Visible = false;
- }
- protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
- {
- }
- private void popula()
- {
- var account = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("Conn"));
- var context = new CRUDManifestacoesEntities(account.TableEndpoint.ToString(), account.Credentials);
- Hashtable ht = (Hashtable)ViewState["filtro"];
- if (ht == null)
- GridView1.DataSource = context.SelectConc(ViewState["x"].ToString());
- else
- GridView1.DataSource = context.SelectConc(ht);
- GridView1.DataBind();
- }
- protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
- {
- string commandname = e.CommandName;
- if (commandname.Equals("atender"))
- {
- string id = GridView1.Rows[int.Parse(e.CommandArgument.ToString())].Cells[2].Text;
- string imgvd = GridView1.Rows[int.Parse(e.CommandArgument.ToString())].Cells[10].Text;
- string lng = GridView1.Rows[int.Parse(e.CommandArgument.ToString())].Cells[8].Text;
- string lat = GridView1.Rows[int.Parse(e.CommandArgument.ToString())].Cells[9].Text;
- string comentarios = GridView1.Rows[int.Parse(e.CommandArgument.ToString())].Cells[6].Text;
- ManifestacaoEntity mf = new ManifestacaoEntity();
- if (GridView1.Rows[int.Parse(e.CommandArgument.ToString())].Cells[7].Text.Equals("Aguardando"))
- {
- mf.status = 1;
- mf.dataatendimento = DateTime.Now;
- mf.id = id;
- var account = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("Conn"));
- var context = new CRUDManifestacoesEntities(account.TableEndpoint.ToString(), account.Credentials);
- context.UPDATEStatus(mf);
- ClientScript.RegisterClientScriptBlock(this.GetType(), "alerta", "<script> alert('Manifestação em atendimento.') ; </script>");
- }
- else if (GridView1.Rows[int.Parse(e.CommandArgument.ToString())].Cells[7].Text.Equals("Em Atendimento"))
- {
- // mf.status = 2;
- ClientScript.RegisterClientScriptBlock(this.GetType(), "alerta", String.Format( "<script> modalWin('{0}'); </script>" , id));
- return;
- }
- else
- {
- ClientScript.RegisterClientScriptBlock(this.GetType(), "alerta", "<script> alert('Manifestação já encerrada.') ; </script>");
- return;
- }
- popula();
- }
- else if (commandname.Equals("ver"))
- {
- string id = GridView1.Rows[int.Parse(e.CommandArgument.ToString())].Cells[2].Text;
- string imgvd = GridView1.Rows[int.Parse(e.CommandArgument.ToString())].Cells[10].Text;
- string lng = GridView1.Rows[int.Parse(e.CommandArgument.ToString())].Cells[8].Text;
- string lat = GridView1.Rows[int.Parse(e.CommandArgument.ToString())].Cells[9].Text;
- string comentarios = GridView1.Rows[int.Parse(e.CommandArgument.ToString())].Cells[6].Text;
- string script = String.Format( "<script>parent.window.frames['mapa'].ponto({0}, {1}, '{2}', '{3}' , '{4}');</script>" , lng, lat , comentarios , id , imgvd) ;
- ClientScript.RegisterClientScriptBlock(this.GetType(), "ver", script);
- Debug.WriteLine(commandname);
- }
- }
- protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
- {
- if (e.Row.Cells.Count > 7)
- {
- if (Crypto.DecryptString(ViewState["x"].ToString()).Equals("art"))
- e.Row.Cells[0].Visible = false;
- else
- e.Row.Cells[11].Visible = false;
- e.Row.Cells[2].Wrap = true;
- e.Row.Cells[6].Visible = false;
- e.Row.Cells[8].Visible = false;
- e.Row.Cells[9].Visible = false;
- e.Row.Cells[10].Visible = false;
- e.Row.Cells[12].Visible = false;
- }
- }
- protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
- {
- GridView1.PageIndex = e.NewPageIndex;
- //Bind grid
- popula();
- }
- protected void Limpa(object sender, EventArgs e)
- {
- ViewState["filtro"] = null;
- popula();
- }
- protected void Button1_Click(object sender, EventArgs e)
- {
- string de = tbxDe.Text;
- string ate = tbxAte.Text;
- string manif = ddlTipoManif.SelectedValue;
- string conc = ddlConcessionaria.SelectedValue;
- string status = ddlStatus.SelectedValue;
- string prazo = ddlPrazo.SelectedValue ;
- Hashtable ht = new Hashtable();
- ht.Add("de", de);
- ht.Add("ate", ate);
- ht.Add("manif", manif);
- ht.Add("conc", conc);
- ht.Add("status", status);
- ht.Add("prazo", prazo);
- ViewState["filtro"] = ht;
- popula();
- }
- protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
- {
- ExportGridView();
- }
- private void ExportGridView()
- {
- string attachment = "attachment; filename=Manifestacoes.xls";
- Response.ClearContent();
- Response.AddHeader("content-disposition", attachment);
- Response.ContentType = "application/ms-excel";
- StringWriter sw = new StringWriter();
- HtmlTextWriter htw = new HtmlTextWriter(sw);
- GridView1.AllowPaging = false;
- GridView1.AllowSorting = false;
- popula();
- // Create a form to contain the grid
- HtmlForm frm = new HtmlForm();
- GridView1.Parent.Controls.Add(frm);
- frm.Attributes["runat"] = "server";
- frm.Controls.Add(GridView1);
- frm.RenderControl(htw);
- //GridView1.RenderControl(htw);
- Response.Write(sw.ToString());
- Response.End();
- GridView1.AllowPaging = true;
- GridView1.AllowSorting = true;
- }
- public override void VerifyRenderingInServerForm(Control control)
- {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement