Esempio n. 1
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");
        }
Esempio n. 2
0
        private async void GetDetails()
        {
            WebService.IPADDRESS = AppPreferences.GetString(this, Utilities.IPAddress);
            //WebService.IPADDRESS = "49.207.180.49";
            //did = "FED11";
            did = AppPreferences.GetString(this, Utilities.DEVICEID);
            //siteId = "2";
            siteId = AppPreferences.GetString(this, Utilities.SITEID);
            try
            {
                //var result = await WebService.Singleton.PostDataToWebService(Utilities.GET_VEHICLE_DETAILS, did, siteId, Utilities.GET_VEHICLE_RESULT);
                //vehiclDetailList = JsonConvert.DeserializeObject<List<VehicleDetails>>(result);
                var itemType = await WebService.Singleton.PostDataToWebService(Utilities.GET_ITEM_DETAILS, did, siteId, Utilities.GET_ITEM_RESULT);

                itemDetails = JsonConvert.DeserializeObject <List <ItemDetails> >(itemType);

                itemList = itemDetails.Select(x => x.MaterialName).ToList();
                //itemList.Insert(0, "Select");
                //itemTypeSpinner.Adapter = new BasicAdapter(this, itemDetails.Select(x => x.MaterialName).ToArray());
                ShowLoader(false);
            }
            catch (Exception ex)
            {
                RunOnUiThread(() =>
                {
                    Toast.MakeText(this, "No Data to load..", ToastLength.Short).Show();
                    ShowLoader(false);
                });
                ExceptionLog.LogDetails(this, ex.Message + "\n\n Exception in GetItem");
            }
        }
Esempio n. 3
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));
                ExceptionLog.LogDetails(this, "App Configured..");
            };
        }
Esempio n. 4
0
 private void CheckFuelAvailbility()
 {
     try
     {
         availableFuel = float.Parse(billDetailsList?.AvailableLiters);
         if (string.IsNullOrEmpty(fuelToFill.Text))
         {
             if (!fuelTypeSpinner.SelectedItem.Equals(ConstantValues.SHORTAGE))
             {
                 fuelAvailable.Text = $"{billDetailsList.AvailableLiters}";
             }
             return;
         }
         if (!string.IsNullOrEmpty(txtOpeningKMS.Text) && !string.IsNullOrEmpty(txtClosingKMS.Text) &&
             string.IsNullOrEmpty(fuelToFill.Text))
         {
             GetKMPL();
         }
     }
     catch (Exception ex)
     {
         Toast.MakeText(this, "Could not load data please sync again", ToastLength.Short).Show();
         ExceptionLog.LogDetails(this, "Sync problem " + ex.Message);
     }
 }
Esempio n. 5
0
        private void DrawPrintView(string[] inwardValues)
        {
            var index = 0;

            foreach (var item in printDetails.GetType().GetProperties())
            {
                try
                {
                    if (item.GetValue(printDetails) != null)
                    {
                        var  layoutInf = (LayoutInflater)GetSystemService(LayoutInflaterService);
                        View view      = layoutInf.Inflate(Resource.Layout.PrintView, null);
                        view.FindViewById <TextView>(Resource.Id.txtName).Text  = inwardValues[index];
                        view.FindViewById <TextView>(Resource.Id.txtValue).Text = item.GetValue(printDetails, null).ToString();
                        layoutMain.AddView(view, index);
                        index++;
                    }
                }
                catch (Exception ex)
                {
                    ExceptionLog.LogDetails(this, "Error in retriving print details " + ex.Message);
                    Console.WriteLine(ex.Message);
                }
                finally
                {
                    btnPrint.Visibility = ViewStates.Visible;
                }
            }
        }
Esempio n. 6
0
 private void ClearHistory()
 {
     FuelDB.Singleton.DeleteTable <BillHistory>();
     historyList.Adapter = null;
     historyList.Invalidate();
     ExceptionLog.LogDetails(this, "History Cleared at" + DateTime.Now);
     Toast.MakeText(this, "Successfully cleared history", ToastLength.Short).Show();
     DisableClearButton(false);
 }
Esempio n. 7
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Create your application here
            SetContentView(Resource.Layout.DeliveryDetail);
            ExceptionLog.LogDetails(this, "\n\n In Vehicle Delivery...");

            TaskScheduler.UnobservedTaskException += (s, e) =>
            {
                Toast.MakeText(this, "Something went wrong", ToastLength.Short).Show();
            };


            lblBillNumber   = FindViewById <TextView>(Resource.Id.lblBillNumber);
            itemTypeSpinner = FindViewById <Spinner>(Resource.Id.itemTypeSpinner);
            //  lblDate = FindViewById<TextView>(Resource.Id.lblDate);
            loaderLayout       = FindViewById <LinearLayout>(Resource.Id.layProgressLoader);
            btnUpdate          = FindViewById <Button>(Resource.Id.btnUpdate);
            btnCheck           = FindViewById <Button>(Resource.Id.btnCheck);
            layBillEntry       = FindViewById <LinearLayout>(Resource.Id.layBillEntry);
            layDeliveryDetails = FindViewById <LinearLayout>(Resource.Id.layDeliveryDetails);

            //bill number text
            txtBillNumber = FindViewById <EditText>(Resource.Id.txtBillNumber);

            btnCheck.Click  += BtnCheck_Click;
            btnUpdate.Click += BtnUpdate_Click;

            ShowLoader(true);
            //loaderLayout.Visibility = Android.Views.ViewStates.Visible;

            lblBillNumber.Text = AppPreferences.GetString(this, Utilities.BILLNUMBER);
            //  lblDate.Text = DateTime.Now.ToString(Utilities.DATE_MONTH_TIME, CultureInfo.InvariantCulture);

            itemTypeSpinner.ItemSelected += (s, e) =>
            {
            };

            Task.Run(() => GetDetails());


            FindViewById <ImageButton>(Resource.Id.btnLogout).Click += (s, e) =>
            {
                var alertDialog = new Android.App.AlertDialog.Builder(this);
                alertDialog.SetTitle("Logout");
                alertDialog.SetMessage("Do you want to logout ?");
                alertDialog.SetPositiveButton("Yes", (se, ee) =>
                {
                    StartActivity(typeof(LogInActivity));
                    Finish();
                });
                alertDialog.SetNegativeButton("No", (se, ee) => { });
                alertDialog.Show();
            };
        }
Esempio n. 8
0
        private async Task GetDetails()
        {
            WebService.IPADDRESS = AppPreferences.GetString(this, Utilities.IPAddress);
            //WebService.IPADDRESS = "49.207.180.49";
            //did = "FED11";
            did = AppPreferences.GetString(this, Utilities.DEVICEID);
            //siteId = "2";
            siteId = AppPreferences.GetString(this, Utilities.SITEID);

            if (!did.Equals(string.Empty) && !siteId.Equals(string.Empty) && !WebService.IPADDRESS.Equals(string.Empty))
            {
                try
                {
                    var result = await WebService.Singleton.PostDataToWebService(Utilities.GET_VEHICLE_DETAILS,
                                                                                 did, siteId, Utilities.GET_VEHICLE_RESULT);

                    vehiclDetailList = JsonConvert.DeserializeObject <List <VehicleDetails> >(result);
                    var itemType = await WebService.Singleton.PostDataToWebService(Utilities.GET_ITEM_DETAILS,
                                                                                   did, siteId, Utilities.GET_ITEM_RESULT);

                    itemDetails = JsonConvert.DeserializeObject <List <ItemDetails> >(itemType);

                    var response = await WebService.Singleton.PostDataToWebService(Utilities.GET_CURRENT_BILL,
                                                                                   did, siteId, Utilities.GET_CURRENT_BILL_RES);

                    var currentBill = JsonConvert.DeserializeObject <List <UploadFirstResult> >(response);
                    RunOnUiThread(() =>
                    {
                        lblBillNumber.Text = currentBill.First().CUNUM;
                        FillVehicleDetails();
                    });
                }
                catch (Exception ex)
                {
                    RunOnUiThread(() =>
                    {
                        Toast.MakeText(this, "No Data to load..", ToastLength.Short).Show();
                    });
                    Console.WriteLine(ex.Message);
                    ExceptionLog.LogDetails(this, ex.Message + "\n\n In GetVE");
                }
            }
            else
            {
                RunOnUiThread(() =>
                {
                    Toast.MakeText(this, "Someting went wrong..", ToastLength.Short).Show();
                });
            }
            ShowLoader(false);
            //itemList.AddRange(itemDetails.Select(x => x.MaterialName).ToList());
        }
