private void add_btn_Click(object sender, EventArgs e) { Add_Update_Assistant add_assistant_form = new Add_Update_Assistant(); add_assistant_form.update_btn.Visible = false; add_assistant_form.add_btn.Visible = true; add_assistant_form.heading_lb.Text = "Add Lecturer Details"; add_assistant_form.ShowDialog(); this.assistant_infoTableAdapter.Fill(this.dataSet_getAssistant_Info.assistant_info); }
private void assistants_info_table_CellClick(object sender, DataGridViewCellEventArgs e) { databaseConnection.Open(); MySqlCommand cmd1 = new MySqlCommand("Select id from assistant_info where assistant_name = '" + this.assistant_info_table.CurrentRow.Cells[0].Value.ToString() + "'", databaseConnection); int id = Convert.ToInt32(cmd1.ExecuteScalar()); databaseConnection.Close(); if (e.ColumnIndex == 6) { Add_Update_Assistant edit_assistant = new Add_Update_Assistant(id, this.assistant_info_table.CurrentRow.Cells[3].Value.ToString()); edit_assistant.assistant_name_textbox.Text = this.assistant_info_table.CurrentRow.Cells[0].Value.ToString(); edit_assistant.work_email_textbox.Text = this.assistant_info_table.CurrentRow.Cells[3].Value.ToString(); edit_assistant.mobile_number_textbox.Text = this.assistant_info_table.Rows[e.RowIndex].Cells[4].Value.ToString(); edit_assistant.gender_combobox.SelectedItem = this.assistant_info_table.Rows[e.RowIndex].Cells[1].Value.ToString(); string priviledge = this.assistant_info_table.Rows[e.RowIndex].Cells[2].Value.ToString(); if (priviledge == "Assistant") { edit_assistant.enable_checkbox.Checked = false; } else { edit_assistant.enable_checkbox.Checked = true; } edit_assistant.update_btn.Visible = true; edit_assistant.add_btn.Visible = false; edit_assistant.heading_lb.Text = "Edit Assitant Details"; edit_assistant.ShowDialog(); this.assistant_infoTableAdapter.Fill(this.dataSet_getAssistant_Info.assistant_info); } else if (e.ColumnIndex == 7) { if (MessageBox.Show("Are you sure want to delete this record?", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { databaseConnection.Open(); DataGridViewRow row = assistant_info_table.Rows[e.RowIndex]; MySqlCommand cmd = new MySqlCommand("Delete from assistant_info where assistant_name = '" + row.Cells[0].Value.ToString() + "'", databaseConnection); cmd.ExecuteNonQuery(); databaseConnection.Close(); //remove from datatable assistantinfoBindingSource.RemoveCurrent(); //refresh table this.assistant_infoTableAdapter.Fill(this.dataSet_getAssistant_Info.assistant_info); } } }