예제 #1
0
 public void InitUpdate( string ValueField, String GroupTableName, int[] RootID, String IDField, String ParentIDField,
     string[] VisibleFields, string[] Captions, string GenName,
     object[] InputColumnType, FieldNameCheck[] Rules)
 {
     plGroupCatNew1.setPopupControl(popupContainerEdit1);
     plGroupCatNew1.Init(GroupElementType.CHOICE_N_ADD, GroupTableName, RootID, IDField,
                         ParentIDField, VisibleFields, Captions, GenName, InputColumnType, Rules);
     this.ValueField = ValueField;
 }
예제 #2
0
 public FieldNameCheck[] GetRuleDM_NHAN_VIEN(object param)
 {
     FieldNameCheck[] checkArray2 = new FieldNameCheck[6];
     object[] other = new object[2];
     other[1] = 200;
     checkArray2[0] = new FieldNameCheck("NAME", new CheckType[] { CheckType.Required, CheckType.RequireMaxLength }, "Họ tên nhân viên", other);
     checkArray2[1] = new FieldNameCheck("CMND", new CheckType[] { CheckType.OptionMaxLength }, "CMND", new object[] { 100 });
     checkArray2[2] = new FieldNameCheck("DIEN_THOAI", new CheckType[] { CheckType.OptionMaxLength }, "Điện thoại", new object[] { 100 });
     checkArray2[3] = new FieldNameCheck("DIA_CHI", new CheckType[] { CheckType.OptionMaxLength }, "Địa chỉ", new object[] { 200 });
     checkArray2[4] = new FieldNameCheck("DEPARTMENT_ID", new CheckType[] { CheckType.Required }, "Phòng ban",null);
     other = new object[2];
     other[0] = 200;
     checkArray2[5] = new FieldNameCheck("EMAIL", new CheckType[] { CheckType.OptionMaxLength, CheckType.OptionEmail }, "Email", other);
     return checkArray2;
 }
예제 #3
0
 /// <summary>
 /// Phân quyền  : Không
 /// VISIBLE_BIT : Không hỗ trợ
 /// Unique      : N Field
 /// RootID      : Không
 /// </summary>
 public void Init(GroupElementType type, 
     String GroupTableName, String IDField, String ParentIDField,
     string[] VisibleFields, string[] Captions, string GenName,
     object[] InputColumnType, FieldNameCheck[] Rules)
 {
     Init(type, GroupTableName, null, IDField, ParentIDField, VisibleFields, Captions, GenName, InputColumnType, Rules);
 }
예제 #4
0
 /// <summary>
 /// Phân quyền  : Không
 /// VISIBLE_BIT : Không hỗ trợ
 /// Unique      : 1 "NAME" Field
 /// RootID      : Có
 /// </summary>
 public void Init(GroupElementType type, 
     String GroupTableName, int[] RootID, String IDField, String ParentIDField,
     string[] VisibleFields, string[] Captions, string GenName,
     object[] InputColumnType, FieldNameCheck[] Rules)
 {
     Init(type, GroupTableName, RootID, IDField, ParentIDField,
                         VisibleFields, Captions, GenName,
                         InputColumnType, Rules,
                         new string[] { "NAME" }, new string[] { "Tên" });
 }
예제 #5
0
 /// <summary>
 /// Phân quyền  : Không
 /// VISIBLE_BIT : Không hỗ trợ
 /// Unique      : N Field
 /// RootID      : Có
 /// </summary>
 public void Init(GroupElementType type, 
     String GroupTableName, int[] RootID, String IDField, String ParentIDField,
     string[] VisibleFields, string[] Captions, string GenName,
     object[] InputColumnType, FieldNameCheck[] Rules,
     string[] UniqueFields, string[] Subjects)
 {
     Init(type, GroupTableName, RootID, IDField, ParentIDField,
                         VisibleFields, Captions, GenName,
                         InputColumnType, Rules,
                         UniqueFields, Subjects, false);
 }
