Exemplo n.º 1
0
        public static TicketData getById(string id)
        {
            MySqlDataReader reader = Db.Read("select * from ticket where id=" + id);
            TicketData      ti     = new TicketData();

            while (reader.Read())
            {
                ti.id          = reader.GetInt32(0);
                ti.title       = reader.GetString(1);
                ti.description = reader.GetString(2);
                ti.created_at  = reader.GetString(4);
                ti.kind_id     = reader.GetInt32(5);
                ti.user_id     = reader.GetInt32(6);
                ti.project_id  = reader.GetInt32(8);
                ti.category_id = reader.GetInt32(9);
                ti.priority_id = reader.GetInt32(10);
                ti.status_id   = reader.GetInt32(11);
            }
            reader.Close();
            return(ti);
        }
Exemplo n.º 2
0
        public static List <TicketData> getAll()
        {
            List <TicketData> tickets = new List <TicketData>();
            MySqlDataReader   reader  = Db.Read("select * from ticket");

            while (reader.Read())
            {
                TicketData ti = new TicketData();
                ti.id          = reader.GetInt32(0);
                ti.title       = reader.GetString(1);
                ti.description = reader.GetString(2);
                ti.created_at  = reader.GetString(4);
                ti.kind_id     = reader.GetInt32(5);
                ti.user_id     = reader.GetInt32(6);
                ti.project_id  = reader.GetInt32(8);
                ti.category_id = reader.GetInt32(9);
                ti.priority_id = reader.GetInt32(10);
                ti.status_id   = reader.GetInt32(11);
                tickets.Add(ti);
            }
            reader.Close();
            return(tickets);
        }
Exemplo n.º 3
0
        public EditTicketForm()
        {
            InitializeComponent();

            TicketData ticket = TicketData.getById(id);

            projects   = ProjectData.getAll();
            kinds      = KindData.getAll();
            statuses   = StatusData.getAll();
            categories = CategoryData.getAll();
            priorities = PriorityData.getAll();
            users      = UserData.getAll();

            string project_str = "";

            foreach (ProjectData p in projects)
            {
                projects_combo.Items.Add(p.name);
                if (p.id == ticket.project_id)
                {
                    project_str = p.name;
                }
            }
            string kind_str = "";

            foreach (KindData k in kinds)
            {
                kind_combo.Items.Add(k.name); if (k.id == ticket.kind_id)
                {
                    kind_str = k.name;
                }
            }
            string status_str = "";

            foreach (StatusData s in statuses)
            {
                status_combo.Items.Add(s.name); if (s.id == ticket.status_id)
                {
                    status_str = s.name;
                }
            }
            string prior_str = "";

            foreach (PriorityData p in priorities)
            {
                prior_combo.Items.Add(p.name); if (p.id == ticket.priority_id)
                {
                    prior_str = p.name;
                }
            }
            string category_str = "";

            foreach (CategoryData c in categories)
            {
                categories_combo.Items.Add(c.name); if (c.id == ticket.category_id)
                {
                    category_str = c.name;
                }
            }
            string user_str = "";

            foreach (UserData u in users)
            {
                users_combo.Items.Add(u.name + " " + u.lastname); if (u.id == ticket.user_id)
                {
                    user_str = u.name + " " + u.lastname;
                }
            }

            textBox1.Text     = ticket.title;
            richTextBox1.Text = ticket.description;


            kind_combo.SelectedIndex       = kind_combo.FindString(kind_str);
            status_combo.SelectedIndex     = status_combo.FindString(status_str);
            prior_combo.SelectedIndex      = prior_combo.FindString(prior_str);
            categories_combo.SelectedIndex = categories_combo.FindString(category_str);
            projects_combo.SelectedIndex   = projects_combo.FindString(project_str);
            users_combo.SelectedIndex      = users_combo.FindString(user_str);
        }
Exemplo n.º 4
0
        public static void renderDatagrid(DataGridView dataGridView1)
        {
            List <TicketData>   tickets = TicketData.getAll();
            List <ProjectData>  projects;
            List <KindData>     kinds;
            List <StatusData>   statuses;
            List <CategoryData> categories;
            List <PriorityData> priorities;
            List <UserData>     users;

            projects   = ProjectData.getAll();
            kinds      = KindData.getAll();
            statuses   = StatusData.getAll();
            categories = CategoryData.getAll();
            priorities = PriorityData.getAll();
            users      = UserData.getAll();



            dataGridView1.Columns.Clear();
            dataGridView1.Rows.Clear();

            dataGridView1.Columns.Add("Id", "Id");
            dataGridView1.Columns.Add("Titulo", "Titulo");
            dataGridView1.Columns.Add("Tipo", "Tipo");
            dataGridView1.Columns.Add("Proyecto", "Proyecto");
            dataGridView1.Columns.Add("Categoria", "Categoria");
            dataGridView1.Columns.Add("Prioridad", "Prioridad");
            dataGridView1.Columns.Add("Estado", "Estado");
            dataGridView1.Columns.Add("Usuario", "Usuario");

            dataGridView1.Columns.Add("Fecha", "Fecha");

            foreach (TicketData ticket in tickets)
            {
                string project_str = "";
                foreach (ProjectData p in projects)
                {
                    if (p.id == ticket.project_id)
                    {
                        project_str = p.name;
                    }
                }
                string kind_str = "";
                foreach (KindData k in kinds)
                {
                    if (k.id == ticket.kind_id)
                    {
                        kind_str = k.name;
                    }
                }
                string status_str = "";
                foreach (StatusData s in statuses)
                {
                    if (s.id == ticket.status_id)
                    {
                        status_str = s.name;
                    }
                }
                string prior_str = "";
                foreach (PriorityData p in priorities)
                {
                    if (p.id == ticket.priority_id)
                    {
                        prior_str = p.name;
                    }
                }
                string category_str = "";
                foreach (CategoryData c in categories)
                {
                    if (c.id == ticket.category_id)
                    {
                        category_str = c.name;
                    }
                }
                string user_str = "";
                foreach (UserData u in users)
                {
                    if (u.id == ticket.user_id)
                    {
                        user_str = u.name + " " + u.lastname;
                    }
                }
                dataGridView1.Rows.Add(ticket.id, ticket.title, kind_str, project_str, category_str, prior_str, status_str, user_str, ticket.created_at);
            }
        }