Esempio n. 9
0
        private void CheckBillNumberAndGetDetails()
        {
            // WebService.IPADDRESS = "49.207.180.49";
            // did = "FED11";
            //AppPreferences.GetString(this, Utilities.DEVICEID);
            // siteId = "2";
            WebService.IPADDRESS = AppPreferences.GetString(this, Utilities.IPAddress);
            did    = AppPreferences.GetString(this, Utilities.DEVICEID);
            siteId = AppPreferences.GetString(this, Utilities.SITEID);

            if (!did.Equals(string.Empty) && !siteId.Equals(string.Empty) && !WebService.IPADDRESS.Equals(string.Empty))
            {
                try
                {
                    var result = WebService.Singleton.GetBillDetails("CheckVE", txtBillNumber.Text, siteId);
                    itemDetailsGetVE = JsonConvert.DeserializeObject <List <VehicleDetailsGETVE> >(result);
                    if (!itemDetailsGetVE.Equals(string.Empty))
                    {
                        if (itemDetailsGetVE.First().IsDS.ToLower().Equals("false"))
                        {
                            layDeliveryDetails.Visibility = Android.Views.ViewStates.Visible;
                            layBillEntry.Visibility       = Android.Views.ViewStates.Gone;
                            isBillEntry        = false;
                            lblBillNumber.Text = itemDetailsGetVE.First().LoadBillNo;
                            var name         = itemDetailsGetVE.First().ItemName;
                            var index        = itemList.FindIndex(x => x.StartsWith(name));
                            var selectedItem = itemList[index];
                            itemList.RemoveAt(index);
                            itemList.Insert(0, selectedItem);
                            itemTypeSpinner.Adapter = new ArrayAdapter(this, Resource.Layout.spinner_item, itemList);
                        }
                        else
                        {
                            ShowWrongText("Already Updated...");
                        }
                    }
                    else
                    {
                        ShowWrongText();
                    }
                }
                catch (Exception ex)
                {
                    Toast.MakeText(this, "No Data to load..", ToastLength.Short).Show();
                    ExceptionLog.LogDetails(this, ex.Message + "\n\n Exception in CheckBillNumberAndGetDetails");
                }
            }
            else
            {
                ShowWrongText();
            }
        }
Esempio n. 10
0
 private void BtnUploadData_Click(object sender, EventArgs e)
 {
     if (ExceptionLog.IsNetworkConected(this))
     {
         ExceptionLog.LogDetails(this, "Upload server started.." + DateTime.Now);
         ExceptionLog.LogDetails(this, IpAddress + " " + siteId + " " + deviceId);
         UploadDetailsToServer();
     }
     else
     {
         Toast.MakeText(this, "Check with Internet Connectivity", ToastLength.Short).Show();
     }
 }
Esempio n. 11
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            try
            {
                nGXPrinter = NGXPrinter.NgxPrinterInstance;
                nGXPrinter.InitService(this, this);
            }
            catch (Exception ex)
            {
                ExceptionLog.LogDetails(this, ex.Message);
            }
            // Create your application here
            SetContentView(Resource.Layout.activity_main);

            TaskScheduler.UnobservedTaskException += (s, e) =>
            {
                Toast.MakeText(this, "Something went wrong", ToastLength.Short).Show();
            };

            layMainLinear = FindViewById <LinearLayout>(Resource.Id.layMainLinear);
            layMainScroll = FindViewById <ScrollView>(Resource.Id.layMainScroll);
            var data  = Intent.GetStringExtra("data");
            var array = Intent.GetStringArrayListExtra("array");

            listType = Intent.GetStringExtra("typeof");

            FindViewById <Button>(Resource.Id.btn).Click += (s, e) =>
            {
                PrintFromPrinter();
                // printAgain();
            };
            btnSave        = FindViewById <Button>(Resource.Id.btnSave);
            btnSave.Click += BtnSave_Click;
            if (listType != null && listType.Equals("UploadItemDetails"))
            {
                var deserializeResult = JsonConvert.DeserializeObject <List <UploadItemDetails> >(data);
                Print(deserializeResult.First(), array);
            }
            else
            {
                var deserializeResult = JsonConvert.DeserializeObject <VehicleDetailsGETVE>(data);
                PrintSecond(deserializeResult, array);
            }
        }
Esempio n. 12
0
        private void BtnUpdate_Click(object sender, EventArgs e)
        {
            //if (itemTypeSpinner.SelectedItemPosition.Equals(0))
            //{
            //    Toast.MakeText(this, "Select the particular item..", ToastLength.Short).Show();
            //    return;
            //}
            try
            {
                //  var itemId = itemDetailsGetVE.First().ItemID_FK;
                var id       = itemDetails.Where(x => x.MaterialName == itemTypeSpinner.SelectedItem.ToString()).Select(x => x.ItemID_PK).First();
                var response = WebService.Singleton.UVEDS(lblBillNumber.Text, id,
                                                          itemTypeSpinner.Selected.ToString(), DateTime.Now.ToString(Utilities.MONTH_DATE_TIME, CultureInfo.InvariantCulture));
                if (!response.Equals(string.Empty))
                {
                    layDeliveryDetails.Visibility = Android.Views.ViewStates.Gone;
                    layBillEntry.Visibility       = Android.Views.ViewStates.Visible;
                    isBillEntry = true;

                    var array = new string[] { "LB. No.", "Out Date and Time", "Item", "Vehicle No." };
                    var list  = new VehicleDetailsGETVE
                    {
                        LoadBillNo = itemDetailsGetVE.First().LoadBillNo,
                        EntryDate  = DateTime.Now.ToString(Utilities.DATE_MONTH_TIME_AMPM, CultureInfo.InvariantCulture),
                        ItemName   = itemTypeSpinner.SelectedItem.ToString(),
                        VehicleNo  = itemDetailsGetVE.First().VehicleNo
                    };
                    var serilizedData = JsonConvert.SerializeObject(list);

                    var intent = new Intent(this, typeof(PrintViewActivity));
                    intent.PutExtra("data", serilizedData);
                    intent.PutStringArrayListExtra("array", array);
                    intent.PutExtra("typeof", "VehicleDetailsGETVE");
                    StartActivity(intent);
                    //Toast.MakeText(this, "Successfully updated..", ToastLength.Short).Show();
                }
                else
                {
                    Toast.MakeText(this, "Error in update..", ToastLength.Short).Show();
                }
            }
            catch (Exception ex)
            {
                ExceptionLog.LogDetails(this, ex.Message + "\n\n Exception in UVEDS...");
            }
        }
Esempio n. 13
0
 private void BtnCheck_Click(object sender, EventArgs e)
 {
     if (!txtBillNumber.Text.Equals(string.Empty))
     {
         loaderLayout.Visibility = Android.Views.ViewStates.Visible;
         try
         {
             CheckBillNumberAndGetDetails();
         }
         catch (Exception ex)
         {
             ExceptionLog.LogDetails(this, ex.Message + "\n\n Exception in CheckBillNumberAndGetDetails");
         }
     }
     else
     {
         Toast.MakeText(this, "Enter the Bill Number..", ToastLength.Short).Show();
     }
 }
Esempio n. 14
0
 private void VehicleNumberAutoComplete_ItemClick(object sender, AdapterView.ItemClickEventArgs e)
 {
     try
     {
         var list = vehiclDetailList.Where(x => x.RegNo == vehicleNumberAutoComplete.Text).FirstOrDefault();
         // ownerNumber.Adapter = new ArrayAdapter(this, Resource.Layout.select_dialog_item_material, list);
         if (list != null)
         {
             ownerName.Text      = list.OName;
             lblEmptyWeight.Text = list.EmptyWeight;
         }
     }
     catch
     {
         ShowText("Something went wrong");
         ExceptionLog.LogDetails(this, "Exception in finding Owner Number or empty weight \n");
     }
     HideKeyboard();
     //ownerNumber.PerformClick();
 }
