protected void btnCreateTicket_Click(object sender, EventArgs e) { ticket new_ticket = new ticket(); string ticket_message = null; try { new_ticket.created_by = new Guid(Session["userid"].ToString().Trim()); new_ticket.created_date = DateTime.Now; new_ticket.title = txtTicketTitle.Text; new_ticket.description = txtTicketDescr.Text; new_ticket.priority = Convert.ToInt32(ddlTicketPriority.SelectedValue); new_ticket.status = TicketsDB.GetStatus("Open").id; TicketsDB.AddEditTicket(new_ticket); ticket_message = TicketsDB.GenerateTicketNumber(new_ticket); } catch (Exception ex) { log_type type = LogsDB.GetLogType("error"); LogsDB.AddLog("Error creating new ticket", type.id, ex); ticket_message = "Unexpected error creating ticket. Refresh page and try again or contact IT"; } ltlMessage.Text = String.Format("<span class='success-message'>{0}</span>", ticket_message); }
private void LoadTickets() { List <project_detail> tickets = ProjectsDB.GetProjectTickets(this_project); ltlTicketCount.Text = tickets.Count().ToString(); StringBuilder sb = new StringBuilder(); sb.Append("<table id='tblTickets' class='display'>"); sb.Append("<thead>"); sb.Append("<th><strong>ID</strong></th>"); sb.Append("<th><strong>Title</strong></th>"); sb.Append("<th class='text-center'><strong>Created By</strong></th>"); sb.Append("<th class='text-center'><strong>Created Date</strong></th>"); sb.Append("<th><strong>Status</strong></th>"); sb.Append("<th><strong>Priority</strong></th>"); sb.Append("<th><strong>Assigned To</strong></th>"); sb.Append("</thead>"); sb.Append("<tbody>"); foreach (project_detail ticket in tickets) { sb.Append("<tr>"); sb.AppendFormat("<td>{0}</td>", TicketsDB.GenerateTicketNumber(TicketsDB.GetTicketHeader(ticket.ticket_id))); sb.AppendFormat("<td>{0}</td>", ticket.title); sb.AppendFormat("<td>{0}</td>", ticket.created_by); sb.AppendFormat("<td>{0: dd/MM/yyyy}</td>", ticket.created_date); sb.AppendFormat("<td>{0}</td>", ticket.status); sb.AppendFormat("<td>{0}</td>", ticket.priority); sb.AppendFormat("<td>{0}</td>", ticket.dev); sb.Append("</tr>"); } sb.Append("</tbody>"); sb.Append("</table>"); ltlTicketsOpen.Text = sb.ToString(); }