string passwordForEncryption = "sA23(^A1&*%1)01Ax)@!21!@#$%^&*()7984651"; string encryptedpassword = StringCipher.Encrypt(ddlRollNo.Text, passwordForEncryption); string encryptedUserName = StringCipher.Encrypt(txtPassword.Text, passwordForEncryption); CTP.HRMS.Business.UserLogin ulogin = new Business.UserLogin(); ulogin.Role_Id = SafeConvert.ToByte(ddlRole.SelectedValue); ulogin.Employee_Id = encryptedUserName; ulogin.Password = encryptedpassword;
string passwordForEncryption = "sA23(^A1&*%1)01Ax)@!21!@#$%^&*()7984651"; string encryptedpassword = StringCipher.Encrypt(txtPWD.Text, passwordForEncryption); string encryptedUserName = StringCipher.Encrypt(txtUserName.Text, passwordForEncryption); Entities entities = new Entities(); CTP.HRMS.WebApp.EF.UserLogin login = entities.UserLogins.FirstOrDefault(x =>x.Employee_Id==encryptedUserName && x.Password == encryptedpassword); //var login = (from u in entities.UserLogins // join ee in entities.Employees on u.Id equals ee.Id // where u.Password == encryptedpassword // && u.UserName == encryptedUserName // select new // { // FormalName = u.FormalName, // gisuyag = ee.Address // }).FirstOrDefault(); if (login != null) { MyUser.UserName = txtUserName.Text; MyUser.Role_Id = login.Role_Id; // MyUser.FormalName = login.FormalName; //Create A fuield that contains full Name of logged in user for diaplay purpose FormsAuthentication.RedirectFromLoginPage(login.Id.ToString(), true); } else { //if data reader doesn’t contains any row, it means user name or password is //incorrect txtUserName.Text = ""; txtPWD.Text = ""; Label3.Text = "User Name/Password not correct"; } }