예제 #6
0
        /// <summary>
        /// Phân quyền  : Không
        /// VISIBLE_BIT : Có
        /// Unique      : N Field
        /// RootID      : Có
        /// </summary>
        public void Init(GroupElementType type,
            String GroupTableName, int[] RootID, String IDField, String ParentIDField,
            string[] VisibleFields, string[] Captions, string GenName,
            object[] InputColumnType, FieldNameCheck[] Rules,
            string[] UniqueFields, string[] Subjects, bool IsVisibleBit)
        {
            this.type = type;
            UpdateItemBtn(this.type);
            this.GroupTableName = GroupTableName;
            this.IDField = IDField;
            this.ParentIDField = ParentIDField;
            this.GenName = GenName;
            this.VisibleFields = VisibleFields;
            this.TreeList_1._BuildTree(this.GroupTableName, RootID, IDField, ParentIDField, VisibleFields, Captions, InputColumnType);
            this.TreeList_1.OptionsView.ShowColumns = true;
            ((DataTable)this.TreeList_1.DataSource).PrimaryKey =
                        new DataColumn[] { ((DataTable)this.TreeList_1.DataSource).Columns[IDField] };
            this.TreeList_1.ExpandAll();
            this.Rules = Rules;
            this.UniqueFields = UniqueFields;
            this.Subjects = Subjects;
            this.IsVisibleBit = IsVisibleBit;

            //HelpTree.ShowFilter(this.TreeList_1, true, IDField, ParentIDField, FilterConditionEnum.NotContains);
        }