Esempio n. 15
0
 private void VehicleNumberAutoComplete_TextChanged(object sender, Android.Text.TextChangedEventArgs e)
 {
     try
     {
         if (vehicleNumberAutoComplete.Text == string.Empty)
         {
             ClearAllFields();
         }
         var isRegisterVehicle = vehiclDetailList.Any(x => x.RegNo.Contains(vehicleNumberAutoComplete.Text));
         if (!isRegisterVehicle)
         {
             ownerName.Text      = Utilities.NEW_VEHICLE;
             lblEmptyWeight.Text = Utilities.EMPTY_WEIGHT;
         }
     }
     catch (Exception ex)
     {
         ExceptionLog.LogDetails(this, ex.Message + "\n In vehicle number autocomplete text..");
     }
 }
Esempio n. 16
0
 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();
     }
 }
Esempio n. 17
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Create your application here
            SetContentView(Resource.Layout.LogIn);
            ExceptionLog.LogDetails(this, ConstantValues.NEWLINE + ConstantValues.NEWLINE + "App Log in at " + DateTime.Now);

            var ipAddress = AppPreferences.GetString(this, Utilities.IPAddress);
            var did       = AppPreferences.GetString(this, Utilities.DEVICEID);
            var siteId    = AppPreferences.GetString(this, Utilities.SITEID);

            var email    = FindViewById <EditText>(Resource.Id.txtEmail);
            var password = FindViewById <EditText>(Resource.Id.txtPassword);

            FindViewById <Button>(Resource.Id.btnLogin).Click += (s, e) =>
            {
                if (email.Text.Equals(Utilities.ADMIN) && password.Text.Equals(Utilities.ADMIN))
                {
                    if (ipAddress.Equals("") || did.Equals("") || siteId.Equals(""))
                    {
                        Toast.MakeText(this, "Please config device first", ToastLength.Short).Show();
                    }
                    else
                    {
                        ExceptionLog.LogDetails(this, "App entering History " + DateTime.Now);
                        StartActivity(typeof(HistoryActivity));
                    }
                }
                else if (email.Text.Equals(Utilities.CONFIG) && password.Text.Equals(Utilities.ADMIN))
                {
                    ExceptionLog.LogDetails(this, "Appgone to Config " + DateTime.Now);
                    StartActivity(typeof(ConfigActivity));
                }
                else
                {
                    Toast.MakeText(this, "Invalid Credentials", ToastLength.Short).Show();
                }
            };
        }
Esempio n. 18
0
        private void SyncButton_Click()
        {
            if (IpAddress.Equals(string.Empty) || siteId.Equals(string.Empty) || deviceId.Equals(string.Empty))
            {
                Toast.MakeText(this, "Configure the device first", ToastLength.Short).Show();
                return;
            }
            RunOnUiThread(() =>
            {
                Toast.MakeText(this, "Please wait..", ToastLength.Short).Show();
                mainHolder.Alpha  = 0.5f;
                loader.Visibility = Android.Views.ViewStates.Visible;
                Window.SetFlags(Android.Views.WindowManagerFlags.NotTouchable, Android.Views.WindowManagerFlags.NotTouchable);
            });

            var thread = new Thread(new ThreadStart(delegate
            {
                var resposeString = WebService.PostDeviceAndSiteIDToWebService("GetVD", deviceId, siteId);
                try
                {
                    var VehicleList = JsonConvert.DeserializeObject <List <VehicleDetails> >(resposeString);
                    CreateDatabaseOrModifyDatabase(VehicleList);
                }
                catch (Exception ec)
                {
                    RunOnUiThread(() =>
                    {
                        Toast.MakeText(this, "Check connectivity", ToastLength.Short).Show();
                        loader.Visibility = Android.Views.ViewStates.Gone;
                        mainHolder.Alpha  = 1f;
                        Window.ClearFlags(Android.Views.WindowManagerFlags.NotTouchable);
                        AppPreferences.SaveBool(this, Utilities.IsDownloaded, false);
                    });
                    ExceptionLog.LogDetails(this, "GetVd Error in fuel Activity " + ec.Message);
                    return;
                }
            }));

            thread.Start();
        }
Esempio n. 19
0
        private void Print(UploadItemDetails uploadItemDetails, IList <string> array)
        {
            var index = 0;

            foreach (var item in uploadItemDetails.GetType().GetProperties())
            {
                try
                {
                    var  layoutInf = (LayoutInflater)GetSystemService(LayoutInflaterService);
                    View view      = layoutInf.Inflate(Resource.Layout.PrintView, null);
                    view.FindViewById <TextView>(Resource.Id.txtName).Text  = array[index];
                    view.FindViewById <TextView>(Resource.Id.txtValue).Text = item.GetValue(uploadItemDetails, null).ToString();
                    layMainLinear.AddView(view, index);
                    index++;
                }
                catch (Exception ex)
                {
                    ExceptionLog.LogDetails(this, ex.Message);
                    Console.WriteLine(ex.Message);
                }
            }
        }
Esempio n. 20
0
        private void SaveDetailsToDb()
        {
            try
            {
                FuelDB.Singleton.CreateTable <FuelEntryDetails>();
                FuelDB.Singleton.CreateTable <BillHistory>();
                var billhistory = new BillHistory
                {
                    CurrentDate   = fuelDetails.CurrentDate,
                    FuelInLtrs    = fuelDetails.FuelInLtrs,
                    VehicleNumber = fuelDetails.VehicleNumber,
                    IsInward      = isInward
                };
                FuelDB.Singleton.InsertFuelEntryValues(fuelDetails);
                FuelDB.Singleton.InsertBillHistoryValues(billhistory);
                FuelDB.Singleton.UpdateFuel(availableFuel.ToString());

                ExceptionLog.LogDetails(this, "Current Value in DB :");
                ExceptionLog.LogDetails(this, "Total Fuel entry " + FuelDB.Singleton.GetFuelValues().ToArray().Count());
                //foreach (var item in FuelDB.Singleton.GetFuelValues())
                //{
                //    ExceptionLog.LogDetails(this, item.BillNumber + " " + item.FuelInLtrs + "  " + item.FuelType);
                //}
                ExceptionLog.LogDetails(this, "Current Fuel Balance :");
                ExceptionLog.LogDetails(this, FuelDB.Singleton.GetBillDetails().FirstOrDefault().AvailableLiters + " "
                                        + FuelDB.Singleton.GetBillDetails().FirstOrDefault().BillPrefix
                                        + FuelDB.Singleton.GetBillDetails().FirstOrDefault().BillCurrentNumber);
                savedToDB = true;
            }
            catch (Exception ex)
            {
                Toast.MakeText(this, "Error in storing the values in DB", ToastLength.Short).Show();
                ExceptionLog.LogDetails(this, "Error in SaveDetailsToDB " + ex.Message);
                btnStore.Clickable = true;
                savedToDB          = false;
            }
        }
Esempio n. 21
0
        private void FillVehicleDetails()
        {
            //var billNum = AppPreferences.GetString(this, Utilities.BILLNUMBER);
            //lblBillNumber.Text = billNum == string.Empty ? "LB1" : billNum;
            if (vehiclDetailList != null)
            {
                try
                {
                    vehicleNumberAutoComplete.Adapter = new ArrayAdapter(this, Resource.Layout.select_dialog_item_material,
                                                                         vehiclDetailList.Select(x => x.RegNo).Distinct().ToArray());

                    wMode.Adapter = new ArrayAdapter(this, Resource.Layout.spinner_item, new string[] { "Sales", "Purchase" });

                    var itemList = itemDetails.Select(x => x.MaterialName).ToList();
                    itemList.Insert(0, "Select");
                    itemTypeSpinner.Adapter = new ArrayAdapter(this, Resource.Layout.spinner_item, itemList);
                }
                catch (Exception ex)
                {
                    ShowText("Something went wrong");
                    ExceptionLog.LogDetails(this, ex.Message + "\n\n In FillVehicleDetails");
                }
            }
        }
