Ejemplo n.º 1
0
        protected override void OnSaveChangesSuccess(RuleCategory ruleCategory, UIActionType action)
        {
            if (action == UIActionType.ADD || action == UIActionType.EDIT)
            {
                DateTime     fromDate, toDate;
                RuleCategory ruleCat = base.GetByID(ruleCategory.ID);

                if (ruleCat.PersonRuleCatAssignList != null && ruleCat.PersonRuleCatAssignList.Count > 0)
                {
                    fromDate = ruleCat.PersonRuleCatAssignList.Min(x => Utility.ToMildiDateTime(x.FromDate));
                    toDate   = ruleCat.PersonRuleCatAssignList.Max(x => Utility.ToMildiDateTime(x.ToDate));
                }
                else
                {
                    fromDate = DateTime.Now.AddYears(-2);
                    toDate   = DateTime.Now.AddYears(5);
                }


                //دوره تاریخ پیشفرض پارامتر
                foreach (Rule rule in ruleCat.RuleList)
                {
                    if (rule.HasParameter && (rule.AssignRuleParamList == null || rule.AssignRuleParamList.Count == 0))
                    {
                        BRuleParameter busRuleParam = new BRuleParameter(rule.TemplateId, ruleCat.ID);
                        busRuleParam.InsertParameter(new List <RuleTemplateParameter>(), fromDate, toDate);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        protected override void OnSaveChangesSuccess(RuleCategory ruleCategory, UIActionType action)
        {
            if (action == UIActionType.ADD)
            {
                new BDataAccess().InsertDataAccess(Infrastructure.DataAccessLevelOperationType.Single, Infrastructure.DataAccessParts.RuleGroup, ruleCategory.ID, BUser.CurrentUser.ID, null, "");
            }

            if (action == UIActionType.ADD || action == UIActionType.EDIT)
            {
                DateTime     fromDate, toDate;
                RuleCategory ruleCat = base.GetByID(ruleCategory.ID);

                if (ruleCat.PersonRuleCatAssignList != null && ruleCat.PersonRuleCatAssignList.Count > 0)
                {
                    fromDate = ruleCat.PersonRuleCatAssignList.Min(x => Utility.ToMildiDateTime(x.FromDate));
                    toDate   = ruleCat.PersonRuleCatAssignList.Max(x => Utility.ToMildiDateTime(x.ToDate));
                }
                else
                {
                    fromDate = DateTime.Now.AddYears(-2);
                    toDate   = DateTime.Now.AddYears(5);
                }


                //دوره تاریخ پیشفرض پارامتر
                foreach (Rule rule in ruleCat.RuleList)
                {
                    if (rule.HasParameter && (rule.AssignRuleParamList == null || rule.AssignRuleParamList.Count == 0))
                    {
                        BRuleParameter busRuleParam = new BRuleParameter(rule.TemplateId, ruleCat.ID);
                        busRuleParam.InsertParameter(new List <RuleTemplateParameter>(), fromDate, toDate, UIActionType.ADD);
                    }
                    else if (rule.HasParameter && (rule.AssignRuleParamList != null || rule.AssignRuleParamList.Count != 0) && ((int)rule.IdentifierCode == (int)RuleParameterType.MissionParameterOne ||
                                                                                                                                (int)rule.IdentifierCode == (int)RuleParameterType.MissionParameterOne ||
                                                                                                                                (int)rule.IdentifierCode == (int)RuleParameterType.Work ||
                                                                                                                                (int)rule.IdentifierCode == (int)RuleParameterType.Absence ||
                                                                                                                                (int)rule.IdentifierCode == (int)RuleParameterType.LeaveParameter3012 ||
                                                                                                                                (int)rule.IdentifierCode == (int)RuleParameterType.LeaveParemeter3017 ||
                                                                                                                                (int)rule.IdentifierCode == (int)RuleParameterType.Miscellaneous
                                                                                                                                ))
                    {
                        BRuleParameter busRuleParam = new BRuleParameter(rule.TemplateId, ruleCat.ID);
                        busRuleParam.InsertParameter(new List <RuleTemplateParameter>(), fromDate, toDate, UIActionType.EDIT);
                    }
                }
            }
        }