PageRenderTime 20ms CodeModel.GetById 15ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/providers/Show.aspx.cs

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