Esempio n. 22
0
        private bool UploadValues()
        {
            var billDetails = FuelDB.Singleton.GetBillDetails()?.First();

            if (billDetails != null)
            {
                var list = new List <UploadDetails>();
                foreach (var item in fuelDetails)
                {
                    list.Add(new UploadDetails
                    {
                        CID        = billDetails.BillCurrentNumber == string.Empty ? ConstantValues.ZERO : billDetails.BillCurrentNumber,
                        DID        = AppPreferences.GetString(this, Utilities.DEVICEID) == string.Empty ? ConstantValues.ZERO : AppPreferences.GetString(this, Utilities.DEVICEID),
                        SID        = AppPreferences.GetString(this, Utilities.SITEID) == string.Empty ? ConstantValues.ZERO : AppPreferences.GetString(this, Utilities.SITEID),
                        CStock     = billDetails.AvailableLiters == string.Empty ? ConstantValues.ZERO : billDetails.AvailableLiters,
                        ClosingKM  = item.ClosingKMS == string.Empty ? ConstantValues.ZERO : item.ClosingKMS,
                        DriverID   = item.DriverID_PK == string.Empty ? ConstantValues.ZERO : item.DriverID_PK,
                        DriverName = item.DriverName == string.Empty ? ConstantValues.ZERO : item.DriverName,
                        FilledBy   = item.FilledBy == string.Empty ? ConstantValues.ZERO : item.FilledBy,
                        FuelDate   = item.CurrentDate == string.Empty ? ConstantValues.ZERO : item.CurrentDate,
                        FuelLts    = item.FuelInLtrs == string.Empty ? ConstantValues.ZERO : item.FuelInLtrs,
                        FuelNo     = item.BillNumber == string.Empty ? ConstantValues.ZERO : item.BillNumber,
                        FuelSource = item.FuelStockType == string.Empty ? ConstantValues.ZERO : item.FuelStockType,
                        KMPL       = item.Kmpl == ConstantValues.KMPL ? ConstantValues.ZERO : item.Kmpl,
                        OpeningKM  = item.OpeningKMS == string.Empty ? ConstantValues.ZERO : item.OpeningKMS,
                        RegNo      = item.VehicleNumber == string.Empty ? ConstantValues.ZERO : item.VehicleNumber,
                        VType      = item.VehicleType == string.Empty ? ConstantValues.ZERO : item.VehicleType,
                        Rate       = item.RatePerLtr == string.Empty ? ConstantValues.ZERO : item.RatePerLtr,
                        TAmount    = item.Price == string.Empty ? ConstantValues.ZERO : item.Price,
                        Remarks    = item.Remarks == string.Empty ? ConstantValues.ZERO : item.Remarks,
                        TransType  = item.FuelType == string.Empty ? ConstantValues.ZERO : item.FuelType,
                        Mode       = item.PaymentType == string.Empty ? ConstantValues.ZERO : item.PaymentType,
                        VehicleID  = item.VID == string.Empty ? ConstantValues.ZERO : item.VID,
                        MeterFault = item.MeterFault == string.Empty ? ConstantValues.ZERO : item.MeterFault,
                        TotalKM    = item.TotalKM == string.Empty ? ConstantValues.ZERO : item.TotalKM,
                        //IsExcess = item.IsExcess,
                        //ExcessLtr = item.ExcessLtr,
                        //IsShortage = item.IsShortage,
                        //ShortageLtr = item.ShortageLtr
                    });
                }
                //Console.WriteLine(list);
                var deserializedData = JsonConvert.SerializeObject(list);
                //Console.WriteLine(deserializedData);
                var resposeAfterPost = WebService.PostAllDataToWebService("UPFStock", deserializedData);
                try
                {
                    var vehicleList = JsonConvert.DeserializeObject <List <VehicleDetails> >(resposeAfterPost);
                    if (vehicleList != null)
                    {
                        CreateDatabaseOrModifyDatabase(vehicleList);
                    }
                }
                catch (Exception ex)
                {
                    ExceptionLog.LogDetails(this, "UPFStock response error " + ex.Message + DateTime.Now);
                    RunOnUiThread(() =>
                    {
                        Toast.MakeText(this, "Error in Upload", ToastLength.Short).Show();
                    });
                    return(false);
                }
                //Console.WriteLine(resposeAfterPost);
            }
            return(true);
        }
