Example #1
0
        protected void context_edit_clic(object sender, EventArgs e)
        {
            List <Table> tableList = MgBox.tableList;

            MenuItem item = (sender as MenuItem);

            ContextMenu owner = item.Parent as ContextMenu;

            switch (item.Text)
            {
            case "delete":
                var confirmDelete = MessageBox.Show("Are you sure to delete this table?", "Confirm Delete!!", MessageBoxButtons.OKCancel);
                if (confirmDelete == DialogResult.OK)
                {
                    int itemToRemove = tableList.FindIndex(i => i.Name == owner.SourceControl.Text);
                    tableList.RemoveAt(itemToRemove);
                    Read_write_xml.Write(tableList, "table removed", true);     // Write with backup
                    if (pnl_search_overlay.Visible == true)
                    {
                        List <Table> result = MgBox.tableList.FindAll(i => i.Number.Contains(search_bar.Text));
                        readAndAdd(result, pnl_search_overlay);
                    }

                    readAndAdd();
                }
                else
                {
                    return;
                }

                break;

            case "edit":
                string num = tableList.Find(i => i.Name == owner.SourceControl.Text).Number;

                var confirmEdit = MessageBox.Show("Are you sure to edit this table?", "Edit: " + num, MessageBoxButtons.OKCancel);
                if (confirmEdit == DialogResult.OK)
                {
                    MgBox.editState   = true;
                    MgBox.tableToEdit = tableList.Find(i => i.Name == owner.SourceControl.Text).Name;

                    Create_table create_table = new Create_table(this);         // Initializing Create_table form and passing this form "designer?!?" as a parameter
                    create_table.ShowDialog();
                }
                else
                {
                    return;
                }

                break;
            }
        }
Example #2
0
        // Open create table dialog
        private void open_crt_tbl_Click(object sender, EventArgs e)
        {
            Create_table create_table = new Create_table(this);     // Initializing Create_table form and passing this form "designer?!?" as a parameter

            create_table.ShowDialog();
        }