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


            SetContentView(Resource.Layout.activity_main);

            try
            {
                NGXPrinter nGXPrinter = NGXPrinter.NgxPrinterInstance;
                //nGXPrinter.InitService(this);
                // nGXPrinter.LineFeed(2);

                Console.WriteLine(nGXPrinter);
            }
            catch (Exception ec)
            {
                Console.WriteLine(ec.Message);
            }
            Android.Support.V7.Widget.Toolbar toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);
            SetSupportActionBar(toolbar);

            FloatingActionButton fab = FindViewById <FloatingActionButton>(Resource.Id.fab);

            fab.Click += FabOnClick;
        }
Example #2
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);
            }
        }
Example #3
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            try
            {
                nGXPrinter = NGXPrinter.NgxPrinterInstance;
                nGXPrinter.InitService(this, this);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            // Create your application here
            SetContentView(Resource.Layout.activity_main);
            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();
            };
            if (listType.Equals("UploadItemDetails"))
            {
                var deserializeResult = JsonConvert.DeserializeObject <List <UploadItemDetails> >(data);
                Print(deserializeResult.First(), array);
            }
            else
            {
                var deserializeResult = JsonConvert.DeserializeObject <VehicleDetailsGETVE>(data);
                PrintSecond(deserializeResult, array);
            }
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.content_main);
            user = JsonConvert.DeserializeObject <PrintDetails>(Intent.GetStringExtra("printDetails"));

            try
            {
                nGXPrinter = NGXPrinter.NgxPrinterInstance;
                nGXPrinter.InitService(this, this);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            var details = FuelDB.Singleton.GetFuelValues();

            btnPrint   = FindViewById <Button>(Resource.Id.btnPrint);
            layoutMain = FindViewById <LinearLayout>(Resource.Id.layPrinterBaseLayout);
            try
            {
                enterdvalues = details?.Last();
            }
            catch (Exception em)
            {
                Console.WriteLine(em.Message);
            }
            mainScrollView = FindViewById <ScrollView>(Resource.Id.mainScrollView);
            // textName.Text = GetTextHeads().ToString();
            //textValue.Text = GetTextValues().ToString();
            //if (enterdvalues.FuelType.Equals("Inwards"))


            //var s = Array.Sort(OutwardValues,);

            //{
            //    textField.Text = "Bill No. \t\t:\t" + enterdvalues?.BillNumber +
            //                    "\n\nDate \t:\t" + DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss tt", CultureInfo.InvariantCulture) +
            //                    "\n\nType \t:\t" + enterdvalues?.FuelType +
            //                    "\n\nFuel From \t:\t" + enterdvalues?.FuelStockType +
            //                    "\n\nVehicle No \t:\t" + enterdvalues?.VehicleNumber +
            //                    "\n\nVehicle \t:\t" + enterdvalues?.VehicleType +
            //                    "\n\nDriver Name \t:\t" + enterdvalues?.DriverName +
            //                    "\n\nLtrs. \t:\t" + enterdvalues?.FuelInLtrs +
            //                     "\n\nFilled By :\t" + enterdvalues?.FilledBy +
            //                     "\n\nPayment \t:\t" + enterdvalues?.PaymentType +
            //                     "\n\nRatePerLtr\t :\t" + enterdvalues?.RatePerLtr +
            //                     "\n\nPrice \t:\t" + enterdvalues?.Price +
            //                     "\n\nRemarks \t:\t" + enterdvalues?.Remarks + "\n\n";
            //}
            //else
            //{
            //    textField.Text = "Bill No: \t:\t\t" + enterdvalues?.BillNumber +
            //                     "\n\nDate \t:\t" + DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss tt", CultureInfo.InvariantCulture) +
            //                     "\n\nType \t:\t" + enterdvalues?.FuelType +
            //                     "\n\nFuel From \t:\t" + enterdvalues?.FuelStockType +
            //                     "\n\nVehicle No \t:\t" + enterdvalues?.VehicleNumber +
            //                     "\n\nVehicle \t:\t" + enterdvalues?.VehicleType +
            //                     "\n\nDriver Name \t:\t" + enterdvalues?.DriverName +
            //                     "\n\nLtrs. \t:\t" + enterdvalues?.FuelInLtrs +
            //                      "\n\nOp. KMS \t:\t" + enterdvalues?.OpeningKMS +
            //                      "\n\nCl. KMS \t:\t" + enterdvalues?.ClosingKMS +
            //                      "\n\nKmpl \t:\t" + enterdvalues?.Kmpl +
            //                      "\n\nFilled By \t:\t" + enterdvalues?.FilledBy +
            //                      "\n\nPayment \t:\t" + enterdvalues?.PaymentType +
            //                      "\n\nRatePerLtr \t:\t" + enterdvalues?.RatePerLtr +
            //                      "\n\nPrice \t:\t" + enterdvalues?.Price +
            //                      "\n\nRemarks \t:\t" + enterdvalues?.Remarks + "\n\n";
            //}
            billNumber    = enterdvalues?.BillNumber;
            fuelStockType = enterdvalues?.FuelStockType;
            //enterdvalues.Find();
            //var index = 0;
            //foreach (var item in enterdvalues.GetType().GetProperties())
            //{
            //    //Console.WriteLine(item.Name+" : "+item.GetValue(enterdvalues,null).ToString());
            //    if (!item.GetValue(enterdvalues, null).ToString().Equals("0")
            //        && !item.GetValue(enterdvalues, null).ToString().Equals(string.Empty))
            //    {
            //        var layoutInf = (LayoutInflater)GetSystemService(LayoutInflaterService);
            //        View view = layoutInf.Inflate(Resource.Layout.PrintView, null);
            //        view.FindViewById<TextView>(Resource.Id.txtName).Text = item.Name;
            //        view.FindViewById<TextView>(Resource.Id.txtValue).Text = item.GetValue(enterdvalues, null).ToString();
            //        layoutMain.AddView(view, index);
            //        index++;
            //    }
            //}
            if (enterdvalues.FuelType.Equals("Inwards"))
            {
                DrawPrintView(InwardValues);
            }
            else
            {
                if (enterdvalues.FuelStockType.Equals("Stock"))
                {
                    if (enterdvalues.MeterFault.Equals("0"))
                    {
                        DrawPrintView(OutwardStock);
                    }
                    else
                    {
                        DrawPrintView(OutwardStockMeterFault);
                    }
                }
                else
                {
                    if (enterdvalues.MeterFault.Equals("0"))
                    {
                        DrawPrintView(OutwardBunk);
                    }
                    else
                    {
                        DrawPrintView(OutwardBunkMeterFault);
                    }
                }
            }

            btnPrint.Click += (s, e) =>
            {
                //nGXPrinter.AddText(textField.Text);
                //nGXPrinter.LineFeed(2);
                //nGXPrinter.Print();
                if (fuelStockType.Equals("Bunk"))
                {
                    var alertDialog = new Android.App.AlertDialog.Builder(this);
                    alertDialog.SetTitle("Fuel is from petrol bunk");
                    alertDialog.SetMessage("Do you want to proceed ?");
                    alertDialog.SetPositiveButton("OK", (ss, se) =>
                    {
                        Print();
                    });
                    alertDialog.Show();
                }
                else
                {
                    Print();
                }
                //var pref = PreferenceManager.GetDefaultSharedPreferences(this);
                //pref.Edit().PutInt("billnumber", Convert.ToInt32(billNumber)).Apply();

                //AppPreferences.SaveInt(this,Utilities.BILLNUMBER, Convert.ToInt32(billNumber));
            };
        }