Esempio n. 23
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

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

            loader       = FindViewById <ProgressBar>(Resource.Id.loader);
            layFuelEntry = FindViewById <LinearLayout>(Resource.Id.layFuelEntry);
            try
            {
                VehicleList = FuelDB.Singleton.GetValue().ToList();
                var allVal = FuelDB.Singleton.GetBillDetails().ToList();
                billDetailsList = allVal.FirstOrDefault();
                billEntryList   = FuelDB.Singleton.GetFuelValues()?.ToList();
            }
            catch (Exception ex)
            {
                //Console.WriteLine(w.Message);
                ExceptionLog.LogDetails(this, "Error in loading vehicle List or GetbillDetails --" + ex.Message);
            }
            if (VehicleList != null)
            {
                myVehiclelist = VehicleList.Select(I => I.RegNo).Distinct().ToArray();
            }

            lblTitle      = FindViewById <TextView>(Resource.Id.lblTittle);
            btnClear      = FindViewById <Button>(Resource.Id.btnClear);
            vehicleNumber = FindViewById <AutoCompleteTextView>(Resource.Id.vehicleNumber);
            if (myVehiclelist != null)
            {
                var adapter = new ArrayAdapter <string>(this, Resource.Layout.select_dialog_item_material, myVehiclelist);
                vehicleNumber.Adapter      = adapter;
                vehicleNumber.Threshold    = 1;
                vehicleNumber.ItemClick   += VehicleNumber_ItemClick;
                vehicleNumber.TextChanged += VehicleNumber_TextChanged;
            }

            billNumber      = FindViewById <TextView>(Resource.Id.txtBillNumber);
            billNumber.Text = billDetailsList?.BillPrefix + billDetailsList?.BillCurrentNumber;

            dateTimeNow = FindViewById <TextView>(Resource.Id.lbldateTime).Text = DateTime.Now.ToString("dd/MM/yyyy hh:mm:ss tt", CultureInfo.InvariantCulture);

            fuelTypeSpinner         = FindViewById <Spinner>(Resource.Id.fuelSpinner);
            fuelTypeSpinner.Adapter = new ArrayAdapter(this, Resource.Layout.select_dialog_item_material,
                                                       new string[]
            {
                ConstantValues.OUTWARD, ConstantValues.INWARD
                //ConstantValues.EXCESS, ConstantValues.SHORTAGE
            });

            fuelFormSpinner         = FindViewById <Spinner>(Resource.Id.fuelFormSpinner);
            fuelFormSpinner.Adapter = new ArrayAdapter(this, Resource.Layout.select_dialog_item_material, StockList);

            var bunkDetailsLayout = FindViewById <LinearLayout>(Resource.Id.layBunkDetails);

            cashModeSpinner         = FindViewById <Spinner>(Resource.Id.paymentMode);
            cashModeSpinner.Adapter = new ArrayAdapter(this, Resource.Layout.select_dialog_item_material,
                                                       new string[]
            {
                ConstantValues.CASH, ConstantValues.CREDIT
            });

            vehicleTypeSpinner = FindViewById <Spinner>(Resource.Id.vehicleType);

            vehicleTypeSpinner.ItemSelected += VehicleTypeSpinner_ItemSelected;

            btnClear.Click += BtnClear_Click;

            var layMeterFault = FindViewById <LinearLayout>(Resource.Id.layMeterFault);

            checkBox = FindViewById <CheckBox>(Resource.Id.chckMeterFault);
            checkBox.CheckedChange += (s, e) =>
            {
                if (fuelTypeSpinner.SelectedItem.ToString() == ConstantValues.OUTWARD)
                {
                    layMeterFault.Visibility = checkBox.Checked ? Android.Views.ViewStates.Gone : Android.Views.ViewStates.Visible;
                }
                txtClosingKMS.Text = string.Empty;
                lblkmpl.Text       = ConstantValues.KMPL;
            };

            driverNameSpinner = FindViewById <Spinner>(Resource.Id.driverName);
            fuelToFill        = FindViewById <EditText>(Resource.Id.fuelToFill);
            fuelAvailable     = FindViewById <TextView>(Resource.Id.fuelAvailable);
            txtOpeningKMS     = FindViewById <TextView>(Resource.Id.txtOpeningKMS);
            txtClosingKMS     = FindViewById <EditText>(Resource.Id.txtClosingKMS);
            lblkmpl           = FindViewById <TextView>(Resource.Id.lblkmpl);
            txtFilledBy       = FindViewById <EditText>(Resource.Id.txtFilledBy);
            txtRate           = FindViewById <EditText>(Resource.Id.txtRate);
            lblTotalPrice     = FindViewById <TextView>(Resource.Id.lblTotalPrice);
            txtRemarks        = FindViewById <EditText>(Resource.Id.txtRemarks);
            imgFuel           = FindViewById <ImageView>(Resource.Id.imgFuel);
            lblButtonStore    = FindViewById <TextView>(Resource.Id.lblButtonStore);

            fuelToFill.TextChanged += (s, e) => CheckFuelAvailbility();
            txtRate.TextChanged    += (s, e) => CalculateFuelTotalAmount();

            driverNameSpinner.ItemSelected += (s, ev) =>
            {
                if (!isDriverNameSpinnerSelected)
                {
                    isDriverNameSpinnerSelected = true;
                    driverNameSpinner.PerformClick();
                }
                else
                {
                    txtOpeningKMS.Text = VehicleList.Where((a => a.DriverName == driverNameSpinner.SelectedItem.ToString()))
                                         .Distinct().Select(i => i.OpeningKM).Distinct().First();

                    fuelToFill.RequestFocus();
                }
            };

            if (billDetailsList != null)
            {
                fuelAvailable.Text = $"{billDetailsList.AvailableLiters}";
            }
            txtClosingKMS.TextChanged += (s, e) =>
            {
                if (txtOpeningKMS.Text.Equals(ConstantValues.ZERO))
                {
                    return;
                }
                if (!string.IsNullOrEmpty(txtOpeningKMS.Text) && !string.IsNullOrEmpty(txtClosingKMS.Text) && !string.IsNullOrEmpty(fuelToFill.Text))
                {
                    if (Convert.ToDecimal(txtClosingKMS.Text) > Convert.ToDecimal(txtOpeningKMS.Text) &&
                        Convert.ToDecimal(fuelToFill.Text) > 0)
                    {
                        GetKMPL();
                    }
                    else
                    {
                        lblkmpl.Text = ConstantValues.KMPL;
                    }
                }
            };

            btnStore        = FindViewById <LinearLayout>(Resource.Id.btnStore);
            btnStore.Click += (s, e) =>
            {
                btnStore.Clickable = false;
                try
                {
                    ShowLoader(true);
                    //if (FuelDB.Singleton.GetBillDetails().LastOrDefault() +
                    //FuelDB.Singleton.GetBillDetails().LastOrDefault().BillCurrentNumber == billNumber.Text)
                    //{
                    //    Console.WriteLine();
                    //}

                    if (fuelTypeSpinner.SelectedItem.Equals(ConstantValues.OUTWARD) &&
                        !fuelToFill.Text.Equals(".") && fuelFormSpinner.SelectedItem.Equals(ConstantValues.STOCK))
                    {
                        if (float.Parse(fuelToFill.Text) > float.Parse(billDetailsList.AvailableLiters))
                        {
                            var alertDialog = new Android.App.AlertDialog.Builder(this);
                            alertDialog.SetTitle("Fuel exceeds stock");
                            //alertDialog.SetMessage($"Do you want add " +
                            //    $"{float.Parse(fuelToFill.Text) - float.Parse(billDetailsList.AvailableLiters)} ltrs. to excess fuel");
                            alertDialog.SetMessage("No Fuel Available...");
                            alertDialog.SetCancelable(false);
                            alertDialog.SetPositiveButton(ConstantValues.OK, (ss, es) =>
                            {
                                ExcessLiter        = float.Parse(fuelToFill.Text) - float.Parse(billDetailsList.AvailableLiters);
                                isExcess           = true;
                                fuelToFill.Text    = string.Empty;
                                ExcessLiter        = 0f;
                                btnStore.Clickable = true;
                                ShowLoader(false);
                                //StoreDetils();
                            });
                            //alertDialog.SetNegativeButton(ConstantValues.CANCEL, (ss, se) =>
                            //{
                            //    fuelToFill.Text = string.Empty;
                            //    ExcessLiter = 0f;
                            //    btnStore.Clickable = true;
                            //    isExcess = false;
                            //    alertDialog.Dispose();
                            //    ShowLoader(false);
                            //});
                            alertDialog.Show();
                            var totalLtrs = (float.Parse(billDetailsList?.AvailableLiters) - float.Parse(fuelToFill.Text));
                            availableFuel = totalLtrs < 1 ? 0f : totalLtrs;
                            return;
                        }
                        else
                        {
                            var totalLtrs = (float.Parse(billDetailsList?.AvailableLiters) - float.Parse(fuelToFill.Text));
                            availableFuel = totalLtrs < 1 ? 0f : totalLtrs;
                        }
                    }

                    /*     if (fuelTypeSpinner.SelectedItem.Equals(ConstantValues.SHORTAGE))
                     *   {
                     *       var alertDialog = new Android.App.AlertDialog.Builder(this);
                     *       alertDialog.SetTitle($"Shortage {availableFuel} ltrs.");
                     *       alertDialog.SetMessage(ConstantValues.PROCEED);
                     *       alertDialog.SetCancelable(false);
                     *       alertDialog.SetPositiveButton(ConstantValues.YES, (ss, se) =>
                     *       {
                     *           UpdateShortageAndRefreshCurrentActivity();
                     *           fuelAvailable.Text = string.Empty;
                     *           availableFuel = 0;
                     *
                     *       });
                     *       alertDialog.SetNegativeButton(ConstantValues.NO, (ss, se) =>
                     *       {
                     *           alertDialog.Dispose();
                     *           btnStore.Clickable = true;
                     *           ShowLoader(false);
                     *       });
                     *       alertDialog.Show();
                     *       return;
                     *   } */
                    if (fuelTypeSpinner.SelectedItem.Equals(ConstantValues.INWARD))
                    //|| fuelTypeSpinner.SelectedItem.Equals(ConstantValues.EXCESS))
                    {
                        if (!fuelAvailable.Text.Equals(ConstantValues.ZERO))
                        {
                            var alertDialog = new Android.App.AlertDialog.Builder(this);
                            alertDialog.SetTitle("Adding fuel");
                            alertDialog.SetMessage("Do you need to add fuel to existing");
                            alertDialog.SetCancelable(false);
                            alertDialog.SetPositiveButton(ConstantValues.YES, (ss, se) =>
                            {
                                fuelAvailable.Text = (Convert.ToInt32(fuelAvailable.Text) + Convert.ToInt32(fuelToFill.Text)).ToString();
                                availableFuel      = float.Parse(billDetailsList?.AvailableLiters) + float.Parse(fuelToFill.Text);
                                StoreDetils();
                            });
                            alertDialog.SetNegativeButton(ConstantValues.NO, (ss, se) =>
                            {
                                alertDialog.Dispose();
                                ShowLoader(false);
                                btnStore.Clickable = true;
                            });
                            alertDialog.Show();
                            return;
                        }
                        else
                        {
                            fuelAvailable.Text = (Convert.ToInt32(fuelAvailable.Text) + Convert.ToInt32(fuelToFill.Text)).ToString();
                            availableFuel      = float.Parse(billDetailsList?.AvailableLiters) + float.Parse(fuelToFill.Text);
                        }
                    }
                    if (fuelFormSpinner.SelectedItem.Equals(ConstantValues.BUNK) && !fuelTypeSpinner.SelectedItem.Equals(ConstantValues.INWARD))
                    {
                        var alertDialog = new Android.App.AlertDialog.Builder(this);
                        alertDialog.SetTitle("Fuel is from petrol bunk");
                        alertDialog.SetMessage(ConstantValues.PROCEED);
                        alertDialog.SetPositiveButton(ConstantValues.OK, (ss, se) =>
                        {
                            StoreDetils();
                        });
                        alertDialog.SetNegativeButton(ConstantValues.CANCEL, (ss, se) =>
                        {
                            btnStore.Clickable = true;
                        });
                        alertDialog.Show();
                    }
                    else
                    {
                        StoreDetils();
                    }
                    ShowLoader(false);
                }
                catch
                {
                    Toast.MakeText(this, "Check all fields are filled...", ToastLength.Short).Show();
                    ShowLoader(false);
                    btnStore.Clickable = true;
                }
            };

            fuelTypeSpinner.ItemSelected += (s, e) =>
            {
                ClearAllFields();
                fuelFormSpinner.Adapter         = null;
                fuelToFill.Enabled              = true;
                vehicleNumber.Enabled           = true;
                vehicleNumber.Focusable         = true;
                fuelToFill.Focusable            = true;
                fuelToFill.FocusableInTouchMode = true;
                if (fuelTypeSpinner.SelectedItem.Equals(ConstantValues.INWARD)) //|| fuelTypeSpinner.SelectedItem.Equals(ConstantValues.EXCESS))
                {
                    vehicleNumber.Text = string.Empty;
                    if (fuelTypeSpinner.SelectedItem.Equals(ConstantValues.INWARD))
                    {
                        fuelFormSpinner.Adapter = new ArrayAdapter(this, Resource.Layout.select_dialog_item_material, new string[] { ConstantValues.BUNK });
                    }
                    else
                    {
                        fuelFormSpinner.Adapter = new ArrayAdapter(this, Resource.Layout.select_dialog_item_material, new string[] { ConstantValues.STOCK });
                    }
                    layMeterFault.Visibility = Android.Views.ViewStates.Gone;
                    FindViewById <LinearLayout>(Resource.Id.layFuelEntry).SetBackgroundResource(Resource.Color.backgroundInward);
                    lblTitle.SetBackgroundResource(Resource.Color.btnAndTitleBackgroundGreen);
                    btnStore.SetBackgroundResource(Resource.Color.btnAndTitleBackgroundGreen);
                    btnClear.SetBackgroundResource(Resource.Color.btnAndTitleBackgroundGreen);
                    layMeterFault.Visibility = Android.Views.ViewStates.Gone;
                    checkBox.Visibility      = Android.Views.ViewStates.Gone;
                    lblButtonStore.Text      = ConstantValues.STORE;
                    isInward = true;
                }

                /* else if (fuelTypeSpinner.SelectedItem.Equals(ConstantValues.SHORTAGE))
                 * {
                 *   lblButtonStore.Text = ConstantValues.UPDATE;
                 *   fuelFormSpinner.Adapter = null;
                 *   vehicleTypeSpinner.Adapter = null;
                 *   driverNameSpinner.Adapter = null;
                 *   vehicleNumber.Enabled = false;
                 *   fuelToFill.Focusable = false;
                 *   fuelToFill.Text = availableFuel.ToString();
                 *   vehicleNumber.Text = ConstantValues.ZERO;
                 *   lblTitle.SetBackgroundResource(Resource.Color.borderColor);
                 *   FindViewById<LinearLayout>(Resource.Id.layFuelEntry).SetBackgroundResource(Resource.Color.borderColor);
                 *   btnStore.SetBackgroundColor(Color.White);
                 *   btnClear.SetBackgroundColor(Color.White);
                 *   layMeterFault.Visibility = Android.Views.ViewStates.Gone;
                 *   checkBox.Visibility = Android.Views.ViewStates.Gone;
                 *   imgFuel.Visibility = Android.Views.ViewStates.Gone;
                 *   isInward = false;
                 * } */
                else
                {
                    fuelFormSpinner.Adapter = new ArrayAdapter(this, Resource.Layout.select_dialog_item_material,
                                                               new string[] {
                        ConstantValues.STOCK, ConstantValues.BUNK
                    });
                    layMeterFault.Visibility = Android.Views.ViewStates.Visible;
                    lblButtonStore.Text      = ConstantValues.STORE;
                    vehicleNumber.Text       = string.Empty;
                    FindViewById <LinearLayout>(Resource.Id.layFuelEntry).SetBackgroundResource(Resource.Color.borderColor);
                    lblTitle.SetBackgroundResource(Resource.Color.borderColor);
                    lblTitle.SetTextColor(Color.Black);
                    btnStore.SetBackgroundColor(Color.White);
                    btnClear.SetBackgroundColor(Color.White);
                    layMeterFault.Visibility = Android.Views.ViewStates.Visible;
                    checkBox.Visibility      = Android.Views.ViewStates.Visible;
                    isInward = false;
                }
            };


            fuelFormSpinner.ItemSelected += (s, e) =>
            {
                if (fuelFormSpinner.SelectedItem.Equals(ConstantValues.STOCK))
                {
                    bunkDetailsLayout.Visibility = Android.Views.ViewStates.Gone;
                    lblTitle.SetTextColor(Color.Black);
                    btnStore.SetBackgroundColor(Color.White);
                    btnClear.SetBackgroundColor(Color.White);
                    lblTitle.SetBackgroundResource(Resource.Color.borderColor);
                    FindViewById <LinearLayout>(Resource.Id.layFuelEntry).SetBackgroundResource(Resource.Color.borderColor);
                    imgFuel.Visibility = Android.Views.ViewStates.Gone;
                }
                else
                {
                    bunkDetailsLayout.Visibility = Android.Views.ViewStates.Visible;
                    if (fuelTypeSpinner.SelectedItem.Equals(ConstantValues.OUTWARD))
                    {
                        FindViewById <LinearLayout>(Resource.Id.layFuelEntry).SetBackgroundResource(Resource.Color.backgroundBunk);
                        btnStore.SetBackgroundColor(Color.Brown);
                        btnClear.SetBackgroundColor(Color.Brown);
                        lblTitle.SetBackgroundResource(Resource.Color.btnAndTitleBackgroundRed);
                    }
                    imgFuel.Visibility = Android.Views.ViewStates.Visible;
                }
            };
            ShowLoader(false);
        }
