/// <summary> /// Checks the that authors file does not contain This book title. /// </summary> /// <param name="filePath">The path to the authors file.</param> /// <param name="bookTitle">Title of book to check if contained in authors file all ready..</param> /// <returns></returns> private bool CheckThatAuthorsFileDoesNotContainThisBookTitle(string filePath, string bookTitle) { this._msgBox.NameOfMethod = MethodBase.GetCurrentMethod().Name; var clsInput = new InputClass(); var bookData = clsInput.ReadAllBookTitlesFromAuthorsFile(filePath); if (!bookData.Any()) { return(false); } var titleOp = new TitlesOperationClass(); var titles = titleOp.GetBookTitleFromBookData(bookData); if (!titles.Any()) { return(false); } var valid = new ValidationClass(); // true if book title is all ready contained in authors file else false. return(valid.ValidateAuthorsFileDoesNotContainThisBookTitle(titles, bookTitle)); }
public void AddProduct(int ProductId, int Quntity, float SellingPrice, float Price1, string Price2) { Product_Table Obj = BussinessObj.Product_tb_search_by_ID(ProductId); if (Obj != null) { total = Quntity * SellingPrice; if (dataGridView1.RowCount == 0) { RowID = dataGridView1.RowCount + 1; row = new string[] { (RowID++).ToString(), Obj.Category_Table.Catagory_Name, Obj.Product_Name, ExpirDate, ExpireOrNot, SellingPrice.ToString(), Price1.ToString(), Price2.ToString(), Quantity.Text, total.ToString(), ProductId.ToString() }; dataGridView1.Rows.Add(row); if (!ProductNames.Contains(comboBox1.Text)) { ProductNames.Add(comboBox1.Text); } } else { if (ProductNames.Contains(comboBox1.Text)) { for (int i = 0; i < ProductNames.Capacity; i++) { if (ProductNames[i] == comboBox1.Text) { dataGridView1[5, (i)].Value = SellingPrice.ToString(); dataGridView1[6, (i)].Value = Price1.ToString(); dataGridView1[7, (i)].Value = Price2.ToString(); dataGridView1[8, (i)].Value = (int.Parse(dataGridView1[8, (i)].Value.ToString()) + Quntity).ToString(); dataGridView1[9, (i)].Value = (int.Parse(dataGridView1[8, (i)].Value.ToString()) * float.Parse(dataGridView1[5, (i)].Value.ToString())).ToString(); break; } } } else { RowID = dataGridView1.RowCount + 1; row = new string[] { (RowID++).ToString(), Obj.Category_Table.Catagory_Name, Obj.Product_Name, ExpirDate, ExpireOrNot, SellingPrice.ToString(), Price1.ToString(), Price2.ToString(), Quantity.Text, total.ToString(), ProductId.ToString() }; dataGridView1.Rows.Add(row); if (!ProductNames.Contains(comboBox1.Text)) { ProductNames.Add(comboBox1.Text); } } } } orderTotal = 0; for (int r = 0; r < dataGridView1.RowCount; r++) { orderTotal = orderTotal + float.Parse((dataGridView1[9, r].Value.ToString())); } textEdit6.Text = orderTotal.ToString(); if (ValidationClass.ISDigit(Pauid.Text)) { float Paid = float.Parse(Pauid.Text); Remin.Text = (orderTotal - Paid).ToString(); } }
private void ValidateUserHasMadeTextSelection(string value) { if (!ValidationClass.ValidateStringHasLength(value)) { throw ArgumentNullException(); } }
void Submit(object obj) { string encryptedString = (obj as PasswordBox).Password; string password = EncryptionHelper.Encrypt(encryptedString); if (string.IsNullOrEmpty(UserName) || string.IsNullOrEmpty(encryptedString)) { MessageBox.Show("You must enter values for username and password"); return; } tblUser newUser = new tblUser(); newUser.UserName = UserName; newUser.UserPassword = password; tblUser userInDb = service.GetUserByUserName(UserName); if (userInDb != null) { MessageBox.Show("Username is taken. Choose another username."); return; } if (!ValidationClass.IsPasswordValid(encryptedString)) { MessageBox.Show("Password is not valid. \nMinimal length must be 6\n" + "You need at least 2 upper case letters"); return; } service.AddUser(newUser); MessageBox.Show("You succesfully created account"); view.Close(); }
private void SubmitCommandExecute(object obj) { try { string password = (obj as PasswordBox).Password; if (ValidationClass.JMBGisValid(UserName) && password.Equals("Gost")) { GuestMainView guestMain = new GuestMainView(UserName); view.Close(); guestMain.Show(); return; } else if (UserName.Equals("Zaposleni") && password.Equals("Zaposleni")) { EmployeeView employeeView = new EmployeeView(); view.Close(); employeeView.Show(); } else { MessageBox.Show("Wrong usename or password"); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void Email_LostFocus(object sender, RoutedEventArgs e) { if (String.IsNullOrWhiteSpace(this.Email.Text)) { this.ErrorEmail.Text = "Please Enter an Email Id."; } else { if (!ValidationClass.ValidateEmailID(this.Email.Text)) { this.ErrorEmail.Text = "This is not a valid Email Id."; } else { using (var ctx = new Choukash_Revamp_DemoEntities()) { var email = ctx.SuperAdmins.Where(a => a.email == this.Email.Text).FirstOrDefault <SuperAdmin>(); if (email == null) { this.ErrorEmail.Text = ""; } else { this.ErrorEmail.Text = "This email is alraedy associated with another user"; } } } } }
private void simpleButton1_Click(object sender, EventArgs e) { int Exist = 0; if (checkEdit1.Checked == true) { Exist = 1; } else { Exist = 0; } bool x = BussinessObj.Category_Table_insert(CataName.Text, CataDes.Text, Exist); if (x == true) { XtraMessageBox.Show("تم اضافة البيانات "); this.category_TableTableAdapter.Fill(this.project_DBDataSet.Category_Table); checkEdit1.Checked = false; CataName.Text = ""; CataDes.Text = ""; } else { XtraMessageBox.Show("توجد مشكلة فى اضافة البيانات "); ValidationClass.showStar(RTSName, x); } }
/// <summary>Called when [ok button clicked].</summary> /// <param name="sender">The source of the event</param> /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param> private void OnOKButton_Clicked(object sender, EventArgs e) { var coll = new BookDataCollection(); BookListPathsProperties.AuthorsNameCurrent = lblAuthor.Text; var clsComb = new CombinePathsClass(); var filePath = clsComb.CombineDirectoryPathWithFileName(BookListPathsProperties.PathAuthorsDirectory, BookListPathsProperties.AuthorsNameCurrent); var valid = new ValidationClass(); var msgBox = new MyMessageBoxClass(); if (!valid.ValidateStringHasLength(filePath)) { msgBox.Msg = "Unable to complete the operation."; msgBox.ShowErrorMessageBox(); return; } BookListPathsProperties.PathOfCurrentWorkingFile = filePath; coll.ClearCollection(); Close(); }
private void AddFormatButton_Click(object sender, RoutedEventArgs e) { string formatname = FormatNameBox.Text.ToString(); var message = ValidationClass.validateStringTextbox(formatname); if (!message.Item1) { MessageBox.Show(message.Item2); return; } if (isEdit) { var format = RepositoryWorkUnit.Instance.Formats.Get().FirstOrDefault(x => x.Id == _format.Id); format.FormatName = formatname; RepositoryWorkUnit.Instance.Formats.Update(format, format.Id); } else { FormatSet format = new FormatSet(); format.FormatName = formatname; RepositoryWorkUnit.Instance.Formats.Insert(format); } _context.Close(); }
/// <summary> /// Called when [series button click]. Set the is series property to /// <see langword="true"/> for series or <see langword="false"/> for not /// a series. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e"> /// The <see cref="EventArgs" /> instance containing the event data. /// </param> private void OnSeriesButton_Click(object sender, EventArgs e) { var validate = new ValidationClass(); var len = txtSeries.SelectionLength; if (len <= 0) { return; } GetSelectedSeriesText(); if (string.IsNullOrEmpty(BookDataProperties.NameOfBookSeries)) { return; } txtSeries.Enabled = true; txtSeries.Text = BookDataProperties.NameOfBookSeries; // If the title and series name match then exit operation. if (validate.ValidateTitleSeriesTextDoesNotMatch()) { var msgBox = new MyMessageBoxClass(); msgBox.Msg = "The book title name can not be the same as the book series name."; msgBox.ShowErrorMessageBox(); return; } lblInfo.Text = "SelectVolumeNumber"; btnVolume.Enabled = true; }
private bool validate() { Control[] controls = new Control[] { memberNoTextBox, nameTextBox, addressTextBox, dobDatePicker, suretyNameTextBox, suretyAddressTextBox }; string[] captions = new string[] { "Member Number", "Name of the Member", "Address of the Member", "Date of Birth of the Member", "Name of the Surety", "Address of the Surety" }; //Member No already exists. if (MemberController.IsMemberExists(memberNoTextBox.Text)) { inValid(memberNoTextBox, "The Member No is already exists!", "Member No"); memberNoTextBox.SelectAll(); return(false); } //Test for Required Fields bool valid = ValidationClass.ValidateEmptyText(highlighter, controls, captions); if (!valid) { return(false); } return(true); }
private void simpleButton1_Click(object sender, EventArgs e) { bool x = false; if (comboBox1.SelectedValue != null) { int Exist = 0; if (chec.Checked == true) { Exist = 1; } else { Exist = 0; } x = Busniss_Logic.Category_Table_update(int.Parse(comboBox1.SelectedValue.ToString()), CataName.Text, CataDes.Text, Exist); if (x == true) { XtraMessageBox.Show("تم تحديث البيانات "); this.category_TableTableAdapter.Fill(this.project_DBDataSet.Category_Table); } else { XtraMessageBox.Show("توجد مشكلة فى اضافة البيانات "); ValidationClass.showStar(RTSName, x); } } }
private void AddGenreButton_Click(object sender, RoutedEventArgs e) { string genrename = GenreNameBox.Text.ToString(); var message = ValidationClass.validateStringTextbox(genrename); if (!message.Item1) { MessageBox.Show(message.Item2); return; } if (isEdit) { var genre = RepositoryWorkUnit.Instance.Genres.Get().FirstOrDefault(x => x.Id == _genre.Id); genre.GenreName = genrename; RepositoryWorkUnit.Instance.Genres.Update(genre, genre.Id); } else { GenreSet genre = new GenreSet(); genre.GenreName = genrename; RepositoryWorkUnit.Instance.Genres.Insert(genre); } _context.Close(); }
private bool validate() { Control[] controls = new Control[] { accTextBox, typeDoubleInput, autherTextBox, publisherTextBox, pubYearIntInput }; string[] captions = new string[] { "Accession Number", "Type Number", "Auther of the Book", "Publisher of the Book", "Published Year" }; //Accession No already exists. if (BookController.IsBookExists(accTextBox.Text)) { ValidationClass.ShowInvalidError(highlighter, accTextBox, "The Accession No is already exists!", "Accession No"); accTextBox.SelectAll(); return(false); } //Test for Required Fields bool valid = ValidationClass.ValidateEmptyText(highlighter, controls, captions); if (!valid) { return(false); } return(true); }
private void ValidateUserHasMadeTextSelection(string value) { if (!ValidationClass.ValidateStringHasLength(value)) { throw new ArgumentNullException("You must select some text"); } }
public PostComentario Post(PostComentario postComentario) { ValidationClass.ValidaClasse(postComentario); _db.PostComentarios.Add(postComentario); _db.SaveChanges(); return(postComentario); }
public void TestValidationNullBoxTrue() { var name = "Наименование"; Exception ex = Assert.Throws <Exception>( delegate { ValidationClass.ValidateNullBox(string.Empty, name); }); Assert.That(ex.Message, Is.EqualTo("Поле " + name + " должно быть заполнено!")); }
public PostComentario Put(PostComentario postComentario) { ValidationClass.ValidaClasse(postComentario); _db.Entry(postComentario).State = System.Data.Entity.EntityState.Modified; _db.SaveChanges(); return(postComentario); }
public Perfil Put(Perfil perfil) { ValidationClass.ValidaClasse(perfil); _db.Entry(perfil).State = System.Data.Entity.EntityState.Modified; _db.SaveChanges(); return(perfil); }
private void AddMenagerExecute() { try { if (!ValidationClass.JMBGisValid(MenagerToAdd.JMBG)) { MessageBox.Show("JMBG nije validan."); return; } //if (!ValidationClass.JMBGIsUnique(employee.JMBG)) //{ // MessageBox.Show("JMBG already exists in database"); // return; //} if (!ValidationClass.IsValidEmail(MenagerToAdd.Email)) { MessageBox.Show("Email nije validan"); return; } int salary; if (!Int32.TryParse(Salary, out salary)) { MessageBox.Show("Plata mora biti broj"); return; } MenagerToAdd.RoleID = MenagerRole.RoleID; MenagerToAdd.SectorID = menagerSector.SectorID; MenagerToAdd.Salary = salary; MenagerToAdd.DateOfBirth = StartDate; EmployeeList = employeeService.GetAllEmployees(); //string textForFile = String.Format("Added user {0} {1} JMBG {2}", employee.FirstName, // employee.LastName, employee.JMBG); //eventObject.OnActionPerformed(textForFile); //employee.GenderID = gender.GenderID; isUpdateUser = true; menagerService.AddMenager(MenagerToAdd); MenagerToAdd = new tblEmployee(); MenagerRole = new tblRole(); MenagerSector = new tblSector(); Salary = ""; MessageBox.Show("Uspesno ste dodali menadzera"); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
void Sort() { try { TransactionOptions transactionOption = new TransactionOptions(); transactionOption.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted; using (TransactionScope tran = new TransactionScope(TransactionScopeOption.Required, transactionOption)) { progressBar1.Value = (progressBar1.Maximum / 2); var re = sc.SchedulePoke(); //排程结束后,对排程数据进行验证 ValidationClass vc = new ValidationClass(); Response response = vc.ValidationSchedule("2"); if (response.IsSuccess) { if (re.IsSuccess) { List <MixedInfo> list = MixedClass.GetUnPokeData(); MixedClass.InsertPokeMixed(list); tran.Complete(); btnPokeSeq.Enabled = true; progressBar1.Value = progressBar1.Maximum; //TimerByTime.Stop();// 计时结束; btnSort.Enabled = true; lblInFO.Text = "分拣车组任务排程成功!" + "\r\n" + "所用时间:" + times + "秒"; MessageBox.Show("分拣车组任务排程成功!" + "\r\n" + "所用时间:" + times + "秒", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { panel2.Visible = false; TimerByTime.Stop();// 计时结束; btnSort.Enabled = true; MessageBox.Show(re.MessageText, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { //回滚排程操作 MessageBox.Show(response.MessageText, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } catch (Exception e) { MessageBox.Show("排程异常:" + e.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } finally { //dgvSortInfo.Rows.Clear(); //List<TaskInfo> list = new List<TaskInfo>(); //dgvSortInfo.DataSource = list; Bind(); panel2.Visible = false; TimerByTime.Stop();// 计时结束; btnSort.Enabled = true; } }
public void TestValidationRangeBoxFalse() { var name = "Цена"; double min = 100, max = 1000; Exception ex = Assert.Throws <Exception>( delegate { ValidationClass.ValidateRangeBox("1001", name, min, max); }); Assert.That(ex.Message, Is.EqualTo("Поле " + name + " должно содержать значения от " + min + " до " + max + "!")); }
public void TestValidationRangeBoxFormatEx() { var name = "Цена"; double min = 100, max = 1000; Exception ex = Assert.Throws <Exception>( delegate { ValidationClass.ValidateRangeBox(string.Empty, name, min, max); }); Assert.That(ex.Message, Is.EqualTo("Поле " + name + " должно содержать цифровые значения!")); }
public void TestValidationLengthBoxTrue() { var name = "Наименование"; int min = 2, max = 255; Exception ex = Assert.Throws <Exception>( delegate { ValidationClass.ValidateLengthBox(string.Empty, name, min, max); }); Assert.That(ex.Message, Is.EqualTo("Поле " + name + " должно содержать от " + min + " до " + max + " символов!")); }
public Categoria Post(Categoria categoria) { ValidationClass.ValidaClasse(categoria); ValidaDuplicidade(categoria); _db.Categorias.Add(categoria); _db.SaveChanges(); return(categoria); }
private void EditShowing_button_Click(object sender, RoutedEventArgs e) { if (SelectDate_EditDelShow.SelectedDate == null) { MessageBox.Show("Please select a date for the required showing"); } else { int showingId = ShowingsClass.getShowingIdByDate(ShowingsClass.formatDateTimeToSqlLiteDateString((DateTime)SelectDate_EditDelShow.SelectedDate)); string startTime = this.TimeOfShowing_EditDeleteShowing_txt.Text; string timeToBeChecked = ValidationClass.TimeChecker(startTime); if (timeToBeChecked != null) { MessageBox.Show(timeToBeChecked); } else { double upperCirclePrice = double.Parse(this.UpperCircle_EditDelShow_txt.Text); string priceToBeChecked = UpperCircle_EditDelShow_txt.Text.ToString(); priceToBeChecked = ValidationClass.FloatChecker(priceToBeChecked); if (priceToBeChecked != null) { MessageBox.Show(priceToBeChecked); } else { double dressCirclePrice = double.Parse(this.DressCircle_EditDelShow_txt.Text); priceToBeChecked = DressCircle_EditDelShow_txt.Text.ToString(); priceToBeChecked = ValidationClass.FloatChecker(priceToBeChecked); if (priceToBeChecked != null) { MessageBox.Show(priceToBeChecked); } else { double stallPrice = double.Parse(this.Stalls_EditDelShow_txt.Text); priceToBeChecked = Stalls_EditDelShow_txt.Text.ToString(); priceToBeChecked = ValidationClass.FloatChecker(priceToBeChecked); if (priceToBeChecked != null) { MessageBox.Show(priceToBeChecked); } else { dataSet = ShowingsClass.getShowingByShowingId(showingId); string unedditedSqlDateTimeString = dataSet.Tables[0].Rows[0]["Date"].ToString(); string newDateTimeSqlString = ShowingsClass.replaceSqlDateTimeWithNewTime(unedditedSqlDateTimeString, startTime); ShowingsClass.editShowingDetails(showingId, newDateTimeSqlString, upperCirclePrice, dressCirclePrice, stallPrice); MessageBox.Show("Showing edited"); } } } } } }
protected void ValidaProgetto_ServerValidate(Object sender, ServerValidateEventArgs args) { ValidationClass c = new ValidationClass(); // true se non esiste già il record args.IsValid = !c.CheckExistence("ProjectCode", args.Value, "Projects"); // Evidenzia campi form in errore c.SetErrorOnField(args.IsValid, FVProgetto, "TBProgetto"); }
protected void ValidaAttivita_ServerValidate(object source, ServerValidateEventArgs args) { ValidationClass c = new ValidationClass(); // true se non esiste già il record args.IsValid = !c.CheckExistence("ActivityCode", args.Value, "Activity"); // cambia colore del campo in errore c.SetErrorOnField(args.IsValid, FVattivita, "ActivityCodeTextBox"); }
public Categoria Put(Categoria categoria) { ValidationClass.ValidaClasse(categoria); ValidaDuplicidade(categoria); _db.Entry(categoria).State = System.Data.Entity.EntityState.Modified; _db.SaveChanges(); return(categoria); }
public Perfil Post(Perfil perfil) { ValidationClass.ValidaClasse(perfil); _db.Perfis.Add(perfil); _db.SaveChanges(); perfil.Permicoes.ForEach(campo => SalvarPermicoes(campo, perfil)); return(perfil); }
public static void Startup() { ValidationClass classToCheck = new ValidationClass(); classToCheck.InputText(true); }