/providers/Show.aspx.cs

http://github.com/gmhawash/SSR · C# · 71 lines · 61 code · 9 blank · 1 comment · 6 complexity · d34067a1f4eb14602c048c02e4566bef MD5 · raw file

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.UI;
  6. using System.Web.UI.WebControls;
  7. using TrackerTableAdapters;
  8. using System.Data.Linq;
  9. using System.Configuration;
  10. using System.Web.Security;
  11. using ZaytonaClasses;
  12. using System.Text;
  13. public partial class providers_Default2 : ZPage
  14. {
  15. protected void Page_Load(object sender, EventArgs e)
  16. {
  17. string Id = Request.QueryString["Id"];
  18. Session.Add("TicketId", Id);
  19. TicketsTableAdapter Adapter = new TicketsTableAdapter();
  20. Tracker.TicketsDataTable tickets = Adapter.GetTicketForShow(new Guid(Id));
  21. if (tickets.Count == 0)
  22. return;
  23. Tracker.TicketsRow ticket = tickets[0];
  24. string[] col1 = { "Number", "Priority", "Status", "Product;Project", "Department;Dept", "Group", "Team" };
  25. string[] col2 = { "Created By;Creator","QA Due Date;QADueDate", "QA Completed Date;QACompletedDate", "User Test Due Date;UserTestDueDate",
  26. "User Test Complete Date;UserTestCompleteDate", "Planned Implementation Date;PlannedImplementationDate", "Implementation Date;ImplementationDate" };
  27. string[] col3 = { "Received On;ReceivedOn", "Actual Hours;Project", "Actual Cost;ActualCost", "Canceled On;CanceledOn", "Canceled By;Canceler" };
  28. string[] col4 = { "Summary", "Description", "CancelComment" };
  29. string[][] cols = { col1, col2, col3 };
  30. // create controls from above array..
  31. foreach (string[] col in cols)
  32. {
  33. TableCell tc = new TableCell(); TableRow1.Cells.Add(tc);
  34. foreach (string cell in col)
  35. {
  36. string[] cells = cell.Split(';');
  37. object value = ticket[cells.Length == 1 ? cells[0] : cells[1]];
  38. if (value.GetType() == typeof(DateTime))
  39. value = ((DateTime)value).ToShortDateString();
  40. tc.Text += "<div class='showfield'><div>" + cells[0] + ": </div><label>" + value + "</label></div>";
  41. }
  42. }
  43. foreach (string cell in col4)
  44. {
  45. if (!DBNull.Value.Equals(ticket[cell]))
  46. ((TextBox)View1.FindControl(cell)).Text = (string)ticket[cell];
  47. }
  48. }
  49. protected void Back_Click(object sender, EventArgs e)
  50. {
  51. GoBack();
  52. }
  53. protected void AddNote_Click(object sender, EventArgs e)
  54. {
  55. string text = ((TextBox)View1.FindControl("Note")).Text;
  56. Guid ticketId = new Guid(Request["Id"]);
  57. Guid author = (Guid)Membership.GetUser().ProviderUserKey;
  58. MessagesTableAdapter ta = new MessagesTableAdapter();
  59. ta.Insert(Guid.NewGuid(), text, DateTime.Now, ticketId, author);
  60. Response.Redirect(Request.Url.AbsoluteUri);
  61. }
  62. }