예제 #1
0
        /// <summary>
        /// 校验单个控件
        /// </summary>
        /// <param name="control"></param>
        /// <returns></returns>
        private bool ValidateSingleControl(Control control)
        {
            if (control.Visible == false)
            {
                return(true);
            }

            if (control is XEditBox)
            {
                XEditBox editBox = control as XEditBox;
                if (editBox.Visible == false)
                {
                    return(true);
                }
                if (!editBox.IsAllowEmpty && editBox.Text.Trim() == string.Empty)
                {
                    this.m_ErrorProvider.SetError(control, "不能为空!");
                    return(false);
                }
            }
            else if (control is XNumberEditBox)
            {
                XNumberEditBox numberEditBox = control as XNumberEditBox;
                if (numberEditBox.Visible == false)
                {
                    return(true);
                }
                double value = XHelper.GetDouble(numberEditBox.Value);
                if (!numberEditBox.IsAllowZero && value == 0)
                {
                    this.m_ErrorProvider.SetError(control, "不能为0!");
                    return(false);
                }
                else if (!numberEditBox.IsAllowLessThanZero && value < 0)
                {
                    this.m_ErrorProvider.SetError(control, "不能小于0!");
                    return(false);
                }
            }
            else if (control is XCombobox)
            {
                XCombobox comboBox = control as XCombobox;
                if (!comboBox.IsAllowEmpty && comboBox.Text.Trim() == string.Empty)
                {
                    this.m_ErrorProvider.SetError(control, "不能为空!");
                    return(false);
                }
            }

            return(true);
        }
예제 #2
0
 /// <summary>
 /// 初始化添加窗体
 /// </summary>
 protected virtual void InitAddForm()
 {
     foreach (Control contorl in this.pnlEdit.Controls)
     {
         contorl.Enabled = true;
         if (contorl is XEditBox)
         {
             if (contorl.Name != "txtParentNode")
             {
                 contorl.Text = string.Empty;
             }
         }
         else if (contorl is XCheckBox)
         {
             XCheckBox checkBox = contorl as XCheckBox;
             checkBox.Checked = false;
         }
         else if (contorl is XNumberEditBox)
         {
             XNumberEditBox numberEditBox = contorl as XNumberEditBox;
             numberEditBox.Value = 0;
         }
     }
 }