private void AutoFillToolStripMenuItem_Click(object sender, EventArgs e)
        {
            String protocolType = ((ToolStripMenuItem)sender).Text;
            //dialog result for adding new node to treeview
            DialogResult dialogResultAddNode = DialogResult.Cancel;
            frmNewProtocol frmProtocolAdd;
            frmNewStep _frmNewStep;
            TreeNode treeNode = new TreeNode();

            switch (protocolType)
            {
                case PROTOCOL_TYPE:

                    frmProtocolAdd = new frmNewProtocol();

                    dialogResultAddNode = frmProtocolAdd.ShowDialog();
                    if (dialogResultAddNode == DialogResult.OK)
                    {
                        //treeNodeText = frmProtocolAdd.getStepName();
                        DataSets.dsModuleStructure3.dtStepCompositeRow compositeRow = _dsModuleStructure.dtStepComposite.NewdtStepCompositeRow();
                        DataSets.dsModuleStructure3.dtModuleRow module = getSelectedModuleRow();
                        if (module == null)
                        {
                            return;
                        }

                        if (module.pk_id.Length == 0)
                        {
                            return;
                        }

                        compositeRow.fk_module_id = module.pk_id;
                        compositeRow.description = frmProtocolAdd.getStepName();

                        if(tlvSteps.SelectedNode != null)
                        {
                            if(tlvSteps.SelectedNode is StepCompositeNode)
                            {
                                StepCompositeNode stepCompositeNode = tlvSteps.SelectedNode as StepCompositeNode;
                                compositeRow.fk_step_parent_id = stepCompositeNode.getStepCompositeRow().pk_id;
                            }
                        }

                        _dsModuleStructure.dtStepComposite.AdddtStepCompositeRow(compositeRow);

                        updateRow(compositeRow);

                        treeNode = new Steps.Parameter_controls.StepCompositeNode(compositeRow);
                    }

                    break;
                case STEP_TYPE:

                    DataSets.dsModuleStructure3.dtModuleRow moduleRow = getSelectedModuleRow();
                    DataSets.dsModuleStructure3.dtStepCompositeRow c = _dsModuleStructure.dtStepComposite.NewdtStepCompositeRow();

                    if (moduleRow == null)
                    {
                        break;
                    }

                    c.fk_module_id = moduleRow.pk_id;
                    //c.fk

                    String headerTitle = moduleRow.pk_id.ToString();

                    _frmNewStep = new frmNewStep(_dsModuleStructure, moduleRow);

                    dialogResultAddNode = _frmNewStep.ShowDialog();
                    if (dialogResultAddNode.Equals(DialogResult.OK))
                    {
                        if (tlvSteps.SelectedNode is StepCompositeNode)
                        {
                            StepCompositeNode stepCompositeNode = tlvSteps.SelectedNode as StepCompositeNode;
                            DataSets.dsModuleStructure3.dtStepLeafRow stepLeafRow = _dsModuleStructure.dtStepLeaf.NewdtStepLeafRow();
                            stepLeafRow.fk_step_composite = stepCompositeNode.getStepCompositeRow().pk_id;
                            stepLeafRow.description = _frmNewStep.getStepDescription();

                            _dsModuleStructure.dtStepLeaf.AdddtStepLeafRow(stepLeafRow);

                            updateRow(stepLeafRow);

                            treeNode = new StepLeafNode(stepLeafRow, _dsModuleStructure.dtActionValue);

                            Dictionary<dsModuleStructure3.dtModuleTypeActionTypeRow, ctrlCommand> command = _frmNewStep.getActionValues();
                            foreach(KeyValuePair<dsModuleStructure3.dtModuleTypeActionTypeRow, ctrlCommand> kvp in command)
                            {

                                Dictionary<dsModuleStructure3.dtActionTypeRow, namedInputTextBox> actionTypeInputBoxDict = kvp.Value.getActionTypesValues();

                                foreach(KeyValuePair<dsModuleStructure3.dtActionTypeRow, namedInputTextBox> kvpActionType in actionTypeInputBoxDict)
                                {
                                    if(kvpActionType.Value.getInputTextValue().Length != 0)
                                    {
                                        DataSets.dsModuleStructure3.dtActionValueRow actionValue = _dsModuleStructure.dtActionValue.NewdtActionValueRow();
                                        actionValue.fk_action_type = kvpActionType.Key.pk_id;
                                        actionValue.fk_action_value_type = kvp.Key.dtActionValueTypeRow.pk_id;
                                        actionValue.fk_step_leaf_id = stepLeafRow.pk_id;
                                        actionValue.description = kvpActionType.Value.getInputTextValue();
                                        _dsModuleStructure.dtActionValue.AdddtActionValueRow(actionValue);
                                        updateRow(actionValue);
                                    }
                                }
                            }
                        }
                    }

                    break;
                default:
                    break;
            }

            if (dialogResultAddNode.Equals(DialogResult.OK))
            {
                if (tlvSteps.SelectedNode != null)
                {
                    tlvSteps.SelectedNode.Nodes.Add(treeNode);
                }
                else
                {
                    tlvSteps.Nodes.Add(treeNode);
                }
            }
        }
        private void AutoFillToolStripMenuItem_Click(object sender, EventArgs e)
        {
            String protocolType = ((ToolStripMenuItem)sender).Text;
            //dialog result for adding new node to treeview
            DialogResult   dialogResultAddNode = DialogResult.Cancel;
            frmNewProtocol frmProtocolAdd;
            frmNewStep     _frmNewStep;
            TreeNode       treeNode = new TreeNode();


            switch (protocolType)
            {
            case PROTOCOL_TYPE:

                frmProtocolAdd = new frmNewProtocol();

                dialogResultAddNode = frmProtocolAdd.ShowDialog();
                if (dialogResultAddNode == DialogResult.OK)
                {
                    //treeNodeText = frmProtocolAdd.getStepName();
                    DataSets.dsModuleStructure3.dtStepCompositeRow compositeRow = _dsModuleStructure.dtStepComposite.NewdtStepCompositeRow();
                    DataSets.dsModuleStructure3.dtModuleRow        module       = getSelectedModuleRow();
                    if (module == null)
                    {
                        return;
                    }

                    if (module.pk_id.Length == 0)
                    {
                        return;
                    }

                    compositeRow.fk_module_id = module.pk_id;
                    compositeRow.description  = frmProtocolAdd.getStepName();

                    if (tlvSteps.SelectedNode != null)
                    {
                        if (tlvSteps.SelectedNode is StepCompositeNode)
                        {
                            StepCompositeNode stepCompositeNode = tlvSteps.SelectedNode as StepCompositeNode;
                            compositeRow.fk_step_parent_id = stepCompositeNode.getStepCompositeRow().pk_id;
                        }
                    }

                    _dsModuleStructure.dtStepComposite.AdddtStepCompositeRow(compositeRow);

                    updateRow(compositeRow);

                    treeNode = new Steps.Parameter_controls.StepCompositeNode(compositeRow);
                }

                break;

            case STEP_TYPE:

                DataSets.dsModuleStructure3.dtModuleRow        moduleRow = getSelectedModuleRow();
                DataSets.dsModuleStructure3.dtStepCompositeRow c         = _dsModuleStructure.dtStepComposite.NewdtStepCompositeRow();


                if (moduleRow == null)
                {
                    break;
                }

                c.fk_module_id = moduleRow.pk_id;
                //c.fk

                String headerTitle = moduleRow.pk_id.ToString();

                _frmNewStep = new frmNewStep(_dsModuleStructure, moduleRow);

                dialogResultAddNode = _frmNewStep.ShowDialog();
                if (dialogResultAddNode.Equals(DialogResult.OK))
                {
                    if (tlvSteps.SelectedNode is StepCompositeNode)
                    {
                        StepCompositeNode stepCompositeNode = tlvSteps.SelectedNode as StepCompositeNode;
                        DataSets.dsModuleStructure3.dtStepLeafRow stepLeafRow = _dsModuleStructure.dtStepLeaf.NewdtStepLeafRow();
                        stepLeafRow.fk_step_composite = stepCompositeNode.getStepCompositeRow().pk_id;
                        stepLeafRow.description       = _frmNewStep.getStepDescription();

                        _dsModuleStructure.dtStepLeaf.AdddtStepLeafRow(stepLeafRow);

                        updateRow(stepLeafRow);

                        treeNode = new StepLeafNode(stepLeafRow, _dsModuleStructure.dtActionValue);

                        Dictionary <dsModuleStructure3.dtModuleTypeActionTypeRow, ctrlCommand> command = _frmNewStep.getActionValues();
                        foreach (KeyValuePair <dsModuleStructure3.dtModuleTypeActionTypeRow, ctrlCommand> kvp in command)
                        {
                            Dictionary <dsModuleStructure3.dtActionTypeRow, namedInputTextBox> actionTypeInputBoxDict = kvp.Value.getActionTypesValues();

                            foreach (KeyValuePair <dsModuleStructure3.dtActionTypeRow, namedInputTextBox> kvpActionType in actionTypeInputBoxDict)
                            {
                                if (kvpActionType.Value.getInputTextValue().Length != 0)
                                {
                                    DataSets.dsModuleStructure3.dtActionValueRow actionValue = _dsModuleStructure.dtActionValue.NewdtActionValueRow();
                                    actionValue.fk_action_type       = kvpActionType.Key.pk_id;
                                    actionValue.fk_action_value_type = kvp.Key.dtActionValueTypeRow.pk_id;
                                    actionValue.fk_step_leaf_id      = stepLeafRow.pk_id;
                                    actionValue.description          = kvpActionType.Value.getInputTextValue();
                                    _dsModuleStructure.dtActionValue.AdddtActionValueRow(actionValue);
                                    updateRow(actionValue);
                                }
                            }
                        }
                    }
                }

                break;

            default:
                break;
            }

            if (dialogResultAddNode.Equals(DialogResult.OK))
            {
                if (tlvSteps.SelectedNode != null)
                {
                    tlvSteps.SelectedNode.Nodes.Add(treeNode);
                }
                else
                {
                    tlvSteps.Nodes.Add(treeNode);
                }
            }
        }