Exemplo n.º 1
0
	void sortB_Click(object sender, EventArgs e) {
		// STARTING THE ANIMATION
		loadTimer.Start();
		loading.Value = 0;

		// RESETTING THE WHOLE LISTVIEW
		listClear();

		// BUBBLE SORT
		for (int i = 0; i < amountEmp; i++) {
			for (int j = 0; j < amountEmp - i - 1; j++) {
				if (empl[j].getSalary() < empl[j + 1].getSalary()) {
					employeeClass temp = new employeeClass();
					temp = empl[j];
					empl[j] = empl[j + 1];
					empl[j + 1] = temp;
				}
			}
		}

		// REFILLING THE LISTVIEW
		for (int k = 0; k < amountEmp; k++) {
			string[] row = {empl[k].getName() + SPACE + empl[k].getSurname(),
							empl[k].getSalary().ToString(FZERO),
							empl[k].getPremium().ToString(FZERO), k.ToString()};
			ListViewItem lvc = new ListViewItem(row);
			employeeL.Items.Add(lvc);
		}
		StreamWriter log = new StreamWriter("logs.txt", true);
		log.WriteLine("[" + DateTime.Today.ToString("dd-MM-yyyy") + "|" +
					  DateTime.Now.ToString("h:mm:ss tt") + "]" +
					  " All records have been successfully sorted. ");
		log.Close();
	}
Exemplo n.º 2
0
	void delete () {
		try {
			// Shifting the whole array to load images
			for (int i = Int32.Parse(employeeL.SelectedItems[0].SubItems[3].Text); i <= amountEmp;
				 i++) {
				employeeClass temp = new employeeClass();
				temp = empl[i];
				empl[i] = empl[i + 1];
				empl[i + 1] = temp;
			}

			// Decrementing the amount of employees and ID track number
			IDnum--;
			amountEmp--;

			// Deleting the row
			employeeL.Items.RemoveAt(employeeL.SelectedIndices[0]);

			// Clearing the listviewiew item (employeeL)
			listClear();

			// Filling the employeeL
			for (int k = 0; k < amountEmp; k++) {
				string[] row = {empl[k].getName() + SPACE + empl[k].getSurname(),
								empl[k].getSalary().ToString(FZERO),
								empl[k].getPremium().ToString(FZERO), k.ToString()};
				ListViewItem lvc = new ListViewItem(row);
				employeeL.Items.Add(lvc);
			}

			// Clearing input
			inputClear();

			// Output amount of employees
			amountGR.Text = (amountGroup + SPACE + amountEmp);
		} catch {
		}
	}
Exemplo n.º 3
0
	void employeeL_Click(object sender, EventArgs e) {
		IMAGE = NOTHING;
		if (profilePicture.Image != null)
			profilePicture.Image.Dispose();
		try {
			tempss = empl[Int32.Parse(employeeL.SelectedItems[0].SubItems[3].Text)];
		} catch {
			return;
		}
		try {
			IMAGE = tempss.getImage();
			profilePicture.Image = Image.FromFile(tempss.getImage());
		} catch {
			File.SetAttributes(NOIMAGE, FileAttributes.Normal);
			profilePicture.Image = Image.FromFile(NOIMAGE);
			File.SetAttributes(NOIMAGE, FileAttributes.Hidden);
		}
		nameT.Text = tempss.getName();
		surnameT.Text = tempss.getSurname();
		eduC.SetItemCheckState(tempss.getEducationLevel(), CheckState.Checked);
		skipT.Text = tempss.getSkippedDays().ToString();
		finT.Text = tempss.getPerformance().ToString();
	}
Exemplo n.º 4
0
	void Form1_Load(object sender, EventArgs e) {

		StreamWriter log = new StreamWriter("logs.txt", true);
		log.WriteLine("[" + DateTime.Today.ToString("dd-MM-yyyy") + "|" +
					  DateTime.Now.ToString("h:mm:ss tt") +
					  "] Salary Calculator has been successfuly executed.");

		// Opening the file login.txt to check the active user
		// (selected user from previous form)
		StreamReader str = new StreamReader(LOGINT);
		usser = str.ReadLine();  // Reading the account type
		namess = str.ReadLine(); // and gender
		str.Close();			 // Closing the file
		if (File.Exists(LOGINT))
			File.Delete(LOGINT); // Deleting the login file

		// Editing accountant privileges
		if (usser == ACCOUNTANTAL) {
			RemoveButton.Visible = false;
			DELALL.Visible = false;
		}

		// Editing user privileges
		if (usser == USERAL) {
			Calculate.Visible = false;
			RemoveButton.Visible = false;
			DELALL.Visible = false;
			loading.Visible = false;
		}

		log.WriteLine("[" + DateTime.Today.ToString("dd-MM-yyyy") + "|" +
					  DateTime.Now.ToString("h:mm:ss tt") + "] Logged as " + usser + ".");
		// Activating all empl array instances (objects)
		for (int j = 0; j < AMOUNT; j++) {
			empl[j] = new employeeClass();
		}

		// Setting the progressBar animation duration
		loading.Minimum = 0;
		loading.Maximum = 1;

		// Filling the listviewitem (employeeL)
		if (amountEmp > 0) {
			for (int i = 0; i < amountEmp; i++) {
				ListViewItem lvi = new ListViewItem(empl[amountEmp].getName() + SPACE +
													empl[amountEmp].getSurname());
				employeeL.Items.Add(lvi);
				amountEmp++;
			}
		}

		// Setting english localiztion by default
		setEnglish();
		log.WriteLine("[" + DateTime.Today.ToString("dd-MM-yyyy") + "|" +
					  DateTime.Now.ToString("h:mm:ss tt") +
					  "] Successfully set the language by default- ENGLISH.");

		// Checking the there is a save file
		if (File.Exists(EMPLOYEEST)) {
			// Loading all the data
			int ammm = 0;
			StreamReader swread = new StreamReader(EMPLOYEEST);
			ammm = Int32.Parse(swread.ReadLine());
			log.WriteLine("[" + DateTime.Today.ToString("dd-MM-yyyy") + "|" +
						  DateTime.Now.ToString("h:mm:ss tt") + "] Amount of loaded records - " +
						  ammm + ".");
			for (int i = 0; i < ammm; i++) {
				nameT.Text = swread.ReadLine();
				surnameT.Text = swread.ReadLine();
				eduC.SetItemChecked(Int32.Parse(swread.ReadLine()), true);
				skipT.Text = swread.ReadLine();
				finT.Text = swread.ReadLine();
				IMAGE = swread.ReadLine();
				add();
			}
			swread.Close(); // Closing the document
			log.WriteLine("[" + DateTime.Today.ToString("dd-MM-yyyy") + "|" +
						  DateTime.Now.ToString("h:mm:ss tt") +
						  "] Successfully loaded all records.");
		}
		log.Close();
	}