private void toolStripButton4_Click(object sender, EventArgs e) { if (selectedPersonId == null) { MessageBox.Show("Välj först ett barn från listan nedan.", "Fel"); } else { // Kontroll Boolean control = false; // Hämta in data. var child = dbOject.executeDbQuery("select * from Children where person_id = '" + selectedPersonId + "'"); if (child.Rows.Count > 0) { control = true; } else { string personNr = selectedPersonId.Insert(6, "-"); child = dbOject.executeDbQuery("select * from Children where person_id = '" + personNr + "'"); if (child.Rows.Count > 0) { control = true; } } // Om det finns ett bra visa if (control == true) { DataRow childDr = child.Rows[child.Rows.Count - 1]; // Skapa objekt för klassen funkton functions funcObject = new functions(); MessageBox.Show(childDr["first_name"].ToString() + " " + childDr["last_name"].ToString() + "\nStatus: " + funcObject.translateStatusCode(int.Parse(childDr["status"].ToString())) + "\n\n2 Månader: " + funcObject.getDateByStartDatePlusInterval(childDr["planned_birthday"].ToString(), 61, "yyyy-MM-dd") + "\n5-6 Månader: " + funcObject.getDateByStartDatePlusInterval(childDr["planned_birthday"].ToString(), 183, "yyyy-MM-dd") + "\n10-12 Månader: " + funcObject.getDateByStartDatePlusInterval(childDr["planned_birthday"].ToString(), 365, "yyyy-MM-dd") + "\n18-20 Månader: " + funcObject.getDateByStartDatePlusInterval(childDr["planned_birthday"].ToString(), 610, "yyyy-MM-dd") + "\n2 år: " + funcObject.getDateByStartDatePlusInterval(childDr["planned_birthday"].ToString(), 730, "yyyy-MM-dd") + "\n5 år: " + funcObject.getDateByStartDatePlusInterval(childDr["planned_birthday"].ToString(), 2013, "yyyy-MM-dd"), "Detaljer"); } } }
public void getDataFromDb() { listView1.View = View.Details; // Hämta in data. DataTable dt; if (sqlQuery != null) { dt = dbOject.executeDbQuery(sqlQuery); } else { dt = dataFromOtherView.Copy(); } for (int i = 0; i < dt.Rows.Count; i++) { // Hämta objektet DataRow dr = dt.Rows[i]; // Visa de olika attibuten i rätt kolumn ListViewItem listitem = new ListViewItem(dr["person_id"].ToString().Insert(6, "-")); listitem.SubItems.Add(dr["first_name"].ToString()); listitem.SubItems.Add(dr["last_name"].ToString()); listitem.SubItems.Add(funcObject.translateStatusCode(int.Parse(dr["status"].ToString()))); listitem.SubItems.Add(funcObject.getDateByStatus(funcObject.formatDate(dr["planned_birthday"].ToString(), "yyyy-MM-dd"), int.Parse(dr["status"].ToString()))); listitem.SubItems.Add(funcObject.formatDate(dr["planned_birthday"].ToString(), "yyyy-MM-dd")); // Visa Ja eller Nej if (dr["interpreter"].ToString() == "1") { listitem.SubItems.Add("Ja"); } else { listitem.SubItems.Add("Nej"); } // Lägg upp i listan listView1.Items.Add(listitem); } }