Example #5
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);
            }
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

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

            try
            {
                nGXPrinter = NGXPrinter.NgxPrinterInstance;
                nGXPrinter.InitService(this, this);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            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);
            btnPrint.Click += BtnPrint_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()
                     );
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.content_main);
            printDetails = JsonConvert.DeserializeObject <PrintDetails>(Intent.GetStringExtra("printDetails"));

            try
            {
                nGXPrinter = NGXPrinter.NgxPrinterInstance;
                nGXPrinter.InitService(this, this);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            var details = FuelDB.Singleton.GetFuelValues();

            btnPrint   = FindViewById <Button>(Resource.Id.btnPrint);
            layoutMain = FindViewById <LinearLayout>(Resource.Id.layPrinterBaseLayout);
            try
            {
                if (details != null) //&& details.Last().IsExcess == ConstantValues.ZERO)
                {
                    enterdvalues = details?.Last();
                }
                else
                {
                    enterdvalues = details?.ElementAt(details.Count() - 2);
                }
            }
            catch (Exception em)
            {
                ExceptionLog.LogDetails(this, "Enterd values null " + em.Message);
                Console.WriteLine(em.Message);
                return;
            }
            mainScrollView = FindViewById <ScrollView>(Resource.Id.mainScrollView);

            billNumber    = enterdvalues?.BillNumber;
            fuelStockType = enterdvalues?.FuelStockType;

            if (enterdvalues.FuelType.Equals(ConstantValues.INWARD))
            {
                DrawPrintView(InwardValues);
            }
            else
            {
                if (enterdvalues.FuelStockType.Equals(ConstantValues.STOCK))
                {
                    if (enterdvalues.MeterFault.Equals(ConstantValues.ZERO))
                    {
                        DrawPrintView(OutwardStock);
                    }
                    else
                    {
                        DrawPrintView(OutwardStockMeterFault);
                    }
                }
                else
                {
                    if (enterdvalues.MeterFault.Equals(ConstantValues.ZERO))
                    {
                        DrawPrintView(OutwardBunk);
                    }
                    else
                    {
                        DrawPrintView(OutwardBunkMeterFault);
                    }
                }
            }

            btnPrint.Click += (s, e) =>
            {
                if (fuelStockType.Equals(ConstantValues.BUNK) && !enterdvalues.FuelType.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) =>
                    {
                        PrintFromPrinter();
                    });
                    alertDialog.Show();
                }
                else
                {
                    PrintFromPrinter();
                }
            };
        }