protected void RegisterButton_Click(object sender, EventArgs e) { string userId = UserIdTextBox.Text.Trim(); string password = PasswordTextBox.Text.Trim(); if (ValidateForm()) { UserDetailDAO userDetails = new UserDetailDAO { UserId = userId, SecurityQuestion = SecurityQuestionList.SelectedItem.Text, FirstName = FirstNameTextBox.Text, LastName = LastNameTextBox.Text, MobileNo = TelephoneTextBox.Text, Answer = SecurityAnswerTextBox.Text, Address = AddressTextBox.Text, Email = EmailTextBox.Text }; try { //password encryption password = FormsAuthentication.HashPasswordForStoringInConfigFile(password, "SHA1"); userDetails.Password = password; //adding images //contacting BLL to DB IUserDetailBussinessService userDetailsBussinessService = BizDelegateFactory.Current.UserDetailBussinessService; int result = userDetailsBussinessService.CreateUser(userDetails); if (result > 0) { Session["userName"] = userId; //User.Identity.Name; FormsAuthentication.RedirectFromLoginPage(userId, true); } else { ShowMessage("Error in insertion", MessageInfo.Information); } } catch (Exception ex) { ShowMessage(ex.Message, MessageInfo.Error); } finally { userDetails = null; } } else { ShowMessage("Please fill the mandatory fields", MessageInfo.Error); UserIdTextBox.Focus(); } }
private UserDetailDAO UpdateUserDetailsDAO() { UserDetailDAO usertailsDAO = new UserDetailDAO(); string userId = Session["UserName"].ToString() ?? string.Empty; //string photo = (PersonalDetailsView.Rows[0].Cells[1].Controls[0] as TextBox).Text; //string firstName = (PersonalDetailsView.Rows[0].Cells[1].Controls[0] as TextBox).Text; //string lastName = (PersonalDetailsView.Rows[0].Cells[1].Controls[0] as TextBox).Text; //string address = (PersonalDetailsView.Rows[0].Cells[1].Controls[0] as TextBox).Text; //string mobileNo = (PersonalDetailsView.Rows[0].Cells[1].Controls[0] as TextBox).Text; //string email = (PersonalDetailsView.Rows[0].Cells[1].Controls[0] as TextBox).Text; return(usertailsDAO); }
/// <summary> /// Inserts new user info into DB /// </summary> /// <param name="userDetailsDAO">UserDetailDAO</param> /// <returns></returns> public int CreateUser(UserDetailDAO userDetailsDAO) { IUserDetailDatabaseService userDetailsDatabaseService = null; try { userDetailsDatabaseService = DBDelegateFactory.Current.UserDetailDatabaseService; return(userDetailsDatabaseService.CreateUser(userDetailsDAO)); } finally { userDetailsDatabaseService = null; } }
/// <summary> /// updates userInformation into database /// </summary> /// <param name="userDetailsDAO"></param> /// <returns></returns> public int UpdatePersonalDetails(UserDetailDAO userDetailsDAO) { IUserDetailDatabaseService userDetailsDatabaseService = null; try { userDetailsDatabaseService = DBDelegateFactory.Current.UserDetailDatabaseService; return(userDetailsDatabaseService.UpdatePersonalDetails(userDetailsDAO)); } finally { userDetailsDatabaseService = null; } }
/// <summary> /// Inserts new user info into DB /// </summary> /// <param name="userDetailsDAO">UserDetailDAO</param> /// <returns></returns> public int CreateUser(UserDetailDAO userDetailsDAO) { Database database = null; DbCommand insertCommand = null; try { database = DatabaseFactory.CreateDatabase(); insertCommand = database.GetStoredProcCommand("uspCreateUser"); database.AddInParameter(insertCommand, "@userId", DbType.String, userDetailsDAO.UserId); database.AddInParameter(insertCommand, "@password", DbType.String, userDetailsDAO.Password); database.AddInParameter(insertCommand, "@securityQuestion", DbType.String, userDetailsDAO.SecurityQuestion); database.AddInParameter(insertCommand, "@answer", DbType.String, userDetailsDAO.Answer); database.AddInParameter(insertCommand, "@firstName", DbType.String, userDetailsDAO.FirstName); database.AddInParameter(insertCommand, "@lastName", DbType.String, userDetailsDAO.LastName); database.AddInParameter(insertCommand, "@address", DbType.String, userDetailsDAO.Address); database.AddInParameter(insertCommand, "@mobileNo", DbType.String, userDetailsDAO.MobileNo); database.AddInParameter(insertCommand, "@email", DbType.String, userDetailsDAO.Email); return(database.ExecuteNonQuery(insertCommand)); } catch (SqlException ex) { SpencerLogger.Error("UserDetailsDatabaseService->CreateUser()", ex); throw new BaseException("DBInsert"); } catch (Exception ex) { SpencerLogger.Error("UserDetailsDatabaseService->CreateUser()", ex); throw new BaseException("DBInsert"); } finally { if (insertCommand.Connection.State == System.Data.ConnectionState.Open) { insertCommand.Connection.Close(); } database = null; } }
protected void PersonalDetailsView_ItemUpdating(object sender, DetailsViewUpdateEventArgs e) { IUserDetailBussinessService userDetailBussinessService = null; UserDetailDAO userDetailsDAO = null;; try { userDetailsDAO = UpdateUserDetailsDAO(); userDetailBussinessService = BizDelegateFactory.Current.UserDetailBussinessService; MyTransactionsGridView.DataSource = userDetailBussinessService.UpdatePersonalDetails(userDetailsDAO); MyTransactionsGridView.DataBind(); } catch (Exception ex) { ShowMessage(ex.Message, MessageInfo.Error); } finally { userDetailBussinessService = null; userDetailsDAO = null; } }
/// <summary> /// updates userInformation into database /// </summary> /// <param name="userDetailsDAO"></param> /// <returns></returns> public int UpdatePersonalDetails(UserDetailDAO userDetailsDAO) { Database database = null; DbCommand insertCommand = null; try { database = DatabaseFactory.CreateDatabase(); insertCommand = database.GetStoredProcCommand("uspCreateUser"); database.AddInParameter(insertCommand, "userId", DbType.String, userDetailsDAO.UserId); database.AddInParameter(insertCommand, "firstName", DbType.String, userDetailsDAO.FirstName); database.AddInParameter(insertCommand, "lastName", DbType.String, userDetailsDAO.LastName); database.AddInParameter(insertCommand, "address", DbType.String, userDetailsDAO.Address); database.AddInParameter(insertCommand, "mobileNo", DbType.String, userDetailsDAO.MobileNo); database.AddInParameter(insertCommand, "email", DbType.String, userDetailsDAO.Email); database.AddInParameter(insertCommand, "imageType", DbType.String, userDetailsDAO.ImageType); database.AddInParameter(insertCommand, "image", DbType.Binary, userDetailsDAO.Image); return(database.ExecuteNonQuery(insertCommand)); } catch (SqlException ex) { SpencerLogger.Error("UserDetailsDatabaseService->UpdatePersonalDetails()", ex); throw new BaseException("DBInsert"); } catch (Exception ex) { SpencerLogger.Error("UserDetailsDatabaseService->UpdatePersonalDetails()", ex); throw new BaseException("DBInsert"); } finally { if (insertCommand.Connection.State == System.Data.ConnectionState.Open) { insertCommand.Connection.Close(); } database = null; } }