Example #1
0
        private async void logout_Button_Click(object sender, RoutedEventArgs e)
        {
            this.Frame.Navigate(typeof(MainPage));
            //onlogout make Logged_In false

            DriversTable newdriver = new DriversTable
            {
                islogin  = false,
                id       = DriverDetail.Driver_ID,
                username = DriverDetail.Driver_Username,
                password = DriverDetail.Driver_Password
            };

            App.MobileService.GetTable <DriversTable>().UpdateAsync(newdriver);

            List <BusLocation> AllBusLocation = await App.MobileService.GetTable <BusLocation>().ToListAsync();

            foreach (BusLocation Bus in AllBusLocation)
            {
                if (Bus.Bus_Id == DriverDetail.Driver_ID)
                {
                    BusLocation NewBus = new BusLocation
                    {
                        id      = Bus.id,
                        islogin = false,
                        Bus_Id  = DriverDetail.Driver_ID,
                    };
                    App.MobileService.GetTable <BusLocation>().UpdateAsync(NewBus);
                    break;
                }
            }
            DriverDetail.Driver_Username = string.Empty;
            DriverDetail.Driver_Password = string.Empty;
            DriverDetail.Driver_ID       = string.Empty;
        }
Example #2
0
        private void submit_Click(object sender, RoutedEventArgs e)
        {
            Dest = destination.Text;
            if (check_1.IsChecked == true)
            {
                check1 = true;
            }
            else
            {
                check1 = false;
            }

            if (check_2.IsChecked == true)
            {
                check2 = true;
            }
            else
            {
                check2 = false;
            }

            if (check_3.IsChecked == true)
            {
                check3 = true;
            }
            else
            {
                check3 = false;
            }

            if (check_4.IsChecked == true)
            {
                check4 = true;
            }
            else
            {
                check4 = false;
            }

            DriversTable newuser = new DriversTable
            {
                islogin  = true,
                id       = DriverDetail.Driver_ID,
                username = DriverDetail.Driver_Username,
                password = DriverDetail.Driver_Password,
                dest     = Dest,
                check1   = check1,
                check2   = check2,
                check3   = check3,
                check4   = check4
            };

            App.MobileService.GetTable <DriversTable>().UpdateAsync(newuser);
        }
Example #3
0
        private async void register_bt_Click(object sender, RoutedEventArgs e)
        {
            Username  = username_regpage.Text;
            Password  = password_regpage.Password;
            PasswordC = passwordcon_regpage.Password;

            if (!String.IsNullOrWhiteSpace(Username) && !String.IsNullOrWhiteSpace(Password) && !String.IsNullOrWhiteSpace(PasswordC))
            {
                if (PasswordC == Password)
                {
                    if (UserRbt)
                    {
                        List <UsersTable> userList = await App.MobileService.GetTable <UsersTable>().ToListAsync();

                        foreach (UsersTable registereduser in userList)
                        {
                            if (registereduser.username == Username)
                            {
                                var SameUserError = new MessageDialog("This username already exists!. Try Different usernaem", "Username Not Available");
                                await SameUserError.ShowAsync();

                                this.Frame.Navigate(typeof(RegisterPage));
                                return;
                            }
                        }
                        UsersTable newuser = new UsersTable
                        {
                            username = Username,
                            password = Password
                        };
                        App.MobileService.GetTable <UsersTable>().InsertAsync(newuser);
                        var SucDia = new MessageDialog("User Registeration Successful");
                        await SucDia.ShowAsync();

                        NavigateBack();
                        // TOAST FOR SER REGISTRATION SUCCESSFULL
                    }
                    else if (DriRbt)
                    {
                        List <DriversTable> driverList = await App.MobileService.GetTable <DriversTable>().ToListAsync();

                        foreach (DriversTable registereddriver in driverList)
                        {
                            if (registereddriver.username == Username)
                            {
                                var SameUserError = new MessageDialog("This username already exists!. Try Different usernaem", "Username Not Available");
                                await SameUserError.ShowAsync();

                                this.Frame.Navigate(typeof(RegisterPage));
                                return;
                            }
                        }
                        DriversTable newdriver = new DriversTable
                        {
                            username = Username,
                            password = Password,
                            islogin  = false
                        };
                        await App.MobileService.GetTable <DriversTable>().InsertAsync(newdriver);

                        List <DriversTable> DriverList = await App.MobileService.GetTable <DriversTable>().ToListAsync();

                        foreach (DriversTable Driver in DriverList)
                        {
                            if (Driver.username == Username && Driver.password == Password)
                            {
                                BusLocation NewBus = new BusLocation
                                {
                                    Bus_Id    = Driver.id,
                                    Latitude  = "0.00000000",
                                    Longitude = "0.00000000",
                                    islogin   = false
                                };
                                await App.MobileService.GetTable <BusLocation>().InsertAsync(NewBus);

                                var SucDia = new MessageDialog("Driver Registration Successful");
                                await SucDia.ShowAsync();

                                break;
                            }
                        }
                        ;
                        NavigateBack();
                    }
                    else
                    {
                        var ErrDia = new MessageDialog("Please Select one User type");
                        await ErrDia.ShowAsync();
                    }
                }
                else
                {
                    var ErrDia = new MessageDialog("Password doesn't MATCH");
                    await ErrDia.ShowAsync();
                }
            }
            else
            {
                var ErrDia = new MessageDialog("All The Fields are Compulsary");
                await ErrDia.ShowAsync();
            }
        }
