@@ -251,7 +251,7 @@ namespace ProjCLR {
251
251
// / </summary>
252
252
void InitializeComponent (void )
253
253
{
254
- System::Windows::Forms::DataGridViewCellStyle^ dataGridViewCellStyle2 = (gcnew System::Windows::Forms::DataGridViewCellStyle ());
254
+ System::Windows::Forms::DataGridViewCellStyle^ dataGridViewCellStyle1 = (gcnew System::Windows::Forms::DataGridViewCellStyle ());
255
255
this ->dataGridView1 = (gcnew System::Windows::Forms::DataGridView ());
256
256
this ->Nome = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn ());
257
257
this ->Localidade = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn ());
@@ -268,6 +268,8 @@ namespace ProjCLR {
268
268
this ->menuStrip1 = (gcnew System::Windows::Forms::MenuStrip ());
269
269
this ->delegadoToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem ());
270
270
this ->novoDelegadoSortearToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem ());
271
+ this ->guardarDelegadoToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem ());
272
+ this ->toolStripComboBox1 = (gcnew System::Windows::Forms::ToolStripMenuItem ());
271
273
this ->estat ísticasToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem ());
272
274
this ->identificarOMaisVelhoToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem ());
273
275
this ->m édiaDeIdadesToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem ());
@@ -289,8 +291,6 @@ namespace ProjCLR {
289
291
this ->btn_feminino = (gcnew System::Windows::Forms::Button ());
290
292
this ->statusStrip1 = (gcnew System::Windows::Forms::StatusStrip ());
291
293
this ->lbl_status = (gcnew System::Windows::Forms::ToolStripStatusLabel ());
292
- this ->guardarDelegadoToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem ());
293
- this ->toolStripComboBox1 = (gcnew System::Windows::Forms::ToolStripMenuItem ());
294
294
(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this ->dataGridView1 ))->BeginInit ();
295
295
this ->groupBox1 ->SuspendLayout ();
296
296
this ->menuStrip1 ->SuspendLayout ();
@@ -306,15 +306,15 @@ namespace ProjCLR {
306
306
| System::Windows::Forms::AnchorStyles::Left)
307
307
| System::Windows::Forms::AnchorStyles::Right));
308
308
this ->dataGridView1 ->BorderStyle = System::Windows::Forms::BorderStyle::None;
309
- dataGridViewCellStyle2 ->Alignment = System::Windows::Forms::DataGridViewContentAlignment::MiddleCenter;
310
- dataGridViewCellStyle2 ->BackColor = System::Drawing::SystemColors::Control;
311
- dataGridViewCellStyle2 ->Font = (gcnew System::Drawing::Font (L" Microsoft Sans Serif" , 8 .25F , System::Drawing::FontStyle::Regular,
309
+ dataGridViewCellStyle1 ->Alignment = System::Windows::Forms::DataGridViewContentAlignment::MiddleCenter;
310
+ dataGridViewCellStyle1 ->BackColor = System::Drawing::SystemColors::Control;
311
+ dataGridViewCellStyle1 ->Font = (gcnew System::Drawing::Font (L" Microsoft Sans Serif" , 8 .25F , System::Drawing::FontStyle::Regular,
312
312
System::Drawing::GraphicsUnit::Point , static_cast <System::Byte >(0 )));
313
- dataGridViewCellStyle2 ->ForeColor = System::Drawing::SystemColors::WindowText;
314
- dataGridViewCellStyle2 ->SelectionBackColor = System::Drawing::SystemColors::Highlight;
315
- dataGridViewCellStyle2 ->SelectionForeColor = System::Drawing::SystemColors::HighlightText;
316
- dataGridViewCellStyle2 ->WrapMode = System::Windows::Forms::DataGridViewTriState::True;
317
- this ->dataGridView1 ->ColumnHeadersDefaultCellStyle = dataGridViewCellStyle2 ;
313
+ dataGridViewCellStyle1 ->ForeColor = System::Drawing::SystemColors::WindowText;
314
+ dataGridViewCellStyle1 ->SelectionBackColor = System::Drawing::SystemColors::Highlight;
315
+ dataGridViewCellStyle1 ->SelectionForeColor = System::Drawing::SystemColors::HighlightText;
316
+ dataGridViewCellStyle1 ->WrapMode = System::Windows::Forms::DataGridViewTriState::True;
317
+ this ->dataGridView1 ->ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1 ;
318
318
this ->dataGridView1 ->ColumnHeadersHeightSizeMode = System::Windows::Forms::DataGridViewColumnHeadersHeightSizeMode::AutoSize;
319
319
this ->dataGridView1 ->Columns ->AddRange (gcnew cli::array< System::Windows::Forms::DataGridViewColumn^ >(5 ) {
320
320
this ->Nome , this ->Localidade ,
@@ -470,6 +470,20 @@ namespace ProjCLR {
470
470
this ->novoDelegadoSortearToolStripMenuItem ->Text = L" Novo Delegado (Sortear)" ;
471
471
this ->novoDelegadoSortearToolStripMenuItem ->Click += gcnew System::EventHandler (this , &Form1::NovoDelegadoSortearToolStripMenuItem_Click);
472
472
//
473
+ // guardarDelegadoToolStripMenuItem
474
+ //
475
+ this ->guardarDelegadoToolStripMenuItem ->Name = L" guardarDelegadoToolStripMenuItem" ;
476
+ this ->guardarDelegadoToolStripMenuItem ->Size = System::Drawing::Size (204 , 22 );
477
+ this ->guardarDelegadoToolStripMenuItem ->Text = L" Guardar Delegado" ;
478
+ this ->guardarDelegadoToolStripMenuItem ->Click += gcnew System::EventHandler (this , &Form1::GuardarDelegadoToolStripMenuItem_Click);
479
+ //
480
+ // toolStripComboBox1
481
+ //
482
+ this ->toolStripComboBox1 ->Name = L" toolStripComboBox1" ;
483
+ this ->toolStripComboBox1 ->Size = System::Drawing::Size (204 , 22 );
484
+ this ->toolStripComboBox1 ->Text = L" Recuperar Delegado" ;
485
+ this ->toolStripComboBox1 ->Click += gcnew System::EventHandler (this , &Form1::ToolStripComboBox1_Click);
486
+ //
473
487
// estatísticasToolStripMenuItem
474
488
//
475
489
this ->estat ísticasToolStripMenuItem->DropDownItems ->AddRange (gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(3 ) {
@@ -637,19 +651,6 @@ namespace ProjCLR {
637
651
this ->lbl_status ->Name = L" lbl_status" ;
638
652
this ->lbl_status ->Size = System::Drawing::Size (0 , 17 );
639
653
//
640
- // guardarDelegadoToolStripMenuItem
641
- //
642
- this ->guardarDelegadoToolStripMenuItem ->Name = L" guardarDelegadoToolStripMenuItem" ;
643
- this ->guardarDelegadoToolStripMenuItem ->Size = System::Drawing::Size (204 , 22 );
644
- this ->guardarDelegadoToolStripMenuItem ->Text = L" Guardar Delegado" ;
645
- //
646
- // toolStripComboBox1
647
- //
648
- this ->toolStripComboBox1 ->Name = L" toolStripComboBox1" ;
649
- this ->toolStripComboBox1 ->Size = System::Drawing::Size (204 , 22 );
650
- this ->toolStripComboBox1 ->Text = L" Recuperar Delegado" ;
651
- this ->toolStripComboBox1 ->Click += gcnew System::EventHandler (this , &Form1::ToolStripComboBox1_Click);
652
- //
653
654
// Form1
654
655
//
655
656
this ->AutoScaleDimensions = System::Drawing::SizeF (6 , 13 );
@@ -665,7 +666,7 @@ namespace ProjCLR {
665
666
this ->MainMenuStrip = this ->menuStrip1 ;
666
667
this ->MinimumSize = System::Drawing::Size (1000 , 640 );
667
668
this ->Name = L" Form1" ;
668
- this ->Text = L" Projecto Alpha" ;
669
+ this ->Text = L" Projeto Alpha" ;
669
670
this ->Load += gcnew System::EventHandler (this , &Form1::Form1_Load);
670
671
(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this ->dataGridView1 ))->EndInit ();
671
672
this ->groupBox1 ->ResumeLayout (false );
@@ -1089,12 +1090,13 @@ private: void gerar_colunas()
1089
1090
{
1090
1091
dataGridView1->Columns [i]->Name = " media" ;
1091
1092
dataGridView1->Columns [i]->Width = 50 ;
1092
-
1093
+ dataGridView1-> Columns [i]-> DefaultCellStyle -> ForeColor = Color::Blue;
1093
1094
}
1094
1095
else if (novas_colunas[i - cur_n] == " Negativas" )
1095
1096
{
1096
1097
dataGridView1->Columns [i]->Name = " negativas" ;
1097
1098
dataGridView1->Columns [i]->Width = 60 ;
1099
+ dataGridView1->Columns [i]->DefaultCellStyle ->ForeColor = Color::Blue;
1098
1100
}
1099
1101
else if (novas_colunas[i - cur_n] == " Estado" )
1100
1102
{
@@ -1106,7 +1108,6 @@ private: void gerar_colunas()
1106
1108
{
1107
1109
dataGridView1->Columns [i]->Name = " d" + (i - cur_n);
1108
1110
dataGridView1->Columns [i]->Width = 38 ;
1109
-
1110
1111
}
1111
1112
}
1112
1113
}
@@ -1241,14 +1242,66 @@ private: void atualizar_estado()
1241
1242
// Guardar o nome do delegado num ficheiro de texto
1242
1243
private: void guardar_delegado ()
1243
1244
{
1245
+ String^ filename = " _Projeto_Alpha__delegado.txt" ;
1246
+ StreamWriter^ fp = gcnew StreamWriter (filename);
1247
+ String^ delegado = " " ;
1248
+ int n_formandos;
1249
+
1250
+ bool linha_intro = dataGridView1->AllowUserToAddRows ;
1251
+ dataGridView1->AllowUserToAddRows = false ;
1252
+ n_formandos = dataGridView1->Rows ->Count ;
1253
+ dataGridView1->AllowUserToAddRows = linha_intro;
1254
+
1255
+ for (int i = 0 ; i < n_formandos && delegado==" " ; i++)
1256
+ {
1257
+ if (dataGridView1->Rows [i]->Cells [" Delegado" ]->Value == " X" )
1258
+ delegado = dataGridView1->Rows [i]->Cells [" Nome" ]->Value ->ToString ();
1259
+ }
1244
1260
1261
+ fp->WriteLine (delegado);
1262
+ fp->Close ();
1245
1263
}
1246
1264
1247
1265
1248
1266
// Recuperar o nome do delegado a partir de um ficheiro de texto
1249
1267
private: void recuperar_delegado ()
1250
1268
{
1251
1269
1270
+ String^ filename = " _Projeto_Alpha__delegado.txt" ;
1271
+ StreamReader^ fp;
1272
+ String^ delegado;
1273
+ int n_formandos;
1274
+
1275
+ bool linha_intro = dataGridView1->AllowUserToAddRows ;
1276
+ dataGridView1->AllowUserToAddRows = false ;
1277
+ n_formandos = dataGridView1->Rows ->Count ;
1278
+ dataGridView1->AllowUserToAddRows = linha_intro;
1279
+
1280
+ try
1281
+ {
1282
+ fp = gcnew StreamReader (filename);
1283
+ }
1284
+ catch (FileNotFoundException^)
1285
+ {
1286
+ MessageBox::Show (" Não há nenhum delegado guardado." );
1287
+ return ;
1288
+ }
1289
+ delegado = fp->ReadLine ();
1290
+
1291
+
1292
+ if (delegado == " " || delegado == nullptr )
1293
+ MessageBox::Show (" Não há nenhum delegado guardado." );
1294
+
1295
+ for (int i = 0 ; i < n_formandos; i++)
1296
+ {
1297
+ if (dataGridView1->Rows [i]->Cells [" Nome" ]->Value ->ToString () == delegado)
1298
+ dataGridView1->Rows [i]->Cells [" Delegado" ]->Value = " X" ;
1299
+ else
1300
+ dataGridView1->Rows [i]->Cells [" Delegado" ]->Value = " " ;
1301
+ }
1302
+
1303
+ fp->Close ();
1304
+ dataGridView1->Columns [" Delegado" ]->Visible = true ;
1252
1305
}
1253
1306
1254
1307
private: void status_formando ()
@@ -1302,7 +1355,7 @@ private: System::Void MostrarOcultarPainelLateralToolStripMenuItem_Click(System:
1302
1355
private: System::Void Btn_painel_Click (System::Object^ sender, System::EventArgs^ e) { alternar_painel_lateral ();}
1303
1356
private: System::Void GerarNotasToolStripMenuItem_Click (System::Object^ sender, System::EventArgs^ e) { gerar_notas ();}
1304
1357
private: System::Void NotasToolStripMenuItem_Click (System::Object^ sender, System::EventArgs^ e) { stats_notas (); }
1305
- private: System::Void ToolStripComboBox1_Click (System::Object^ sender, System::EventArgs^ e) {
1306
- }
1358
+ private: System::Void ToolStripComboBox1_Click (System::Object^ sender, System::EventArgs^ e) { recuperar_delegado (); }
1359
+ private: System::Void GuardarDelegadoToolStripMenuItem_Click (System::Object^ sender, System::EventArgs^ e) { guardar_delegado (); }
1307
1360
};
1308
1361
}
0 commit comments