private void BtnDownloadData_Click(object sender, EventArgs e)
 {
     if (ExceptionLog.IsNetworkConected(this))
     {
         if (!AppPreferences.GetBool(this, Utilities.IsDownloaded))
         {
             ExceptionLog.LogDetails(this, IpAddress + " " + siteId + " " + deviceId);
             ExceptionLog.LogDetails(this, "Download button Clicked.." + DateTime.Now);
             SyncButton_Click();
         }
         else
         {
             Toast.MakeText(this, "Please Upload Data and Try again..", ToastLength.Short).Show();
         }
     }
     else
     {
         Toast.MakeText(this, "Check with Internet Connectivity", ToastLength.Short).Show();
     }
 }
Exemple #2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.MainScreen);

            mainLayout = FindViewById <LinearLayout>(Resource.Id.layHolder);
            loader     = FindViewById <ProgressBar>(Resource.Id.loader);
            mainHolder = FindViewById <RelativeLayout>(Resource.Id.mainRelativeHolder);

            //var pref = PreferenceManager.GetDefaultSharedPreferences(this);
            //Ipadress = pref.GetString(Utilities.IPAddress, string.Empty);

            //Get IPAdress for preference
            IpAddress = AppPreferences.GetString(this, Utilities.IPAddress);
            siteId    = AppPreferences.GetString(this, Utilities.SITEID);
            deviceId  = AppPreferences.GetString(this, Utilities.DEVICEID);

            WebService.IPADDRESS = IpAddress;


            FindViewById <ImageButton>(Resource.Id.btnLogout).Click += (s, e) =>
            {
                var alertDialog1 = new Android.App.AlertDialog.Builder(this);
                alertDialog1.SetTitle("Logout");
                alertDialog1.SetMessage("Do you want to exit ?");
                alertDialog1.SetPositiveButton("OK", (ss, se) => Finish());
                alertDialog1.Show();
            };
            FindViewById <Button>(Resource.Id.btnFuelEntry).Click += (s, e) =>
            {
                //VehicleList = FuelDB.Singleton.GetValue().ToList();

                if (FuelDB.Singleton.DBExists() && FuelDB.Singleton.GetBillDetails() != null)
                {
                    if (AppPreferences.GetString(this, Utilities.DEVICESTATUS).Equals("1"))
                    {
                        StartActivity(typeof(FuelActivity));
                    }
                    else
                    {
                        Toast.MakeText(this, "Device not avalable", ToastLength.Short).Show();
                    }
                }
                else
                {
                    var alertDialog1 = new Android.App.AlertDialog.Builder(this);
                    alertDialog1.SetTitle("you need to sync first");
                    alertDialog1.SetPositiveButton("OK", (ss, se) => { });
                    alertDialog1.Show();
                }
                // SyncButton_Click();
            };

            btnDownloadData        = FindViewById <Button>(Resource.Id.btnDownloadData);
            btnDownloadData.Click += (s, e) =>
            {
                if (!AppPreferences.GetBool(this, Utilities.IsDownloaded))
                {
                    SyncButton_Click();
                }
                else
                {
                    Toast.MakeText(this, "Please Upload Data and Try again..", ToastLength.Short).Show();
                }
            };

            btnUploadData        = FindViewById <Button>(Resource.Id.btnUploadData);
            btnUploadData.Click += (s, e) =>
            {
                UploadDetailsToServer();
            };
        }