Exemplo n.º 1
0
        // sang man hinh dang ky.
        private async void doRegister()
        {
            try
            {
                if (!Validate())
                {
                    return;
                }

                var user = new UserItem()
                {
                    UserName = UserName,
                    PassWord = PassWord
                };
                await UserDao.SaveItemAsync(user);

                UtilViews.ShowAlerNotTitle("Đăng ký thành công!", "Xác nhận", async() =>
                {
                    await Application.Current.MainPage.Navigation.PopAsync();
                });
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                UtilViews.ShowAlerNotTitle("Có lỗi xảy ra, vui lòng thử lại!", "Xác nhận", () => { });
            }
        }
        private void onSave()
        {
            try
            {
                if (!validate())
                {
                    return;
                }

                if (contact.ContactId != 0)
                {
                    RContactDao.UpdateItemAsync(contact);
                }
                else
                {
                    RContactDao.InsertItemAsync(contact);
                }

                Application.Current.MainPage.Navigation.PopAsync();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                UtilViews.ShowAlerNotTitle("Có lỗi xảy ra, vui lòng thử lại!", "Xác nhận", () => { });
            }
        }
        private bool validate()
        {
            if (string.IsNullOrEmpty(contact.ContactName))
            {
                UtilViews.ShowAlerNotTitle("Bạn chưa nhập tên!", "Xác nhận", () => { });
                return(false);
            }

            if (string.IsNullOrEmpty(contact.ContactRole))
            {
                UtilViews.ShowAlerNotTitle("Bạn chưa chọn chức vụ!", "Xác nhận", () => { });
                return(false);
            }

            if (string.IsNullOrEmpty(contact.ContactPhone))
            {
                UtilViews.ShowAlerNotTitle("Bạn chưa nhập số điện thoại!", "Xác nhận", () => { });
                return(false);
            }

            if (contact.ContactAge == 0)
            {
                UtilViews.ShowAlerNotTitle("Bạn chưa nhập tuổi!", "Xác nhận", () => { });
                return(false);
            }

            if (string.IsNullOrEmpty(contact.ContactGender))
            {
                UtilViews.ShowAlerNotTitle("Bạn chưa chọn giới tính!", "Xác nhận", () => { });
                return(false);
            }

            if (string.IsNullOrEmpty(contact.ContactEmail))
            {
                UtilViews.ShowAlerNotTitle("Bạn chưa nhập email!", "Xác nhận", () => { });
                return(false);
            }

            if (!UtilViews.ValidateEmail(contact.ContactEmail))
            {
                UtilViews.ShowAlerNotTitle("Email không hợp lệ, vui lòng thử lại!", "Xác nhận", () => { });
                return(false);
            }

            if (string.IsNullOrEmpty(contact.ContactAddress))
            {
                UtilViews.ShowAlerNotTitle("Bạn chưa nhập địa chỉ!", "Xác nhận", () => { });
                return(false);
            }

            return(true);
        }
 private void onDelete()
 {
     try
     {
         RContactDao.DeleteItemAsync(contact);
         Application.Current.MainPage.Navigation.PopAsync();
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         UtilViews.ShowAlerNotTitle("Có lỗi xảy ra, vui lòng thử lại!", "Xác nhận", () => { });
     }
 }
Exemplo n.º 5
0
        private bool Validate()
        {
            if (string.IsNullOrEmpty(UserName) || string.IsNullOrEmpty(PassWord) || string.IsNullOrEmpty(RePassWord))
            {
                //hiển thị thông bao
                UtilViews.ShowAlerNotTitle("Vui lòng nhập đầy đủ thông tin đăng ký!", "Xác nhận", () => { });
                return(false);
            }

            if (!string.Equals(PassWord, RePassWord))
            {
                //hiển thị thông bao
                UtilViews.ShowAlerNotTitle("Mật khẩu không trùng nhau!", "Xác nhận", () => { });
                return(false);
            }

            return(true);
        }
Exemplo n.º 6
0
 private async void doLogin()
 {
     try
     {
         Application.Current.MainPage = new NavigationPage(new ContactListPage());
         //var users = await UserDao.GetItemsAsync();
         //var fUser = users.Find(u => u.UserName == UserName && u.PassWord == PassWord);
         //if (fUser != null)
         //{
         //    // to contact list screen.
         //    Application.Current.MainPage = new NavigationPage(new ContactListPage());
         //}
         //else
         //{
         //    UtilViews.ShowAlerNotTitle("Tài khoản hoặc mật khẩu không đúng, vui lòng thử lại!", "Xác nhận", () => { });
         //}
     }
     catch (Exception e)
     {
         UtilViews.ShowAlerNotTitle("Có lỗi xảy ra, vui lòng thử lại!", "Xác nhận", () => { });
     }
 }