当用户没有实际输入时,十进制会导致问题

本文关键字:十进制 问题 输入 用户 | 更新日期: 2023-09-27 18:03:18

我遇到了实体和保存的问题,我想更新记录的值,所以我正在做以下操作。

我在其他窗口中使用了下面的代码,但它在这里不起作用,有些原因保存了记录,它说键已经存在。

_dal.portalEntities.Entry(_custInfo).State = System.Data.Entity.EntityState.Modified;
_dal.portalEntities.SaveChanges();
_dal.portalEntities.Entry(_custInfo).Reload();

下面是我的主程序

tblPortalUser _users; 
_users = _dal.GetUserRecordByEmail(_myuser.EmailAddress.ToLower());
//password is the same warn the user as current 
 if (PasswordHash.ValidatePassword(password.Text, _users.password) == true)
{    
    lblerror.Text = "Password choose a password you have not used before";
    }else
 lblerror.Text = "Current Password is invalid.";
            // if password is the same as the confirm password then proceed if not warn the user
 if (password.Text == confirmpass.Text)
 {
   _users.password = PasswordHash.HashPassword(password.Text);
  _dal.portalEntities.SaveChanges();
 //lets send out the verification codes for the email and sms
   _notifications.sendNotification(new Guid(portalbl.BLConstants.resetPasswordEmail), _custInfo.firstName + " " + _custInfo.lastName, "", _custInfo.email.ToLower(), "", "", portalbl.BLConstants.portalNotifications.Email, "");
 Response.Redirect(@"~'myaccount'logout.aspx", false);
 }

GetUserRecordByEmail

public tblPortalUser GetUserRecordByEmail(string Email)
    {
        try
        {
            tblPortalUser _user;
            _user = (from _users in _dal.portalEntities.tblPortalUsers
                     where _users.EmailAddress.ToLower() == Email
                     select _users).FirstOrDefault();

            return _user;
        }
        catch (Exception ex)
        {
            string inner = string.Empty;
            if (ex.InnerException != null)
            {
                inner = ex.InnerException.ToString();
            }
            return null;
        }
    }

编辑1 例外是在这里显示抱歉,我不知道如何包含一个没有链接的图像当得分低于10

https://snag.gy/QMSzaE.jpg

当用户没有实际输入时,十进制会导致问题

从屏幕截图来看,例外是明确的,您需要首先分离用户并再次附加它,它将工作

查看这篇文章:附加和分离对象