protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); ap = new AppPreferences(this); SetContentView(Resource.Layout.activity_list); _toolbar = FindViewById <Toolbar>(Resource.Id.toolbar); SetSupportActionBar(_toolbar); _rv = FindViewById <RecyclerView>(Resource.Id.rv); _rv.HasFixedSize = true; _rvLayoutManager = new LinearLayoutManager(this); _rv.SetLayoutManager(_rvLayoutManager); _listItems = new List <ListItem>(); var listaJson = ap.GetString("listaPesquisa", ""); var listaPesquisas = JsonConvert.DeserializeObject <List <Pesquisa> >(listaJson); foreach (var item in listaPesquisas) { _listItem = new ListItem(); _listItem.Title = item.Descricao; _listItem.PageType = typeof(POPActivity); _listItems.Add(_listItem); } _adapter = new CustomAdapter(_listItems, this.Resources); _adapter.ItemClick += OnItemClick; _rv.SetAdapter(_adapter); }
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); }); Console.WriteLine(ex.Message); } }
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(); }; }
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(); Console.WriteLine(ex.Message); } } else { ShowWrongText(); } }
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()); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Create your application here SetContentView(Resource.Layout.LogIn); 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"); } }; }
private void FillVehicleDetails() { var billNum = AppPreferences.GetString(this, Utilities.BILLNUMBER); lblBillNumber.Text = billNum == string.Empty ? "LB1" : billNum; if (vehiclDetailList != null) { 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); } }
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(); } }; }
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; }
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); }
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"); } }; }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.MainScreen); mainLayout = FindViewById <LinearLayout>(Resource.Id.layHolder); loader = FindViewById <ProgressBar>(Resource.Id.loader); mainHolder = FindViewById <RelativeLayout>(Resource.Id.mainRelativeHolder); //var pref = PreferenceManager.GetDefaultSharedPreferences(this); //Ipadress = pref.GetString(Utilities.IPAddress, string.Empty); //Get IPAdress for preference IpAddress = AppPreferences.GetString(this, Utilities.IPAddress); siteId = AppPreferences.GetString(this, Utilities.SITEID); deviceId = AppPreferences.GetString(this, Utilities.DEVICEID); WebService.IPADDRESS = IpAddress; FindViewById <ImageButton>(Resource.Id.btnLogout).Click += (s, e) => { var alertDialog1 = new Android.App.AlertDialog.Builder(this); alertDialog1.SetTitle("Logout"); alertDialog1.SetMessage("Do you want to exit ?"); alertDialog1.SetPositiveButton("OK", (ss, se) => Finish()); alertDialog1.Show(); }; FindViewById <Button>(Resource.Id.btnFuelEntry).Click += (s, e) => { //VehicleList = FuelDB.Singleton.GetValue().ToList(); if (FuelDB.Singleton.DBExists() && FuelDB.Singleton.GetBillDetails() != null) { if (AppPreferences.GetString(this, Utilities.DEVICESTATUS).Equals("1")) { StartActivity(typeof(FuelActivity)); } else { Toast.MakeText(this, "Device not avalable", ToastLength.Short).Show(); } } else { var alertDialog1 = new Android.App.AlertDialog.Builder(this); alertDialog1.SetTitle("you need to sync first"); alertDialog1.SetPositiveButton("OK", (ss, se) => { }); alertDialog1.Show(); } // SyncButton_Click(); }; btnDownloadData = FindViewById <Button>(Resource.Id.btnDownloadData); btnDownloadData.Click += (s, e) => { if (!AppPreferences.GetBool(this, Utilities.IsDownloaded)) { SyncButton_Click(); } else { Toast.MakeText(this, "Please Upload Data and Try again..", ToastLength.Short).Show(); } }; btnUploadData = FindViewById <Button>(Resource.Id.btnUploadData); btnUploadData.Click += (s, e) => { UploadDetailsToServer(); }; }