protected void lbtnNextStep_Click(object sender, EventArgs e) { try { string sss = Session["SetupASPNETID"].ToString(); Guid setASPNETID = Guid.Parse(Session["SetupASPNETID"].ToString()); int setAccId = Int32.Parse(Session["SetupAcountId"].ToString()); DictionaryModel.Account account = entities.Accounts.FirstOrDefault(acc => acc.ASPNETID == setASPNETID); if (hdnEditPersonalInformation.Value == "") //New Account { account.FirstName = txtFirstName.Text.Trim(); account.LastName = txtLastName.Text.Trim(); account.Country = Int32.Parse((ddlCountry.SelectedValue != "0") ? ddlCountry.SelectedValue :"27"); entities.SaveChanges(); if (StepCompleted != null) { NewAccountStepCompletedEventArgs args = new NewAccountStepCompletedEventArgs(NewAccountWizardSteps.PersonalInformation); args.ASPNETID = setASPNETID; args.CurrentAccountId = setAccId; args.CurrentCountryId = account.Country.Value; StepCompleted.Invoke(this, args); } } else // Edit Account { account.FirstName = txtFirstName.Text.Trim(); account.LastName = txtLastName.Text.Trim(); account.Country = Int32.Parse((ddlCountry.SelectedValue != "0") ? ddlCountry.SelectedValue : "27"); entities.SaveChanges(); if (StepCompleted != null) { NewAccountStepCompletedEventArgs args = new NewAccountStepCompletedEventArgs(NewAccountWizardSteps.PersonalInformation); args.ASPNETID = setASPNETID; args.CurrentAccountId = SetupAccountId; args.CurrentCountryId = account.Country.Value; StepCompleted.Invoke(this, args); } } } catch { lblError.Text = "Възникна проблем, моля опитайте по-късно."; } }
void WizardStepCompleted(object sender, NewAccountStepCompletedEventArgs e) { stepAccountSecurity.Visible = false; stepPersonalInformation.Visible = false; stepAdditionalInformation.Visible = false; stepCompleted.Visible = false; SetupASPNETID = e.ASPNETID; SetupAccountId = e.CurrentAccountId; switch (e.CurrentStepCompleted) { case NewAccountWizardSteps.AccountSecurity: lbtnPersonalInformation.Enabled = true; stepPersonalInformation.Visible = true; stepPersonalInformation.SetupASPNETID = SetupASPNETID; stepPersonalInformation.SetupAccountId = SetupAccountId; stepPersonalInformation.LoadDetails(); break; case NewAccountWizardSteps.PersonalInformation: SetupCountryId = e.CurrentCountryId; lbtnAdditionalInformation.Enabled = true; stepAdditionalInformation.Visible = true; stepAdditionalInformation.SetupASPNETID = SetupASPNETID; stepAdditionalInformation.SetupAccountId = SetupAccountId; stepAdditionalInformation.SetupCountryId = SetupCountryId; stepAdditionalInformation.LoadDetails(); break; case NewAccountWizardSteps.AdditionalInformation: stepCompleted.Visible = true; stepCompleted.SetupASPNETID = SetupASPNETID; stepCompleted.SetupAccountId = SetupAccountId; stepCompleted.LoadDetails(); break; case NewAccountWizardSteps.SetupCompleted: SetupCompleted = e.SetupCompleted; lbtnAccountSecurity.Enabled = false; lbtnPersonalInformation.Enabled = false; lbtnAdditionalInformation.Enabled = false; stepAccountSecurity.Visible = false; stepAccountSecurity.SetupCompleted = SetupCompleted; stepAdditionalInformation.LoadDetails(); pnlCreateNewAccount.Visible = false; pnlSuccess.Visible = true; break; default: break; } UpdatePanelNewAccount.Update(); }
protected void lbtnContinue_Click(object sender, EventArgs e) { if (StepCompleted != null) { NewAccountStepCompletedEventArgs args = new NewAccountStepCompletedEventArgs(NewAccountWizardSteps.SetupCompleted); Guid setASPNETID = Guid.Parse(Session["SetupASPNETID"].ToString()); int setAccId = Int32.Parse(Session["SetupAcountId"].ToString()); args.SetupCompleted = 1; args.CurrentAccountId = setAccId; args.ASPNETID = setASPNETID; StepCompleted.Invoke(this, args); } }
protected void lbtnNextStep_Click(object sender, EventArgs e) { try { bool password = txtPassword.Text == txtConfirmPassword.Text; bool answer = txtAnswer.Text == txtConfirmAnswer.Text; if (!password) { lblError.Text = "Въведените пароли не съвпадат."; return; } if (password && answer) { if (hdnEditAccountSecutiry.Value == "") //New Account { DictionaryModel.Account account = new DictionaryModel.Account(); MembershipCreateStatus status; MembershipUser user = Membership.CreateUser(DateTime.Now.ToString("ddhhmmssfff"), txtPassword.Text, txtEmail.Text.Trim().ToLower(), txtQuestion.Text.Trim(), txtAnswer.Text.Trim(), chkApproved.Checked, out status); if (status != MembershipCreateStatus.Success) { switch (status) { case MembershipCreateStatus.DuplicateEmail: lblError.Text = "Въведеният Email адрес е зает."; break; case MembershipCreateStatus.DuplicateProviderUserKey: lblError.Text = "Дублиращ се потребителски код."; break; case MembershipCreateStatus.DuplicateUserName: lblError.Text = "Въведеното потребителско име е заето."; break; case MembershipCreateStatus.InvalidAnswer: lblError.Text = "Въведохте невалиден отговор на тайният въпрос."; break; case MembershipCreateStatus.InvalidEmail: lblError.Text = "Въведохте невалиден Email адрес."; break; case MembershipCreateStatus.InvalidPassword: lblError.Text = "Въведохте невалидна парола."; break; case MembershipCreateStatus.InvalidProviderUserKey: lblError.Text = "Невалиден потретбителски код."; break; case MembershipCreateStatus.InvalidQuestion: lblError.Text = "Веведохте невалиден таен въпрос."; break; case MembershipCreateStatus.InvalidUserName: lblError.Text = "Въведохте невалидно потребителско име."; break; case MembershipCreateStatus.ProviderError: lblError.Text = "Възникна грешка, моля опитайте отново."; break; case MembershipCreateStatus.UserRejected: lblError.Text = "Вашият профил е спрян."; break; default: break; } return; } user.IsApproved = chkApproved.Checked; user.Comment = txtReminder.Text; Membership.UpdateUser(user); Roles.AddUserToRole(user.UserName, "User"); account.ASPNETID = (Guid)user.ProviderUserKey; account.FirstName = string.Empty; account.LastName = string.Empty; entities.Accounts.AddObject(account); entities.SaveChanges(); if (StepCompleted != null) { NewAccountStepCompletedEventArgs args = new NewAccountStepCompletedEventArgs(NewAccountWizardSteps.AccountSecurity); Session["SetupASPNETID"] = args.ASPNETID = account.ASPNETID; Session["SetupAcountId"] = args.CurrentAccountId = account.Id; StepCompleted.Invoke(this, args); //HideEditAddControls(); } } else //Edit Account { MembershipUser user = Membership.GetUser(SetupASPNETID); user.ChangePasswordQuestionAndAnswer(txtPassword.Text, txtQuestion.Text, txtAnswer.Text); user.Comment = txtReminder.Text; user.IsApproved = chkApproved.Checked; Membership.UpdateUser(user); hdnEditAccountSecutiry.Value = null; HideEditAddControls(); if (StepCompleted != null) { NewAccountStepCompletedEventArgs args = new NewAccountStepCompletedEventArgs(NewAccountWizardSteps.AccountSecurity); args.ASPNETID = (Guid)user.ProviderUserKey; StepCompleted.Invoke(this, args); } } } else { lblError.Text = "Въведените отговори на тайният въпрос не съвпадат."; } } catch (Exception ex) { lblError.Text = ex.Message;// "Възникна проблем, моля опитайте по-късно."; } }
protected void lbtnFinishStep_Click(object sender, EventArgs e) { try { Guid setASPNETID = (Guid)Session["SetupASPNETID"]; int setAccId = Int32.Parse(Session["SetupAcountId"].ToString()); DictionaryModel.Account account = entities.Accounts.FirstOrDefault(acc => acc.ASPNETID == setASPNETID); if (ddlArea.SelectedValue != "0") { account.Area = Int32.Parse(ddlArea.SelectedValue); if (ddlCity.SelectedValue != "0") { account.City = Int32.Parse(ddlCity.SelectedValue); if (ddlVillage.SelectedValue != "0") { account.Village = Int32.Parse(ddlVillage.SelectedValue); } } } int phone; if (Int32.TryParse(txtPhone.Text, out phone)) { account.Phone = phone; } account.Address = txtAddress.Text; account.Notes = txtNotes.Text; if (fuSource.HasFile) { string fileExt = System.IO.Path.GetExtension(fuSource.PostedFile.FileName); if (fileExt == ".jpg" || fileExt == ".jpeg" || fileExt == ".png" || fileExt == ".bmp") { if ((fuSource.PostedFile.ContentLength > 0) && (fuSource.PostedFile.ContentLength < 10000000)) { string currentTime = DateTime.Now.ToString().Replace("/", "").Replace(":", "").Replace(" ", ""); string fileName = fuSource.PostedFile.FileName; string fileDirectory = Server.MapPath("~/Files/FileUpload"); string SaveLocation = fileDirectory + "\\" + currentTime + fileName; //string displayedImgThumb = Server.MapPath("~/Files/FileUpload") + "/Thumb/"; if (!Directory.Exists(fileDirectory)) { Directory.CreateDirectory(fileDirectory); } try { fuSource.PostedFile.SaveAs(SaveLocation); //System.Drawing.Image myimg = System.Drawing.Image.FromFile(SaveLocation); //myimg = myimg.GetThumbnailImage(100, 100, null, IntPtr.Zero); //myimg.Save(displayedImgThumb + SaveLocation, myimg.RawFormat); account.Picture = currentTime + fileName; } catch (Exception ex) { lblError.Text = "Error: " + ex.Message; } } else { lblError.Text = "Файла е прекалено голям."; } } } entities.SaveChanges(); if (StepCompleted != null) { NewAccountStepCompletedEventArgs args = new NewAccountStepCompletedEventArgs(NewAccountWizardSteps.AdditionalInformation); args.ASPNETID = setASPNETID; args.CurrentAccountId = setAccId; StepCompleted.Invoke(this, args); } } catch { lblError.Text = "Възникна проблем, моля опитайте по-късно."; } }