public QrCodeResultForm(string[][] qrContents, Image qrCode) { this.InitializeComponent(); long totalSize = 0; foreach (var qrContent in qrContents) { var titleId = qrContent[0]; var name = qrContent[1]; this.titleInfoRichTextbox.AppendText(titleId + ": " + name); var size = qrContent[2]; var sizeAsLong = long.Parse(size); totalSize += sizeAsLong; this.titleInfoRichTextbox.AppendText(Environment.NewLine + "Size: " + DatabaseParser.HumanReadableFileSize(sizeAsLong) + Environment.NewLine); this.titleInfoRichTextbox.AppendText(Environment.NewLine); var url = qrContent[3]; this.urlRichTextbox.AppendText(url); this.urlRichTextbox.AppendText(Environment.NewLine); } if (qrContents.Length > 1) { this.titleInfoRichTextbox.AppendText("Total size: " + DatabaseParser.HumanReadableFileSize(totalSize)); } this.qrCodeBox.Image = qrCode; }
/// <summary> /// Sets the image of the doctorsnote button to completed if the document exists. /// </summary> /// <param name="button">The PictureBox to change</param> private void DoctorsNoteCheckIfUploaded(PictureBox button) { if (DatabaseParser.ExistDoctorsNote(_user)) { button.Image = completedImage; } }
/// <summary> /// Fills the combobox with the maxium of lessons that should be able to be selected /// </summary> /// <param name="comboBox">The combobox that should be filled</param> /// <param name="lessons">The lessons that can be selected</param> private void FillComboBox(ComboBox comboBox, int lessons) { int maxLessonsToBook = addThisLesson.LessonTemplate.Time - Session.GetLastLessonFromType(_appointment.LessonType).Progress; if (maxLessonsToBook == 0) // when users have completed a different lesson type and the next lesson type have to start { addThisLessonLessonTemplate = DatabaseParser.GetNextLessonTemplateFromID(addThisLesson.LessonTemplate.Id, _appointment.LessonType); addThisLessonTemplateID = addThisLesson.LessonTemplate.Id; maxLessonsToBook = addThisLessonLessonTemplate.Time; } if (addThisLessonLessonTemplate.Type != DatabaseParser.GetLessonTemplateFromID(addThisLessonLessonTemplate.Id + 1).Type) { lessons = maxLessonsToBook < lessons ? maxLessonsToBook : lessons; // always make sure that the you can only book the required lessons to complete a lesson type } else { lessons = 4 < lessons ? 4 : lessons; // if type is diferent } lessonsComboBox.Items.Clear(); for (int i = 0; i < lessons; i++) { comboBox.Items.Add(i + 1); } }
public void LoadCapture(string path) { PacketListView.Items.Clear(); _currentXmlFile = path; ChangeTitle(System.IO.Path.GetFileNameWithoutExtension(_currentXmlFile)); try { var capture = XmlCaptureImporter.Load(path); _commitSha = null; _version = capture.Version; _db = _mainWindow.VersioningProvider.GetDatabaseForVersion(_version); foreach (var packet in capture.Packets) { // Add a packet to the view, but no update to the label AddPacketToListView(packet, true); } // Backwards compatibility _wasCapturedMs = capture.UsingSystemTime != null && bool.Parse(capture.UsingSystemTime); UpdateInfoLabel(); } catch (Exception exc) { new ExtendedErrorView($"Could not load capture at {path}.", exc.ToString(), "Error").ShowDialog(); #if DEBUG throw; #endif } }
/// <summary> /// Logs into the system if the username and password match. /// </summary> /// <param name="sender">The object sender</param> /// <param name="e">The event args</param> private void loginButton_Click(object sender, EventArgs e) { Cursor = Cursors.AppStarting; if (UsernameBox.Text != "Username") { User user = DatabaseParser.GetUserByUsername(UsernameBox.Text); if (user == null || user.Password != PasswordBox.Text) { CustomMsgBox.ShowOk("Wrong username or password", "Error", CustomMsgBoxIcon.Error); // resets password with false login information if (PasswordBox.Text != "Password") { PasswordBox.Clear(); } return; } Session.LoadUser(user); this.Hide(); MainWindow main = new MainWindow(); main.ShowDialog(this); Session.LogOut(); // resets information after logout ResetInformation(); Cursor = Cursors.Arrow; } else { CustomMsgBox.ShowOk("Wrong username or password", "Error", CustomMsgBoxIcon.Error); } }
/// <summary> /// Registers the given user in the system, if all fields are valid. /// </summary> /// <param name="sender">The object sender</param> /// <param name="e">The event args</param> private void registerCreateNewUserButton_Click(object sender, EventArgs e) { if (_isFirstnameOk && _isLastnameOk && _isPhoneOk && _isEmailOk && _isCprOk && _isAdressOk && _isCityOk && _isZipOk && _isUsernameOk && _isPasswordOk && _isVerifyPasswordOk && _isSignatureOk) { bool UserCreated = DatabaseParser.AddUser(registerFirstnameBox.Text, registerLastnameBox.Text, registerPhoneBox.Text, registerEmailBox.Text, registerCprBox.Text, registerAdressBox.Text, registerZipBox.Text, registerCityBox.Text, registerUsernameBox.Text, registerPasswordBox.Text, _uploader.SaveProfilePicture(ProfileImage, Properties.Settings.Default["PictureUpload"].ToString()), _uploader.SavePicture(_signatureImage, Properties.Settings.Default["PictureUpload"].ToString())); if (UserCreated) { CustomMsgBox.ShowOk("You have succesfully created a user", "Sucess", CustomMsgBoxIcon.Complete); this.Dispose(); _loginForm.Show(); } else { CustomMsgBox.ShowOk("Failed to create new user, please try again later!", "Failed", CustomMsgBoxIcon.Error); } } else { foreach (TextboxBorderColor tb in this.Controls.OfType <TextboxBorderColor>()) { if (string.IsNullOrEmpty(tb.Text)) { tb.BorderColor = Color.Crimson; } } } }
/// <summary> /// Method used to add the selected period as an appointment to the database /// </summary> /// <param name="sender">The Object Sender</param> /// <param name="e">The EventArgs</param> private void AddAppointmentButton_Click(object sender, EventArgs e) { if (!String.IsNullOrEmpty(LessonTypecomboBox.Text) && !String.IsNullOrEmpty(StartTimecomboBox.Text) && !String.IsNullOrEmpty(lessonsComboBox.Text)) { TimeSpan startTime = TimeSpan.Parse(StartTimecomboBox.Text); DateTime dateToAdd = date.Date + startTime; bool appointmentAdded = DatabaseParser.AddAppointment(LessonTypecomboBox.Text, dateToAdd, (int)lessonsComboBox.SelectedItem, Session.LoggedInUser.Id.ToString()); if (appointmentAdded) { CustomMsgBox.ShowOk("Succes", "Appointment succesfully added", CustomMsgBoxIcon.Complete); AppointmentStructure appointmentStructure = new AppointmentStructure(-1, Session.LoggedInUser.Id, dateToAdd, (int)lessonsComboBox.SelectedItem, LessonTypecomboBox.Text, false, Session.LoggedInUser.Fullname); _appointments.Add(new Appointment(appointmentStructure)); this.Dispose(); } else { CustomMsgBox.ShowOk("Failure", "Appointment failed to upload", CustomMsgBoxIcon.Error); } } else { CustomMsgBox.ShowOk("Failure", "Some fields need to be filled", CustomMsgBoxIcon.Warrning); } }
/// <summary> /// Get all appointments from the database and adds it to the calendar /// </summary> private void GetAppointsments() { foreach (var appointment in DatabaseParser.AppointmentsList()) { AddAppointment(appointment); } }
/// <summary> /// Method used to get all the appointments and lessons for a instructor /// </summary> public void GetInstructorLessons() { InstructorAppointments = DatabaseParser.GetAppointmentsByInstructorId(Id).OrderBy(a => a.StartTime).ToList(); InstructorLessons = DatabaseParser.GetAllLessonsFromMultipleAppointmentIds(InstructorAppointments); }
/// <summary> /// The doubleclick function for the praticaltest button. /// Allows the sysmin to confirm the specific praticaltest. /// </summary> /// <param name="sender">The object sender</param> /// <param name="e">The event args</param> private void praticalTestPictureButton_DoubleClick(object sender, EventArgs e) { if (!Session.LoggedInUser.Sysmin) { return; } PictureBox icon = sender as PictureBox; DialogResult confirmamtionBox = CustomMsgBox.ShowYesNo($"Are you sure {_user.Fullname} has completed a {practicalTestLabel.Text.ToLower()}", "Confirm", CustomMsgBoxIcon.Warrning); if (confirmamtionBox == DialogResult.Yes) { DatabaseParser.SetUserPracticalTestDone(_user.Id, true); DatabaseParser.SetUserActive(_user.Id, false); _user = DatabaseParser.GetUserById(_user.Id); icon.Image = completedImage; } else if (confirmamtionBox == DialogResult.No) { DatabaseParser.SetUserPracticalTestDone(_user.Id, false); DatabaseParser.SetUserActive(_user.Id, true); _user = DatabaseParser.GetUserById(_user.Id); icon.Image = incompleteImage; } }
/// <summary> /// Sets the image of the firstaid button to completed if the document exists. /// </summary> /// <param name="button">The PictureBox to change</param> private void FirstCheckIfUploaded(PictureBox button) { if (DatabaseParser.ExistFirstAid(_user)) { button.Image = completedImage; } }
/// <summary> /// The click function for the edit button. /// Opens a new EditUserInfoForm. /// </summary> /// <param name="sender">The object sender</param> /// <param name="e">The event args</param> private void editButton_Click(object sender, EventArgs e) { EditUserInfoForm editForm = new EditUserInfoForm(_user); editForm.ShowDialog(this); _user = DatabaseParser.GetUserById(_user.Id); UpdateInfo(); }
public void ReloadDb() { _db = _mainWindow.VersioningProvider.GetDatabaseForVersion(_version); if (_db != null) { ReloadCurrentPackets(); } }
/// <summary> /// Method used to add the selected lessons to the database for the user /// </summary> /// <returns>Returns true if all the lessons are succesfully added</returns> private bool AddLesson() { int numberOfLessons = lessonsComboBox.SelectedIndex + 1; bool result = true; if (addedFirstLesson) { numberOfLessons -= 1; Lesson firstLesson = Session.GetLastLessonFromType(_appointment.LessonType); firstLesson.Progress = 1; Lesson newLesson = new Lesson( Session.LoggedInUser.Id, _appointment.Id, firstLesson.TemplateID, firstLesson.Progress, addThisLessonLessonTemplate, startDateTime, startDateTime = startDateTime.AddMinutes(45), false); result = DatabaseParser.AddLesson(newLesson); if (result) // if lesson is added its manually added to lessons in appointment id { Session.LoggedInUser.LessonsList.Add(newLesson); Session.UpdateCurrentLesson(); } addThisLessonProgress = firstLesson.Progress; } for (int i = 0; i < numberOfLessons; i++) { if (!result) { return(false); } Lesson newLesson = new Lesson( Session.LoggedInUser.Id, _appointment.Id, Session.NextLesson.TemplateID, Session.NextLesson.Progress, Session.NextLesson.LessonTemplate, startDateTime, startDateTime = startDateTime.AddMinutes(45), false); result = DatabaseParser.AddLesson(newLesson); Session.LoggedInUser.LessonsList.Add(newLesson); Session.UpdateCurrentLesson(); } return(true); }
public void SetDBViaCommit(string commitSha) { _commitSha = commitSha; _db = _mainWindow.VersioningProvider.GetDatabaseForCommitHash(_commitSha, true); if (_db != null) { ReloadCurrentPackets(); } UpdateInfoLabel(); }
/// <summary> /// Method to load the doctors note document for the user /// </summary> /// <param name="user">This is the user that the doctors note document will be loaded from</param> public void LoadDoctorsNote(User user) { SetType(Session.TypeDoctorsNote); string notePath = DatabaseParser.GetDoctorsNote(user); if (!String.IsNullOrEmpty(notePath)) { LoadDocument(notePath); } }
private async void MainForm_Shown(object sender, EventArgs e) { this.SetVersion(); this.currentTitleStatusLabel.Text = string.Empty; if (!File.Exists(Files.DbPath)) { var result = MessageBox.Show( Properties.Resources.Disclaimer, "boo", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); if (result == DialogResult.Cancel) { Environment.Exit(0); } this.statusProgressbar.Style = ProgressBarStyle.Marquee; this.UpdateAction("Downloading database..."); await Task.Run(() => DatabaseParser.DownloadDatabase(Files.DbPath)); this.UpdateAction($"Prettifying JSON in \"{Files.DbPath}\"..."); File.WriteAllText(Files.DbPath, JsonPrettifier.FormatJson(File.ReadAllText(Files.DbPath))); } if (!File.Exists(Files.SizesPath)) { this.UpdateAction("Downloading sizes data..."); await Task.Run(() => DatabaseParser.DownloadSizes(Files.SizesPath)); } this.UpdateAction($"Reading data from \"{Files.DbPath}\" and \"{Files.SizesPath}\"..."); this.allTitles = DatabaseParser.ParseFromDatabase(Files.DbPath, Files.SizesPath); if (File.Exists(Files.FilterPath)) { this.titleFilter = TitleFilterStorage.ParseFilterSettings(Files.FilterPath); } this.titles = new SortableBindingList <Nintendo3DSTitle>(TitleFilter.FilterTitles(this.allTitles, this.titleFilter)); this.titlesDataGrid.DoubleBuffered(true); this.titlesDataGrid.DataSource = this.titles; this.SortDataGrid(); this.UpdateAction(string.Empty); this.currentTitleStatusLabel.Text = string.Empty; this.titlesCountLabel.Text = this.titles.Count + " titles"; this.statusProgressbar.Style = ProgressBarStyle.Blocks; this.generateAllTicketsButton.Enabled = true; this.filterButton.Enabled = true; this.generateQrCodeButton.Enabled = true; }
public AdministratorPresenter(IAdminForm form, IDataBaseModel dataBase, DatabaseParser parser) { this.form = form; this.dataBase = dataBase; this.parser = parser; this.form.materialChanged += TableChanged; this.form.changeAdd += ChangeAddCycle; this.form.delete += DataDeleted; this.form.submit += DataSubmitted; this.form.changeUser += ChangeUser; }
public void SetDBViaVersion(int version) { _commitSha = null; _version = version; _db = _mainWindow.VersioningProvider.GetDatabaseForVersion(_version); if (_db != null) { ReloadCurrentPackets(); } UpdateInfoLabel(); }
/// <summary> /// Updates information and adds the info to the listview /// </summary> private void UpdateInfo() { lessonTitleLabel.Text = "Lesson Type: " + _lessonList[0].LessonTemplate.Type; dateLabel.Text = $"Date: {_lessonList[0].StartDate} to {_lessonList[0].EndDate}"; foreach (Lesson l in _lessonList) { string[] subitems = { DatabaseParser.GetUserById(l.StudentId).Fullname, l.LessonTemplate.Title }; attendingStudentsList.Items.Add("").SubItems.AddRange(subitems); attendingStudentsList.Items[attendingStudentsList.Items.Count - 1].Checked = true; } }
/// <summary> /// Removes the selected template /// </summary> /// <param name="sender">The object sender</param> /// <param name="e">the EventArgs</param> private void removebutton_Click(object sender, EventArgs e) { _templates.Remove(_activeButton); _activeButton.Dispose(); DatabaseParser.DeleteTemplate(Convert.ToInt32(_currentId)); _activeButton = null; foreach (Button template in _templates) { template.Location = new Point(20, 30 + template.Height * (_templates.IndexOf(template) + 1) + 5 * _templates.IndexOf(template)); } }
/// <summary> /// Event method raised when clicking the message edit button /// </summary> /// <param name="sender">The object sender</param> /// <param name="e">The EventArgs</param> private void overviewUpdateTodaysNote_Click(object sender, EventArgs e) { if (todaysNoteTextbox.Enabled) { todaysNoteTextbox.Enabled = false; DatabaseParser.AddTodaysNote(Session.LoggedInUser, todaysNoteTextbox.Text); } else { todaysNoteTextbox.Enabled = true; } }
/// <summary> /// Saves the new template if all reuired fields have been filled out /// </summary> /// <param name="sender">The object sender</param> /// <param name="e">the EventArgs</param> private void saveButton_Click(object sender, EventArgs e) { if (IsAllRequiredFilledOut()) { DatabaseParser.UploadTemplate(_currentId, titleTextBox.Text, descriptionTextbox.Text, radioPractical.Checked ? "Practical" : "Theoretical", timeAmount.Value.ToString(), readingTextbox.Text); UpdateTemplateButtons(); } else { errorLabel.Text = "Please fill out all required fields"; } }
public void ExtractQuery_NonExistingSharedDataSet_CorrectQuery() { var request = new NBi.Core.Report.DatabaseRequest( ConnectionStringReader.GetReportServerDatabase() , "/AdventureWorks 2012/" , "Employee_Sales_Summary" , "NonExisting" ); var parser = new DatabaseParser(); var ex = Assert.Throws <ArgumentException>(() => parser.ExtractQuery(request)); Assert.That(ex.Message, Is.StringContaining("Quota").And.StringContaining("2008R2")); }
public void ExtractQuery_NonExistingDataSetMoreThanOneExisting_CorrectExceptionReturned() { var request = new NBi.Core.Report.DatabaseRequest( ConnectionStringReader.GetReportServerDatabase() , "/AdventureWorks Sample Reports/" , "Currency Rates" , "Non Existing" ); var parser = new DatabaseParser(); var ex = Assert.Throws <ArgumentException>(() => parser.ExtractQuery(request)); Assert.That(ex.Message, Is.StringContaining("DataSet1").And.StringContaining("DataSet2")); }
/// <summary> /// Completes or denies lessons and closes the form /// </summary> /// <param name="sender">The object sender</param> /// <param name="e">The EventArgs</param> private void saveButton_Click(object sender, EventArgs e) { StringBuilder text = new StringBuilder(); text.AppendLine("Are you sure you want to complete the lesson with the following attendees?"); text.AppendLine(); text.AppendLine("Attended:"); // Lists All the students who attended the lesson for (int i = 0; i < attendingStudentsList.Items.Count; i++) { if (attendingStudentsList.Items[i].Checked) { text.AppendLine(attendingStudentsList.Items[i].SubItems[1].Text); } } text.AppendLine(); text.AppendLine("Did Not Attend:"); // Lists All the students who did not attend the lesson for (int i = 0; i < attendingStudentsList.Items.Count; i++) { if (!attendingStudentsList.Items[i].Checked) { text.AppendLine(attendingStudentsList.Items[i].SubItems[1].Text); } } // Show the dialog and save result DialogResult result = CustomMsgBox.ShowConfirm(text.ToString(), "Confirm Attendees", CustomMsgBoxIcon.Complete, 20 * attendingStudentsList.Items.Count + 80); if (result == DialogResult.OK) { for (int i = 0; i < attendingStudentsList.Items.Count; i++) { // If row is checked then complete lesson else deny lesson if (attendingStudentsList.Items[i].Checked) { DatabaseParser.SetLessonToStatus(_lessonList[i].StudentId, _lessonList[i].AppointmentID, _lessonList[i].Progress, true); } else { List <Lesson> deleteList = DatabaseParser.FindLessonsToCancel(_lessonList[i].TemplateID, _lessonList[i].Progress, _lessonList[i].StudentId); DatabaseParser.DeleteLessons(deleteList); } } this.DialogResult = DialogResult.Yes; this.Close(); } }
public void ExtractQuery_NonExistingReport_CorrectExceptionReturned() { var request = new DatasetRequest( ConnectionStringReader.GetReportServerDatabase() , "/AdventureWorks Sample Reports/" , "Not Existing" , "DataSet1" ); var parser = new DatabaseParser(); var ex = Assert.Throws <ArgumentException>(() => parser.ExtractQuery(request)); Assert.That(ex.Message, Is.StringContaining("No report found")); }
/// <summary> /// Method for doctors note this opens the already existing doctors note or an empty one /// </summary> /// <param name="sender">The Object Sender</param> /// <param name="e">The EventArgs</param> private void doctorsNoteButton_Click_1(object sender, EventArgs e) { Cursor = Cursors.AppStarting; if (DatabaseParser.ExistDoctorsNote(Session.LoggedInUser)) { OpenPage(sender, documentViewer); documentViewer.LoadDoctorsNote(Session.LoggedInUser); } else { OpenPage(sender, documentViewer); documentViewer.SetType(Session.TypeDoctorsNote); } Cursor = Cursors.Arrow; }
/// <summary> /// Method for when the first aid button is clciked, opens the exisitng first aid or empty one /// </summary> /// <param name="sender">The Object Sender</param> /// <param name="e">The EventArgs</param> private void firstAidButton_Click(object sender, EventArgs e) { Cursor = Cursors.AppStarting; if (DatabaseParser.ExistFirstAid(Session.LoggedInUser)) { OpenPage(sender, documentViewer); documentViewer.LoadFirstAid(Session.LoggedInUser); } else { OpenPage(sender, documentViewer); documentViewer.SetType(Session.TypeFirstAid); } Cursor = Cursors.Arrow; }
public void LoadCapture(PacketEntry[] packets) { PacketListView.Items.Clear(); ChangeTitle("Imported Capture"); _commitSha = null; _version = -1; _db = _mainWindow.VersioningProvider.GetDatabaseForVersion(_version); foreach (var packet in packets) { AddPacketToListView(packet); } UpdateInfoLabel(); }