private void InitFormSelector()
 {
     if (dataBaseManager == null)
     {
         dataBaseManager = new DataBaseManager();
     }
     frmSelector               = new SelectorForm();
     frmSelector.Title         = Title;
     frmSelector.OutColumn     = OutColumn;
     frmSelector.HideOutColumn = HideOutColumn;
     frmSelector.SelectItem   += new SelectItemHandle(frmSelector_SelectItem);
 }
 void frmSelector_SelectItem(string item)
 {
     if (item == null)
     {
         frmSelector = null;
         return;
     }
     OutValue = item;
     if (ActionType == TextBoxWithSelectorActionType.查询 && Query != null)
     {
         Query(this);
     }
 }
Esempio n. 3
0
        //Precondition: AddressList must be > 0
        //Postcondition: The address selected will be updated with newly specified values
        private void addressToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            if (upv.AddressCount < SelectorForm.MIN_ADDRESSES) //Count of Addresses in the upv must be greater than 0
            {
                MessageBox.Show("Need at least " + SelectorForm.MIN_ADDRESSES + " Address", "Address Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return; // Exit now since can't create valid letter
            }

            SelectorForm Selector = new SelectorForm(upv.AddressList); // The Selector dialog box form
            DialogResult result   = Selector.ShowDialog();             //Show Selector Form as dialog and store result

            AddressForm Editor   = new AddressForm();                  //The Editor dialog box form
            int         addIndex = Selector.Index;                     //local variable to store the index selected in the Editor Form

            Editor.AddressName = upv.AddressAt(addIndex).Name;         //Set Property to the Name of the AddressAt the SelectedIndex
            Editor.Address1    = upv.AddressAt(addIndex).Address1;     //Set Property to the Address1 of the AddressAt the SelectedIndex
            Editor.Address2    = upv.AddressAt(addIndex).Address2;     //Set Property to the Address2 of the AddressAt the SelectedIndex
            Editor.City        = upv.AddressAt(addIndex).City;         //Set Property to the City of the AddressAt the SelectedIndex
            Editor.State       = upv.AddressAt(addIndex).State;        //Set Property to the State of the AddressAt the SelectedIndex
            Editor.ZipText     = $"{upv.AddressAt(addIndex).Zip}";     //Set Property to the Zip of the AddressAt the SelectedIndex


            if (result == DialogResult.OK)                                 //if OK was clicked (Selector Form)
            {
                DialogResult result1 = Editor.ShowDialog();                //Show Editor form as a dialog box
                int          zipResult;                                    //integer holding TryParse result

                if (result1 == DialogResult.OK)                            //if OK was clicked (Editor Form)
                {
                    upv.AddressAt(addIndex).Name     = Editor.AddressName; //set upv Name property to the current value held in the Editor Forms TextBox
                    upv.AddressAt(addIndex).Address1 = Editor.Address1;    //set upv Address1 property to the current value held in the Editor Forms TextBox
                    upv.AddressAt(addIndex).Address2 = Editor.Address2;    //set upv Address2 property to the current value held in the Editor Forms TextBox
                    upv.AddressAt(addIndex).City     = Editor.City;        //set upv City property to the current value held in the Editor Forms TextBox
                    upv.AddressAt(addIndex).State    = Editor.State;       //set upv State property to the current value held in the Editor Forms TextBox

                    if (int.TryParse(Editor.ZipText, out zipResult))       //Try parsing the value in the TextBox, if successful, set the upv Zip property to that value
                    {
                        upv.AddressAt(addIndex).Zip = zipResult;
                    }
                }
                Editor.Dispose();     //dispose of resources
                Selector.Dispose();   //dispose of resources
            }
        }