protected void GridView_User_List_RowUpdating(object sender, GridViewUpdateEventArgs e) { GridViewRow gVR = GridView_User_List.Rows[e.RowIndex]; int index = GridView_User_List.Rows[e.RowIndex].DataItemIndex; String userId = ((Label)gVR.Cells[0].FindControl("Label_User_Id")).Text; String userName = ((TextBox)gVR.Cells[0].FindControl("TextBox_Name_Edit")).Text; BackEndObjects.userDetails userObj = BackEndObjects.userDetails.getUserDetailsbyIdDB(userId); //Combine salt and generate the password byte[] plainTextBytes = System.Text.Encoding.UTF8.GetBytes(((TextBox)gVR.Cells[0].FindControl("TextBox_Password_Edit")).Text + userObj.getSalt()); HashAlgorithm hashConverter = new SHA256Managed(); byte[] hashedByteStream = hashConverter.ComputeHash(plainTextBytes); String encryptedAndConvertedPassword = Convert.ToBase64String(hashedByteStream); String passWord = encryptedAndConvertedPassword; String emailId = ((TextBox)gVR.Cells[0].FindControl("TextBox_Email_Id_Edit")).Text; String contactNo = ((TextBox)gVR.Cells[0].FindControl("TextBox_Contact_No_Edit")).Text; String reportsTo = ((DropDownList)gVR.Cells[0].FindControl("DropDownList_Reports_To")).SelectedValue; Dictionary <String, String> whereCls = new Dictionary <string, string>(); Dictionary <String, String> targetCls = new Dictionary <string, string>(); whereCls.Add(BackEndObjects.userDetails.USER_DETAILS_COL_BUSINESS_ID, Session[SessionFactory.MAIN_BUSINESS_ENTITY_ID_STRING].ToString()); whereCls.Add(BackEndObjects.userDetails.USER_DETAILS_COL_USERID, userId); targetCls.Add(BackEndObjects.userDetails.USER_DETAILS_COL_PASSWORD, passWord); targetCls.Add(BackEndObjects.userDetails.USER_DETAILS_COL_NAME, userName); targetCls.Add(BackEndObjects.userDetails.USER_DETAILS_COL_EMAIL_ID, emailId); targetCls.Add(BackEndObjects.userDetails.USER_DETAILS_COL_CONTACT_NO, contactNo); targetCls.Add(BackEndObjects.userDetails.USER_DETAILS_COL_REPORTS_TO, reportsTo); try { BackEndObjects.userDetails.updateUserDetailsDB(targetCls, whereCls, DBConn.Connections.OPERATION_UPDATE); DataTable dt = (DataTable)Session[SessionFactory.ADMIN_PREF_USER_MGMT_BASIC_USER_DET_GRID]; dt.Rows[index]["UserName"] = userName; dt.Rows[index]["Password"] = ((TextBox)gVR.Cells[0].FindControl("TextBox_Password_Edit")).Text; dt.Rows[index]["EmailId"] = emailId; dt.Rows[index]["ContactNo"] = contactNo; dt.Rows[index]["reportsTo"] = reportsTo; GridView_User_List.EditIndex = -1; GridView_User_List.DataSource = dt; GridView_User_List.DataBind(); Session[SessionFactory.ADMIN_PREF_USER_MGMT_BASIC_USER_DET_GRID] = dt; } catch (Exception ex) { } }
protected void Button_Submit_Req_Click(object sender, EventArgs e) { BackEndObjects.userDetails userObj = BackEndObjects.userDetails.getUserDetailsbyIdDB(User.Identity.Name); //Combine salt and generate the password byte[] plainTextBytes = System.Text.Encoding.UTF8.GetBytes(TextBox_Pass2.Text + userObj.getSalt()); HashAlgorithm hashConverter = new SHA256Managed(); byte[] hashedByteStream = hashConverter.ComputeHash(plainTextBytes); String encryptedAndConvertedPassword = Convert.ToBase64String(hashedByteStream); Dictionary <String, String> targetVals = new Dictionary <string, string>(); targetVals.Add(BackEndObjects.userDetails.USER_DETAILS_COL_PASSWORD, encryptedAndConvertedPassword); Dictionary <String, String> whereCls = new Dictionary <string, string>(); whereCls.Add(BackEndObjects.userDetails.USER_DETAILS_COL_BUSINESS_ID, Session[SessionFactory.MAIN_BUSINESS_ENTITY_ID_STRING].ToString()); whereCls.Add(BackEndObjects.userDetails.USER_DETAILS_COL_USERID, User.Identity.Name); try { BackEndObjects.userDetails.updateUserDetailsDB(targetVals, whereCls, DBConn.Connections.OPERATION_UPDATE); Label_Pass_Change_Stat.Visible = true; Label_Pass_Change_Stat.Text = "Password Changed Successfully"; Label_Pass_Change_Stat.ForeColor = System.Drawing.Color.Green; } catch (Exception ex) { Label_Pass_Change_Stat.Visible = true; Label_Pass_Change_Stat.Text = "Password Change Failed"; Label_Pass_Change_Stat.ForeColor = System.Drawing.Color.Red; } }
protected void LoginButton_Click(object sender, EventArgs e) { // BackEndObjects.userDetails uDObj = new BackEndObjects.userDetails(); BackEndObjects.userDetails userObj = BackEndObjects.userDetails.getUserDetailsbyIdDB(UserName.Text); //Combine salt and generate the password byte[] plainTextBytes = System.Text.Encoding.UTF8.GetBytes(Password.Text + userObj.getSalt()); HashAlgorithm hashConverter = new SHA256Managed(); byte[] hashedByteStream = hashConverter.ComputeHash(plainTextBytes); String encryptedAndConvertedPassword = Convert.ToBase64String(hashedByteStream); if (userObj.authenticateUserDB(UserName.Text, encryptedAndConvertedPassword)) { Session[SessionFactory.LOGGED_IN_USER_ID_STRING] = UserName.Text.Trim(); Session[SessionFactory.LOGGED_IN_USER_THEME] = userObj.getTheme() == null || userObj.getTheme().Equals("") ? "ThemeBlue" : userObj.getTheme(); //Session[SessionFactory.MAIN_BUSINESS_ENTITY_ID_STRING] = BackEndObjects.userDetails.getUserDetailsbyIdDB(UserName.Text).getMainEntityId(); Session[SessionFactory.MAIN_BUSINESS_ENTITY_ID_STRING] = userObj.getMainEntityId(); Session[SessionFactory.ACCESSLIST_FOR_USER] = new ActionLibrary.LoginActions(). retrieveAccessList(UserName.Text.Trim(), Session[SessionFactory.MAIN_BUSINESS_ENTITY_ID_STRING].ToString()); Session[SessionFactory.CURRENCY_LIST] = BackEndObjects.Currency.getAllCurrencyDetailsDB(); Session[SessionFactory.MAIN_BUSINESS_ENTITY_DEFAULT_CURRENCY] = AddressDetails. getAddressforMainBusinessEntitybyIdDB(Session[SessionFactory.MAIN_BUSINESS_ENTITY_ID_STRING].ToString()).getBaseCurrencyId(); ArrayList contactObjList = Contacts. getAllContactsbyEntityIdDB(Session[SessionFactory.MAIN_BUSINESS_ENTITY_ID_STRING].ToString()); Dictionary <String, String> existingContactDict = new Dictionary <string, string>(); for (int i = 0; i < contactObjList.Count; i++) { String contactName = ((Contacts)contactObjList[i]).getContactName(); String contactEntId = ((Contacts)contactObjList[i]).getContactEntityId(); if (!existingContactDict.ContainsKey(contactName)) { existingContactDict.Add(contactName, contactEntId); } } Session[SessionFactory.EXISTING_CONTACT_DICTIONARY] = existingContactDict; FormsAuthentication.RedirectFromLoginPage(UserName.Text, RememberMe.Checked); } else { FailureText.Visible = true; } }