public static List <KindData> getAll() { List <KindData> tickets = new List <KindData>(); MySqlDataReader reader = Db.Read("select * from kind"); while (reader.Read()) { KindData ti = new KindData(); ti.id = reader.GetInt32(0); ti.name = reader.GetString(1); tickets.Add(ti); } reader.Close(); return(tickets); }
public NewTicketForm() { InitializeComponent(); projects = ProjectData.getAll(); kinds = KindData.getAll(); statuses = StatusData.getAll(); categories = CategoryData.getAll(); priorities = PriorityData.getAll(); users = UserData.getAll(); foreach (ProjectData p in projects) { projects_combo.Items.Add(p.name); } foreach (KindData k in kinds) { kind_combo.Items.Add(k.name); } foreach (StatusData s in statuses) { status_combo.Items.Add(s.name); } foreach (PriorityData p in priorities) { prior_combo.Items.Add(p.name); } foreach (CategoryData c in categories) { categories_combo.Items.Add(c.name); } foreach (UserData u in users) { users_combo.Items.Add(u.name + " " + u.lastname); } }
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); }
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); } }