Esempio n. 24
0
        private void StoreDetils()
        {
            try
            {
                if (txtClosingKMS.Text != string.Empty && txtOpeningKMS.Text != string.Empty)
                {
                    fuelDetails = new FuelEntryDetails
                    {
                        BillNumber    = billNumber.Text == string.Empty ? ConstantValues.ZERO : billNumber.Text,
                        CurrentDate   = DateTime.Now.ToString(Utilities.MONTH_DATE_TIME, CultureInfo.InvariantCulture),
                        FuelType      = fuelTypeSpinner.SelectedItem.ToString(),
                        FuelStockType = fuelFormSpinner.SelectedItem.ToString(),
                        VehicleNumber = vehicleNumber.Text,
                        VehicleType   = vehicleTypeSpinner.SelectedItem.ToString(),
                        DriverName    = driverNameSpinner.SelectedItem.ToString(),
                        FuelInLtrs    = fuelToFill.Text == string.Empty ? ConstantValues.ZERO : fuelToFill.Text,
                        FilledBy      = txtFilledBy.Text,
                        ClosingKMS    = txtClosingKMS.Text == string.Empty ? ConstantValues.ZERO : txtClosingKMS.Text,
                        Kmpl          = lblkmpl.Text == ConstantValues.KMPL ? ConstantValues.ZERO : lblkmpl.Text,
                        OpeningKMS    = txtOpeningKMS.Text == string.Empty ? ConstantValues.ZERO : txtOpeningKMS.Text,
                        PaymentType   = cashModeSpinner.SelectedItem?.ToString(),
                        Price         = lblTotalPrice.Text == string.Empty ? ConstantValues.ZERO : lblTotalPrice.Text,
                        RatePerLtr    = txtRate.Text == string.Empty ? ConstantValues.ZERO : txtRate.Text,
                        Remarks       = txtRemarks.Text,
                        VID           = VehicleList.Where(I => I.RegNo == vehicleNumber.Text).Select(i => i.VID).First(),
                        DriverID_PK   = VehicleList.Where(I => I.RegNo == vehicleNumber.Text).First().DriverID_PK,
                        MeterFault    = checkBox.Checked == true ? ConstantValues.ONE : ConstantValues.ZERO,
                        TotalKM       = (Convert.ToDouble(txtClosingKMS.Text) - Convert.ToDouble(txtOpeningKMS.Text)).ToString(),
                        //IsExcess = isExcess ? ConstantValues.ONE : ConstantValues.ZERO,
                        //ExcessLtr = isExcess ? Convert.ToDecimal(ExcessLiter) : 0m
                    };
                }
                else
                {
                    fuelDetails = new FuelEntryDetails
                    {
                        BillNumber    = billNumber.Text == string.Empty ? ConstantValues.ZERO : billNumber.Text,
                        CurrentDate   = DateTime.Now.ToString(Utilities.MONTH_DATE_TIME, CultureInfo.InvariantCulture),
                        FuelType      = fuelTypeSpinner.SelectedItem.ToString(),
                        FuelStockType = fuelFormSpinner.SelectedItem.ToString(),
                        VehicleNumber = vehicleNumber.Text,
                        VehicleType   = vehicleTypeSpinner.SelectedItem.ToString(),
                        DriverName    = driverNameSpinner.SelectedItem.ToString(),
                        FuelInLtrs    = fuelToFill.Text == string.Empty ? ConstantValues.ZERO : fuelToFill.Text,
                        FilledBy      = txtFilledBy.Text,
                        ClosingKMS    = txtClosingKMS.Text == string.Empty ? ConstantValues.ZERO : txtClosingKMS.Text,
                        Kmpl          = lblkmpl.Text == ConstantValues.KMPL ? ConstantValues.ZERO : lblkmpl.Text,
                        OpeningKMS    = txtOpeningKMS.Text == string.Empty ? ConstantValues.ZERO : txtOpeningKMS.Text,
                        PaymentType   = cashModeSpinner.SelectedItem?.ToString(),
                        Price         = lblTotalPrice.Text == string.Empty ? ConstantValues.ZERO : lblTotalPrice.Text,
                        RatePerLtr    = txtRate.Text == string.Empty ? ConstantValues.ZERO : txtRate.Text,
                        Remarks       = txtRemarks.Text,
                        VID           = VehicleList.Where(I => I.RegNo == vehicleNumber.Text).Select(i => i.VID).First(),
                        DriverID_PK   = VehicleList.Where(I => I.RegNo == vehicleNumber.Text).First().DriverID_PK,
                        MeterFault    = checkBox.Checked == true ? ConstantValues.ONE : ConstantValues.ZERO,
                        TotalKM       = ConstantValues.ZERO,
                        // IsExcess = isExcess ? ConstantValues.ONE : ConstantValues.ZERO,
                        // ExcessLtr = isExcess ? Convert.ToDecimal(ExcessLiter) : 0m
                    };
                }
            }

            catch (Exception ec)
            {
                //Console.WriteLine(ec.Message);
                Toast.MakeText(this, "Error in storing the values", ToastLength.Short).Show();
                ExceptionLog.LogDetails(this, "Error in storing Details for print next method savedetailsToDB \n" + ec.Message);
                btnStore.Clickable = true;
                return;
            }
            SaveDetailsToDb();
            if (savedToDB)
            {
                NavigateToPrintScreen();
            }
            else
            {
                Toast.MakeText(this, "Error New", ToastLength.Short).Show();
            }
        }
