예제 #1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Create your application here
            SetContentView(Resource.Layout.config);

            var txtIpAddress = FindViewById <EditText>(Resource.Id.txtIP);
            var txtDeviceID  = FindViewById <EditText>(Resource.Id.txtDeviceId);
            var txtSiteID    = FindViewById <EditText>(Resource.Id.txtSiteId);

            FindViewById <Button>(Resource.Id.btnConfig).Click += (s, e) =>
            {
                if (txtIpAddress.Text.Equals(string.Empty) || txtDeviceID.Text.Equals(string.Empty) ||
                    txtSiteID.Text.Equals(string.Empty))
                {
                    Toast.MakeText(this, "Enter all fields..", ToastLength.Short).Show();
                    return;
                }
                Toast.MakeText(this, "Success", ToastLength.Short).Show();
                AppPreferences.SaveString(this, Utilities.IPAddress, txtIpAddress.Text.Replace(" ", ""));
                AppPreferences.SaveString(this, Utilities.DEVICEID, txtDeviceID.Text.Replace(" ", ""));
                AppPreferences.SaveString(this, Utilities.SITEID, txtSiteID.Text.Replace(" ", ""));
                StartActivity(typeof(LogInActivity));
            };
        }
예제 #2
0
        public void CreateDatabaseOrModifyDatabase(List <VehicleDetails> vehicleList)
        {
            DeleteDatabase(FuelDB.Singleton.DBPath);
            FuelDB.Singleton.CreateTable <VehicleDetails>();
            FuelDB.Singleton.CreateTable <BillDetails>();

            var details = vehicleList?.First();

            vehicleList.RemoveAt(0);
            var billDetails = new BillDetails
            {
                AvailableLiters   = details.VID,
                BillCurrentNumber = details.DriverID_PK,
                BillPrefix        = details.RegNo,
                DeviceStatus      = details.DriverName
            };

            AppPreferences.SaveString(this, Utilities.DEVICESTATUS, billDetails.DeviceStatus);
            AppPreferences.SaveBool(this, Utilities.IsDownloaded, true);
            FuelDB.Singleton.InsertValues(vehicleList);
            btnDownloadData.Clickable = false;
            FuelDB.Singleton.InsertBillDetails(billDetails);

            RunOnUiThread(() =>
            {
                loader.Visibility = Android.Views.ViewStates.Gone;
                mainHolder.Alpha  = 1f;
                Window.ClearFlags(Android.Views.WindowManagerFlags.NotTouchable);
                Toast.MakeText(this, "success..", ToastLength.Short).Show();
                btnDownloadData.Clickable = false;
                AppPreferences.SaveBool(this, Utilities.IsDownloaded, true);
            });
            ExceptionLog.LogDetails(this, "Database created successfully");
        }
예제 #3
0
        private void CreateDatabaseOrModifyDatabase(List <VehicleDetails> vehicleList)
        {
            DeleteDatabase(FuelDB.Singleton.DBPath);
            FuelDB.Singleton.CreateTable <VehicleDetails>();
            FuelDB.Singleton.CreateTable <BillDetails>();

            //FuelDB.Singleton.CreateDatabase<Fuel>();

            var details = vehicleList?.First();

            vehicleList.RemoveAt(0);
            var billDetails = new BillDetails
            {
                AvailableLiters   = details.VID,
                BillCurrentNumber = details.DriverID_PK,
                BillPrefix        = details.RegNo,
                DeviceStatus      = details.DriverName
            };

            AppPreferences.SaveString(this, Utilities.DEVICESTATUS, billDetails.DeviceStatus);
            AppPreferences.SaveBool(this, Utilities.IsDownloaded, true);
            FuelDB.Singleton.InsertValues(vehicleList);
            btnDownloadData.Clickable = false;
            FuelDB.Singleton.InsertBillDetails(billDetails);
        }
