private void ClickStartGame(object sender, RoutedEventArgs e) { try { server.StartGame(gameName); } catch (CommunicationObjectFaultedException ex) { Console.WriteLine(ex.ToString()); CustomMessageBox.ShowOK(Properties.Resources.ServerIsOff, Properties.Resources.ServerIsOff, Properties.Resources.GoBack_Button); ClickGoBack(sender, e); } }
private void GenerateReportButton_Clicked(object sender, RoutedEventArgs e) { try { GenerateExcelReport(); } catch (EntityException) { CustomMessageBox.ShowOK("Ocurrió un error en la conexión con la base de datos. Por favor intentelo más tarde.", "Fallo en conexión con la base de datos", "Aceptar"); ReturnToLogin(new object(), new RoutedEventArgs()); } }
private void DeleteCommandBinding_OnExecuted(object sender, ExecutedRoutedEventArgs e) { if (GrdList.SelectedItem is Student student && CustomMessageBox.ShowYesNo($"جهت حذف رکورد '{student.FullName}' اطمینان دارید ؟", "حذف رکورد", "بله", "خیر", MessageBoxImage.Warning) == MessageBoxResult.Yes) { _context.Students.Attach(student); _context.Entry(student).State = EntityState.Deleted; _context.SaveChanges(); Reset(); CustomMessageBox.ShowOK("اطلاعات شما با موفقیت حذف گردید.", "حذف", "بسیار خوب"); } }
/// <summary> /// Creates the user /// </summary> /// <param name="sender">The sender</param> /// <param name="e">The event args</param> private void btnCreateUser_Click(object sender, RoutedEventArgs e) { if (txtNewUserName.Text.IsNameValid()) { User testUser = new User { UserName = txtNewUserName.Text, Password = pwNewUserPassword.Password, IsLoggedIn = false }; if (testUser.IsUserContainedInUserList(userList) == false) { if (pwNewUserPassword.Password == pwConfirmNewUserPassword.Password && pwNewUserPassword.Password.Length > 0) { if (txtNewUserName.Text.IsEachCharAlphaNumericOrBlank()) { user = new User(txtNewUserName.Text, pwNewUserPassword.Password); createUser = UserAction.CreateUser; OnSuccessfulCreationOfUser(new UserUpdateEventArgs(createUser, user)); // Raise the successful creation of a user event this.Close(); } else { CustomMessageBox.ShowOK("The user name can only contain alphanumeric characters or blank spaces. Please enter a valid name.", "String Must Be Alphanumeric or Blank Space", "Thanks, got it!", MessageBoxImage.Information); } } else { if (pwNewUserPassword.Password.Length > 0) { CustomMessageBox.ShowOK("The password and the confirmation do not match.", "Password is Not Confirmed", "Thanks, got it!", MessageBoxImage.Information); } else { CustomMessageBox.ShowOK("The password cannot be blank.", "Password Cannot Be Blank", "Thanks, got it!", MessageBoxImage.Information); } } } else { CustomMessageBox.ShowOK("There is already a user using that name, please pick a unique name.", "User name must be unique", "Thanks, got it!", MessageBoxImage.Information); } } else { CustomMessageBox.ShowOK("User name must be between 3 and 12 characters. Please try again.", "User Name is Invalid", "Thanks, got it!", MessageBoxImage.Information); } }
public static bool VerificateNRC(string Nrc) { Regex rgx = new Regex("^[0-9]+$"); if (rgx.IsMatch(Nrc)) { return(true); } else { CustomMessageBox.ShowOK("Asegurese de ingresar un valor valido de NRC", "Error de formato de NRC", "Aceptar"); return(false); } }
public static bool VerificateName(string name) { Regex rgx = new Regex(@"^[a-zA-ZÀ-ÿ\u00f1\u00d1\s]+$"); if (rgx.IsMatch(name)) { return(true); } else { CustomMessageBox.ShowOK("Asegurese de que el nombre y apellidos solo contenga datos alfabéticos", "Error nombre inválido", "Aceptar"); return(false); } }
public static bool VerificateWorkerNumber(string workerNumber) { Regex rgx = new Regex("^[0-9]+$"); if (rgx.IsMatch(workerNumber)) { return(true); } else { CustomMessageBox.ShowOK("Asegurese de ingresar un numero de trabajador válido", "Error de formato de RFC", "Aceptar"); return(false); } }
public static bool VerificateEmail(string email) { string emailFormat = "\\w+([-+.']\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*"; if (Regex.IsMatch(email, emailFormat)) { return(true); } else { CustomMessageBox.ShowOK("Asegurese de introducir un correo valido.", "Error de formato de correo", "Aceptar"); return(false); } }
public static bool VerificatePhone(string phoneNumber) { Regex rgx = new Regex(@"^\+?[\d- ]{9,}$"); if (rgx.IsMatch(phoneNumber)) { return(true); } else { CustomMessageBox.ShowOK("Asegurese de ingresar un numero de telefono correcto", "Error de formato de telefono", "Aceptar"); return(false); } }
public static bool VerificateNumext(string numext) { Regex rgx = new Regex("^[0-9]+$"); if (rgx.IsMatch(numext)) { return(true); } else { CustomMessageBox.ShowOK("Asegurese de introducir un número exterior valido.", "Error de formato de número exterior", "Aceptar"); return(false); } }
public static bool VerficiateSection(string Nrc) { Regex rgx = new Regex("^[a-zA-Z0-9]+$"); if (rgx.IsMatch(Nrc)) { return(true); } else { CustomMessageBox.ShowOK("Asegurese de ingresar un valor valido la Sección", "Error de formato de sección", "Aceptar"); return(false); } }
public static bool VerificateMatricula(string matricula) { Regex rgx = new Regex(@"^[S]\d{7}[a-zA-Z0-9]$"); if (rgx.IsMatch(matricula)) { return(true); } else { CustomMessageBox.ShowOK("Asegurese que la matricula es una S seguida de 8 números", "Error de formato de matricula", "Aceptar"); return(false); } }
public static bool VerificateDate(string date) { Regex rgx = new Regex(@"^(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.](19|20)\d\d$"); if (rgx.IsMatch(date)) { return(true); } else { CustomMessageBox.ShowOK("Asegurese de que la fecha contenga unicamente datos numericos (dd/mm/aaaa)", "Error campo inválido", "Aceptar"); return(false); } }
/// <summary> /// This method updates the games collection. /// </summary> public void UpdateGames() { Games.Clear(); try { server.GetGames(); } catch (CommunicationObjectFaultedException ex) { Console.WriteLine(ex.ToString()); CustomMessageBox.ShowOK(Properties.Resources.ServerIsOff, Properties.Resources.ServerIsOff, Properties.Resources.GoBack_Button); ClickGoBack(this, new RoutedEventArgs()); } }
public static bool VerificateString(string stringData, string field) { Regex rgx = new Regex(@"^[a-zA-ZÀ-ÿ\u00f1\u00d1\s]+$"); if (rgx.IsMatch(stringData)) { return(true); } else { CustomMessageBox.ShowOK("Asegurese de que el campo '" + field + "' solo contenga datos alfabéticos", "Error campo inválido", "Aceptar"); return(false); } }
public static bool VerificatePostalCode(string matricula) { Regex rgx = new Regex(@"^\d{5}$"); if (rgx.IsMatch(matricula)) { return(true); } else { CustomMessageBox.ShowOK("Asegurese de solo introducir datos numericos como código postal", "Error de formato de codigo postal", "Aceptar"); return(false); } }
public static bool VerificatePostalCode(string postalCode) { Regex rgx = new Regex(@"^\d{5}$"); if (rgx.IsMatch(postalCode)) { return(true); } else { CustomMessageBox.ShowOK("Asegurese de introducir un código postal valido.", "Error de formato de código postal", "Aceptar"); return(false); } }
private async void AddInventoryBtn_Executed(object sender, ExecutedRoutedEventArgs e) { AddInventoryModel context = this.DataContext as AddInventoryModel; if (context.IsNull()) { CustomMessageBox.ShowOK("Not enough information for inventory. Please try again.", "Error", "OK", MessageBoxImage.Error); return; } Inventory inventory = GetInventoryFromContext(); using (SQLiteConnection connection = new SQLiteConnection(SqlHelpers.ConnectionString)) { connection.Open(); using (var cmd = connection.CreateCommand()) { cmd.CommandText = "SELECT Number FROM Inventory WHERE Number = @Number"; cmd.Parameters.AddWithValue("Number", inventory.Number); using (var reader = await cmd.ExecuteReaderAsync()) { if (reader.HasRows) { CustomMessageBox.ShowOK("The Inventory has already existed", "Error", "OK", MessageBoxImage.Error); return; } } cmd.CommandText = "INSERT INTO Inventory ([Number], [Object], [Incoming Date], [Repack], [Price]) VALUES (@Number, @Object, @InDate, @Repack, @Price)"; cmd.Parameters.AddWithValue("Number", inventory.Number); cmd.Parameters.AddWithValue("Object", inventory.Object); cmd.Parameters.AddWithValue("InDate", inventory.InDate); cmd.Parameters.AddWithValue("Repack", inventory.Repack); cmd.Parameters.AddWithValue("Price", inventory.Price); var res = await cmd.ExecuteNonQueryAsync(); if (res != -1) { CustomMessageBox.ShowOK("Inventory added successfully.", "Information", "OK", MessageBoxImage.Information); context.ObjectNumbers.Insert(0, inventory.Number); ClearContext(); return; } CustomMessageBox.ShowOK("Something wrong while adding inventory. Please try again later.", "Error", "OK", MessageBoxImage.Error); } } }
/// <summary> /// Callback that allows the user to start the game. /// </summary> /// <param name="idGame"> Game identifier to which the user is going to enter. </param> public void StartRound(int idGame) { try { GameWindow gameWindow = new GameWindow(idGame, username, isHost); gameWindow.Show(); this.menuWindow.Close(); } catch (EndpointNotFoundException ex) { Console.WriteLine(ex.ToString()); CustomMessageBox.ShowOK(Properties.Resources.ServerIsOff, Properties.Resources.ServerIsOff, Properties.Resources.GoBack_Button); ClickGoBack(this, new RoutedEventArgs()); } }
private void CancelButton_Click(object sender, RoutedEventArgs e) { if (isFromRegisterStudent) { NavigationService.RemoveBackEntry(); } if (NavigationService.CanGoBack) { NavigationService.GoBack(); } else { CustomMessageBox.ShowOK("No hay entrada a la cual volver.", "Error al navegar hacía atrás", "Aceptar"); } }
private bool ProjectsAvailable() { using (SCPPContext context = new SCPPContext()) { var projects = context.Proyecto.Where(p => p.Inscripción.Count < p.Noestudiantes); if (projects.Count() >= 3) { return(true); } else { CustomMessageBox.ShowOK("No hay proyectos disponibles por el momento", "Error", "Aceptar"); return(false); } } }
private void ClickJoinGame(object sender, RoutedEventArgs e) { try { gameName = (string)GamesList.SelectedItem; if (gameName != null) { server.JoinGame(gameName); } } catch (CommunicationObjectFaultedException ex) { Console.WriteLine(ex.ToString()); CustomMessageBox.ShowOK(Properties.Resources.ServerIsOff, Properties.Resources.ServerIsOff, Properties.Resources.GoBack_Button); ClickGoBack(sender, e); } }
private void AddButton_Click(object sender, RoutedEventArgs e) { if (CheckProjectSelection()) { foreach (var project in selectedProjects) { choosenProjectsCollection.Add(project); } ChoosenProjectsList.ItemsSource = choosenProjectsCollection; UpdateProjectsList(); CheckAgreedButton(); } else { CustomMessageBox.ShowOK("Solo se pueden añadir 3 proyectos", "Error", "Aceptar"); } }
private bool StudentChoseProjectsAlready() { string matricula = userSesion.Username; using (SCPPContext context = new SCPPContext()) { var projectsSelected = context.Selecciónproyecto.FirstOrDefault(s => s.Matriculaestudiante.Equals(matricula) && s.PeriodoID.Equals(period)); if (projectsSelected != null) { CustomMessageBox.ShowOK("Ya has escogido proyectos", "Error", "Aceptar"); return(true); } else { return(false); } } }
private void UpdateButton_Clicked(object sender, RoutedEventArgs e) { try { if (VerificateFields()) { OrganizationUserApi organizationtUserApi = new OrganizationUserApi(); organizationUser.Name = NameTextBox.Text; organizationUser.ContactEmail = AgentEmailTextBox.Text; organizationUser.User.City = CityTextBox.Text; organizationUser.User.Country = CountryTextBox.Text; if (myStream != null) { using (MemoryStream ms = new MemoryStream()) { myStream.CopyTo(ms); byte[] imageFile = ms.ToArray(); organizationUser.User.ProfilePhoto.File = imageFile; } } organizationUser.ContactName = AgentTextBox.Text; organizationUser.ContactPhone = PhoneTextBox.Text; organizationUser.ZipCode = Convert.ToInt32(PostalCodeTextBox.Text); organizationUser.WebSite = WebSiteTextBox.Text; organizationUser.About = DescripctionTextBox.Text; organizationUser.WorkSector = (Sector)SectorComboBox.SelectedItem; organizationtUserApi.PatchOrganizationUserById(organizationUser, organizationUser.User.Email); CustomMessageBox.ShowOK("Los datos se han actualizado con éxito.", "Actualización exitosa", "Aceptar"); BackIcon_Clicked(new object(), new RoutedEventArgs()); } } catch (ApiException ex) { if (ex.ErrorCode == 500) { CustomMessageBox.ShowOK("Ocurrió un error en la conexión con la base de datos. Por favor intentelo más tarde", "Error de conexión", "Aceptar"); Restarter.RestarEmployex(); } } }
private void PublishButton_Click(object sender, RoutedEventArgs e) { try { JobOfferApi jobOfferApi = new JobOfferApi(); JobOffer jobOffer = new JobOffer(job: JobTextBox.Text, description: DescriptionTextBox.Text, jobCategory: (JobCategory)JobCategoryCombobox.SelectedItem, media: imagesList); jobOfferApi.AddJobOffer(jobOffer); CustomMessageBox.ShowOK("La oferta de trabajo ha sido publicada con éxito.", "Publicación exitosa", "Aceptar"); BackIcon_Clicked(new object(), new RoutedEventArgs()); } catch (ApiException ex) { if (ex.ErrorCode == 400) { } //CustomMessageBox.ShowOK("Ya existe un usuario con el correo " + EmailTextBox.Text, "Usuario existente", "Aceptar"); } }
private void AgreeButton_Click(object sender, RoutedEventArgs e) { try { if (VerificateGroupCapacity()) { ChangeStudentsGroups(); ConfirmedAssociationMessage(); } else { CustomMessageBox.ShowOK("No hay suficiente espacio en el grupo.", "Error al asignar estudiantes a grupo", "Aceptar"); } } catch (EntityException) { Restarter.RestarSCPP(); } }
private bool IsStudentEnrolled() { string matricula = userSesion.Username; Inscripción inscripción; using (SCPPContext context = new SCPPContext()) { inscripción = context.Inscripción.FirstOrDefault(i => i.Matriculaestudiante.Equals(matricula) && i.Estatus.Equals("Cursando")); if (inscripción != null) { CustomMessageBox.ShowOK("Ya tienes asignado un proyecto", "Error", "Aceptar"); return(true); } else { return(false); } } }
private void AddToTransferCommand_Executed(object sender, ExecutedRoutedEventArgs e) { TransferBookModel context = this.DataContext as TransferBookModel; string number = context.BookNumber.PadLeft(6, '0'); int.TryParse(context.BookNumber, out int bookNumber); if (context.TransferList.Any(n => n.Number == number)) { //error string msg = Application.Current.FindResource("TransferBook.CodeBehind.WarningAdd.Exist.Message").ToString(); string caption = Application.Current.FindResource("TransferBook.CodeBehind.WarningAdd.Exist.Caption").ToString(); CustomMessageBox.ShowOK(msg, caption, CustomMessageBoxButton.OK, MessageBoxImage.Warning); } else { SqlMethods.SqlConnect(out SQLiteConnection con); SQLiteCommand selectCommand = con.CreateCommand(); selectCommand.CommandText = $"SELECT BookId,Number,Title FROM Books WHERE Number=@Number"; selectCommand.Parameters.AddWithValue("Number", bookNumber); SQLiteDataReader r = selectCommand.ExecuteReader(); selectCommand.Parameters.Clear(); if (r.Read()) { TransferingBook book = new TransferingBook(); int.TryParse(Convert.ToString(r["BookId"]), out int result); book.BookId = result; book.Number = Convert.ToString(r["Number"]); book.Title = Convert.ToString(r["Title"]); context.TransferList.Add(book); } else { // No book is found string msg = Application.Current.FindResource("TransferBook.CodeBehind.ErrorAdd.NotFound.Message").ToString(); string caption = Application.Current.FindResource("TransferBook.CodeBehind.ErrorAdd.NotFound.Caption").ToString(); CustomMessageBox.ShowOK(msg, caption, CustomMessageBoxButton.OK, MessageBoxImage.Error); } r.Close(); con.Close(); } context.BookNumber = string.Empty; }
private void SaveChanges_Click(object sender, RoutedEventArgs e) { try { if (VerificateFields()) { using (SCPPContext context = new SCPPContext()) { var studentUptdated = UpdateStudent(); CustomMessageBox.ShowOK("El registro se ha cambiado con éxito", "Cambio exitoso", "Finalizar"); } ItsNotModifying(); } } catch (EntityException) { Restarter.RestarSCPP(); } }