private void button1_Click(object sender, EventArgs e) { string title = textBox1.Text; int category = comboBox1.SelectedIndex; string cost = textBox2.Text; string discription = textBox3.Text; string quantity = textBox4.Text; string categoryMess; int costInt; int quantityInt; if (inputCheck.CheckAddEdit(title, category, cost, discription, quantity)) { categoryMess = comboBox1.SelectedItem.ToString(); costInt = Int32.Parse(cost); quantityInt = Int32.Parse(quantity); string[] newRec = new string[6] { title, categoryMess, cost, discription, quantity, ans[5] }; if (inputCheck.ChangeCheck(ans, newRec)) { if (inputCheck.AccessMessage(String.Format("Do you really want to change the record? " + StrForAccess(AccessEditor(newRec))))) { string req = ReqEditor(title, categoryMess, costInt, discription, quantityInt); bd.WorkWithBD(req); bd.ViewAll(listBox, true); } } } }
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); } }