예제 #7
0
        //PHUOCNT TODO
        public static void add(Dictionary<string, XlsCellCheck> xlsCellChecks, FieldNameCheck[] fieldNameChecks)
        {
            try
            {

                //Hàm này sẽ chuyển các FieldNameCheck thành dạng XlsCellCheck.

                //Khanhdtn: Hàm này chỉ chuyển tương đối, vì trong excel mỗi field chỉ được kiểm tra theo một nội dung kiểm tra (ko tính require),
                //còn FieldNameCheck thì có thể kiểm tra nhiều kiểu --> Lấy cái CheckType (ko tính Require) cuối cùng để chuyển";

                if (fieldNameChecks != null)
                {
                    string mss = "";
                    for (int i = 0; i < fieldNameChecks.Length; i++)
                    {
                        if (xlsCellChecks.ContainsKey(fieldNameChecks[i].FieldName)) continue;
                        //Chuyển qua được
                        XlsCellCheck xlsCheck = new XlsCellCheck();
                        xlsCheck.AlertType = XlDVAlertStyle.xlValidAlertStop;
                        xlsCheck.ErrTitle = "Thông báo";
                        xlsCheck.ShowError = false;
                        xlsCheck.Require = false;
                        xlsCheck.ValidationType = XlDVType.xlValidateInputOnly;//Giá trị mặc định
                        for (int j = 0; j < fieldNameChecks[i].Types.Length; j++)
                        {
                            #region
                            mss = "";
                            switch (fieldNameChecks[i].Types[j])
                            {
                                case CheckType.DateALessB:
                                    xlsCheck.ValidationType = XlDVType.xlValidateDate;
                                    xlsCheck.OperatorValid = XlFormatConditionOperator.xlLess;
                                    mss = string.Format("ngày nhỏ hơn {1}", fieldNameChecks[i].Params[j]);
                                    xlsCheck.Value1 = fieldNameChecks[i].Params[j];
                                    break;
                                case CheckType.DateALessEqualB:
                                    xlsCheck.ValidationType = XlDVType.xlValidateDate;
                                    xlsCheck.OperatorValid = XlFormatConditionOperator.xlLessEqual;
                                    mss = string.Format("ngày nhỏ hơn hoặc bằng {1}", fieldNameChecks[i].Params[j]);
                                    xlsCheck.Value1 = fieldNameChecks[i].Params[j];
                                    break;
                                case CheckType.DecALessB:
                                    xlsCheck.ValidationType = XlDVType.xlValidateDecimal;
                                    xlsCheck.OperatorValid = XlFormatConditionOperator.xlLess;
                                    mss = string.Format("là số nhỏ hơn {1}", fieldNameChecks[i].Params[j]);
                                    xlsCheck.Value1 = fieldNameChecks[i].Params[j];
                                    //xlsCheck.Value3=? (số thập phân)
                                    break;
                                case CheckType.DecALessEqualB:
                                    xlsCheck.ValidationType = XlDVType.xlValidateDecimal;
                                    xlsCheck.OperatorValid = XlFormatConditionOperator.xlLessEqual;
                                    mss = string.Format("là số nhỏ hơn hoặc bằng {1}", fieldNameChecks[i].Params[j]);
                                    xlsCheck.Value1 = fieldNameChecks[i].Params[j];
                                    //xlsCheck.Value3=? (số thập phân)
                                    break;
                                case CheckType.DecGreater0:
                                    xlsCheck.ValidationType = XlDVType.xlValidateDecimal;
                                    xlsCheck.OperatorValid = XlFormatConditionOperator.xlGreater;
                                    mss = "là số lớn hơn 0";
                                    xlsCheck.Require = true;
                                    xlsCheck.Value1 = 0;
                                    xlsCheck.Value3 = (fieldNameChecks[i].Params[j] != null ? HelpNumber.ParseInt32(fieldNameChecks[i].Params[j]) : 0);

                                    break;
                                case CheckType.DecGreaterEqual0:
                                    xlsCheck.ValidationType = XlDVType.xlValidateDecimal;
                                    xlsCheck.OperatorValid = XlFormatConditionOperator.xlGreaterEqual;
                                    mss = "là số lớn hơn hoặc bằng 0";
                                    xlsCheck.Value1 = 0;
                                    xlsCheck.Value3 = (fieldNameChecks[i].Params[j] != null ? HelpNumber.ParseInt32(fieldNameChecks[i].Params[j]) : 0);

                                    break;
                                case CheckType.DecGreaterZero:
                                    xlsCheck.ValidationType = XlDVType.xlValidateDecimal;
                                    xlsCheck.OperatorValid = XlFormatConditionOperator.xlGreater;
                                    mss = "là số lớn hơn 0";
                                    xlsCheck.Require = true;
                                    xlsCheck.Value1 = 0;
                                    xlsCheck.Value3 = (fieldNameChecks[i].Params[j] != null ? HelpNumber.ParseInt32(fieldNameChecks[i].Params[j]) : 0);

                                    break;
                                case CheckType.IntALessB:
                                    xlsCheck.ValidationType = XlDVType.xlValidateDecimal;
                                    xlsCheck.OperatorValid = XlFormatConditionOperator.xlLess;
                                    mss = "là số nhỏ hơn 0";
                                    xlsCheck.Value1 = 0;
                                    xlsCheck.Value3 = 0;
                                    break;
                                case CheckType.IntALessEqualB:
                                    xlsCheck.ValidationType = XlDVType.xlValidateDecimal;
                                    xlsCheck.OperatorValid = XlFormatConditionOperator.xlLessEqual;
                                    mss = "là số nhỏ hơn hoặc bằng 0";
                                    xlsCheck.Value1 = 0;
                                    xlsCheck.Value3 = 0;
                                    break;
                                case CheckType.IntGreater0:
                                    xlsCheck.ValidationType = XlDVType.xlValidateDecimal;
                                    xlsCheck.OperatorValid = XlFormatConditionOperator.xlGreater;
                                    mss = "là số lớn hơn 0";
                                    xlsCheck.Value1 = 0;
                                    xlsCheck.Value3 = 0;
                                    xlsCheck.Require = true;
                                    break;
                                case CheckType.IntGreaterEqual0:
                                    xlsCheck.ValidationType = XlDVType.xlValidateDecimal;
                                    xlsCheck.OperatorValid = XlFormatConditionOperator.xlGreaterEqual;
                                    mss = "là số lớn hơn hoặc bằng 0";
                                    xlsCheck.Value1 = 0;
                                    xlsCheck.Value3 = 0;
                                    break;
                                case CheckType.IntGreaterZero:
                                    xlsCheck.ValidationType = XlDVType.xlValidateDecimal;
                                    xlsCheck.OperatorValid = XlFormatConditionOperator.xlGreater;
                                    mss = "là số lớn hơn 0";
                                    xlsCheck.Value1 = 0;
                                    xlsCheck.Value3 = 0;
                                    xlsCheck.Require = true;
                                    break;
                                case CheckType.OptionDate:
                                    xlsCheck.ValidationType = XlDVType.xlValidateDate;
                                    xlsCheck.OperatorValid = null;
                                    mss = "là dạng ngày";
                                    break;
                                case CheckType.OptionEmail:
                                    xlsCheck.ValidationType = XlDVType.xlValidateCustom;
                                    xlsCheck.OperatorValid = null;
                                    mss = "đúng dạng email";
                                    xlsCheck.Value2 = @"\S+@\S+\.\S+";
                                    //Chưa chuyển được kiểu tương ứng
                                    break;
                                case CheckType.OptionMaxLength:
                                    xlsCheck.ValidationType = xlsCheck.ValidationType | XlDVType.xlValidateTextLength;
                                    xlsCheck.OperatorValid = XlFormatConditionOperator.xlLessEqual;
                                    mss = string.Format("có số ký tự nhỏ hơn hoặc bằng {0}", fieldNameChecks[i].Params[j]);
                                    xlsCheck.Value1 = fieldNameChecks[i].Params[j];
                                    break;
                                case CheckType.Required:
                                    xlsCheck.Require = true;
                                    mss = "";
                                    break;
                                case CheckType.RequireDate:
                                    xlsCheck.ValidationType = XlDVType.xlValidateDate;
                                    xlsCheck.OperatorValid = null;
                                    mss = "là dạng ngày";
                                    xlsCheck.Require = true;
                                    break;
                                case CheckType.RequiredID:
                                    xlsCheck.ValidationType = XlDVType.xlValidateDecimal;
                                    xlsCheck.OperatorValid = XlFormatConditionOperator.xlGreater;
                                    mss = "là số lớn hơn 0";
                                    xlsCheck.Value1 = 0;
                                    xlsCheck.Value3 = 0;
                                    xlsCheck.Require = true;
                                    break;
                                case CheckType.RequireEmail:
                                    xlsCheck.Require = true;
                                    xlsCheck.ValidationType = XlDVType.xlValidateCustom;
                                    xlsCheck.OperatorValid = null;
                                    mss = "đúng dạng email";
                                    xlsCheck.Value2 = @"\S+@\S+\.\S+";
                                    break;
                                case CheckType.RequireMaxLength:
                                    xlsCheck.ValidationType = XlDVType.xlValidateTextLength;
                                    xlsCheck.OperatorValid = XlFormatConditionOperator.xlLessEqual;
                                    mss = string.Format("có số ký tự nhỏ hơn hoặc bằng {0}", fieldNameChecks[i].Params[j]);
                                    xlsCheck.Value1 = fieldNameChecks[i].Params[j];
                                    break;
                            }
                            #endregion

                            if (fieldNameChecks[i].Subject != null)
                            {
                                xlsCheck.ErrMesage = (string.Format("Vui lòng vào thông tin \"{0}\"", fieldNameChecks[i].Subject) + (xlsCheck.Require ? " và " : " ") + mss).Trim();
                            }
                            else
                            {
                                xlsCheck.ErrMesage = fieldNameChecks[i].ErrMsgs[j];
                            }
                        }
                        if (xlsCheck.Require && xlsCheck.ValidationType == XlDVType.xlValidateInputOnly)
                        {
                            xlsCheck.ValidationType = XlDVType.xlValidateTextLength;
                            xlsCheck.OperatorValid = XlFormatConditionOperator.xlGreater;
                            xlsCheck.Value1 = 0;
                        }
                        xlsCellChecks.Add(fieldNameChecks[i].FieldName, xlsCheck);
                    }
                }
            }
            catch (Exception ex)
            {

                PLException.AddException(ex);
                HelpMsgBox.ShowNotificationMessage("Thông tin cấu hình FieldNamCheck không đúng!");
            }
        }