Esempio n. 25
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Create your application here
            SetContentView(Resource.Layout.LogIn);
            ExceptionLog.LogDetails(this, "Login Activity...");

            AppDomain.CurrentDomain.UnhandledException += (s, e) =>
            {
                Toast.MakeText(this, "Something went wrong", ToastLength.Short).Show();
            };

            TaskScheduler.UnobservedTaskException += (s, e) =>
            {
                Toast.MakeText(this, "Something went wrong", ToastLength.Short).Show();
            };

            var email    = FindViewById <EditText>(Resource.Id.txtEmail);
            var password = FindViewById <EditText>(Resource.Id.txtPassword);

            var ipAddress = AppPreferences.GetString(this, Utilities.IPAddress);
            var did       = AppPreferences.GetString(this, Utilities.DEVICEID);
            var siteId    = AppPreferences.GetString(this, Utilities.SITEID);



            FindViewById <Button>(Resource.Id.btnLogin).Click += (s, e) =>
            {
                if (email.Text.Equals(Utilities.ADMIN) && password.Text.Equals(Utilities.ADMIN))
                {
                    if (ipAddress.Equals("") || did.Equals("") || siteId.Equals(""))
                    {
                        ShowText("Please config device first");
                    }
                    else
                    {
                        StartActivity(typeof(VehicleDetailActivity));
                    }
                }
                else if (email.Text.Equals(Utilities.CONFIG) && password.Text.Equals(Utilities.ADMIN))
                {
                    StartActivity(typeof(ConfigActivity));
                }
                else if (email.Text.Equals(Utilities.DELIVERY) && password.Text.Equals(Utilities.ADMIN))
                {
                    if (ipAddress.Equals("") || did.Equals("") || siteId.Equals(""))
                    {
                        ShowText("Please config device first");
                    }
                    else
                    {
                        StartActivity(typeof(DeliveryActivity));
                    }
                }
                else
                {
                    ShowText("Invalid Credentials");
                }
            };
        }
Esempio n. 26
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.MainScreen);

            ExceptionLog.LogDetails(this, "App at MainScreen " + DateTime.Now);

            mainLayout = FindViewById <LinearLayout>(Resource.Id.layHolder);
            loader     = FindViewById <ProgressBar>(Resource.Id.loader);
            mainHolder = FindViewById <RelativeLayout>(Resource.Id.mainRelativeHolder);
            var alertDialog = new Android.App.AlertDialog.Builder(this);

            FindViewById <ImageButton>(Resource.Id.btnLogout).Click += (s, e) =>
            {
                alertDialog.SetTitle("Logout");
                alertDialog.SetMessage("Do you want to logout ?");
                alertDialog.SetPositiveButton("Yes", (se, ee) =>
                {
                    StartActivity(typeof(LogInActivity));
                    ExceptionLog.LogDetails(this, "Logged out " + DateTime.Now);
                    Finish();
                });
                alertDialog.SetNegativeButton("No", (se, ee) => { });
                alertDialog.Show();
            };

            //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<Button>(Resource.Id.history).Click += (S, E) =>
            //{
            //    StartActivity(typeof(HistoryActivity));
            //};
            var btnFuelEntry = FindViewById <Button>(Resource.Id.btnFuelEntry);

            btnFuelEntry.Click += (s, e) =>
            {
                try
                {
                    if (FuelDB.Singleton.DBExists() && FuelDB.Singleton.GetBillDetails() != null)
                    {
                        if (AppPreferences.GetString(this, Utilities.DEVICESTATUS).Equals(ConstantValues.ONE))
                        {
                            Toast.MakeText(this, "Please wait...", ToastLength.Short).Show();
                            btnFuelEntry.Enabled = false;
                            StartActivity(typeof(FuelActivity));
                            btnFuelEntry.Enabled = true;
                        }
                        else
                        {
                            Toast.MakeText(this, "Device not available", 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();
                    }
                }
                catch (Exception ex)
                {
                    ExceptionLog.LogDetails(this, "Button fuel entry click " + ex.Message);
                    Toast.MakeText(this, "No Vehicle Details to load", ToastLength.Short).Show();
                }
            };

            btnDownloadData        = FindViewById <Button>(Resource.Id.btnDownloadData);
            btnDownloadData.Click += BtnDownloadData_Click;

            btnUploadData        = FindViewById <Button>(Resource.Id.btnUploadData);
            btnUploadData.Click += BtnUploadData_Click;
        }
Esempio n. 27
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Create your application here
            SetContentView(Resource.Layout.VehicleDetails);
            ExceptionLog.LogDetails(this, "Vehicle Entry Details...");

            TaskScheduler.UnobservedTaskException += (s, e) =>
            {
                ShowText("Something went wrong");
                ExceptionLog.LogDetails(this, "Exception in Vehicle Details Activity...");
            };
            progressLoader = FindViewById <ProgressBar>(Resource.Id.loader);
            // progressLoader.Visibility = Android.Views.ViewStates.Visible;
            layScroll = FindViewById <ScrollView>(Resource.Id.layScroll);
            //layScroll.Alpha = 0.5f;
            var lblTittle = FindViewById <TextView>(Resource.Id.lblTittle);

            lblBillNumber             = FindViewById <TextView>(Resource.Id.lblBillNumber);
            lblDate                   = FindViewById <TextView>(Resource.Id.lbldateTime);
            lblEmptyWeight            = FindViewById <TextView>(Resource.Id.lblEmptyWeight);
            vehicleNumberAutoComplete = FindViewById <AutoCompleteTextView>(Resource.Id.vehicleNumber);
            radioGroup                = FindViewById <RadioGroup>(Resource.Id.radioPaymentMode);
            cashRadioButton           = FindViewById <RadioButton>(Resource.Id.cashRadioButton);
            creditRadioButton         = FindViewById <RadioButton>(Resource.Id.creditRadioButton);
            itemTypeSpinner           = FindViewById <Spinner>(Resource.Id.itemTypeSpinner);
            // ownerNumber = FindViewById<Spinner>(Resource.Id.ownerNumberSpinner);

            layScrollview            = FindViewById <ScrollView>(Resource.Id.layScrollview);
            layLinear                = FindViewById <LinearLayout>(Resource.Id.layLinear);
            layScrollview.Visibility = ViewStates.Gone;

            ownerName       = FindViewById <TextView>(Resource.Id.lblOwnerName);
            wMode           = FindViewById <Spinner>(Resource.Id.vehicleModeSpinner);
            btnPrint        = FindViewById <Button>(Resource.Id.btnPrint);
            btnClear        = FindViewById <Button>(Resource.Id.btnClear);
            btnPrint.Click += BtnPrint_Click;
            btnClear.Click += BtnClear_Click;
            lblDate.Text    = DateTime.Now.ToString(Utilities.DATE_MONTH_TIME_AMPM, CultureInfo.InvariantCulture);
            vehicleNumberAutoComplete.ItemClick   += VehicleNumberAutoComplete_ItemClick;
            vehicleNumberAutoComplete.TextChanged += VehicleNumberAutoComplete_TextChanged;
            vehicleNumberAutoComplete.Threshold    = 1;

            FindViewById <ImageButton>(Resource.Id.btnLogout).Click += (s, e) =>
            {
                var alertDialog = new Android.App.AlertDialog.Builder(this);
                alertDialog.SetTitle("Logout");
                alertDialog.SetMessage("Do you want to logout ?");
                alertDialog.SetPositiveButton("Yes", (se, ee) =>
                {
                    StartActivity(typeof(LogInActivity));
                    Finish();
                });
                alertDialog.SetNegativeButton("No", (se, ee) => { });
                alertDialog.Show();
            };
            //    var task = new Thread(() =>
            //      {
            //          RunOnUiThread(() =>
            //          {
            //              progressLoader.Visibility = Android.Views.ViewStates.Visible;
            //              layScroll.Alpha = 0.5f;
            //              Window.SetFlags(Android.Views.WindowManagerFlags.NotTouchable, Android.Views.WindowManagerFlags.NotTouchable);
            //          });
            //      });
            //    task.Start();
            ShowLoader(true);
            Task.Run(() => GetDetails()
                     );
        }
