public void fillOtherData() { lb_SelectedCustomer_Kin.Items.Clear(); lb_SelectedCustomer_State.Items.Clear(); //TODO: Add select for some extended data for customer selection //var cust = getSomeData(); try { DataGridViewRow x = dg_DataTable.Rows[selectedrow]; lbl_SelectedCustomer_Name.Text = dg_DataTable.Rows[selectedrow].Cells[0].Value.ToString(); lbl_SelectedCustomer_ID.Text = "#" + x.Cells[2].Value.ToString(); c_MainDataRow data = x.Cells[1].Tag as c_MainDataRow; if (data != null) { lbl_SelectedCustomer_Added.Text = data.dateAdded.ToShortDateString(); if (data.lastSupport == null) { lbl_SelectedCustomer_LastSupported.Text = ""; } else { lbl_SelectedCustomer_LastSupported.Text = ((DateTime)data.lastSupport).ToShortDateString(); } lbl_SelectedCustomer_JILead.Text = data.j == true ? "PIPA" : "IX"; lbl_SelectedCustomer_Dwelling_City.Text = data.city; lbl_SelectedCustomer_Dwelling_ZipCode.Text = data.zip; lbl_SelectedCustomer_Dwelling_Street.Text = data.houseno; foreach (string s in data.kin) { lb_SelectedCustomer_Kin.Items.Add(s); } foreach (string s in data.state.Split('|')) { lb_SelectedCustomer_State.Items.Add(s); } } } catch (Exception ex) { Console.Error.Write(ex.ToString()); } }
/// <summary> /// Get all rows for the mainData type (the type that is used to fill the main data table) /// </summary> /// <param name="sqlc">Current open SQLiteConnection</param> /// <returns>List containing every row in c_MainDataRow objects</returns> public static List <c_MainDataRow> getMainRowData(SQLiteConnection sqlc, string where) { string main_command = @" SELECT id,COALESCE(nev, '') AS nev, COALESCE(jovedelem_igazolas, 'F') AS jovedelem_igazolas, COALESCE(azonosito,'') AS azonosito, COALESCE(lakcim_varos,'') AS lakcim_varos, COALESCE(lakcim_uh,'') AS lakcim_uh, COALESCE(lakcim_zip,'') AS lakcim_zip, COALESCE(allapot,'') AS allapot, COALESCE(hozzaadas_datuma,'') AS hozzaadas_datuma, COALESCE(utolso_tamogatas_idopontja,'') AS utolso_tamogatas_idopontja FROM ugyfel " + where; List <c_MainDataRow> lst = new List <c_MainDataRow>(); SQLiteCommand sqlk = new SQLiteCommand(main_command, sqlc); SQLiteDataReader r = sqlk.ExecuteReader(); string current_azonosito = c_DBHandler.get_azonosito(sqlc); c_MainDataRow mdr = new c_MainDataRow(); while (r.Read()) { mdr = new c_MainDataRow(); mdr.id = r.GetInt32(r.GetOrdinal("id")); mdr.name = (r.GetString(r.GetOrdinal("nev"))); mdr.j = ((r.GetString(r.GetOrdinal("jovedelem_igazolas"))) == "T" ? true : false); mdr.identification = (r.GetString(r.GetOrdinal("azonosito"))); mdr.city = (r.GetString(r.GetOrdinal("lakcim_varos"))); mdr.houseno = (r.GetString(r.GetOrdinal("lakcim_uh"))); mdr.zip = (r.GetString(r.GetOrdinal("lakcim_zip"))); mdr.state = (r.GetString(r.GetOrdinal("allapot"))); DateTime o_dtadded; if (DateTime.TryParse(r.GetValue(r.GetOrdinal("hozzaadas_datuma")).ToString(), out o_dtadded)) { mdr.dateAdded = o_dtadded; } else { mdr.dateAdded = default(DateTime); //TODO: Checkdate-ben lekezelni az üres értéket mdr.dtadded = r.GetValue(r.GetOrdinal("hozzaadas_datuma")).ToString(); } string d = (r.GetString(r.GetOrdinal("utolso_tamogatas_idopontja"))); try { mdr.lastSupport = (d != "" ? Convert.ToDateTime(c_DBHandler.checkDate(d)) : (DateTime?)null); } catch { mdr.lastSupport = null; } mdr.kin = new List <string>(); string kin_command = "SELECT * FROM haztartasban_elok WHERE ugyfel_id=" + mdr.id; SQLiteCommand sqlk2 = new SQLiteCommand(kin_command, sqlc); SQLiteDataReader rr = sqlk2.ExecuteReader(); while (rr.Read()) { mdr.kin.Add((rr.GetValue(rr.GetOrdinal("rokoni_kapcsolat"))) + ":" + (rr.GetValue(rr.GetOrdinal("nev")))); } lst.Add(mdr); } if (c_DBHandler.greater(current_azonosito, mdr.identification)) { current_azonosito = mdr.identification; } c_DBHandler.set_azonosito(sqlc, current_azonosito); return(lst); }