Exemplo n.º 1
0
        private async void button1_Click(object sender, EventArgs e)
        {
            FirebaseResponse resp = await client.GetTaskAsync("counter/node");

            Counter_class get = resp.ResultAs <Counter_class>();

            MessageBox.Show(get.cnt);

            var data = new Data
            {
                homeID                 = (Convert.ToInt32(get.cnt) + 1).ToString(),
                CitizenID              = textBox2.Text,
                Name                   = textBox3.Text,
                NIC                    = textBox4.Text,
                Birthday               = textBox5.Text,
                gender                 = textBox6.Text,
                Maritaul_status_ID     = textBox7.Text,
                email                  = textBox8.Text,
                Nationality            = textBox9.Text,
                job                    = textBox10.Text,
                village                = textBox15.Text,
                Allowance              = textBox14.Text,
                Landpolicy             = textBox13.Text,
                house_type             = textBox12.Text,
                water_type             = textBox11.Text,
                Disability             = textBox20.Text,
                power_supply           = textBox19.Text,
                toilets                = textBox18.Text,
                education_qulification = textBox16.Text
            };

            SetResponse response = await client.SetTaskAsync("Information/" + data.homeID, data);

            Data result = response.ResultAs <Data>();

            MessageBox.Show("Data inserted" + result.homeID);

            var obj = new Counter_class
            {
                cnt = data.homeID
            };

            SetResponse response1 = await client.SetTaskAsync("counter/node", obj);

            export();

            /*FirebaseResponse resp = await client.GetTaskAsync("counter/node");
             * Counter_class get = resp.ResultAs<Counter_class>();
             *
             * MessageBox.Show(get.cnt);
             *
             * var data = new Data
             * {
             *
             *  homeID = (Convert.ToInt32(get.cnt) + 1).ToString(),
             *  CitizenID = textBox2.Text,
             *  Name = textBox3.Text,
             *  NIC = textBox4.Text,
             *  Birthday = textBox5.Text,
             *  gender = textBox6.Text,
             *  Maritaul_status_ID = textBox7.Text,
             *  email = textBox8.Text,
             *  Nationality = textBox9.Text,
             *  job = textBox10.Text,
             *  village = textBox15.Text,
             *  Allowance = textBox14.Text,
             *  Landpolicy = textBox13.Text,
             *  house_type = textBox12.Text,
             *  water_type = textBox11.Text,
             *  Disability = textBox20.Text,
             *  power_supply = textBox19.Text,
             *  toilets = textBox18.Text,
             *  education_qulification = textBox16.Text
             *
             * };
             *
             * SetResponse response = await client.SetTaskAsync("Information/" + data.homeID, data);
             * Data result = response.ResultAs<Data>();
             *
             * MessageBox.Show("Data inserted" + result.homeID);
             *
             * var obj = new Counter_class
             * {
             *  cnt = data.homeID
             * };
             *
             * SetResponse response1 = await client.SetTaskAsync("counter/node", obj);*/
        }
Exemplo n.º 2
0
        private async void export()
        {
            dt.Rows.Clear();
            int i = 0;
            FirebaseResponse resp1 = await client.GetTaskAsync("counter/node");

            Counter_class obj1 = resp1.ResultAs <Counter_class>();
            int           cnt  = Convert.ToInt32(obj1.cnt);



            while (true)
            {
                if (i == cnt)
                {
                    break;
                }

                i++;
                try
                {
                    FirebaseResponse resp2 = await client.GetTaskAsync("Information/" + i);

                    Data    obj2 = resp2.ResultAs <Data>();
                    DataRow row  = dt.NewRow();

                    /*foreach (DataRow item in dtdepartment.Rows)
                     * {
                     * int n = departmentdataGridView1.Rows.Add();
                     * departmentdataGridView1.Rows[n].Cells[0].Value = item["D_ID"].ToString();
                     * departmentdataGridView1.Rows[n].Cells[1].Value = item["D_name"].ToString();
                     * departmentdataGridView1.Rows[n].Cells[2].Value = item["Desicnation"].ToString();
                     *
                     * }*/



                    row["homeID"]                 = obj2.homeID;
                    row["CitizenID"]              = obj2.CitizenID;
                    row["Name"]                   = obj2.Name;
                    row["NIC"]                    = obj2.NIC;
                    row["Birthday"]               = obj2.Birthday;
                    row["gender"]                 = obj2.gender;
                    row["Maritaul_status_ID"]     = obj2.Maritaul_status_ID;
                    row["email"]                  = obj2.email;
                    row["Nationality"]            = obj2.Nationality;
                    row["job"]                    = obj2.job;
                    row["village"]                = obj2.village;
                    row["Allowance"]              = obj2.Allowance;
                    row["Landpolicy"]             = obj2.Landpolicy;
                    row["house_type"]             = obj2.house_type;
                    row["water_type"]             = obj2.water_type;
                    row["Disability"]             = obj2.Disability;
                    row["power_supply"]           = obj2.power_supply;
                    row["toilets"]                = obj2.toilets;
                    row["education_qulification"] = obj2.education_qulification;


                    dt.Rows.Add(row);
                }
                catch
                {
                }
            }


            MessageBox.Show(cnt.ToString());
        }