예제 #8
0
        /// <summary>Kiểm tra và đánh dấu lỗi
        /// </summary>
        /// <returns></returns>
        public static bool ValidateRecord(VGridControl vgrid, FieldNameCheck[] CheckList)
        {
            if (CheckList == null) return true;
            bool flag = true;
            for (int i = 0; i < CheckList.Length; i++)
            {
                string FieldName = CheckList[i].FieldName;
                string Data = null;
                BaseRow br = vgrid.GetRowByFieldName(FieldName);
                Data = vgrid.GetCellDisplayText(br, 0);
                for (int j = 0; j < CheckList[i].Types.Length; j++)
                {
                    string ErrMsg = "";
                    if (CheckList[i].Subject != null)
                        ErrMsg = GetErrMsg(CheckList[i].Types[j], CheckList[i].Subject);
                    else
                        ErrMsg = CheckList[i].ErrMsgs[j];
                    switch (CheckList[i].Types[j])
                    {
                        #region 1. Số thực
                        case CheckType.DecGreaterZero:
                            if (HelpIsCheck.isDecGreater0(Data))
                            {
                                ClearError(vgrid, FieldName);
                            }
                            else
                            {
                                SetError(vgrid, FieldName, ErrMsg);
                                flag = false;
                            }
                            break;
                        case CheckType.DecGreater0:
                            if (HelpIsCheck.isDecGreater0(Data))
                            {
                                ClearError(vgrid, FieldName);
                            }
                            else
                            {
                                SetError(vgrid, FieldName, ErrMsg);
                                flag = false;
                            }
                            break;
                        case CheckType.DecGreaterEqual0:
                            if (HelpIsCheck.isDecGreaterEqual0(Data))
                            {
                                ClearError(vgrid, FieldName);
                            }
                            else
                            {
                                SetError(vgrid, FieldName, ErrMsg);
                                flag = false;
                            }
                            break;
                        #endregion
                        #region 1. Số nguyên
                        case CheckType.IntGreaterZero:
                            if (HelpIsCheck.isIntGreater0(Data))
                            {
                                ClearError(vgrid, FieldName);
                            }
                            else
                            {
                                SetError(vgrid, FieldName, ErrMsg);
                                flag = false;
                            }
                            break;
                        case CheckType.IntGreater0:
                            if (HelpIsCheck.isIntGreater0(Data))
                            {
                                ClearError(vgrid, FieldName);
                            }
                            else
                            {
                                SetError(vgrid, FieldName, ErrMsg);
                                flag = false;
                            }
                            break;
                        case CheckType.IntGreaterEqual0:
                            if (HelpIsCheck.isIntGreaterEqual0(Data))
                            {
                                ClearError(vgrid, FieldName);
                            }
                            else
                            {
                                SetError(vgrid, FieldName, ErrMsg);
                                flag = false;
                            }
                            break;
                        #endregion
                        #region 1. Email
                        case CheckType.RequireEmail:
                            if (Data != null && Data != "" && HelpIsCheck.isValidEmail(Data))
                            {
                                ClearError(vgrid, FieldName);
                            }
                            else
                            {
                                SetError(vgrid, FieldName, ErrMsg);
                                flag = false;
                            }
                            break;
                        case CheckType.OptionEmail:
                            if (Data == null || Data == "" || HelpIsCheck.isValidEmail(Data))
                            {
                                ClearError(vgrid, FieldName);
                            }
                            else
                            {
                                SetError(vgrid, FieldName, ErrMsg);
                                flag = false;
                            }
                            break;
                        #endregion
                        #region 1. Chuỗi
                        case CheckType.RequireMaxLength:
                            if (Data != null && Data != "" && HelpIsCheck.IsMaxLength(Data, (int)CheckList[i].Params[j]))
                            {
                                ClearError(vgrid, FieldName);
                            }
                            else
                            {
                                SetError(vgrid, FieldName, ErrMsg);
                                flag = false;
                            }
                            break;
                        case CheckType.OptionMaxLength:
                            if (Data == null || Data == "" || HelpIsCheck.IsMaxLength(Data, (int)CheckList[i].Params[j]))
                            {
                                ClearError(vgrid, FieldName);
                            }
                            else
                            {
                                SetError(vgrid, FieldName, ErrMsg);
                                flag = false;
                            }
                            break;
                        #endregion
                        #region 1. Date
                        case CheckType.RequireDate:
                            if (Data != null && Data != "" && br.Properties.Value is DateTime && !HelpIsCheck.isBlankDate((DateTime)br.Properties.Value))
                            {
                                ClearError(vgrid, FieldName);
                            }
                            else
                            {
                                SetError(vgrid, FieldName, ErrMsg);
                                flag = false;
                            }
                            break;
                        case CheckType.OptionDate:
                            if (Data == null || Data == "" || br.Properties.Value is DateTime)
                            {
                                ClearError(vgrid, FieldName);
                            }
                            else
                            {
                                SetError(vgrid, FieldName, ErrMsg);
                                flag = false;
                            }
                            break;
                        case CheckType.DateALessB:
                            DateTime B;
                            if (CheckList[i].Params[j] is DateTime)
                                B = (DateTime)CheckList[i].Params[j];
                            else
                                B = (DateTime)vgrid.GetRowByFieldName(CheckList[i].Params[j].ToString()).Properties.Value;
                            if (HelpIsCheck.IsALessB((DateTime)br.Properties.Value, B))
                            {
                                ClearError(vgrid, FieldName);
                            }
                            else
                            {
                                SetError(vgrid, FieldName, ErrMsg);
                                flag = false;
                            }
                            break;
                        case CheckType.DateALessEqualB:
                            DateTime C;
                            if (CheckList[i].Params[j] is DateTime)
                                C = (DateTime)CheckList[i].Params[j];
                            else
                                C = (DateTime)vgrid.GetRowByFieldName(CheckList[i].Params[j].ToString()).Properties.Value;
                            if (HelpIsCheck.IsALessEqualB((DateTime)br.Properties.Value, C))
                            {
                                ClearError(vgrid, FieldName);
                            }
                            else
                            {
                                SetError(vgrid, FieldName, ErrMsg);
                                flag = false;
                            }
                            break;
                        #endregion
                        #region 1. Danh mục
                        case CheckType.RequiredID:
                            long ID = HelpNumber.DecimalToInt64(Data);
                            if (ID > 0)
                            {
                                ClearError(vgrid, FieldName);
                            }
                            else
                            {
                                SetError(vgrid, FieldName, ErrMsg);
                                flag = false;
                            }
                            break;
                        #endregion
                        #region 1. Other
                        case CheckType.Required:
                            if (Data != null && Data != "" && Data != "-1")
                            {
                                ClearError(vgrid, FieldName);
                            }
                            else
                            {
                                //PHUOCNT TODO Kiem tra lai
                                if (vgrid.GetCellValue(br, 0) == null)
                                {
                                    SetError(vgrid, FieldName, ErrMsg);
                                    flag = false;
                                }
                                else
                                {
                                    ClearError(vgrid, FieldName);
                                }
                            }
                            break;
                        #endregion
                    }

                    if (vgrid.HasRowErrors) break;
                }
            }
            return flag;
        }
