Advertisement
Guest User

Untitled

a guest
Jun 19th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.07 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using System.IO;
  11.  
  12. namespace kurs
  13. {
  14. public partial class Form6 : Form
  15. {
  16. public Form6()
  17. {
  18. InitializeComponent();
  19. }
  20. string path_cli = @"clients.txt";
  21. string path_work = @"work.txt";
  22. int[] stud_hhd = new int[0];
  23. string[] stud = new string[0];
  24. string[] stud_cab = new string[0];
  25. string[] stud_cab_counter = new string[0];
  26. int[] stud_counter = new int[0];
  27. int[] stud_h_counter = new int[0];
  28. string[] stud_work = new string[0];
  29. int[] hrs = new int[0];
  30. int rk = 0;
  31. int rk1 = 0;
  32. int rk2 = 1;
  33. int nn = 0;
  34. int hr = 0;
  35. private void Form6_Load(object sender, EventArgs e)
  36. {
  37. dataGridView1.Columns.Add("Kod", "Код");
  38. dataGridView1.Columns.Add("Stud", "Фамилия студента");
  39. dataGridView1.Columns.Add("kabs", "Количество посещенных кабинетов");
  40. dataGridView1.Columns.Add("hrs", "Общее кол-во часов");
  41. dataGridView1.Columns.Add("exs", "Посещал кабинеты");
  42. using (StreamReader sr = new StreamReader(path_cli, Encoding.GetEncoding(1251)))
  43. {
  44. string line;
  45. while ((line = sr.ReadLine()) != null)
  46. {
  47. string[] split = line.Split(';');
  48. Array.Resize(ref stud, stud.Length + 1);
  49. stud[rk] = split[1];
  50. Array.Resize(ref stud_counter, stud_counter.Length + 1);
  51. stud_counter[rk] = 0;
  52. Array.Resize(ref stud_h_counter, stud_h_counter.Length + 1);
  53. stud_h_counter[rk] = 0;
  54. Array.Resize(ref stud_cab_counter, stud_cab_counter.Length + 1);
  55. stud_cab_counter[rk] = "";
  56. rk++;
  57. }
  58. }
  59.  
  60. using (StreamReader sr = new StreamReader(path_work, Encoding.GetEncoding(1251)))
  61. {
  62. string line;
  63. while ((line = sr.ReadLine()) != null)
  64. {
  65. string[] split = line.Split(';');
  66. Array.Resize(ref stud_hhd, stud_hhd.Length + 1);
  67. stud_hhd[rk1] = Int32.Parse(split[5]);
  68. Array.Resize(ref stud_work, stud_work.Length + 1);
  69. stud_work[rk1] = split[2];
  70. Array.Resize(ref stud_cab, stud_cab.Length + 1);
  71. stud_cab[rk1] = split[4];
  72. rk1++;
  73. }
  74. }
  75.  
  76. }
  77.  
  78. private void Form6_FormClosing(object sender, FormClosingEventArgs e)
  79. {
  80. e.Cancel = true;
  81. Hide();
  82. }
  83.  
  84. private void button1_Click(object sender, EventArgs e)
  85. {
  86. for (int i = 0; i < stud_work.Length; i++)
  87. {
  88. if (stud.Contains(stud_work[i]))
  89. {
  90. stud_counter[Array.IndexOf(stud, stud_work[i])]++;
  91. stud_h_counter[Array.IndexOf(stud, stud_work[i])]+=stud_hhd[i];
  92. stud_cab_counter[Array.IndexOf(stud, stud_work[i])] += stud_cab[i] + ",";
  93.  
  94. }
  95. }
  96. for (int i = 0; i < stud.Length; i++)
  97. {
  98. dataGridView1.Rows.Add(i, stud[i], stud_counter[i], stud_h_counter[i], stud_cab_counter[i]);
  99. }
  100.  
  101.  
  102. }
  103. }
  104. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement