public override bool OnOptionsItemSelected(IMenuItem item)
        {
            var res = new ReturnedSaveFuncInfo();

            res.AddReturnedValue(CheckValidation());
            if (res.HasError)
            {
                Toast.MakeText(this, res.ErrorMessage, ToastLength.Short).Show();
                return(base.OnOptionsItemSelected(item));
            }

            if (cus == null)
            {
                cus = new UserBussines()
                {
                    Guid     = Guid.NewGuid(),
                    Modified = DateTime.Now,
                    Status   = true,
                };
            }

            cus.Name     = txtName.Text;
            cus.UserName = txtUserName.Text;
            cus.Mobile   = txtMobile.Text;
            cus.Email    = txtEmail.Text;
            var ue        = new UTF8Encoding();
            var bytes     = ue.GetBytes(txtPass.Text.Trim());
            var md5       = new MD5CryptoServiceProvider();
            var hashBytes = md5.ComputeHash(bytes);
            var password  = System.Text.RegularExpressions.Regex.Replace(BitConverter.ToString(hashBytes), "-", "")
                            .ToLower();

            cus.Password = password;
            if (rbtnManager.Checked)
            {
                cus.Type = EnUserType.Manager;
            }
            else if (rbtnOperator.Checked)
            {
                cus.Type = EnUserType.Operator;
            }
            else if (rbtnVisitor.Checked)
            {
                cus.Type = EnUserType.Visitor;
            }

            UserBussines.Save(cus);
            Finish();
            return(base.OnOptionsItemSelected(item));
        }
示例#2
0
        private void LstCustomers_ItemClick(object sender, AdapterView.ItemClickEventArgs e)
        {
            if (e.Position < 0 && list.Count <= 0)
            {
                return;
            }
            var cus = lstCustomers.GetItemAtPosition(e.Position).Cast <UserBussines>();

            if (!cus.IsBlock)
            {
                AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(
                    new ContextThemeWrapper(this, Android.Resource.Style.WidgetMaterialLightButtonBarAlertDialog));
                alertDialogBuilder.SetTitle("مسدودسازی کاربر");
                alertDialogBuilder.SetMessage($"آیا از مسدود کردن {cus?.Name} اطمینان دارید؟");
                alertDialogBuilder.SetCancelable(false);


                alertDialogBuilder
                .SetPositiveButton("بله", (sent, args) =>
                {
                    cus.IsBlock = true;
                    UserBussines.Save(cus);
                    BindList();
                })
                .SetNegativeButton("خیر", (sent, args) => { })
                ;
                alertDialogBuilder.Show();
            }
            else
            {
                AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(
                    new ContextThemeWrapper(this, Android.Resource.Style.WidgetMaterialLightButtonBarAlertDialog));
                alertDialogBuilder.SetTitle("آزادسازی کاربر");
                alertDialogBuilder.SetMessage($"آیا از آزاد کردن {cus?.Name} اطمینان دارید؟");
                alertDialogBuilder.SetCancelable(false);


                alertDialogBuilder
                .SetPositiveButton("بله", (sent, args) =>
                {
                    cus.IsBlock = false;
                    UserBussines.Save(cus);
                    BindList();
                })
                .SetNegativeButton("خیر", (sent, args) => { })
                ;
                alertDialogBuilder.Show();
            }
        }