Пример #1
0
        //perkrauna visus objektis
        private void reloadObjektai(MySqlConnection conn)
        {
            objektai.Items.Clear();

            string       sql  = "SELECT * FROM objektai";
            MySqlCommand comm = new MySqlCommand(sql, conn);

            MySqlDataReader eil = comm.ExecuteReader();

            while (eil.Read())
            {
                Objektas ob = new Objektas();
                ob.clear();
                ob.ID       = Int32.Parse(eil["obid"].ToString());
                ob.Kvad     = Double.Parse(eil["ob_kvad"].ToString());
                ob.Nuoma    = Double.Parse(eil["Nuoma"].ToString());
                ob.Address  = eil["ob_addr"].ToString();
                ob.corr_nid = Int32.Parse(eil["corr_nid"].ToString());
                ob.ce_oid   = Int32.Parse(eil["ce_oid"].ToString());
                ob.cd_oid   = Int32.Parse(eil["cd_oid"].ToString());
                ob.cv_oid   = Int32.Parse(eil["cv_oid"].ToString());
                ob.ci_oid   = Int32.Parse(eil["ci_oid"].ToString());
                ob.set_variables();

                objektai.Items.Add(ob);
            }

            conn.Close();
        }
Пример #2
0
        //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();
            }
        }