public void bntEdit_Click(Object sender, EventArgs e) { var id = Page.Request.Params["id"]; var profile = new UsersProfiles { ID = Convert.ToInt32(id), UserID = UserID }; if (!String.IsNullOrEmpty(id)) { profile.GetById(); profile.ContactPersonFIO = tbContactPersonFIO.Text; profile.StatusID = 0; if (profile.TypeID == 1) { profile.PassportData = tbPassportData.Text; profile.PassportNumber = tbPassportNumber.Text; profile.FirstName = tbFirstName.Text; profile.LastName = tbLastName.Text; profile.ThirdName = tbThirdName.Text; profile.Address = tbAddress.Text; try { profile.PassportDate = Convert.ToDateTime(tbPassportDate.Text); } catch (Exception) { Page.Response.Redirect("~/usernotification/9"); } profile.PassportSeria = tbPassportSeria.Text; if (!String.IsNullOrEmpty(tbContactPhoneNumbers2Fiz.Text)) { profile.ContactPhoneNumbers = tbContactPhoneNumbersFiz.Text + ";" + tbContactPhoneNumbers2Fiz.Text; } else { profile.ContactPhoneNumbers = tbContactPhoneNumbersFiz.Text; } } else { profile.CompanyName = tbCompanuName.Text; profile.CompanyAddress = tbCompanyAddress.Text; profile.BankName = tbBankName.Text; profile.BankAddress = tbBankAddress.Text; profile.BankCode = tbBankCode.Text; profile.RasShet = tbRS.Text; profile.UNP = tbUNP.Text; profile.DirectorPhoneNumber = tbDirectorPhoneNumber.Text; profile.FirstName = tbFirstName2.Text; profile.LastName = tbLastName2.Text; profile.ThirdName = tbThirdName2.Text; profile.PostAddress = tbPostAddress.Text; if (!String.IsNullOrEmpty(tbContactPhoneNumbers2.Text)) { profile.ContactPhoneNumbers = tbContactPhoneNumbers.Text + ";" + tbContactPhoneNumbers2.Text; } else { profile.ContactPhoneNumbers = tbContactPhoneNumbers.Text; } } profile.Update(); } else { profile.TypeID = Convert.ToInt32(ddlProfileType.SelectedValue); profile.ContactPersonFIO = tbContactPersonFIO.Text; if (profile.TypeID == 1) { profile.PassportData = tbPassportData.Text; profile.PassportNumber = tbPassportNumber.Text; profile.FirstName = tbFirstName.Text; profile.LastName = tbLastName.Text; profile.ThirdName = tbThirdName.Text; profile.Address = tbAddress.Text; try { profile.PassportDate = Convert.ToDateTime(tbPassportDate.Text); } catch (Exception) { Page.Response.Redirect("~/usernotification/9"); } profile.PassportSeria = tbPassportSeria.Text; if (!String.IsNullOrEmpty(tbContactPhoneNumbers2Fiz.Text)) { profile.ContactPhoneNumbers = tbContactPhoneNumbersFiz.Text + ";" + tbContactPhoneNumbers2Fiz.Text; } else { profile.ContactPhoneNumbers = tbContactPhoneNumbersFiz.Text; } } else { profile.CompanyName = tbCompanuName.Text; profile.CompanyAddress = tbCompanyAddress.Text; profile.BankName = tbBankName.Text; profile.BankAddress = tbBankAddress.Text; profile.BankCode = tbBankCode.Text; profile.RasShet = tbRS.Text; profile.UNP = tbUNP.Text; profile.DirectorPhoneNumber = tbDirectorPhoneNumber.Text; profile.FirstName = tbFirstName2.Text; profile.LastName = tbLastName2.Text; profile.ThirdName = tbThirdName2.Text; profile.PostAddress = tbPostAddress.Text; if (!String.IsNullOrEmpty(tbContactPhoneNumbers2.Text)) { profile.ContactPhoneNumbers = tbContactPhoneNumbers.Text + ";" + tbContactPhoneNumbers2.Text; } else { profile.ContactPhoneNumbers = tbContactPhoneNumbers.Text; } } profile.Create(); var currentAppAddress = BackendHelper.TagToValue("current_app_address"); var sendEmailWhenProfileCreateArray = BackendHelper.TagToValue("send_email_when_profile_create"); var recipientEmailsList = sendEmailWhenProfileCreateArray.Split(new[] { ',' }); EmailMethods.MailSendHTML( String.Format("Новый профиль от пользователя #{0}", UserID), String.Format( "Пользователь <b>{0}</b> создал новый профиль. Для его просмотра и редактирования перейдите на <a href=\"http://{1}/ManagerUI/ProfilesView.aspx?uid={2}&stateSave=1\">страницу просмотра профилей</a>", UsersHelper.UserIDToFullName(UserID.ToString()), currentAppAddress, UserID), recipientEmailsList); } Page.Response.Redirect("~/UserUI/ProfilesView.aspx"); }
public void bntCreate_Click(object sender, EventArgs e) { var dm = new DataManager(); var userRegPosible = UsersHelper.UserLoginEmailRegisteredChecker(tbEmail.Text); var emailCorrectly = EmailMethods.EmailChecker(tbEmail.Text); var registrationPosible = true; if (!userRegPosible) { lblError.Text = "Пользователь с таким логином либо e-mail'ом уже есть в нашей базе!<br/>"; registrationPosible = false; } if (!emailCorrectly) { lblError.Text = "Введен недопустимый е-mail!<br/>"; registrationPosible = false; } if (!registrationPosible) { return; } #region Создание клиента var userInSession = (Users)Session["userinsession"]; var user = new Users { Name = tbName.Text, Family = tbFamily.Text, Email = tbEmail.Text, Login = tbEmail.Text, Password = "******", Role = Users.Roles.User.ToString(), Phone = tbPhone.Text, CreateDate = DateTime.Now, ContactDate = string.IsNullOrEmpty(tbContactDate.Text) ? Convert.ToDateTime("01.01.0001 0:00:00") : Convert.ToDateTime(tbContactDate.Text), StatusStady = Convert.ToInt32(ddlStatusStady.SelectedValue), Status = 1, /* not activated */ SalesManagerID = Convert.ToInt32(ddlSalesManager.SelectedValue), Note = WebUtility.HtmlEncode(string.Format( "<div class='comment-history-body'>{1}</div>" + "<div>" + "<span class='comment-history-name'>{0}</span>" + "<span class='comment-history-date'>{2}</span>" + "</div>", UsersHelper.UserIDToFullName(userInSession.ID.ToString()), tbComment.Text, DateTime.Now.ToString("dd.MM в HH:mm"))) }; user.Create(); #endregion var userId = Convert.ToInt32(dm.QueryWithReturnDataSet("SELECT `ID` FROM `users` ORDER BY `ID` DESC LIMIT 1").Tables[0].Rows[0][0]); #region Создание профиля var profile = new UsersProfiles { UserID = userId, StatusID = 0, TypeID = Convert.ToInt32(ddlProfileType.SelectedValue), CreateDate = DateTime.Now, IsDefault = 1, CompanyName = string.Format("{0} «{1}»", ddlCompanyType.SelectedItem, tbCompanyName.Text), DirectorPhoneNumber = tbDirectorPhone.Text, FirstName = tbDirectorFamily.Text, LastName = tbDirectorName.Text, ThirdName = tbDirectorPatronymic.Text, ContactPersonFIO = tbContactPersonFIO.Text, }; if (!string.IsNullOrEmpty(tbContactPhoneNumbers2.Text)) { profile.ContactPhoneNumbers = tbContactPhoneNumbers.Text + ";" + tbContactPhoneNumbers2.Text; } else { profile.ContactPhoneNumbers = tbContactPhoneNumbers.Text; } profile.Create(); #endregion #region Добавление клиенту категорий foreach (var items in lvAllCategory.Items) { var hfCategoryId = (HiddenField)items.FindControl("hfCategoryId"); var cbCategory = (CheckBox)items.FindControl("cbCategory"); if (cbCategory.Checked) { dm.QueryWithoutReturnData(null, string.Format("INSERT IGNORE INTO `userstocategory` (`UserID`, `CategoryID`) VALUES ('{0}', '{1}');", userId, hfCategoryId.Value)); } } #endregion Page.Response.Redirect("~/ManagerUI/Menu/Souls/ClientsView.aspx"); }