예제 #1
0
        private async Task <ReturnedSaveFuncInfo> CheckValidationAsync()
        {
            var res = new ReturnedSaveFuncInfo();

            try
            {
                if (string.IsNullOrWhiteSpace(Owner))
                {
                    res.AddError("مالک نمی تواند خالی باشد");
                }
                if (Number <= 0)
                {
                    res.AddError("شماره نمی تواند خالی باشد");
                }
                if (!await CheckNumberAsync(Number, Guid))
                {
                    res.AddError("شماره وارد شده تکراری می باشد");
                }
                if (!CheckPerssonValidation.CheckMobile(Number.ToString().Trim()))
                {
                    res.AddError("شماره موبایل وارد شده صحیح نمی باشد");
                }
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
                res.AddReturnedValue(ex);
            }

            return(res);
        }
예제 #2
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(txtNumber.Text))
                {
                    frmNotification.PublicInfo.ShowMessage("شماره نمی تواند خالی باشد");
                    txtNumber.Focus();
                    return;
                }
                if (!CheckPerssonValidation.CheckMobile(txtNumber.Text.Trim()))
                {
                    frmNotification.PublicInfo.ShowMessage("شماره موبایل وارد شده صحیح نمی باشد");
                    txtNumber.Focus();
                    txtNumber.SelectAll();
                    return;
                }

                AddItems(txtNumber.Text);
                txtNumber.Text = "";
                txtNumber.Focus();
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
            }
        }
예제 #3
0
        private async void btnFinish_Click(object sender, EventArgs e)
        {
            try
            {
                if (cls.Guid == Guid.Empty)
                {
                    cls.Guid = Guid.NewGuid();
                }

                if (string.IsNullOrWhiteSpace(txtName.Text))
                {
                    frmNotification.PublicInfo.ShowMessage("نام و نام خانوادگی نمی تواند خالی باشد");
                    txtName.Focus();
                    return;
                }
                if (string.IsNullOrWhiteSpace(txtUserName.Text))
                {
                    frmNotification.PublicInfo.ShowMessage("نام کاربری نمی تواند خالی باشد");
                    txtUserName.Focus();
                    return;
                }
                if (!await UserBussines.CheckUserNameAsync(cls.Guid, txtUserName.Text))
                {
                    frmNotification.PublicInfo.ShowMessage("نام کاربری تکراری می باشد");
                    txtUserName.Focus();
                    return;
                }
                if (string.IsNullOrWhiteSpace(txtPass1.Text))
                {
                    frmNotification.PublicInfo.ShowMessage("کلمه عبور نمی تواند خالی باشد");
                    txtPass1.Focus();
                    return;
                }
                if (string.IsNullOrWhiteSpace(txtPass2.Text))
                {
                    frmNotification.PublicInfo.ShowMessage("تکرار کلمه عبور نمی تواند خالی باشد");
                    txtPass2.Focus();
                    return;
                }
                if (txtPass1.Text != txtPass2.Text)
                {
                    frmNotification.PublicInfo.ShowMessage("کلمه عبور با تکرار آن همخوانی ندارد");
                    txtPass1.Focus();
                    return;
                }

                if (!CheckPerssonValidation.CheckEmail(txtEmail.Text.Trim()))
                {
                    frmNotification.PublicInfo.ShowMessage("ایمیل وارد شده صحیح نمی باشد");
                    txtEmail.Focus();
                    return;
                }
                if (!CheckPerssonValidation.CheckMobile(txtMobile.Text.Trim()))
                {
                    frmNotification.PublicInfo.ShowMessage("شماره موبایل وارد شده صحیح نمی باشد");
                    txtMobile.Focus();
                    return;
                }

                cls.Status   = true;
                cls.Name     = txtName.Text.Trim();
                cls.UserName = txtUserName.Text.Trim();
                var ue        = new UTF8Encoding();
                var bytes     = ue.GetBytes(txtPass1.Text.Trim());
                var md5       = new MD5CryptoServiceProvider();
                var hashBytes = md5.ComputeHash(bytes);
                cls.Password = System.Text.RegularExpressions.Regex.Replace(BitConverter.ToString(hashBytes), "-", "")
                               .ToLower();
                cls.Email  = txtEmail.Text.Trim();
                cls.Mobile = txtMobile.Text.Trim();
                cls.Type   = (EnUserType)cmbAccessLevel.SelectedIndex;

                var res = await UserBussines.SaveAsync(cls);

                if (res.HasError)
                {
                    frmNotification.PublicInfo.ShowMessage(res.ErrorMessage);
                    return;
                }
                DialogResult = DialogResult.OK;
                Close();
            }
            catch (Exception exception)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(exception);
            }
        }