Ejemplo n.º 1
0
        public async void ApiRSTlist()
        {
            var progressDialog = ProgressDialog.Show(this, "Please wait...", "Updating Data From Server...", true);

            try
            {
                var address = ConAddress.GetListArray1("select * from tblAddressList where sync='1'");
                foreach (var x in address)
                {
                    await(ApiConnection1.AddressId(GlobalVariables.GlobalUrl + "/addressid"));
                    await(ApiConnection1.Updatedata(GlobalVariables.GlobalUrl + "/address/" + GlobalVariables.GlobalUserid + "/" + x.province + "/" + x.city + "/" + x.barangay + "/" + x.building_no + "/" + x.fname + "/" + x.lname + "/" + x.contact));
                    var member = ConMember.GetListArray1("select * from tblmember where address_id='" + x.id + "'");
                    foreach (var m in member)
                    {
                        var ename = m.ename;
                        if (m.ename == "")
                        {
                            ename = "000";
                        }
                        await(ApiConnection1.Updatedata(GlobalVariables.GlobalUrl + "/member/" + GlobalVariables.GlobalAddressId + "/" + m.fname + "/" + m.mname + "/" + m.lname + "/" + ename + "/" + m.rhousehold + "/" + m.gender + "/" + m.birthday + "/" + m.birth_certificate + "/" + m.marital_status + "/" + m.religion + "/" + m.school_attendance + "/" + m.literacy + "/" + m.highest_grade + "/" + m.work_status + "/" + m.occupation));
                    }
                    var housing = ConHousing.GetListSingle("select * from tblHousing where address_id='" + x.id + "'");
                    await(ApiConnection1.Updatedata(GlobalVariables.GlobalUrl + "/housing/" + GlobalVariables.GlobalAddressId + "/" + housing.building + "/" + housing.roof + "/" + housing.wall + "/" + housing.light + "/" + housing.drink + "/" + housing.cooking + "/" + housing.tenure));

                    var death = ConDeath.GetListArray1("select * from tblDeath where address_id='" + x.id + "'");
                    foreach (var d in death)
                    {
                        await(ApiConnection1.Updatedata(GlobalVariables.GlobalUrl + "/death/" + GlobalVariables.GlobalAddressId + "/" + d.fname + "/" + d.lname + "/" + d.gender + "/" + d.age_death + "/" + d.register + "/" + d.birthcertificate));
                    }

                    ConAddress.DeleteAddressQuery("delete from tblAddressList where id='" + housing.address_id + "'");
                    ConMember.DeleteMemberQuery("delete from tblmember where address_id='" + housing.address_id + "'");
                    ConHousing.DeleteHousingQuery("delete from tblHousing where address_id='" + housing.address_id + "'");
                    ConDeath.DeleteDeathQuery("delete from tblDeath where address_id='" + housing.address_id + "'");

                    Toast.MakeText(this, "Saving Successful..", ToastLength.Long).Show();
                    refreshItems();
                }
            }
            catch (Exception ex)
            {
                Toast.MakeText(this, "Unable To Update Data.\n" + ex.Message, ToastLength.Long).Show();
            }

            progressDialog.Cancel();
        }