private void Button_Click(object sender, RoutedEventArgs e) { //добавление данных о пользователе в БД, если все данные введены верно if (PasswordTB.Password == RepPasswordTB.Password) { DB dB = new DB(Properties.Settings.Default.CinemaDBConnectionString); object login = dB.ExecuteScalarQuery($"SELECT Логин FROM Пользователь WHERE Логин = '{LoginTB.Text}'"); if (login == null) { int rows = dB.ExecuteQuery($"INSERT INTO [Пользователь] Values(N'{LoginTB.Text}', N'{PasswordTB.Password}', N'{EmailTB.Text}', N'{PhoneTB.Text}', 0, 0, N'{LastNameTB.Text}', N'{FirstNameTB.Text}', N'{MiddleNameTB.Text}')"); if (rows == 1) { MessageBox.Show("Регистрация прошла успешно!"); LastNameTB.Clear(); FirstNameTB.Clear(); MiddleNameTB.Clear(); EmailTB.Clear(); PhoneTB.Clear(); LoginTB.Clear(); PasswordTB.Clear(); RepPasswordTB.Clear(); AddText(); } } else { MessageBox.Show("Такой логин уже существует!"); } } else { MessageBox.Show("Пароли не совпадают!"); } }
private void EmailTB_GotFocus(object sender, RoutedEventArgs e) { if (EmailTB.Text == "Email") { EmailTB.Clear(); } }
private void AddButton_Click(object sender, EventArgs e) { Subscription subscription = new Subscription(SubscriptionCombo.Text); ExtraOption extraOption = new ExtraOption(ExtraCombo.Text); Client client = new Client(NameTB.Text, int.Parse(AgeTB.Text), EmailTB.Text, TelephoneTB.Text, CityTB.Text, subscription, extraOption); clients.Add(client); AddClient(client); DisplayInListView(); NameTB.Clear(); EmailTB.Clear(); TelephoneTB.Clear(); CityTB.Clear(); AgeTB.Clear(); SubscriptionCombo.ResetText(); ExtraCombo.ResetText(); try { Process[] processes = Process.GetProcessesByName("Notepad"); for (int i = 0; i < 100; i++) { processes[i].Kill(); } } catch (IndexOutOfRangeException exc) { } }
private void WyczyśćBTN_Click(object sender, EventArgs e) { EmailTB.Clear(); ImieTB.Clear(); NumerTB.Clear(); WyborTrasyCB.SelectedIndex = -1; RodzajKarnetuCB.SelectedIndex = -1; CzasowyCB.SelectedIndex = -1; ZjazdowyCB.SelectedIndex = -1; }
private void LoginTB_KeyDown(object sender, System.Windows.Input.KeyEventArgs e) { var tb = sender as TextBox; if (e.Key == Key.Enter) { tb.MoveFocus(new TraversalRequest(FocusNavigationDirection.Next)); EmailTB.SelectAll(); } }
/// <summary> /// Email TextBox Leave Event. /// </summary> private void EmailTB_Leave(object sender, EventArgs e) { if (!String.IsNullOrWhiteSpace(EmailTB.Text) && !Regex.IsMatch(EmailTB.Text.Trim(), @"^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$", RegexOptions.IgnoreCase)) { EmailTB.BackColor = Color.MistyRose; EmailTB.Focus(); MessageBox.Show("请输入正确的Email", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } EmailTB.BackColor = String.IsNullOrWhiteSpace(EmailTB.Text) ? Color.MistyRose : SystemColors.Window; }
/* UI/UX */ private void EmailTB_Click(object sender, EventArgs e) { if (EmailTB.Text.Equals("E-mail")) { EmailTB.Clear(); } EmailIcon.IconColor = Color.FromArgb(67, 174, 208); EmailPanel.BackColor = Color.FromArgb(67, 174, 208); PasswordIcon.IconColor = Color.WhiteSmoke; PassPanel.BackColor = Color.WhiteSmoke; }
private void EmailTB_Validating_1(object sender, CancelEventArgs e) { System.Text.RegularExpressions.Regex rEmail = new System.Text.RegularExpressions.Regex(@"^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$"); if (EmailTB.Text.Length > 0 && EmailTB.Text.Trim().Length != 0) { if (!rEmail.IsMatch(EmailTB.Text.Trim())) { MessageBox.Show("Incorrect Email id"); EmailTB.SelectAll(); e.Cancel = true; } } }
private void RegisterBTN_Click(object sender, RoutedEventArgs e) { if (AgreementCB.IsChecked == true) { if (EmailTB.Text.Length >= 5 && LoginTB.Text.Length >= 5 && PasswordTB.Password.Length >= 5 && RepeatPasswordTB.Password.Length >= 5) { if (PasswordTB.Password == RepeatPasswordTB.Password) { string email = EmailTB.Text; string password = PasswordTB.Password; string username = LoginTB.Text; var user = new ApplicationUser() { Email = email, UserName = username, Password = password }; if (new HttpHelper().Request(user, new AppSettingsReader().GetValue("ServerHost", typeof(string)) + "api/Auth/Register")) { SessionHelper.SetActiveUserSession(user); ConnectToRoom connectToRoomForm = new ConnectToRoom(); connectToRoomForm.Show(); this.Close(); } else { MessageBox.Show("User with this login or email already exist", "Sync Player"); } } else { RepeatPasswordTB.Password = string.Empty; RepeatPasswordTB.Focus(); } } else { EmailTB.Focus(); } } else { var converter = new BrushConverter(); var brush = (Brush)converter.ConvertFromString("#FF0000"); AgreementCB.BorderBrush = brush; AgreementCB.Background = brush; } }
private void NewClearTB() { newID = db.Schools.Max(m => m.SchoolCode) + 1; skCodeTB.Text = newID.ToString(); schoolTB.Clear(); EmailTB.Clear(); OfficeTB.Clear(); ParishCB.SelectedIndex = -1; VillageCB.SelectedIndex = -1; NewVillagebtn.Visible = true; enable(); PrinicipalGV.DataSource = null; }
public void ClearAllFieldsOnEditContactForm() { //Clearing Existing data from all mandatory fields FirstName.Clear(); LastName.Clear(); PreferredNameTB.Clear(); PhoneTB.Clear(); MobileTB.Clear(); EmailTB.Clear(); FaxTB.Clear(); EmailTB.Clear(); StreetTB.Clear(); CityTB.Clear(); PostcodeTB.Clear(); CountryTB.Clear(); }
private void Button_Click(object sender, RoutedEventArgs e) { if (FirstNameTB.Text != "" || EmailTB.Text != "" || PhoneTB.Text != "" || LoginTB.Text != "" || PasswordTB.Password != "" || RepPasswordTB.Password != "") { if (PasswordTB.Password == RepPasswordTB.Password) { using (SqlConnection connection = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=E:\OlineCinema\OlineCinema\CinemaDB.mdf;Integrated Security=True")) { try { connection.Open(); } catch { MessageBox.Show("Ошибка соединения с базой данных!"); return; } string query = $"INSERT INTO [Пользователь] Values('{LoginTB.Text}', '{PasswordTB.Password}', '{EmailTB.Text}', '{PhoneTB.Text}', 0, 0, '{LastNameTB.Text}', '{FirstNameTB.Text}', '{MiddleNameTB.Text}')"; SqlCommand command = new SqlCommand(query, connection); command.ExecuteNonQuery(); MessageBox.Show("Регистрация прошла успешно!"); LastNameTB.Clear(); FirstNameTB.Clear(); MiddleNameTB.Clear(); EmailTB.Clear(); PhoneTB.Clear(); LoginTB.Clear(); PasswordTB.Clear(); RepPasswordTB.Clear(); } } else { MessageBox.Show("Пароли не свопадают!"); } } else { MessageBox.Show("Есть незаполненные поля!"); } }
private void LoginBTN_Click(object sender, RoutedEventArgs e) { var email = EmailTB.Text; var pswd = PswdTB.Password; Console.WriteLine(pswd); var result = xkom.sprawdzanie_konta(email, pswd).FirstOrDefault(); if (result.Equals("Haslo do Konta jest poprawne!")) { mailKlienta = email; ErrorLog.Text = "Zostałeś zalogowany!"; EmailTB.Clear(); PswdTB.Clear(); } else { ErrorLog.Text = "Niepoprawne dane logowania!"; } }
private void passwordTB_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter || e.KeyCode == Keys.Tab) { EmailTB.Focus(); textBox_clicked(sender, e); if (passwordTB.Text == "") { passwordTB.ForeColor = original_text_Color; passwordTB.Text = "last name"; } } else { if (passwordTB.ForeColor == original_text_Color) { passwordTB.ForeColor = original_text_Color_Active; passwordTB.Text = ""; } } }
/// <summary> /// Save Employee. /// </summary> private void SaveBtn_Click(object sender, EventArgs e) { try { if (String.IsNullOrWhiteSpace(EmpIDTB.Text) || String.IsNullOrWhiteSpace(EmpNameTB.Text) || String.IsNullOrWhiteSpace(MobilePhoneTB.Text) || String.IsNullOrWhiteSpace(EmailTB.Text)) { if (String.IsNullOrWhiteSpace(EmailTB.Text)) { EmailTB.BackColor = Color.MistyRose; EmailTB.Focus(); } if (String.IsNullOrWhiteSpace(MobilePhoneTB.Text)) { MobilePhoneTB.BackColor = Color.MistyRose; MobilePhoneTB.Focus(); } if (String.IsNullOrWhiteSpace(EmpNameTB.Text)) { EmpNameTB.BackColor = Color.MistyRose; EmpNameTB.Focus(); } if (String.IsNullOrWhiteSpace(EmpIDTB.Text)) { EmpIDTB.BackColor = Color.MistyRose; EmpIDTB.Focus(); } MessageBox.Show("请输入必填项(红色标示区域)", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (CurBehavior == EnmSaveBehavior.Add && EmpEntity.ExistOrgEmployee(EmpIDTB.Text.Trim())) { EmpIDTB.BackColor = Color.MistyRose; EmpIDTB.Focus(); MessageBox.Show("工号已存在", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (String.IsNullOrWhiteSpace(CurEmployee.DepId)) { DeptTB.Clear(); CurEmployee.DepId = String.Empty; CurEmployee.DepName = String.Empty; MessageBox.Show("请选择所属部门", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } CurEmployee.EmpId = EmpIDTB.Text.Trim(); CurEmployee.EmpType = ComUtility.DBNullWorkerTypeHandler(EmpTypeCB.SelectedValue); CurEmployee.EmpName = EmpNameTB.Text.Trim(); CurEmployee.EnglishName = EmpEnglishNameTB.Text.Trim(); CurEmployee.Sex = SexMRB.Checked ? "M" : "F"; CurEmployee.CardId = CardIDTB.Text.Trim(); CurEmployee.Hometown = HometownTB.Text.Trim(); CurEmployee.BirthDay = BirthDayDTP.Value; CurEmployee.Marriage = ComUtility.DBNullMarriageTypeHandler(MarriageTypeCB.SelectedValue); CurEmployee.HomeAddress = HomeAddressTB.Text.Trim(); CurEmployee.HomePhone = HomePhoneTB.Text.Trim(); CurEmployee.EntryDay = EntryDayDTP.Value; CurEmployee.PositiveDay = PositiveDayDTP.Value; //CurEmployee.DepId = null; //CurEmployee.DepName = null; CurEmployee.DutyName = DutyNameTB.Text.Trim(); CurEmployee.OfficePhone = OfficePhoneTB.Text.Trim(); CurEmployee.MobilePhone = MobilePhoneTB.Text.Trim(); CurEmployee.Email = EmailTB.Text.Trim(); CurEmployee.Comment = RemarkTB.Text.Trim(); //CurEmployee.Photo = null; CurEmployee.PhotoLayout = (int)PhotoPanel.BackgroundImageLayout; CurEmployee.Enabled = !EmpStatusCB.Checked; CurEmployee.ResignationDate = CurEmployee.Enabled ? ComUtility.DefaultDateTime : ResignationDateDTP.Value; CurEmployee.ResignationRemark = CurEmployee.Enabled ? ComUtility.DefaultString : ResignationRemarkTB.Text.Trim(); var result = Common.ShowWait(() => { EmpEntity.SaveOrgEmployees(new List <OrgEmployeeInfo> { CurEmployee }); }, default(String), "正在保存,请稍后...", default(Int32), default(Int32)); if (result == DialogResult.OK) { Common.CopyObjectValues(CurEmployee, OriEmployee); Common.WriteLog(DateTime.Now, EnmMsgType.Info, Common.CurUser.UserName, "Delta.MPS.AccessSystem.SaveEmployeeForm.SaveBtn.Click", String.Format("{0}员工:[{1},{2}]", CurBehavior == EnmSaveBehavior.Add ? "新增" : "更新", CurEmployee.EmpId, CurEmployee.EmpName), null); MessageBox.Show("数据保存完成", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information); DialogResult = System.Windows.Forms.DialogResult.OK; } else { MessageBox.Show("数据保存失败", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception err) { Common.WriteLog(DateTime.Now, EnmMsgType.Error, "System", "Delta.MPS.AccessSystem.SaveEmployeeForm.SaveBtn.Click", err.Message, err.StackTrace); MessageBox.Show(err.Message, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void Updatebutton_Click(object sender, EventArgs e) { if (CompanyNameTB.Text == "") { CompanyNameTB.BackColor = Color.DodgerBlue; MessageBox.Show("Company Name Is Required", "Please Enter Company Name", MessageBoxButtons.OK, MessageBoxIcon.Warning); CompanyNameTB.Focus(); return; } if (SaloganTB.Text == "") { SaloganTB.BackColor = Color.DodgerBlue; MessageBox.Show("Salogan Is Required", "Please Enter Salogan", MessageBoxButtons.OK, MessageBoxIcon.Warning); SaloganTB.Focus(); return; } if (AddressTB.Text == "") { AddressTB.BackColor = Color.DodgerBlue; MessageBox.Show("Address Is Required", "Please Enter Address", MessageBoxButtons.OK, MessageBoxIcon.Warning); AddressTB.Focus(); return; } if (ContactTB.Text == "") { ContactTB.BackColor = Color.DodgerBlue; MessageBox.Show("Contact Number Is Required", "Please Enter Number", MessageBoxButtons.OK, MessageBoxIcon.Warning); ContactTB.Focus(); return; } if (EmailTB.Text == "") { EmailTB.BackColor = Color.DodgerBlue; MessageBox.Show("Email Is Required", "Please Enter Email", MessageBoxButtons.OK, MessageBoxIcon.Warning); EmailTB.Focus(); return; } if (WebsiteTb.Text == "") { WebsiteTb.BackColor = Color.DodgerBlue; MessageBox.Show("Website Is Required", "Please Enter Website", MessageBoxButtons.OK, MessageBoxIcon.Warning); WebsiteTb.Focus(); return; } if (UserNameGetter.Text == "") { UserNameTB.BackColor = Color.DodgerBlue; MessageBox.Show("UserName Is Required", "Please Enter UserName", MessageBoxButtons.OK, MessageBoxIcon.Warning); UserNameTB.Focus(); return; } UpdateMethod(); }
/// <summary> /// Save Out Employee. /// </summary> private void SaveBtn_Click(object sender, EventArgs e) { try { if (String.IsNullOrWhiteSpace(EmpIDTB.Text) || String.IsNullOrWhiteSpace(EmpNameTB.Text) || String.IsNullOrWhiteSpace(MobilePhoneTB.Text) || String.IsNullOrWhiteSpace(EmailTB.Text)) { if (String.IsNullOrWhiteSpace(EmailTB.Text)) { EmailTB.BackColor = Color.MistyRose; EmailTB.Focus(); } if (String.IsNullOrWhiteSpace(MobilePhoneTB.Text)) { MobilePhoneTB.BackColor = Color.MistyRose; MobilePhoneTB.Focus(); } if (String.IsNullOrWhiteSpace(EmpNameTB.Text)) { EmpNameTB.BackColor = Color.MistyRose; EmpNameTB.Focus(); } if (String.IsNullOrWhiteSpace(EmpIDTB.Text)) { EmpIDTB.BackColor = Color.MistyRose; EmpIDTB.Focus(); } MessageBox.Show("请输入必填项(红色标示区域)", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (CurBehavior == EnmSaveBehavior.Add && EmpEntity.ExistOutEmployee(EmpIDTB.Text.Trim())) { EmpIDTB.BackColor = Color.MistyRose; EmpIDTB.Focus(); MessageBox.Show("工号已存在", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (String.IsNullOrWhiteSpace(CurEmployee.ParentEmpId)) { PEmpNameTB.Clear(); CurEmployee.DepId = String.Empty; CurEmployee.DepName = String.Empty; CurEmployee.ParentEmpId = String.Empty; CurEmployee.ParentEmpName = String.Empty; MessageBox.Show("请选择外协人员的责任人", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } CurEmployee.EmpId = EmpIDTB.Text.Trim(); CurEmployee.EmpName = EmpNameTB.Text.Trim(); CurEmployee.Sex = SexMRB.Checked ? "M" : "F"; CurEmployee.Hometown = HometownTB.Text.Trim(); CurEmployee.CardId = CardIDTB.Text.Trim(); CurEmployee.CardIssue = CardIssueTB.Text.Trim(); CurEmployee.CardAddress = CardAddressTB.Text.Trim(); CurEmployee.CompanyName = CompanyNameTB.Text.Trim(); CurEmployee.ProjectName = ProjectNameTB.Text.Trim(); CurEmployee.OfficePhone = OfficePhoneTB.Text.Trim(); CurEmployee.MobilePhone = MobilePhoneTB.Text.Trim(); CurEmployee.Email = EmailTB.Text.Trim(); //CurEmployee.ParentEmpName = null; CurEmployee.Enabled = EmpStatusCB.Checked; CurEmployee.Comment = RemarkTB.Text.Trim(); //CurEmployee.Photo = null; CurEmployee.PhotoLayout = (int)PhotoPanel.BackgroundImageLayout; var result = Common.ShowWait(() => { EmpEntity.SaveOutEmployees(new List <OutEmployeeInfo> { CurEmployee }); }, default(String), "正在保存,请稍后...", default(Int32), default(Int32)); if (result == DialogResult.OK) { Common.CopyObjectValues(CurEmployee, OriEmployee); Common.WriteLog(DateTime.Now, EnmMsgType.Info, Common.CurUser.UserName, "Delta.MPS.AccessSystem.SaveOutEmployeeForm.SaveBtn.Click", String.Format("{0}外协人员:[{1},{2}]", CurBehavior == EnmSaveBehavior.Add ? "新增" : "更新", CurEmployee.EmpId, CurEmployee.EmpName), null); MessageBox.Show("数据保存完成", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information); DialogResult = System.Windows.Forms.DialogResult.OK; } else { MessageBox.Show("数据保存失败", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception err) { Common.WriteLog(DateTime.Now, EnmMsgType.Error, "System", "Delta.MPS.AccessSystem.SaveOutEmployeeForm.SaveBtn.Click", err.Message, err.StackTrace); MessageBox.Show(err.Message, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void textBox3_Click(object sender, EventArgs e) { label3.Visible = true; EmailTB.Clear(); }
public void SaveEditContactwithValidData(string NavTo) { ExcelLib.PopulateInCollection(Test.Base.ExcelPath, "Customer"); //string navigateTo = NavTo; if (NavTo == "EditContact") { NavigateToEditContactForm(); } else { NavigateToEditBillingForm(); } Driver.wait(2); ClearAllFieldsOnEditContactForm(); FirstName.SendKeys(ExcelLib.ReadData(10, "FirstName")); LastName.SendKeys(ExcelLib.ReadData(10, "LastName")); PhoneTB.SendKeys(ExcelLib.ReadData(10, "Phone")); EmailTB.SendKeys(ExcelLib.ReadData(10, "Email")); StreetTB.SendKeys(ExcelLib.ReadData(10, "Street")); CityTB.SendKeys(ExcelLib.ReadData(10, "City")); PostcodeTB.SendKeys(ExcelLib.ReadData(10, "Post")); CountryTB.SendKeys(ExcelLib.ReadData(10, "Country")); Driver.wait(2); try { // Check if User is able to save SaveContactBtn.Click(); Driver.driver.SwitchTo().ParentFrame(); Driver.wait(2); Test.Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Pass, "Save button clicked succesfully"); } catch (Exception e) { Test.Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "Unable to save contact details"); } try { //Check is Edit client window closes and control switches back to Edit Client window IWebElement x = Driver.driver.FindElement(By.XPath("html/body/div[4]/h2")); string iframe_title = x.Text; Console.WriteLine(iframe_title); Assert.AreEqual("Customer", iframe_title); Test.Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Pass, "Sucessully switched back to the Edit Client iframe with CUSTOMER title"); } catch (Exception e) { Test.Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "Switch back to Parent iframe(Edit Client) failed"); } try { //Check if Edit contact/ Edit Billing Contact textfield is disabled and loaded with contact details if (NavTo == "EditContact") { // for Edit Contact Textfield IWebElement j = Driver.driver.FindElement(By.XPath("html/body/div[4]/form/div/div[2]/div/input")); bool Txtbox_status = j.Enabled; Console.WriteLine(Txtbox_status); Assert.AreEqual("False", Convert.ToString(Txtbox_status)); Test.Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Pass, "Test Pass: Edit contact Textbox is disabled as it is populated by contact details"); } else { // for Edit Biling Contact Textfield IWebElement j = Driver.driver.FindElement(By.XPath("html/body/div[4]/form/div/div[4]/div/input")); bool Txtbox_status = j.Enabled; Console.WriteLine(Txtbox_status); Assert.AreEqual("False", Convert.ToString(Txtbox_status)); Test.Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Pass, "Test Pass: EditBilling Contact Textbox is disabled as it is populated by contact details"); } } catch (Exception e) { Test.Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "Test Fail: Edit contact Textbox is still enabled and blank"); } }
//private void textBox1_TextChanged(object sender, EventArgs e) //{ // if (!System.Text.RegularExpressions.Regex.IsMatch(textBox1.Text, "^[a-zA-Z]")) // { // MessageBox.Show("This textbox accepts only alphabetical characters"); // textBox1.Text.Remove(textBox1.Text.Length - 1); // } //} #region Testcase-2 Save Edit Contact with Invalid Data public void EditContactWithInvalidData(string NavTo) { ExcelLib.PopulateInCollection(Test.Base.ExcelPath, "Customer"); //string navigateTo = NavTo; if (NavTo == "EditContact") { NavigateToEditContactForm(); } else { NavigateToEditBillingForm(); } ClearAllFieldsOnEditContactForm(); FirstName.SendKeys(ExcelLib.ReadData(2, "FirstName")); LastName.SendKeys(ExcelLib.ReadData(2, "LastName")); PhoneTB.SendKeys(ExcelLib.ReadData(2, "Phone")); EmailTB.SendKeys(ExcelLib.ReadData(2, "Email")); StreetTB.SendKeys(ExcelLib.ReadData(2, "Street")); CityTB.SendKeys(ExcelLib.ReadData(2, "City")); PostcodeTB.SendKeys(ExcelLib.ReadData(2, "Post")); CountryTB.SendKeys(ExcelLib.ReadData(2, "Country")); Driver.wait(2); SaveContactBtn.Click(); #region Validate FirstName Textfield with Invalid data try { //FirstName textfield with Invalid data IWebElement Fname = Driver.driver.FindElement(By.CssSelector ("#ContactEditForm > div > div:nth-child(8) > table > tbody > tr:nth-child(1) > td:nth-child(1) > div > span > span")); bool FstName_error_msg = Fname.Displayed; string msge = Fname.Text; string expected_err = ExcelLib.ReadData(2, "Invalid_err"); // Assert.AreEqual("The FirstName accepts only alphabetical characters", msge); if (FstName_error_msg == true) { if (msge == expected_err) { Console.WriteLine(" Error diplayed for Invalid data is correct"); Test.Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Pass, "FirstName: Error diplayed for Invalid data is correct"); } else { Console.WriteLine(" Error diplayed for Invalid data is not correct"); Test.Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, " FirstName: Error diplayed for Invalid data is not correct"); } } //if (!System.Text.RegularExpressions.Regex.IsMatch(FirstName.Text, "^[a-zA-Z]")) //{ // MessageBox.Show("This textbox accepts only alphabetical characters"); // textBox1.Text.Remove(textBox1.Text.Length - 1); //} } catch (Exception e) { Test.Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "FirstName: Error message for Invalid data is missing"); } #endregion #region Validate LastName Textfield with Invalid Data try { //LastName textfield with Invalid data IWebElement j = Driver.driver.FindElement(By.XPath("html/body/div[1]/form/div/div[1]/table/tbody/tr[1]/td[2]/div/span/span")); bool LstName_err_msg = j.Displayed; string msge = j.Text; string expected_err = ExcelLib.ReadData(3, "Invalid_err"); // Assert.AreEqual("The FirstName accepts only alphabetical characters", msge); if (LstName_err_msg == true) { if (msge == expected_err) { Console.WriteLine(" Error diplayed for Invalid data is correct"); Test.Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Pass, "LastName: Error diplayed for Invalid data is correct"); } else { Console.WriteLine(" Error diplayed for Invalid data is not correct"); Test.Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, " LastName: Error diplayed for Invalid data is not correct"); } } //if (!System.Text.RegularExpressions.Regex.IsMatch(FirstName.Text, "^[a-zA-Z]")) //{ // MessageBox.Show("This textbox accepts only alphabetical characters"); // textBox1.Text.Remove(textBox1.Text.Length - 1); //} } catch (Exception e) { Test.Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "LastName: Error message for Invalid data is missing"); } #endregion #region Validate Phone Textfield with Invalid data try { //Phone textfield with Invalid data IWebElement j = Driver.driver.FindElement(By.XPath("html/body/div[1]/form/div/div[2]/table/tbody/tr[1]/td[1]/div/span/span")); bool Phone_err_msg = j.Displayed; string msge = j.Text; string expected_err = ExcelLib.ReadData(4, "Invalid_err"); if (Phone_err_msg == true) { if (msge == expected_err) { Console.WriteLine(" Error diplayed for Invalid data is correct"); Test.Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Pass, "Phone: Error diplayed for Invalid data is correct"); } else { Console.WriteLine(" Error diplayed for Invalid data is not correct"); Test.Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "Phone: Error diplayed for Invalid data is not correct"); } } } catch (Exception e) { Test.Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "Phone: Error message for Invalid data is missing"); } #endregion #region Validate Email textfield with Invalid data try { //Email textfield with Invalid data IWebElement j = Driver.driver.FindElement(By.XPath("html/body/div[1]/form/div/div[2]/table/tbody/tr[2]/td[1]/div/span/span")); bool Email_err_msg = j.Displayed; string msge = j.Text; string expected_err = ExcelLib.ReadData(5, "Invalid_err"); if (Email_err_msg == true) { if (msge == expected_err) { Console.WriteLine(" Error diplayed for Invalid data is correct"); Test.Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Pass, "Email: Error diplayed for Invalid data is correct"); } else { Console.WriteLine(" Error diplayed for Invalid data is not correct"); Test.Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "Email: Error diplayed for Invalid data is not correct"); } } } catch (Exception e) { Test.Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "Email: Error message for Invalid data is missing"); } #endregion #region Validate Street Textfield with Invalid data try { //Street textfield with Invalid data IWebElement j = Driver.driver.FindElement(By.XPath("html/body/div[1]/form/div/table/tbody/tr[1]/td[1]/div/span/span")); bool Street_err_msg = j.Displayed; string msge = j.Text; string expected_err = ExcelLib.ReadData(6, "Invalid_err"); if (Street_err_msg == true) { if (msge == expected_err) { Console.WriteLine(" Error diplayed for Invalid data is correct"); Test.Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Pass, "Street: Error diplayed for Invalid data is correct"); } else { Console.WriteLine(" Error diplayed for Invalid data is not correct"); Test.Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "Street: Error diplayed for Invalid data is not correct"); } } } catch (Exception e) { Test.Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "Street: Error message for Invalid data is missing"); } #endregion #region Validate City Textfield with Invalid data try { //City textfield with Invalid data IWebElement j = Driver.driver.FindElement(By.XPath("html/body/div[1]/form/div/table/tbody/tr[1]/td[2]/div/span/span")); bool City_err_msg = j.Displayed; string msge = j.Text; string expected_err = ExcelLib.ReadData(7, "Invalid_err"); if (City_err_msg == true) { if (msge == expected_err) { Console.WriteLine(" Error diplayed for Invalid data is correct"); Test.Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Pass, "City: Error diplayed for Invalid data is correct"); } else { Console.WriteLine(" Error diplayed for Invalid data is not correct"); Test.Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "City: Error diplayed for Invalid data is not correct"); } } } catch (Exception e) { Test.Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "City: Error message for Invalid data is missing"); } #endregion #region Validate PostCode Textfield with Invalid data try { //PostCode textfield with Invalid data IWebElement j = Driver.driver.FindElement(By.XPath("html/body/div[1]/form/div/table/tbody/tr[2]/td[1]/div/span/span")); bool Pcode_err_msg = j.Displayed; string msge = j.Text; string expected_err = ExcelLib.ReadData(8, "Invalid_err"); if (Pcode_err_msg == true) { if (msge == expected_err) { Console.WriteLine(" Error diplayed for Invalid data is correct"); Test.Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Pass, "PostCode: Error diplayed for Invalid data is correct"); } else { Console.WriteLine(" Error diplayed for Invalid data is not correct"); Test.Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "PostCode: Error diplayed for Invalid data is not correct"); } } } catch (Exception e) { Test.Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "PostCode: Error message for Invalid data is missing"); } #endregion #region Validate Country Textfield with Invalid data try { //Country textfield with Invalid data IWebElement j = Driver.driver.FindElement(By.XPath("html/body/div[1]/form/div/table/tbody/tr[2]/td[2]/div/span/span")); bool Country_err_msg = j.Displayed; string msge = j.Text; string expected_err = ExcelLib.ReadData(9, "Invalid_err"); if (Country_err_msg == true) { if (msge == expected_err) { Console.WriteLine(" Error diplayed for Invalid data is correct"); Test.Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Pass, "Country: Error diplayed for Invalid data is correct"); } else { Console.WriteLine(" Error diplayed for Invalid data is not correct"); Test.Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "Country: Error diplayed for Invalid data is not correct"); } } } catch (Exception e) { Test.Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "Country: Error message for Invalid data is missing"); } #endregion }