private void dataGridViewStudents_Info_CellClick(object sender, DataGridViewCellEventArgs e) { if (MessageBox.Show("If you Update? click Yes \nIf Sent Email? click No", "Update/Sent Email", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { pnlVSUpdate.Visible = true; try { int i = Convert.ToInt32(dataGridViewStudents_Info.SelectedCells[0].Value.ToString()); try { con.Open(); SqlCommand cmd = con.CreateCommand(); cmd.CommandType = CommandType.Text; cmd.CommandText = "SELECT * FROM Students_Info WHERE Id = " + i + ""; cmd.ExecuteNonQuery(); DataTable dt = new DataTable(); SqlDataAdapter da = new SqlDataAdapter(cmd); da.Fill(dt); foreach (DataRow dr in dt.Rows) { txtVSUName.Text = dr["Name_of_Students"].ToString(); txtVSUFName.Text = dr["Fathers_Name"].ToString(); txtVSUMName.Text = dr["Mothers_Name"].ToString(); dateTimePickerVSUB.Text = dr["Date_of_Birth"].ToString(); cmbVSUGender.Text = dr["Gender"].ToString(); cmbVSUClass.Text = dr["Class"].ToString(); txtVSURoll.Text = dr["Class_Roll"].ToString(); dateTimePickerVSUA.Text = dr["Date_of_Admission"].ToString(); txtVSUEmail.Text = dr["Email"].ToString(); txtVSUAddress.Text = dr["Address"].ToString(); } con.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } catch (FormatException) { MessageBox.Show("Please click Id no"); } } else { string email = dataGridViewStudents_Info.SelectedCells[9].Value.ToString(); this.Hide(); Sent_Email sm = new Sent_Email(); sm.To = email; sm.Show(); } }
private void emailToolStripMenuItem_Click(object sender, EventArgs e) { Sent_Email SM = new Sent_Email(); SM.Show(); }