private void button2_Click(object sender, EventArgs e) { int ind = listBox1.SelectedIndex; int id; string title; if (inputCheck.SelectedItemCheck(ind)) { id = subString.IndReturn(listBox1.Text, "Title"); title = subString.TitleReturn(listBox1.Text, "Title", "Category"); if (button2.Text == "Delete") { if (inputCheck.AccessMessage(String.Format("Do you really want to delete the record? ({0} {1})", id, title))) { string req = String.Format("DELETE FROM Products WHERE Id = {0}", id); bd.WorkWithBD(req); bd.ViewAll(listBox1, true); } } else { EditForm editForm = new EditForm(id, bd.WorkWithBD(id), listBox1); editForm.Show(); } } else { errorList.ErrorMessage(10); } }
private void button2_Click(object sender, EventArgs e) { int ind = listBox1.SelectedIndex; int id; string login; if (inputCheck.SelectedItemCheck(ind)) { id = subString.IndReturn(listBox1.Text, "Login"); login = subString.TitleReturn(listBox1.Text, "Login", "Password"); login.Replace(" ", ""); if (inputCheck.AccessMessage(String.Format("Do you really want to delete the record? ({0} {1})", id, login))) { string req = String.Format("DELETE FROM Accounts WHERE Id = {0}", id); bd.WorkWithBD(req); bd.ViewAllAcc(listBox1); } } else { errorList.ErrorMessage(10); } }