Beispiel #1
0
        private void buttonEditKT_Click(object sender, EventArgs e)
        {
            int id = 0;

            try
            {
                id = Convert.ToInt32(dataGridView4[0, dataGridView4.CurrentRow.Index].Value.ToString());
            }
            catch (NullReferenceException) { }

            FormKeeleTasud dlg = new FormKeeleTasud("Edit entry", "Edit KeeleTasud", "Save", id);

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                Database db = new Database();
                db.open();

                if (db.Connected)
                {
                    try
                    {
                        db.cmd_exec("UPDATE [dbo].[KeeleTasud] SET Tase = '" + dlg.Tase + "', Summa = '" + dlg.Summa + "' WHERE Id = '" + dlg.Id + "'");
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("Entry edit fail!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                    }

                    buttonRefreshKT_Click(sender, e);
                }
            }
        }
Beispiel #2
0
        private void buttonAddKT_Click(object sender, EventArgs e)
        {
            FormKeeleTasud dlg = new FormKeeleTasud("New entry", "Add to KeeleTasud", "Add", 0);

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                Database db = new Database();
                db.open();

                if (db.Connected)
                {
                    try
                    {
                        db.cmd_exec("INSERT INTO [dbo].[KeeleTasud] (Tase, Summa) VALUES('" + dlg.Tase + "', '" + dlg.Summa + "')");
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("Entry add fail!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                    }

                    buttonRefreshKT_Click(sender, e);
                }
            }
        }