Esempio n. 1
0
        private void remove_Click(object sender, EventArgs e)
        {
            AskAdminID admin = new AskAdminID();

            admin.ShowDialog();

            int admin_id = admin.id;

            using (ticket_systemEntities db = new ticket_systemEntities())
            {
                ObjectParameter count = new ObjectParameter("res", SqlDbType.Int);
                if (t.admin_id == admin_id)
                {
                    db.RemoveTicket(this.t.code, count);
                    try
                    {
                        db.SaveChanges();
                    }
                    catch (DbUpdateConcurrencyException exc)
                    {
                        TicketSystemDBQueryable.overwrite(exc);
                    }
                }
                if (!count.Value.Equals(0))
                {
                    MessageBox.Show("Ticket successfully removed");
                    OnTicketChanged(EventArgs.Empty);
                }
                else
                {
                    MessageBox.Show("Error");
                }
            }
            Close();
        }
Esempio n. 2
0
        private void UpdateUI()
        {
            ticket_list.Items.Clear();

            IEnumerable <ticket> tickets;

            using (ticket_systemEntities db = new ticket_systemEntities())
            {
                if (show_non_closed.Checked)
                {
                    tickets = new TicketSystemDBQueryable().getNonClosedTicketsTable(db);
                }
                else
                {
                    tickets = new TicketSystemDBQueryable().getAllTicketsTable(db);
                }
                setUpListView(tickets);
            }
        }
Esempio n. 3
0
 private void edit_ticket_Click(object sender, EventArgs e)
 {
     using (ticket_systemEntities db = new ticket_systemEntities())
     {
         if (ticket_list.SelectedItems.Count < 1)
         {
             MessageBox.Show("You need to select a Ticket");
         }
         else
         {
             int           code           = int.Parse(ticket_list.SelectedItems[0].Text);
             var           ticket         = new TicketSystemDBQueryable().getTicketById(db, code);
             var           info_requests  = new TicketSystemDBQueryable().getTicketRequests(db, code);
             var           ticket_actions = new TicketSystemDBQueryable().getTicketActions(db, code);
             var           steps          = ticket.id_type != null ? new TicketSystemDBQueryable().getStepsOfType(db, (int)ticket.id_type) : null;
             TicketDetails t = new TicketDetails(ticket, info_requests, ticket_actions, steps);
             t.Changed += new TicketDetails.RemovedEventHandler(TicketRemoved);
             t.Show();
         }
     }
 }
Esempio n. 4
0
        private void export_Click(object sender, EventArgs e)
        {
            client               c       = null;
            administrator        admin   = null;
            type                 tp      = null;
            IEnumerable <action> actions = null;

            using (ticket_systemEntities db = new ticket_systemEntities())
            {
                c     = new TicketSystemDBQueryable().getClientById(db, t.client_id);
                admin = new TicketSystemDBQueryable().getAdminById(db, t.admin_id);
                if (t.id_type != null)
                {
                    tp = new TicketSystemDBQueryable().getTypeById(db, t.id_type);
                }
                actions = new TicketSystemDBQueryable().getTicketActions(db, t.code);

                StringWriter wr = writeTicketToXml(t, c, admin, tp, actions);

                Console.Write(wr.GetStringBuilder().ToString());
            }
        }
Esempio n. 5
0
        private void submit_action_Click(object sender, EventArgs e)
        {
            AskAdminID admin = new AskAdminID();

            admin.ShowDialog();

            int admin_id = admin.id;

            using (ticket_systemEntities db = new ticket_systemEntities())
            {
                if (state_list.SelectedItem.ToString().Equals(t.STATE))
                {
                    int order = steps_list.SelectedIndex;
                    if (order != -1)
                    {
                        db.CreateAction(note.Text, t.code, admin_id, order + 1, t.id_type);
                        try
                        {
                            db.SaveChanges();
                        }
                        catch (DbUpdateConcurrencyException exc)
                        {
                            TicketSystemDBQueryable.overwrite(exc);
                        }
                        Close();
                    }
                    else
                    {
                        MessageBox.Show("Must choose step to resolve");
                    }
                }
                else
                {
                    if (new TicketSystemDBQueryable().existsActions(db, t.code))
                    {
                        if (t.admin_id == admin_id)
                        {
                            db.CloseTicket(t.code);
                            try
                            {
                                db.SaveChanges();
                                OnTicketChanged(EventArgs.Empty);
                            }
                            catch (DbUpdateConcurrencyException exc)
                            {
                                TicketSystemDBQueryable.overwrite(exc);
                            }
                            Close();
                        }
                        else
                        {
                            MessageBox.Show("You cannot close this ticket");
                        }
                    }
                    else
                    {
                        MessageBox.Show("This ticket has no Actions");
                    }
                }
            }
        }