Exemplo n.º 1
0
 private void butOK_Click(object sender, EventArgs e)
 {
     AutoNoteCur.AutoNoteName = textBoxAutoNoteName.Text;
     AutoNoteCur.MainText     = textMain.Text;
     if (IsNew)
     {
         AutoNotes.Insert(AutoNoteCur);
     }
     else
     {
         AutoNotes.Update(AutoNoteCur);
     }
     DialogResult = DialogResult.OK;
 }
Exemplo n.º 2
0
        private void butOK_Click(object sender, EventArgs e)
        {
            if (textBoxAutoNoteName.Text == "")
            {
                MsgBox.Show(this, "Please enter a name for the Auto Note into the text box");
                return;
            }
            //bool IsUsed=AutoNotes.AutoNoteNameUsed(textBoxAutoNoteName.Text.ToString(),AutoNoteCur.AutoNoteName);
            //if(IsUsed) {
            //	MsgBox.Show(this,"This name is already used please choose a different name");
            //	return;
            //}

            /*if (listBoxControlsToIncl.Items.Count==0) {
             *      MsgBox.Show(this, "Please add some controls to the Auto Note");
             *      return;
             * }*/
            //Save changes to database here
            //Saves the items in the listboxControlsToIncl in a array that will be passed on
            string controlsToIncText = "";

            for (int i = 0; i < listBoxControlToIncNum.Items.Count; i++)
            {
                if (listBoxControlsToIncl.Items[i].ToString() != "")
                {
                    controlsToIncText = controlsToIncText + listBoxControlToIncNum.Items[i].ToString() + ",";
                }
            }
            AutoNoteCur.ControlsToInc = controlsToIncText;
            AutoNoteCur.AutoNoteName  = textBoxAutoNoteName.Text.ToString();
            if (IsNew)
            {
                AutoNotes.Insert(AutoNoteCur);
            }
            else
            {
                AutoNotes.Update(AutoNoteCur);
            }
            DialogResult = DialogResult.OK;
        }
Exemplo n.º 3
0
        private void treeNotes_DragDrop(object sender, DragEventArgs e)
        {
            if (_grayNode != null)
            {
                _grayNode.BackColor = Color.White;
            }
            if (!e.Data.GetDataPresent("System.Windows.Forms.TreeNode", false))
            {
                return;
            }
            TreeNode sourceNode = (TreeNode)e.Data.GetData("System.Windows.Forms.TreeNode");

            if (sourceNode == null || !(sourceNode.Tag is Def || sourceNode.Tag is AutoNote))
            {
                return;
            }
            TreeNode topNodeCur = treeNotes.TopNode;

            if (treeNotes.TopNode == sourceNode && sourceNode.PrevVisibleNode != null)
            {
                //if moving the topNode to another category, make the previous visible node the topNode once the move is successful
                topNodeCur = sourceNode.PrevVisibleNode;
            }
            Point    pt       = ((TreeView)sender).PointToClient(new Point(e.X, e.Y));
            TreeNode destNode = ((TreeView)sender).GetNodeAt(pt);

            if (destNode == null || !(destNode.Tag is Def || destNode.Tag is AutoNote)) //moving to root node (category 0)
            {
                if (sourceNode.Parent == null)                                          //already at the root node, nothing to do
                {
                    return;
                }
                if (!MsgBox.Show(this, MsgBoxButtons.YesNo, "Move the selected " + (sourceNode.Tag is AutoNote?"Auto Note":"category") + " to the root level?"))
                {
                    return;
                }
                if (sourceNode.Tag is Def)
                {
                    ((Def)sourceNode.Tag).ItemValue = "";
                }
                else                  //must be an AutoNote
                {
                    ((AutoNote)sourceNode.Tag).Category = 0;
                }
            }
            else              //moving to another folder (category)
            {
                if (destNode.Tag is AutoNote)
                {
                    destNode = destNode.Parent;                  //if destination is AutoNote, set destination to the parent, which is the category def node for the note
                }
                if (!IsValidDestination(sourceNode, destNode, sourceNode.Tag is Def))
                {
                    return;
                }
                if (!MsgBox.Show(this, MsgBoxButtons.YesNo,
                                 "Move the selected " + (sourceNode.Tag is AutoNote?"Auto Note":"category") + (destNode == null?" to the root level":"") + "?"))
                {
                    return;
                }
                //destNode will be null if a root AutoNote was selected as the destination
                long destDefNum = (destNode == null?0:((Def)destNode.Tag).DefNum);
                if (sourceNode.Tag is Def)
                {
                    ((Def)sourceNode.Tag).ItemValue = (destDefNum == 0?"":destDefNum.ToString()); //make a DefNum of 0 be a blank string in the db, not a "0" string
                }
                else                                                                              //must be an AutoNote
                {
                    ((AutoNote)sourceNode.Tag).Category = destDefNum;
                }
            }
            if (sourceNode.Tag is Def)
            {
                Defs.Update((Def)sourceNode.Tag);
                DataValid.SetInvalid(InvalidType.Defs);
            }
            else              //must be an AutoNote
            {
                AutoNotes.Update((AutoNote)sourceNode.Tag);
                DataValid.SetInvalid(InvalidType.AutoNotes);
            }
            treeNotes.TopNode = topNodeCur;          //if sourceNode was the TopNode and was moved, make the TopNode the previous visible node
            AutoNoteL.FillListTree(treeNotes, _userOdCurPref);
        }