Advertisement
Guest User

Untitled

a guest
Jan 17th, 2013
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.69 KB | None | 0 0
  1. //Login
  2.  
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Web;
  7. using System.Web.UI;
  8. using System.Web.UI.WebControls;
  9. using System.Web.Security;
  10. using AzureTableLayer;
  11. using Microsoft.WindowsAzure;
  12. using Microsoft.WindowsAzure.StorageClient;
  13. using Microsoft.WindowsAzure.ServiceRuntime;
  14. namespace manager
  15. {
  16. public partial class login : System.Web.UI.Page
  17. {
  18. protected void Page_Load(object sender, EventArgs e)
  19. {
  20. CloudStorageAccount storageAccount = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("Conn"));
  21. CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
  22. // Retrieve a reference to a container
  23. CloudBlobContainer container = blobClient.GetContainerReference("fiscal");
  24. // Create the container if it doesn't already exist
  25. container.CreateIfNotExist();
  26. }
  27.  
  28. protected void Button1_Click(object sender, EventArgs e)
  29. {
  30. //string hashstring = FormsAuthentication.HashPasswordForStoringInConfigFile(tbxSenha.Text, "qual a cor");
  31.  
  32. if (FormsAuthentication.Authenticate(tbxLogin.Text, tbxSenha.Text))
  33. {
  34. string crypto = Crypto.EncryptData(tbxLogin.Text);
  35. Server.Transfer("main.aspx?x=" + crypto);
  36. return;
  37. }
  38. else
  39. {
  40. lbllogin.Text = "Login inválido";
  41. }
  42.  
  43. }
  44. }
  45. }
  46.  
  47.  
  48. // Main.aspx.cs
  49.  
  50. using System;
  51. using System.Collections.Generic;
  52. using System.Linq;
  53. using System.Web;
  54. using System.Web.UI;
  55. using System.Web.UI.WebControls;
  56. using AzureTableLayer;
  57. using Microsoft.WindowsAzure;
  58. using Microsoft.WindowsAzure.StorageClient;
  59. using Microsoft.WindowsAzure.ServiceRuntime;
  60.  
  61. namespace manager
  62. {
  63. public partial class main : System.Web.UI.Page
  64. {
  65. public string crypto;
  66. protected void Page_Load(object sender, EventArgs e)
  67. {
  68. CloudStorageAccount storageAccount = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("Conn"));
  69. CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
  70. // Retrieve a reference to a container
  71. CloudBlobContainer container = blobClient.GetContainerReference("fiscal");
  72. // Create the container if it doesn't already exist
  73. container.CreateIfNotExist();
  74.  
  75. }
  76. }
  77. }
  78.  
  79. //Main.html
  80.  
  81. <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="main.aspx.cs" Inherits="manager.main" %>
  82.  
  83. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  84.  
  85. <html xmlns="http://www.w3.org/1999/xhtml">
  86. <head runat="server">
  87. <title></title>
  88. </head>
  89. <frameset rows="65%,35%" name='frames'>
  90. <frame name="mapa" id="mapa" src="gmaps.aspx" />
  91. <frame name="grid" id="grid" src="grid.aspx?x=<%=Request["x"].ToString()%>" />
  92.  
  93. </frameset>
  94.  
  95. </html>
  96.  
  97.  
  98. //grid.aspx
  99.  
  100. using System;
  101. using System.Collections.Generic;
  102. using System.Linq;
  103. using System.Web;
  104. using System.Web.UI;
  105. using System.Web.UI.WebControls;
  106. using Microsoft.WindowsAzure;
  107. using Microsoft.WindowsAzure.ServiceRuntime;
  108. using AzureTableLayer;
  109. using System.Diagnostics;
  110. using System.Collections;
  111. using System.IO;
  112. using System.Web.UI.HtmlControls;
  113.  
  114. namespace manager
  115. {
  116. public partial class grid : System.Web.UI.Page
  117. {
  118. protected void Page_Load(object sender, EventArgs e)
  119. {
  120. if (!Page.IsPostBack)
  121. {
  122. tbxDe.Text = DateTime.Now.AddDays(-1).ToShortDateString();
  123. tbxAte.Text = DateTime.Now.ToShortDateString();
  124. ViewState["x"] = Request["x"].ToString();
  125. popula();
  126. }
  127.  
  128. if (!Crypto.DecryptString(ViewState["x"].ToString()).Equals("art"))
  129. trconc.Visible = false;
  130.  
  131. }
  132.  
  133. protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
  134. {
  135.  
  136. }
  137.  
  138. private void popula()
  139. {
  140. var account = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("Conn"));
  141. var context = new CRUDManifestacoesEntities(account.TableEndpoint.ToString(), account.Credentials);
  142.  
  143. Hashtable ht = (Hashtable)ViewState["filtro"];
  144.  
  145. if (ht == null)
  146. GridView1.DataSource = context.SelectConc(ViewState["x"].ToString());
  147. else
  148. GridView1.DataSource = context.SelectConc(ht);
  149.  
  150. GridView1.DataBind();
  151. }
  152.  
  153. protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
  154. {
  155. string commandname = e.CommandName;
  156.  
  157.  
  158. if (commandname.Equals("atender"))
  159. {
  160. string id = GridView1.Rows[int.Parse(e.CommandArgument.ToString())].Cells[2].Text;
  161. string imgvd = GridView1.Rows[int.Parse(e.CommandArgument.ToString())].Cells[10].Text;
  162. string lng = GridView1.Rows[int.Parse(e.CommandArgument.ToString())].Cells[8].Text;
  163. string lat = GridView1.Rows[int.Parse(e.CommandArgument.ToString())].Cells[9].Text;
  164. string comentarios = GridView1.Rows[int.Parse(e.CommandArgument.ToString())].Cells[6].Text;
  165.  
  166. ManifestacaoEntity mf = new ManifestacaoEntity();
  167.  
  168. if (GridView1.Rows[int.Parse(e.CommandArgument.ToString())].Cells[7].Text.Equals("Aguardando"))
  169. {
  170. mf.status = 1;
  171. mf.dataatendimento = DateTime.Now;
  172. mf.id = id;
  173. var account = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("Conn"));
  174. var context = new CRUDManifestacoesEntities(account.TableEndpoint.ToString(), account.Credentials);
  175. context.UPDATEStatus(mf);
  176. ClientScript.RegisterClientScriptBlock(this.GetType(), "alerta", "<script> alert('Manifestação em atendimento.') ; </script>");
  177. }
  178. else if (GridView1.Rows[int.Parse(e.CommandArgument.ToString())].Cells[7].Text.Equals("Em Atendimento"))
  179. {
  180. // mf.status = 2;
  181. ClientScript.RegisterClientScriptBlock(this.GetType(), "alerta", String.Format( "<script> modalWin('{0}'); </script>" , id));
  182. return;
  183. }
  184. else
  185. {
  186. ClientScript.RegisterClientScriptBlock(this.GetType(), "alerta", "<script> alert('Manifestação já encerrada.') ; </script>");
  187. return;
  188. }
  189.  
  190.  
  191.  
  192. popula();
  193.  
  194. }
  195. else if (commandname.Equals("ver"))
  196. {
  197. string id = GridView1.Rows[int.Parse(e.CommandArgument.ToString())].Cells[2].Text;
  198. string imgvd = GridView1.Rows[int.Parse(e.CommandArgument.ToString())].Cells[10].Text;
  199. string lng = GridView1.Rows[int.Parse(e.CommandArgument.ToString())].Cells[8].Text;
  200. string lat = GridView1.Rows[int.Parse(e.CommandArgument.ToString())].Cells[9].Text;
  201. string comentarios = GridView1.Rows[int.Parse(e.CommandArgument.ToString())].Cells[6].Text;
  202.  
  203. string script = String.Format( "<script>parent.window.frames['mapa'].ponto({0}, {1}, '{2}', '{3}' , '{4}');</script>" , lng, lat , comentarios , id , imgvd) ;
  204. ClientScript.RegisterClientScriptBlock(this.GetType(), "ver", script);
  205. Debug.WriteLine(commandname);
  206. }
  207.  
  208. }
  209.  
  210. protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
  211. {
  212. if (e.Row.Cells.Count > 7)
  213. {
  214. if (Crypto.DecryptString(ViewState["x"].ToString()).Equals("art"))
  215. e.Row.Cells[0].Visible = false;
  216. else
  217. e.Row.Cells[11].Visible = false;
  218.  
  219. e.Row.Cells[2].Wrap = true;
  220. e.Row.Cells[6].Visible = false;
  221. e.Row.Cells[8].Visible = false;
  222. e.Row.Cells[9].Visible = false;
  223. e.Row.Cells[10].Visible = false;
  224. e.Row.Cells[12].Visible = false;
  225.  
  226. }
  227. }
  228.  
  229. protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
  230. {
  231. GridView1.PageIndex = e.NewPageIndex;
  232. //Bind grid
  233. popula();
  234. }
  235.  
  236. protected void Limpa(object sender, EventArgs e)
  237. {
  238. ViewState["filtro"] = null;
  239. popula();
  240. }
  241.  
  242. protected void Button1_Click(object sender, EventArgs e)
  243. {
  244. string de = tbxDe.Text;
  245. string ate = tbxAte.Text;
  246. string manif = ddlTipoManif.SelectedValue;
  247. string conc = ddlConcessionaria.SelectedValue;
  248. string status = ddlStatus.SelectedValue;
  249. string prazo = ddlPrazo.SelectedValue ;
  250.  
  251. Hashtable ht = new Hashtable();
  252. ht.Add("de", de);
  253. ht.Add("ate", ate);
  254. ht.Add("manif", manif);
  255. ht.Add("conc", conc);
  256. ht.Add("status", status);
  257. ht.Add("prazo", prazo);
  258.  
  259.  
  260. ViewState["filtro"] = ht;
  261.  
  262. popula();
  263.  
  264. }
  265.  
  266. protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
  267. {
  268. ExportGridView();
  269. }
  270.  
  271. private void ExportGridView()
  272. {
  273. string attachment = "attachment; filename=Manifestacoes.xls";
  274. Response.ClearContent();
  275. Response.AddHeader("content-disposition", attachment);
  276. Response.ContentType = "application/ms-excel";
  277. StringWriter sw = new StringWriter();
  278. HtmlTextWriter htw = new HtmlTextWriter(sw);
  279. GridView1.AllowPaging = false;
  280. GridView1.AllowSorting = false;
  281.  
  282. popula();
  283.  
  284. // Create a form to contain the grid
  285. HtmlForm frm = new HtmlForm();
  286. GridView1.Parent.Controls.Add(frm);
  287. frm.Attributes["runat"] = "server";
  288. frm.Controls.Add(GridView1);
  289.  
  290. frm.RenderControl(htw);
  291. //GridView1.RenderControl(htw);
  292. Response.Write(sw.ToString());
  293. Response.End();
  294.  
  295. GridView1.AllowPaging = true;
  296. GridView1.AllowSorting = true;
  297.  
  298. }
  299.  
  300. public override void VerifyRenderingInServerForm(Control control)
  301. {
  302. }
  303.  
  304. }
  305. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement