Exemplo n.º 1
0
        /// <summary>
        /// 验证Form的ViewModel
        /// </summary>
        /// <param name="form">BaseForm</param>
        /// <returns></returns>
        public static bool ValidForm(BaseForm form)
        {
            bool validFlag = true;
            List <ValidResult> validList = ValidationFunc.ValidAll(form.Model);

            if (validList == null)
            {
                MessageBox.Show("验证内部错误!");
                validFlag = false;
            }
            else
            {
                foreach (ValidResult ret in validList)
                {
                    if (ret.Result)
                    {
                        //消除验证结果信息
                        RemoveValidLabel(form, ret);
                    }
                    else
                    {
                        //添加验证结果信息
                        CreateValidLabel(form, ret);
                        validFlag = false;
                    }
                }
            }
            return(validFlag);
        }
 protected void FireOkClicked(EventArgs e)
 {
     if (ValidationFunc == null || ValidationFunc.Invoke(CalendarDate.Date))
     {
         Date = CalendarDate.Date;
         AfterAction?.Invoke();
     }
 }