private void butOK_Click(object sender, EventArgs e)
 {
     if (textBoxControlDescript.Text.ToString() == "" ||
         comboType.SelectedIndex == -1)
     {
         MsgBox.Show(this, "Please make sure that the Description and Type are not blank");
         return;
     }
     if (!Regex.IsMatch(textBoxControlDescript.Text, "^[a-zA-Z_0-9 ]*$"))
     {
         MsgBox.Show(this, "The description can only contain letters, numbers, underscore, and space.");
         return;
     }
     ControlCur.Descript       = textBoxControlDescript.Text.ToString();
     ControlCur.ControlLabel   = textBoxControlLabel.Text.ToString();
     ControlCur.ControlType    = comboType.SelectedItem.ToString();
     ControlCur.ControlOptions = textOptions.Text;
     if (IsNew)
     {
         AutoNoteControls.Insert(ControlCur);
     }
     else
     {
         AutoNoteControls.Update(ControlCur);
     }
     DialogResult = DialogResult.OK;
 }
Exemple #2
0
        private void butOK_Click(object sender, EventArgs e)
        {
            //bool IsUsed=AutoNoteControls.ControlNameUsed(textBoxControlDescript.Text.ToString(), textBoxDescriptControl.Text.ToString());
            //if (IsUsed==true) {
            //	MessageBox.Show(Lan.g(this, "This name is already used please choose a different name"));
            //	return;
            //}
            if (textBoxControlDescript.Text.ToString() == "" || comboBoxControlType.SelectedIndex == -1)
            {
                MessageBox.Show(Lan.g(this, "Please make sure that the Name and Type field are not blank"));
                return;
            }
            //converts the items in ListBoxControlOptions into a string with a comma between each option
            string ControlOptions = "";

            for (int i = 0; i < listBoxControlOptions.Items.Count; i++)
            {
                ControlOptions = ControlOptions + listBoxControlOptions.Items[i].ToString() + ",";
            }
            ControlCur.ControlType    = comboBoxControlType.SelectedItem.ToString();
            ControlCur.Descript       = textBoxControlDescript.Text.ToString();
            ControlCur.ControlLabel   = textBoxControlLabel.Text.ToString();
            ControlCur.PrefaceText    = textBoxTextPreface.Text.ToString();
            ControlCur.MultiLineText  = textBoxMultiLineText.Text.ToString();
            ControlCur.ControlOptions = ControlOptions;
            if (IsNew)
            {
                AutoNoteControls.Insert(ControlCur);
            }
            else
            {
                AutoNoteControls.ControlUpdate(ControlCur);
            }
            this.DialogResult = DialogResult.OK;
            this.Close();
        }