Advertisement
Guest User

hhhh

a guest
May 22nd, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.87 KB | None | 0 0
  1. using System;
  2. using System.Windows.Forms;
  3.  
  4. namespace StudentiDataGrid
  5. {
  6. public partial class Form1 : Form
  7. {
  8. public string[,] studenti = new string[4, 4];
  9. public int j, k = 0;
  10.  
  11. public Form1()
  12. {
  13. InitializeComponent();
  14. }
  15.  
  16. private void button1_Click(object sender, EventArgs e)
  17. {
  18. if (j < 4)
  19. {
  20. studenti[j, 0] = textBox3.Text;
  21. studenti[j, 1] = textBox4.Text;
  22. studenti[j, 2] = textBox5.Text;
  23.  
  24. j++;
  25.  
  26. DataGridViewRow riga = new DataGridViewRow();
  27. riga.CreateCells(dataGridView1);
  28.  
  29. for (int i = 0; i < 3; i++)
  30. riga.Cells[i].Value = studenti[j - 1, i];
  31.  
  32. dataGridView1.Rows.Add(riga);
  33. }
  34.  
  35. else
  36. MessageBox.Show("Numero massimo di inserimenti raggiunto.", "Errore", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  37. }
  38.  
  39. private void button2_Click(object sender, EventArgs e)
  40. {
  41. if (k < 4)
  42. {
  43. int voto_min = Convert.ToInt32(textBox6.Text);
  44. int assenze_max = Convert.ToInt32(textBox7.Text);
  45.  
  46. for (int i = k; i < k + 1; i++)
  47. {
  48. if (Convert.ToInt32(studenti[i, 1]) >= voto_min && Convert.ToInt32(studenti[i, 2]) <= assenze_max)
  49. studenti[i, 3] = "Promosso";
  50.  
  51. else
  52. studenti[i, 3] = "Bocciato";
  53.  
  54. dataGridView1.Rows[i].Cells[3].Value = studenti[i, 3];
  55. }
  56.  
  57. k++;
  58. }
  59.  
  60. else
  61. MessageBox.Show("Numero massimo di inserimenti raggiunto.", "Errore", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  62. }
  63. }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement