private void salonTree_AfterSelect(object sender, TreeViewEventArgs e) { currentNode = (SalonNode)e.Node; Salon s = currentNode.salon; name.Text = s.name; discount.Text = s.discount.ToString() + " %"; dep.Text = (s.depend == 1 ? "Да" : "Нет"); description.Text = s.description; price.Text = ""; price.Focus(); }
private void Form1_Load(object sender, EventArgs e) { List <Salon> res = DB.Get.execReaderSalon("SELECT * FROM salon ORDER BY pid ASC"); IDictionary <long, SalonNode> nodes = new Dictionary <long, SalonNode>(); foreach (Salon s in res) { SalonNode node = new SalonNode(); node.salon = s; node.Text = s.name; nodes[s.id] = node; if (s.pid == 0) { salonTree.Nodes.Add(node); } else { nodes[s.pid].Nodes.Add(node); } } salonTree.ExpandAll(); salonTree.SelectedNode = salonTree.Nodes[0]; currentNode = (SalonNode)salonTree.Nodes[0]; List <Results> listResults = DB.Get.execReaderResults("SELECT * FROM results ORDER BY id ASC"); foreach (Results r in listResults) { int rowNum = dataGridView1.Rows.Add(); dataGridView1.Rows[rowNum].Cells[0].Value = DB.Get.execScalar("SELECT name FROM salon WHERE id = " + r.sid).ToString(); dataGridView1.Rows[rowNum].Cells[1].Value = r.price.ToString(); dataGridView1.Rows[rowNum].Cells[2].Value = r.result.ToString(); } }