//galutinė išvestis private void finalOutput(object sender, RoutedEventArgs e) { MySqlConnection conn = new MySqlConnection(connStr); bool correct = true; correct = chkComboBox(out_ob, out_ob_label, correct); correct = chkTextBoxNum(out_e, correct); correct = chkTextBoxNum(out_d, correct); correct = chkTextBoxNum(out_v, correct); correct = chkTextBoxNum(out_i, correct); if (output.filename != null && correct) { output.obid = Int32.Parse(get_strid(out_ob.Text)); output.elek = Double.Parse(out_e.Text); output.duj = Double.Parse(out_d.Text); output.vand = Double.Parse(out_v.Text); output.inter = Double.Parse(out_i.Text); for (int i = 0; i < out_bend.Items.Count; i++) { BendrMok eile = (BendrMok)out_bend.Items[i]; output.bendrpav.Add(eile.Pavadinimas); output.bendrkain.Add(eile.Kaina); } output.Generate(conn); output.Clear(); } else if (output.filename == null) { out_filebutton.BorderBrush = new SolidColorBrush(Colors.Red); } }
//uzkrauna pasirinkta objekta i isvesties langa private void loadOutObjektas(object sender, EventArgs e) { string obid = get_strid(out_ob.Text); if (obid != "null") { MySqlConnection conn = new MySqlConnection(connStr); Objektas ob = new Objektas(); conn.Open(); //komunaliniai string sql = "SELECT corr_nid, ce_oid, cd_oid, cv_oid, ci_oid FROM objektai WHERE obid =" + obid + ";"; MySqlCommand comm = new MySqlCommand(sql, conn); MySqlDataReader data = comm.ExecuteReader(); while (data.Read()) { ob.clear(); ob.ID = Int32.Parse(obid); ob.corr_nid = Int32.Parse(data["corr_nid"].ToString()); ob.ce_oid = Int32.Parse(data["ce_oid"].ToString()); ob.cd_oid = Int32.Parse(data["cd_oid"].ToString()); ob.cv_oid = Int32.Parse(data["cv_oid"].ToString()); ob.ci_oid = Int32.Parse(data["ci_oid"].ToString()); ob.set_variables(); } out_e_title.Content = "Elektra ( " + ob.Elek.ToString() + " ):"; out_d_title.Content = "Dujos/šiluma ( " + ob.Duj.ToString() + " ):"; out_v_title.Content = "Vanduo ( " + ob.Vand.ToString() + " ):"; out_i_title.Content = "Internetas ( " + ob.Int.ToString() + " ):"; //reikia pavaizutoti interneto kaina, nes ji nekinta sql = "SELECT op_rate FROM operatoriai WHERE oid=" + ob.ci_oid.ToString() + ";"; comm = new MySqlCommand(sql, conn); data.Dispose(); data = comm.ExecuteReader(); while (data.Read()) { out_i.Text = data["op_rate"].ToString(); } //bendrijos List <BendrMok> ben = new List <BendrMok>(); sql = "SHOW COLUMNS FROM ben_" + obid + ";"; comm = new MySqlCommand(sql, conn); data.Dispose(); data = comm.ExecuteReader(); while (data.Read()) { if (data["Field"].ToString() != "timestamp" && data["Field"].ToString() != "kmokid") { BendrMok buf = new BendrMok(); buf.Pavadinimas = data["Field"].ToString(); buf.Kaina = 0; ben.Add(buf); } } sql = "SELECT * FROM ben_" + obid + " ORDER BY kmokid DESC LIMIT 1;"; comm = new MySqlCommand(sql, conn); data.Dispose(); data = comm.ExecuteReader(); int count = 0; string name; while (data.Read()) { name = ben[count].Pavadinimas.ToString(); ben[count].Kaina = Double.Parse(data[name].ToString()); count++; } out_bend.ItemsSource = ben; conn.Close(); } }