private void btnEdit_Click(object sender, EventArgs e) { if (txtID.Text != "") { if (btnEdit.Text == "Edit") { enableOrDisable(true); btnCancel.Text = "Cancel"; btnEdit.Text = "Update"; gbQB.Text = "Edit Question Bank"; btnSave.Enabled = false; } else { string status = ""; if (rbON.Checked) { status = "ON"; } else if (rbOFF.Checked) { status = "OFF"; } if (CheckField() == true) { errorProvider1.Clear(); English_Learning_Application.Entity.QuestionBank Q = new Entity.QuestionBank(txtTitle.Text, int.Parse(CountQuestion.Text), int.Parse(txtDuration.Text), status, temp_user_Id); QB.UpdateQuestonBank(Q, int.Parse(txtID.Text)); MessageBox.Show("Question Bank Has Been Updated", "INFORMATION", MessageBoxButtons.OK, MessageBoxIcon.Information); clearField(); setDatagridview(dgQuestion); } getField(); enableOrDisable(false); btnEdit.Text = "Edit"; btnCancel.Text = "Close"; gbQB.Text = "Form Question Bank"; btnSave.Enabled = true; } } else { MessageBox.Show("Please, Choose the Question Bank to Edit...!", "WARNING", MessageBoxButtons.OK, MessageBoxIcon.Warning); dgQuestion.Focus(); } }
private void btnSave_Click(object sender, EventArgs e) { if (btnSave.Text == "Add") { btnSave.Text = "Save"; btnCancel.Text = "Cancel"; gbQB.Text = "New Question Bank"; enableOrDisable(true); } else if (btnSave.Text == "Save") { string status = ""; if (rbON.Checked) { status = "ON"; } else if (rbOFF.Checked) { status = "OFF"; } if (CheckField() == true) { errorProvider1.Clear(); English_Learning_Application.Entity.QuestionBank Q = new Entity.QuestionBank(txtTitle.Text, int.Parse(CountQuestion.Text), int.Parse(txtDuration.Text), status, temp_user_Id); QB.InsertQuestonBank(Q); MessageBox.Show("Add New User has Successfuly", "INFORMATION", MessageBoxButtons.OK, MessageBoxIcon.Information); clearField(); setDatagridview(dgQuestion); } btnSave.Text = "Add"; gbQB.Text = "Form Question Bank"; enableOrDisable(false); } }