private object GetValeurControl(Control ctrl, CChampCustom champ, int rowNum)
        {
            object objVal = null;

            if (champ.ListeValeurs.Count > 0)
            {
                objVal = champ.ValueFromDisplay(m_combobox.Text);
            }
            else
            {
                if (ctrl is CheckBox)
                {
                    objVal = ((CheckBox)ctrl).Checked;
                }
                else if (ctrl is DateTimePicker)
                {
                    objVal = ((DateTimePicker)ctrl).Value;
                }
                else if (ctrl is NumericUpDown)
                {
                    objVal = ((NumericUpDown)ctrl).Value;
                }
                else
                {
                    objVal = ctrl.Text;
                }
            }
            //Vérifie que la valeur est correcte

            if (objVal == null)
            {
                objVal = champ.ValeurParDefaut;
            }
            CResultAErreur result = champ.IsCorrectValue(objVal);

            if (!result)
            {
                m_bIsErreur[rowNum] = true;
            }
            else
            {
                m_bIsErreur[rowNum] = false;
            }
            return(objVal);
        }
예제 #2
0
        protected override bool Commit(
            CurrencyManager dataSource,
            int rowNum
            )
        {
            if (m_control != null && m_control.Visible)
            {
                object       objVal = null;
                CChampCustom champ  = ((CChampCustom)m_listeChamps[rowNum]);
                if (champ.ListeValeurs.Count > 0)
                {
                    objVal = champ.ValueFromDisplay(m_combobox.Text);
                }
                else
                {
                    objVal = GetValeurControle(m_control);
                };
                //Vérifie que la valeur est correcte

                if (objVal == null)
                {
                    objVal = champ.ValeurParDefaut;
                }
                CResultAErreur result = champ.IsCorrectValue(objVal);
                if (!result)
                {
                    m_bIsErreur[rowNum] = true;
                }
                else
                {
                    m_bIsErreur[rowNum] = false;
                }
                SetColumnValueAtRow(dataSource, rowNum, objVal);
            }
            m_control.Visible = false;
            return(true);
        }