예제 #4
0
        private void BtnPrint_Click(object sender, EventArgs e)
        {
            //var response = UploadItemDetails();
            //if (response != null && !response.Equals(string.Empty))
            //{
            //    AppPreferences.SaveString(this, Utilities.BILLNUMBER, response);
            //    Toast.MakeText(this, "Sucess", ToastLength.Short).Show();
            //}
            if (itemTypeSpinner.SelectedItemPosition.Equals(0))
            {
                Toast.MakeText(this, "Select the particular item..", ToastLength.Short).Show();
                return;
            }
            RunOnUiThread(() =>
            {
                progressLoader.Visibility = ViewStates.Visible;
                layScroll.Alpha           = 0.5f;
                Window.SetFlags(WindowManagerFlags.NotTouchable, WindowManagerFlags.NotTouchable);
            });
            var str = FindViewById <RadioButton>(radioGroup.CheckedRadioButtonId).Text;

            try
            {
                //Console.WriteLine(dataToUpload);
                var list = new List <UploadItemDetails>()
                {
                    new UploadItemDetails
                    {
                        // DID = AppPreferences.GetString(this, Utilities.DEVICEID),
                        DID       = did,
                        EntryDate = DateTime.Now.ToString("MM/dd/yyyy", CultureInfo.InvariantCulture),
                        EWeight   = lblEmptyWeight.Text,
                        LBNo      = lblBillNumber.Text,
                        OwnerName = ownerName.Text,
                        PayMode   = str,
                        VehicleNo = vehicleNumberAutoComplete.Text,
                        //SiteID = AppPreferences.GetString(this, Utilities.SITEID),
                        SiteID    = siteId,
                        WMode     = wMode.SelectedItem.ToString(),
                        ItemName  = itemTypeSpinner.SelectedItem.ToString(),
                        OwnerId   = vehiclDetailList.Where(x => x.RegNo == vehicleNumberAutoComplete.Text).First().OID,
                        VehicleId = vehiclDetailList.Where(x => x.RegNo == vehicleNumberAutoComplete.Text).First().VID,
                        ItemId    = itemDetails.Where(x => x.MaterialName == itemTypeSpinner.SelectedItem.ToString()).First().ItemID_PK
                    }
                };
                var serializedData = JsonConvert.SerializeObject(list);
                var result         = WebService.Singleton.PostAllDataToWebService(Utilities.INVE, serializedData, "INVEResult");
                if (result == null)
                {
                    RunOnUiThread(() =>
                    {
                        progressLoader.Visibility = ViewStates.Gone;
                        layScroll.Alpha           = 1f;
                        Window.ClearFlags(WindowManagerFlags.NotTouchable);
                        Toast.MakeText(this, "Error in upload..", ToastLength.Short).Show();
                    });
                    return;
                }
                var deserializeResult = JsonConvert.DeserializeObject <List <UploadFirstResult> >(result);
                //Save bill number
                AppPreferences.SaveString(this, Utilities.BILLNUMBER, deserializeResult.First().CUNUM);

                var intent             = new Intent(this, typeof(PrintViewActivity));
                var lista              = list.Select(x => new { x.LBNo, x.EntryDate, x.VehicleNo, x.OwnerName, x.ItemName, x.EWeight, x.PayMode, x.WMode });
                var array              = new string[] { "LB. No.", "Date", "Vehicle", "Customer", "Item", "Empty Weight", "Pay Mode", "W Mode" };
                var seralizedPrintData = JsonConvert.SerializeObject(lista);
                intent.PutExtra("data", seralizedPrintData);
                intent.PutStringArrayListExtra("array", array);
                intent.PutExtra("typeof", "UploadItemDetails");
                StartActivity(intent);
                RunOnUiThread(() =>
                {
                    progressLoader.Visibility = ViewStates.Gone;
                    layScroll.Alpha           = 1f;
                    Window.ClearFlags(WindowManagerFlags.NotTouchable);
                });
            }
            catch (Exception ex)
            {
                RunOnUiThread(() =>
                {
                    progressLoader.Visibility = ViewStates.Gone;
                    layScroll.Alpha           = 1f;
                    Window.ClearFlags(WindowManagerFlags.NotTouchable);
                });
            }
        }