private void deleteBtn_Click(object sender, EventArgs e) { try { var confirmResult = MessageBox.Show("Сигурни ли сте, че искате да изтриете записа?", "Потвърждение!!", MessageBoxButtons.YesNo); if (confirmResult == DialogResult.Yes) { con.Open(); SqlCommand cmd = con.CreateCommand(); cmd.CommandType = CommandType.Text; cmd.CommandText = @"DELETE from CoursePoosition WHERE PositionID = '" + dataGridView1.CurrentRow.Cells[0].Value.ToString() + "' AND CourseID = '" + label3.Text + "'"; cmd.ExecuteNonQuery(); con.Close(); MessageBox.Show("Успешно изтрити данни!"); EditPositions srch = new EditPositions(label1.Text, label3.Text); srch.MdiParent = this.MdiParent; srch.Show(); this.Hide(); } } catch { MessageBox.Show("Невалидна команда!"); } }
private void editPositionsBtn_Click(object sender, EventArgs e) { EditPositions srch = new EditPositions(nameCTxt.Text, noTxt.Text); srch.MdiParent = this.MdiParent; srch.Show(); }
private void addBtn_Click(object sender, EventArgs e) { try { con.Open(); SqlCommand cmd = con.CreateCommand(); cmd.CommandType = CommandType.Text; cmd.CommandText = @"insert into CoursePoosition(PositionID, CourseID) values('" + positionCmb.SelectedValue + "' ,'" + label3.Text + "')"; cmd.ExecuteNonQuery(); con.Close(); MessageBox.Show("Успешно добавени данни!"); EditPositions srch = new EditPositions(label1.Text, label3.Text); srch.MdiParent = this.MdiParent; srch.Show(); this.Hide(); } catch { MessageBox.Show($"{positionCmb.Text} вече съществува!"); } }