예제 #9
0
        /// <summary>Kiểm tra và đánh dấu lỗi
        /// </summary>
        /// <returns></returns>
        public static bool ValidateRow(GridView Grid, DataRow Row, FieldNameCheck[] CheckList)
        {
            if (CheckList == null) return true;
            bool flag = true;
            for (int i = 0; i < CheckList.Length; i++)
            {
                string FieldName = CheckList[i].FieldName;
                string Data = null;
                if (Row[FieldName] != null) Data = Row[FieldName].ToString();
                for (int j = 0; j < CheckList[i].Types.Length; j++)
                {
                    string ErrMsg = "";
                    if (CheckList[i].Subject != null)
                        ErrMsg = GetErrMsg(CheckList[i].Types[j], CheckList[i].Subject);
                    else
                        ErrMsg = CheckList[i].ErrMsgs[j];
                    switch (CheckList[i].Types[j])
                    {
                        #region 1. Số thực
                        case CheckType.DecGreaterZero:
                            if (HelpIsCheck.isDecGreater0(Data))
                            {
                                ClearError(Row, FieldName);
                            }
                            else
                            {
                                SetError(Row, FieldName, ErrMsg); flag = false;
                            }
                            break;
                        case CheckType.DecGreater0:
                            if (HelpIsCheck.isDecGreater0(Data))
                            {
                                ClearError(Row, FieldName);
                            }
                            else
                            {
                                SetError(Row, FieldName, ErrMsg); flag = false;
                            }
                            break;
                        case CheckType.DecGreaterEqual0:
                            if (HelpIsCheck.isDecGreaterEqual0(Data))
                            {
                                ClearError(Row, FieldName);
                            }
                            else
                            {
                                SetError(Row, FieldName, ErrMsg); flag = false;
                            }
                            break;
                        #endregion
                        #region 1. Số nguyên
                        case CheckType.IntGreaterZero:
                            if (HelpIsCheck.isIntGreater0(Data))
                            {
                                ClearError(Row, FieldName);
                            }
                            else
                            {
                                SetError(Row, FieldName, ErrMsg);
                                flag = false;
                            }
                            break;
                        case CheckType.IntGreater0:
                            if (HelpIsCheck.isIntGreater0(Data))
                            {
                                ClearError(Row, FieldName);
                            }
                            else
                            {
                                SetError(Row, FieldName, ErrMsg);
                                flag = false;
                            }
                            break;
                        case CheckType.IntGreaterEqual0:
                            if (HelpIsCheck.isIntGreaterEqual0(Data))
                            {
                                ClearError(Row, FieldName);
                            }
                            else
                            {
                                SetError(Row, FieldName, ErrMsg);
                                flag = false;
                            }
                            break;
                        #endregion
                        #region 1. Email
                        case CheckType.RequireEmail:
                            if (Data != null && Data != "" && HelpIsCheck.isValidEmail(Data))
                            {
                                ClearError(Row, FieldName);
                            }
                            else
                            {
                                SetError(Row, FieldName, ErrMsg);
                                flag = false;
                            }
                            break;
                        case CheckType.OptionEmail:
                            if (Data == null || Data == "" || HelpIsCheck.isValidEmail(Data))
                            {
                                ClearError(Row, FieldName);
                            }
                            else
                            {
                                SetError(Row, FieldName, ErrMsg);
                                flag = false;
                            }
                            break;
                        #endregion
                        #region 1. Chuỗi
                        case CheckType.RequireMaxLength:
                            if (Data != null && Data != "" && HelpIsCheck.IsMaxLength(Data, (int)CheckList[i].Params[j]))
                            {
                                ClearError(Row, FieldName);
                            }
                            else
                            {
                                if (Data == String.Empty) ErrMsg = GetErrMsg(CheckType.Required, CheckList[i].Subject);
                                SetError(Row, FieldName, ErrMsg);
                                flag = false;
                            }
                            break;
                        case CheckType.OptionMaxLength:
                            if (Data == null || Data == "" || HelpIsCheck.IsMaxLength(Data, (int)CheckList[i].Params[j]))
                            {
                                ClearError(Row, FieldName);
                            }
                            else
                            {
                                SetError(Row, FieldName, ErrMsg);
                                flag = false;
                            }
                            break;
                        #endregion
                        #region 1. Date
                        case CheckType.RequireDate:
                            if (Data != null && Data != "" && Row[FieldName] is DateTime && !HelpIsCheck.isBlankDate((DateTime)Row[FieldName]))
                            {
                                ClearError(Row, FieldName);
                            }
                            else
                            {
                                if (Data == String.Empty) ErrMsg = GetErrMsg(CheckType.Required, CheckList[i].Subject);
                                SetError(Row, FieldName, ErrMsg);
                                flag = false;
                            }
                            break;
                        case CheckType.OptionDate:
                            if (Data == null || Data == "" || Row[FieldName] is DateTime)
                            {
                                ClearError(Row, FieldName);
                            }
                            else
                            {
                                SetError(Row, FieldName, ErrMsg);
                                flag = false;
                            }
                            break;
                        case CheckType.DateALessB:
                            DateTime B;
                            if (CheckList[i].Params[j] is DateTime) B = (DateTime)CheckList[i].Params[j];
                            else B = (DateTime)Row[CheckList[i].Params[j].ToString()];
                            if (HelpIsCheck.IsALessB((DateTime)Row[FieldName], B))
                            {
                                ClearError(Row, FieldName);
                            }
                            else
                            {
                                SetError(Row, FieldName, ErrMsg);
                                flag = false;
                            }
                            break;
                        case CheckType.DateALessEqualB:
                            DateTime C;
                            if (CheckList[i].Params[j] is DateTime) C = (DateTime)CheckList[i].Params[j];
                            else C = (DateTime)Row[CheckList[i].Params[j].ToString()];
                            if (HelpIsCheck.IsALessEqualB((DateTime)Row[FieldName], C))
                            {
                                ClearError(Row, FieldName);
                            }
                            else
                            {
                                SetError(Row, FieldName, ErrMsg);
                                flag = false;
                            }
                            break;
                        #endregion
                        #region 1. Danh mục
                        case CheckType.RequiredID:
                            long ID = HelpNumber.DecimalToInt64(Data);
                            if (ID > 0)
                            {
                                ClearError(Row, FieldName);
                            }
                            else
                            {
                                SetError(Row, FieldName, ErrMsg);
                                flag = false;
                            }
                            break;
                        #endregion
                        #region 1. Other
                        case CheckType.Required:
                            if (Data != null && Data != "" && Data != "-1")
                            {
                                ClearError(Row, FieldName);
                            }
                            else
                            {
                                SetError(Row, FieldName, ErrMsg);
                                flag = false;
                            }
                            break;
                        #endregion
                    }

                    if (Row.HasErrors) break;
                }
            }
            return flag;
        }
