protected void lbtnChangeAddress_Click(object sender, EventArgs e) { int accountId = (Page as BasePage).CurrentAccountId; DictionaryModel.Account account = entities.Accounts.FirstOrDefault(acc => acc.Id == accountId); lbtnChangeAddress.Visible = false; lbtnCancelAddress.Visible = lbtnSaveAddress.Visible = true; lblCountry.Visible = lblArea.Visible = lblCity.Visible = lblVillage.Visible = true; txtCountry.Visible = txtArea.Visible = txtCity.Visible = txtVillage.Visible = false; ddlCountry.Visible = ddlArea.Visible = ddlCity.Visible = ddlVillage.Visible = true; lblAddress.Visible = txtAddress.Enabled = true; DataBindCountry(); ddlCountry.SelectedValue = account.Country == null ? "0" : account.Country.ToString(); DataBindArea(); ddlArea.SelectedValue = account.Area == null ? "0" : account.Area.ToString(); DataBindCity(); ddlCity.SelectedValue = account.City == null ? "0" : account.City.ToString(); DataBindVillage(); ddlVillage.SelectedValue = account.Village == null ? "0" : account.Village.ToString(); }
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 = "Възникна проблем, моля опитайте по-късно."; } }
protected void lbtnSaveNames_Click(object sender, EventArgs e) { if (Page.IsValid) { int accountId = (Page as BasePage).CurrentAccountId; DictionaryModel.Account account = entities.Accounts.FirstOrDefault(acc => acc.Id == accountId); account.FirstName = txtFirstName.Text; account.LastName = txtLastName.Text; entities.SaveChanges(); DataBindNames(); } }
public void LoadDetails() { if (SetupCountryId != 0) //Loading all details of current Account { DictionaryModel.Account currentAccount = entities.Accounts.First(acc => acc.Id == SetupAccountId); MembershipUser user = Membership.GetUser(SetupASPNETID); txtFirstName.Text = currentAccount.FirstName; txtLastName.Text = currentAccount.LastName; ddlCountry.SelectedValue = currentAccount.Country.ToString(); hdnEditPersonalInformation.Value = "Edite Account"; } DataBindCountries(); }
protected void DataBindNames() { int accountId = (Page as BasePage).CurrentAccountId; DictionaryModel.Account account = entities.Accounts.FirstOrDefault(acc => acc.Id == accountId); txtFirstName.Text = account.FirstName; txtFirstName.Enabled = false; txtLastName.Text = account.LastName; txtLastName.Enabled = false; lbtnChangeNames.Visible = true; lbtnCancelNames.Visible = false; lbtnSaveNames.Visible = false; imgPersonalPicture.ImageUrl = "~/Files/FileUpload/" + (account.Picture == null ? "Default.png" : account.Picture); imgPersonalPicture.ToolTip = account.FirstName + " " + account.LastName; imgPersonalPicture.Width = 400; imgPersonalPicture.Height = 300; }
public void LoadDetails() { Guid setASPNETID = (Guid)Session["SetupASPNETID"]; int setAccId = Int32.Parse(Session["SetupAcountId"].ToString()); DictionaryModel.Account account = entities.Accounts.FirstOrDefault(acc => acc.ASPNETID == SetupASPNETID); MembershipUser user = Membership.GetUser(SetupASPNETID); txtEmail.Text = user.Email; txtFirstName.Text = account.FirstName; txtLastName.Text = account.LastName; //txtCountry.Text = entities.Countries.Select((country => country.Id == account.Country)Name; //txtArea.Text = // txtCity.Text = // txtVillage.Text = txtAddress.Text = account.Address; txtPhone.Text = account.Phone.ToString(); txtNotes.Text = account.Notes; }
protected void lbtnSaveChangePicture_Click(object sender, EventArgs e) { if (fuSource.HasFile) { int currentUserId = (Page as BasePage).CurrentAccountId; DictionaryModel.Account account = entities.Accounts.FirstOrDefault(acc => acc.Id == currentUserId); string fileExt = System.IO.Path.GetExtension(fuSource.PostedFile.FileName); 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; entities.SaveChanges(); Response.Redirect("~/AccountInformation.aspx"); } catch (Exception ex) { lblResultMessage.Text = "Error: " + ex.Message; } } else { lblResultMessage.Text = "Файла е прекалено голям."; } } }
protected void lbtnSaveAddress_Click(object sender, EventArgs e) { if (Page.IsValid) { int accounId = (Page as BasePage).CurrentAccountId; DictionaryModel.Account account = entities.Accounts.FirstOrDefault(acc => acc.Id == accounId); account.Country = Int32.Parse(ddlCountry.SelectedValue); int?areaId = Int32.Parse(ddlArea.SelectedValue); account.Area = areaId != 0 ? areaId : null; int?cityId = Int32.Parse(ddlCity.SelectedValue); account.City = cityId != 0 ? cityId : null; int?villageId = Int32.Parse(ddlVillage.SelectedValue); account.Village = villageId != 0 ? villageId : null; account.Address = txtAddress.Text == string.Empty ? null : txtAddress.Text; entities.SaveChanges(); DataBindAddress(); } }
protected void SetCurrentAccountVariables(MembershipUser user) { DictionaryModel.DictionaryEntities entities = new DictionaryModel.DictionaryEntities(); // >>>>>IZVYN METODA Guid aspnetId = (Guid)user.ProviderUserKey; DictionaryModel.Account account = entities.Accounts.FirstOrDefault(acc => acc.ASPNETID == aspnetId); if (account != null) //The Manager is Admin { this.CurrentAccountUsername = user.UserName; this.CurrentAccountId = account.Id; this.CurrentUserNames = account.FirstName + " " + account.LastName; } else //The user is guest { this.CurrentAccountUsername = "******";//.CurrentManagerUsername = user.UserName; this.CurrentAccountId = 1; //.CurrentCompanyId = accountManager.CompanyId.Value;// accountManager.CompanyId; } HttpCookie UserName = new HttpCookie("UserName", user.UserName); Response.Cookies.Add(UserName); }
protected void DataBindAddress() { ddlCountry.Visible = ddlArea.Visible = ddlCity.Visible = ddlVillage.Visible = false; txtCountry.Enabled = txtArea.Enabled = txtCity.Enabled = txtVillage.Enabled = false; int accountId = (Page as BasePage).CurrentAccountId; DictionaryModel.Account account = entities.Accounts.FirstOrDefault(acc => acc.Id == accountId); txtCountry.Visible = true; txtCountry.Text = entities.Countries.First(coutnry => coutnry.Id == account.Country).Name; int areaId; if (Int32.TryParse(account.Area.ToString(), out areaId)) { lblCity.Visible = txtArea.Visible = true; txtArea.Text = entities.Areas.First(area => area.Id == account.Area).Name; } else { lblArea.Visible = txtArea.Visible = false; } int cityId; if (Int32.TryParse(account.City.ToString(), out cityId)) { lblCity.Visible = txtCity.Visible = true; txtCity.Text = entities.Cities.First(city => city.Id == account.City).Name; } else { lblCity.Visible = txtCity.Visible = false; } int villageId; if (Int32.TryParse(account.Village.ToString(), out villageId)) { lblVillage.Visible = txtVillage.Visible = true; txtVillage.Text = entities.Villages.First(village => village.Id == account.Village).Name; } else { lblVillage.Visible = txtVillage.Visible = false; } if (account.Address != null && account.Address != "") { lblAddress.Visible = txtAddress.Visible = true; txtAddress.Text = account.Address; txtAddress.Enabled = false; } else { lblAddress.Visible = txtAddress.Visible = false; } lbtnChangeAddress.Visible = true; lbtnCancelAddress.Visible = false; lbtnSaveAddress.Visible = false; }
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 = "Възникна проблем, моля опитайте по-късно."; } }