Esempio n. 1
0
        /// <summary>
        /// Called as we exit from edit mode - we need to ensure that what we have entered is valid
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ulvPickItems_ItemExitingEditMode(object sender, ItemExitingEditModeEventArgs e)
        {
            UltraListViewItem lvi            = e.Item;
            PickItem          editedPickItem = lvi.Tag as PickItem;
            //string name = (string)e.Editor.Value;
            string name = e.Editor.Value.ToString();

            // If the name is blank then it will be invalid
            if (name == "")
            {
                MessageBox.Show("Please specify a unique name for this pickitem", "Enter Name", MessageBoxButtons.OK, MessageBoxIcon.Information);
                e.Cancel = true;
                return;
            }

            // Get the picklist so we check it's items
            PickList picklist = _activeItem.Tag as PickList;

            // Does the specified value duplicate an existing pickitem?
            foreach (PickItem item in picklist)
            {
                if ((item.Name == name) && (item.PickItemID != editedPickItem.PickItemID))
                {
                    MessageBox.Show(
                        "The specified name matches that of an existing item in this picklist, please specify a unique name for this pickitem",
                        "Duplicate Name",
                        MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    e.Cancel = true;
                    return;
                }
            }

            // If it's a new pickitem then we need to add it to the parent list also
            if (editedPickItem.PickItemID == 0)
            {
                picklist.Add(editedPickItem);
            }

            // Update the PickItem in the database
            editedPickItem.Name = name;
            editedPickItem.Update();

            // Prevent editing again for now
            this.ulvPickItems.ItemSettings.AllowEdit = Infragistics.Win.DefaultableBoolean.False;
        }
Esempio n. 2
0
        private void bnOK_Click(object sender, EventArgs e)
        {
            string strPickItemName = tbPickItemName.Text.ToString();

            // If the name is blank then it will be invalid
            if (strPickItemName == "")
            {
                MessageBox.Show("Please specify a unique name for this pickitem", "Enter Name", MessageBoxButtons.OK, MessageBoxIcon.Information);
                tbPickItemName.Focus();
                this.DialogResult = DialogResult.None;
                return;
            }

            // Get the picklist so we check it's items
            PickList picklist = m_activeItem.Tag as PickList;

            // Does the specified value duplicate an existing pickitem?
            foreach (PickItem item in picklist)
            {
                if ((item.Name == strPickItemName) && (item.PickItemID != _pickItem.PickItemID))
                {
                    MessageBox.Show(
                        "The specified name matches that of an existing item in this picklist, please specify a unique name for this pickitem",
                        "Duplicate Name",
                        MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    tbPickItemName.Focus();
                    this.DialogResult = DialogResult.None;
                    return;
                }
            }
            // If it's a new pickitem then we need to add it to the parent list also
            if (_pickItem.PickItemID == 0)
            {
                picklist.Add(_pickItem);
            }

            // Update the PickItem in the database
            _pickItem.Name = strPickItemName;
            _pickItem.Update();
        }