Esempio n. 28
0
        private void UploadDetailsToServer()
        {
            RunOnUiThread(() =>
            {
                Toast.MakeText(this, "Please wait..", ToastLength.Short).Show();
                mainHolder.Alpha  = 0.5f;
                loader.Visibility = Android.Views.ViewStates.Visible;
                Window.SetFlags(Android.Views.WindowManagerFlags.NotTouchable, Android.Views.WindowManagerFlags.NotTouchable);
            });
            var thread = new Thread(new ThreadStart(delegate
            {
                try
                {
                    fuelDetails = FuelDB.Singleton.GetFuelValues();

                    if (fuelDetails != null && fuelDetails?.Count() > 0)
                    {
                        btnUploadData.Clickable = true;
                        //btnDownloadData.Clickable = false;
                        AppPreferences.SaveBool(this, Utilities.IsDownloaded, true);
                        var result = UploadValues();
                        if (result)
                        {
                            RunOnUiThread(() =>
                            {
                                Toast.MakeText(this, "Upload Success", ToastLength.Short).Show();
                            });
                            ExceptionLog.LogDetails(this, "Upload Success at .." + DateTime.Now);
                            //btnDownloadData.Clickable = true;
                            //AppPreferences.SaveBool(this, Utilities.IsDownloaded, false);
                        }
                        else
                        {
                            RunOnUiThread(() =>
                            {
                                loader.Visibility = Android.Views.ViewStates.Gone;
                                mainHolder.Alpha  = 1f;
                                Window.ClearFlags(Android.Views.WindowManagerFlags.NotTouchable);
                                Toast.MakeText(this, "Upload Failed...", ToastLength.Short).Show();
                            });
                        }
                        RunOnUiThread(() =>
                        {
                            loader.Visibility = Android.Views.ViewStates.Gone;
                            mainHolder.Alpha  = 1f;
                            Window.ClearFlags(Android.Views.WindowManagerFlags.NotTouchable);
                        });
                    }
                    else
                    {
                        RunOnUiThread(() =>
                        {
                            loader.Visibility = Android.Views.ViewStates.Gone;
                            mainHolder.Alpha  = 1f;
                            Window.ClearFlags(Android.Views.WindowManagerFlags.NotTouchable);
                            Toast.MakeText(this, "No Data to upload", ToastLength.Short).Show();
                        });
                        btnUploadData.Clickable = true;
                        //btnDownloadData.Clickable = true;
                        AppPreferences.SaveBool(this, Utilities.IsDownloaded, false);
                    }
                }
                catch (Exception ex)
                {
                    RunOnUiThread(() =>
                    {
                        loader.Visibility = Android.Views.ViewStates.Gone;
                        mainHolder.Alpha  = 1f;
                        Window.ClearFlags(Android.Views.WindowManagerFlags.NotTouchable);
                        Toast.MakeText(this, "No Data to Upload", ToastLength.Short).Show();
                    });
                    ExceptionLog.LogDetails(this, "Upload Exception" + DateTime.Now + ex.Message);
                    btnUploadData.Clickable = true;
                    //btnDownloadData.Clickable = true;
                    AppPreferences.SaveBool(this, Utilities.IsDownloaded, false);
                    return;
                }
            }));

            thread.Start();
        }
Esempio n. 29
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

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

            try
            {
                nGXPrinter = NGXPrinter.NgxPrinterInstance;
                nGXPrinter.InitService(this, this);
            }
            catch (Exception ex)
            {
                ExceptionLog.LogDetails(this, "Printer not connected " + ex.Message);
                Console.WriteLine(ex.Message);
            }

            var clearAlertDialog = new Android.App.AlertDialog.Builder(this);

            clearAlertDialog.SetTitle("Clear History");
            clearAlertDialog.SetMessage("Do you want to clear history ?");
            clearAlertDialog.SetPositiveButton("OK", (ss, se) =>
            {
                ClearHistory();
            });
            clearAlertDialog.SetNegativeButton("Cancel", (ss, se) => { });

            var home     = FindViewById <Button>(Resource.Id.btnHomeFromHistory);
            var btnPrint = FindViewById <Button>(Resource.Id.btnHistoryPrint);

            btnclearHistory = FindViewById <Button>(Resource.Id.btnClearHistory);
            var btnHome = FindViewById <Button>(Resource.Id.btnHomeFromHistory);

            linearLayout       = FindViewById <LinearLayout>(Resource.Id.baseLinearLayout);
            ParentLinearLayout = FindViewById <LinearLayout>(Resource.Id.parentLinearLayout);

            btnclearHistory.Click += (s, e) =>
            {
                clearAlertDialog.Show();
            };
            btnPrint.Click += BtnPrint_Click;

            btnHome.Click += BtnHome_Click;

            historyList = FindViewById <ListView>(Resource.Id.historylistView);
            billHistory = FuelDB.Singleton.GetBillHitory();
            try
            {
                if (billHistory?.Count() > 0)
                {
                    adapter             = new BillHistoryListAdapter(this, billHistory.ToList());
                    historyList.Adapter = adapter;
                    DisableClearButton(true);
                }
                else
                {
                    Toast.MakeText(this, "There is no history to show..", ToastLength.Short).Show();
                    DisableClearButton(false);
                }
            }
            catch
            {
                Toast.MakeText(this, "There is no history to show..", ToastLength.Short).Show();
                DisableClearButton(false);
            }
        }
Esempio n. 30
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();
                        ExceptionLog.LogDetails(this, "Exception during upload..");
                    });
                    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 newList = new List <UploadItemDetails>()
                {
                    new UploadItemDetails
                    {
                        LBNo      = list.First().LBNo,
                        EntryDate = DateTime.Now.ToString(Utilities.DATE_MONTH_TIME_AMPM, CultureInfo.CurrentCulture),
                        VehicleNo = list.First().VehicleNo,
                        OwnerName = list.First().OwnerName,
                        ItemName  = list.First().ItemName,
                        EWeight   = list.First().EWeight,
                        PayMode   = list.First().PayMode,
                        WMode     = list.First().WMode
                    }
                };
                var lista = newList.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);
                Finish();
                RunOnUiThread(() =>
                {
                    progressLoader.Visibility = ViewStates.Gone;
                    layScroll.Alpha           = 1f;
                    Window.ClearFlags(WindowManagerFlags.NotTouchable);
                });
            }
            catch (Exception ex)
            {
                RunOnUiThread(() =>
                {
                    Toast.MakeText(this, "Something went wrong", ToastLength.Short).Show();
                    progressLoader.Visibility = ViewStates.Gone;
                    layScroll.Alpha           = 1f;
                    Window.ClearFlags(WindowManagerFlags.NotTouchable);
                });
                ExceptionLog.LogDetails(this, ex.Message + "\n\n Exception during button print");
            }
        }