Example #4
0
        private async void loginbuttondriver_Click(object sender, RoutedEventArgs e)
        {
            input_username = username_textbox.Text;
            input_password = pass_textbox.Password;

            /* var notificationXml = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText02);
             * var toeastElement = notificationXml.GetElementsByTagName("text");
             * toeastElement[0].AppendChild(notificationXml.CreateTextNode("Trying to logging in as a DRIVER"));
             * toeastElement[1].AppendChild(notificationXml.CreateTextNode("It might take a few seconds"));
             * var toastNotification = new ToastNotification(notificationXml);
             * ToastNotificationManager.CreateToastNotifier().Show(toastNotification);
             */
            if (input_username == "" || input_password == "")
            {
                var dialog = new MessageDialog("Please Enter Username and Password both", "Error");
                await dialog.ShowAsync();
            }
            else
            {
                try
                {
                    List <DriversTable> AllDrivers = await App.MobileService.GetTable <DriversTable>().ToListAsync();

                    List <BusLocation> AllBusLocation = await App.MobileService.GetTable <BusLocation>().ToListAsync();

                    foreach (DriversTable driver in AllDrivers)
                    {
                        if (input_username == driver.username && input_password == driver.password)
                        {
                            DriversTable newdriver = new DriversTable
                            {
                                username = input_username,
                                password = input_password,
                                islogin  = true,
                                id       = driver.id
                            };
                            DriverDetail.Driver_ID       = driver.id;
                            DriverDetail.Driver_Username = input_username;
                            DriverDetail.Driver_Password = input_password;
                            foreach (BusLocation Bus in AllBusLocation)
                            {
                                if (Bus.Bus_Id == DriverDetail.Driver_ID)
                                {
                                    BusLocation NewBus = new BusLocation
                                    {
                                        id      = Bus.id,
                                        islogin = true,
                                        Bus_Id  = DriverDetail.Driver_ID,
                                    };
                                    App.MobileService.GetTable <BusLocation>().UpdateAsync(NewBus);
                                    break;
                                }
                            }
                            App.MobileService.GetTable <DriversTable>().UpdateAsync(newdriver);
                            this.Frame.Navigate(typeof(DriverMain));
                            LoginStatus = true;
                            break;
                        }
                    }
                }
                catch (Exception exc)
                {
                    //var dialog = new MessageDialog("Please Connect To Internet!", "Error");
                    //await dialog.ShowAsync();
                    var notification2Xml = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText02);
                    var toeastElement2   = notification2Xml.GetElementsByTagName("text");
                    toeastElement2[0].AppendChild(notification2Xml.CreateTextNode("NO INTERNET"));
                    toeastElement2[1].AppendChild(notification2Xml.CreateTextNode("Connect to INTERNET and TRY AGAIN"));
                    var toastNotification2 = new ToastNotification(notification2Xml);
                    ToastNotificationManager.CreateToastNotifier().Show(toastNotification2);
                }
                if (!LoginStatus)
                {
                    var dialog = new MessageDialog("Username and Password doesn't exist or doesn't match!", "Error");
                    await dialog.ShowAsync();

                    LoginStatus = false;
                }
            }
        }