示例#1
0
        private void button4_Click(object sender, EventArgs e)
        {
            try
            {
                if (action == "add")
                {
                    Account.executeSQL("INSERT INTO tblactivity VALUES ('" + activity_id + "' , '" + date + "' , '" + username + "' , '" + dept + "' , '" + actv_name + "' , '" + actv_date + "' , '" + actv_purpose + "','','','','')");

                    if (Account.rowAffected > 0)
                    {
                        MessageBox.Show("Activity  Saved", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        Account.executeSQL("INSERT INTO tbllogs VALUES ('" + DateTime.Now.ToString() +
                                           "' , 'Added an Activity with an id of : " + activity_id + "' , '" + username + "' , 'Borrowing Management')");
                        this.Hide();

                        frmaddborrow exit = new frmaddborrow(username, dept);
                        exit.Close();
                        //refresh datagrid
                        formactivity add = (formactivity)Application.OpenForms["formactivity"];
                        add.refresh();
                        refresh();
                    }
                }


                else if (action == "edit")
                {
                    MessageBox.Show("Activity Updated!", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    Account.executeSQL("INSERT INTO tbllogs VALUES ('" + DateTime.Now.ToString() + "' ,'Updated an activity with an id of-" + activity_id + "' , '3' ,'Borrowing Management ')");
                    this.Hide();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "error", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        private void borrowingToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            formactivity form_activity = new formactivity(username, dept);

            form_activity.Show();
        }