예제 #1
0
        private void btnObrisi_Click(object sender, EventArgs e)
        {
            bool uspjeh = false;

            if (dgvUgovori.SelectedCells.Count > 0)
            {
                if (dgvStavkeUgovora.SelectedCells.Count > 0)
                {
                    MessageBox.Show("It's not possible to delete contract who has lines!", "Warning", MessageBoxButtons.OK);
                }
                else
                {
                    if (MessageBox.Show("Are you sure you want to delete the selected contract?", "Warning", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        int indeksOznacenog = dgvUgovori.SelectedCells[0].RowIndex;

                        DataGridViewRow oznaceniRed = dgvUgovori.Rows[indeksOznacenog];

                        int ID = int.Parse(oznaceniRed.Cells["IDUgovora"].Value.ToString());

                        uspjeh = Upiti.ObrisiUgovor(ID);
                        if (uspjeh)
                        {
                            OsvjeziPrikaz();
                            OsvjeziStavke(ID_ugovora);
                        }
                    }
                }
            }
        }