예제 #10
0
 public static bool ValidateGrid(GridView Grid, FieldNameCheck[] CheckList)
 {
     bool flag = true;
     DataView view = (DataView)Grid.DataSource;
     for (int i = 0; i < view.DataViewManager.DataSet.Tables[0].Rows.Count; i++)
     {
         if (view.DataViewManager.DataSet.Tables[0].Rows[i].RowState != DataRowState.Deleted)
         {
             if (!ValidateRow(Grid, view.DataViewManager.DataSet.Tables[0].Rows[i], CheckList))
                 flag = false;
         }
     }
     return flag;
 }
예제 #11
0
 /// <summary>Kiểm tra và đánh dấu lỗi
 /// </summary>
 /// <returns></returns>
 public static bool ValidateRow(GridView grid, DataRow row, FieldNameCheck[] checkList)
 {
     return GridValidation.ValidateRow(grid, row, checkList);
 }
예제 #12
0
 /// <summary>Kiểm tra trên toàn grid
 /// </summary>
 public static bool ValidateGrid(GridView grid, FieldNameCheck[] checkList)
 {
     return GridValidation.ValidateGrid(grid, checkList);
 }
        public void InitUpdate(TreeList treeList, String GroupTableName,DataTable dtSource, int[] RootID, String IDField, String ParentIDField,
            string[] VisibleFields, string[] Captions, string GenName,
            object[] InputColumnType, FieldNameCheck[] Rules, string columnField, string getField, string FilterField)
        {
            plGroupCatNew1.Init(GroupElementType.CHOICE_N_ADD, GroupTableName, RootID, IDField,
                                ParentIDField, VisibleFields, Captions, GenName, InputColumnType, Rules);
            this.ValueField = getField;
            this.FilterField = FilterField;
            AddCondition();

            if (!dtSource.Columns.Contains(columnField + getField))
            {
                dtSource.Columns.Add(new DataColumn(columnField + getField));
                SetValueTable(ref dtSource, columnField, columnField + getField, GroupTableName, "ID", getField);
                treeList.DataSource = dtSource;
            }
            long idValue;
            treeList.CellValueChanging += delegate(object sender, DevExpress.XtraTreeList.CellValueChangedEventArgs e)
            {
                if (e.Column.FieldName.Equals(columnField + getField))
                {
                    idValue = _getSelectedID();
                    DataRow row = ((DataRowView)treeList.GetDataRecordByNode(e.Node)).Row;
                    row[columnField] = idValue;
                    row[columnField + getField] = e.Value;
                }
            };
        }
        public void InitUpdate(GridView gridView, String GroupTableName, int[] RootID, String IDField, String ParentIDField,
            string[] VisibleFields, string[] Captions, string GenName,
            object[] InputColumnType, FieldNameCheck[] Rules,string columnField,string getField, string FilterField)
        {
            plGroupCatNew1.Init(GroupElementType.CHOICE_N_ADD, GroupTableName, RootID, IDField,
                                ParentIDField, VisibleFields, Captions, GenName, InputColumnType, Rules);
            this.ValueField = getField;
            this.FilterField = FilterField;
            AddCondition();
            gridView.GridControl.DataSourceChanged += delegate(object sender, EventArgs e)
            {
                if (gridView.GridControl.DataSource != null &&
                    !((DataTable)gridView.GridControl.DataSource).Columns.Contains(columnField + getField))
                {

                    DataTable dt = (DataTable)gridView.GridControl.DataSource;
                    dt.Columns.Add(new DataColumn(columnField + getField));
                    SetValueTable(ref dt, columnField, columnField + getField, GroupTableName, "ID", getField);
                }
            };

            long idValue;

            gridView.CellValueChanging += delegate(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
            {
                if (e.Column.FieldName.Equals(columnField + getField))
                {
                    idValue = _getSelectedID();
                    if (e.RowHandle > 0)
                    {
                        DataTable dt = ((DataTable)gridView.GridControl.DataSource);
                        DataRow row = dt.Rows[e.RowHandle];
                        row[columnField] = idValue;
                        row[columnField + getField] = e.Value;
                    }
                }
            };
            gridView.RowUpdated += delegate(object sender, DevExpress.XtraGrid.Views.Base.RowObjectEventArgs e)
            {
                DataRow row = ((DataRowView)e.Row).Row;
                if (row.RowState == DataRowState.Added)
                    row[columnField] = _getSelectedID();
            };
        }
예제 #15
0
 public static RepositoryItemSelectDMTreeGroup CotDMTreeUpdate(GridView gridView, GridColumn column, String GroupTableName, int[] RootID, String IDField, String ParentIDField,
     string[] VisibleFields, string[] Captions, string GenName,
     object[] InputColumnType, FieldNameCheck[] Rules, string ColumnField, string getField, string FilterField)
 {
     column.FieldName = ColumnField + getField;
     RepositoryItemSelectDMTreeGroup dmTree = new RepositoryItemSelectDMTreeGroup();
     dmTree.InitUpdate(gridView, GroupTableName, RootID, IDField, ParentIDField, VisibleFields, Captions, GenName, InputColumnType, Rules, ColumnField, getField, FilterField);
     column.ColumnEdit = dmTree;
     return dmTree;
 }