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 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");
                    }
                }
            }
        }