Пример #1
0
        private void dgCjenici_KeyDown(object sender, KeyEventArgs e)
        {
            try
            {
                if (e.KeyCode == Keys.F4)
                {
                    top = gratis.TopRowIndex;
                    focus = gratis.FocusedRowHandle;

                    if (gratis.RowCount > 0)
                    {
                        System.Data.DataRow row = gratis.GetDataRow(gratis.FocusedRowHandle);
                        if (row != null)
                        {
                            IDGratisa = row["gr_ID"].ToString();
                            frmZapisnik UForm = null;
                            if ((UForm = (frmZapisnik)IsFormAlreadyOpen(typeof(frmZapisnik))) == null)
                            {
                                frmZapisnik _frm = new frmZapisnik();
                                _frm.MdiParent = frmMain.ActiveForm;
                                _frm.oznaka = "F4";
                                _frm.gratisID = IDGratisa;
                                _frm.Show();
                            }
                            else
                            {
                                UForm.Focus();
                                return;
                            }

                        }
                    }
                    else
                    {
                        MessageBox.Show("Nemate niti jednu stavku koju biste ažurirali!");
                    }

                }
                else if (e.KeyCode == Keys.Delete)
                {
                    if (gratis.RowCount > 0)
                    {
                        DialogResult result;
                        System.Data.DataRow row = gratis.GetDataRow(gratis.FocusedRowHandle);
                        if (row != null)
                        {

                            result = MessageBox.Show("Želite obrisati odabrani zapis?", this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);

                            if (result == DialogResult.Yes)
                            {
                                string gr_ID = row[16].ToString();
                                veza.ExecuteQuery("delete from gratis where gr_ID = " + gr_ID + "");
                                MessageBox.Show("Uspješno ste obrisali odabrani zapis!");
                                osvjezi.PerformClick();
                            }

                        }
                    }
                }

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Пример #2
0
 private void btnZapisnik_Click(object sender, EventArgs e)
 {
     frmZapisnik UForm = null;
     if ((UForm = (frmZapisnik)IsFormAlreadyOpen(typeof(frmZapisnik))) == null)
     {
         frmZapisnik _frm = new frmZapisnik();
         _frm.MdiParent = frmMain.ActiveForm;
         _frm.oznaka = "F7";
         _frm.Show();
     }
     else
     {
         UForm.Focus();
         return;
     }
 }