private void button1_Click(object sender, EventArgs e) { this.Hide(); Form comentarios_admin = new Comentarios_admin(); comentarios_admin.Closed += (s, args) => this.Close(); comentarios_admin.Show(); }
private void comentáriosAdminToolStripMenuItem_Click(object sender, EventArgs e) { this.Hide(); Form comentarios_admin = new Comentarios_admin(); comentarios_admin.Closed += (s, args) => this.Close(); comentarios_admin.Show(); }
private void radioButton1_CheckedChanged(object sender, EventArgs e) { string text = radioButton1.Text.ToString(); foreach (DataGridViewRow row in dataGridView1.Rows) { if (this.dataGridView1.SelectedRows.Count == 1) { // get information of 1st column from the row string selected = this.dataGridView1.SelectedRows[0].Cells[2].Value.ToString(); } } if (selected != "") { if (radioButton1.Checked == true) { MessageBox.Show("a" + selected + "a"); string value = dataGridView1.SelectedRows[Convert.ToInt16(selected)].Cells[0].Value.ToString(); //procura id no ficheiro de texto String line; StreamReader sr = new StreamReader("Ficheiros de Texto/comentarios.txt"); //Read the first line of text line = sr.ReadLine(); string[] parts = line.Split(';'); int cont = 0; int linha = -1; string linhaAntiga = ""; string linhaSaved = ""; while (line != null) { parts = line.Split(';'); if (parts[0] == value) { linha = cont; linhaSaved = parts[0] + ";" + parts[1] + ";" + parts[2] + ";" + parts[3] + ";1;" + text; linhaAntiga = line; } line = sr.ReadLine(); cont++; } sr.Close(); string[] lines1 = File.ReadAllLines("Ficheiros de Texto/comentarios.txt"); lines1[linha] = linhaSaved; File.WriteAllLines("Ficheiros de Texto/comentarios.txt", lines1); MessageBox.Show("Estado Alterado!"); this.Hide(); Form comentarios_admin = new Comentarios_admin(); comentarios_admin.Closed += (s, args) => this.Close(); comentarios_admin.Show(); } } else { MessageBox.Show("É obrigatório escolher uma linha!"); } }