示例#1
0
        private void button1_Click(object sender, EventArgs e)
        {
            string groupName = textBox1.Text;

            bool   requiredError = false;
            string err           = "";

            if (groupName == "")
            {
                err           = "Minden mező kitöltése kötelező";
                requiredError = true;
            }

            if (requiredError == false)
            {
                string insertQuery = "INSERT INTO `groups` (`groupName`) VALUES ('" + groupName + "')";
                Framework.db.RunQuery(insertQuery);

                int lastId = Framework.LastInsertId();

                string   getGroupsQuery = "SELECT * FROM groups WHERE groupName = '" + groupName + "' ORDER BY groupid DESC";
                var      groupTable     = Framework.db.GetData(getGroupsQuery);
                DataView groupView      = new DataView(groupTable);
                int      countRows      = Int32.Parse(groupView.Count.ToString());

                string groupid = groupView[0]["groupid"].ToString();

                string insertQueryJoin = "";
                foreach (string menu_id in selectedMenus)
                {
                    insertQueryJoin = "INSERT INTO groupsmenus (`group_id`,`menu_id`) VALUES ('" + groupid + "','" + menu_id + "')";
                    Framework.db.RunQuery(insertQueryJoin);
                }

                MessageBox.Show("Jogosultsági csoport feltöltve!");
                Framework.insertLog(Framework.MyUserId, Framework.Operation("Sikeres jogosultsági csoport feltöltés"), lastId);

                Framework.mainForm.panel1.Controls.Clear();
                GroupList listForm = new GroupList();
                listForm.TopLevel   = false;
                listForm.AutoScroll = true;
                Framework.mainForm.panel1.Controls.Add(listForm);
                listForm.Show();
            }
            else
            {
                Framework.insertLog(Framework.MyUserId, Framework.Operation("Sikertelen jogosultsági csoport feltöltés"), 0);
                MessageBox.Show(err);
            }
        }
示例#2
0
        private void button1_Click(object sender, EventArgs e)
        {
            string groupName = textBox1.Text;

            bool   requiredError = false;
            string err           = "";

            if (groupName == "")
            {
                err           = "Minden mező kitöltése kötelező";
                requiredError = true;
            }

            if (requiredError == false)
            {
                string updateQuery = "UPDATE `groups` SET `groupName` = '" + groupName + "' WHERE `groupid` =" + groupid;
                Framework.db.RunQuery(updateQuery);

                string insertQuery = "";
                string deleteQuery = "DELETE FROM groupsmenus WHERE `group_id` =" + groupid;
                Framework.db.RunQuery(deleteQuery);
                foreach (string menu_id in selectedMenus)
                {
                    insertQuery = "INSERT INTO groupsmenus (`group_id`,`menu_id`) VALUES ('" + groupid + "','" + menu_id + "')";
                    Framework.db.RunQuery(insertQuery);
                }

                Framework.insertLog(Framework.MyUserId, Framework.Operation("Sikeres jogosultsági csoport frissítés"), Convert.ToInt32(groupid));

                MessageBox.Show("Jogosultsági csoport frissítve!");

                Framework.mainForm.panel1.Controls.Clear();
                GroupList listForm = new GroupList();
                listForm.TopLevel   = false;
                listForm.AutoScroll = true;
                Framework.mainForm.panel1.Controls.Add(listForm);
                listForm.Show();
            }
            else
            {
                Framework.insertLog(Framework.MyUserId, Framework.Operation("Sikertelen jogosultsági csoport frissítés"), Convert.ToInt32(groupid));
                MessageBox.Show(err);
            }
        }