示例#1
0
        public void NUnit_Relatives_Domain_Add()
        {
            Hre_RelativesServices service = new Hre_RelativesServices();
            string result  = string.Empty;
            int    countSC = 0;

            for (int i = 1; i <= 10; i++)
            {
                var model = new Hre_Relatives
                {
                    ProfileID    = 1,
                    RelativeName = "RelativesName " + i,
                    DependantID  = 1,
                    IsColleaggue = true
                };
                result = service.Add(model);
                if (result != string.Empty)
                {
                    countSC += 1;
                    Console.WriteLine("Process Success >>> Create >>> " + model.Id
                                      + " | " + model.RelativeName
                                      );
                }
            }
            Console.WriteLine("Total success record: " + countSC);
        }
 public void NUnit_Relatives_Domain_Add()
 {
     Hre_RelativesServices service = new Hre_RelativesServices();
     string result = string.Empty;
     int countSC = 0;
     for (int i = 1; i <= 10; i++)
     {
         var model = new Hre_Relatives
         {
             ProfileID = 1,
             RelativeName = "RelativesName " + i,
             DependantID = 1,
             IsColleaggue = true
         };
         result = service.Add(model);
         if (result != string.Empty)
         {
             countSC += 1;
             Console.WriteLine("Process Success >>> Create >>> " + model.Id
                 + " | " + model.RelativeName
                 );
         }
     }
     Console.WriteLine("Total success record: " + countSC);
 }
 public void NUnit_Relatives_Domain_Get()
 {
     string status = string.Empty;
     Hre_RelativesServices service = new Hre_RelativesServices();
     var repo = service.GetAllUseEntity<Hre_RelativesEntity>(ref status);
     Console.Write("Total Record: " + repo.Count());
 }
示例#4
0
        public void NUnit_Relatives_Domain_Get()
        {
            string status = string.Empty;
            Hre_RelativesServices service = new Hre_RelativesServices();
            var repo = service.GetAllUseEntity <Hre_RelativesEntity>(ref status);

            Console.Write("Total Record: " + repo.Count());
        }
 public void NUnit_Relatives_Domain_GetById()
 {
     string status = string.Empty;
     Hre_RelativesServices service = new Hre_RelativesServices();
     var model = new Hre_Relatives { Id = 10 };
     var result = service.GetById<Hre_RelativesEntity>(model.Id, ref status) as Hre_RelativesEntity;
     NUnit.Framework.Assert.IsNotNull(result);
     Console.Write("SearchResult: " + result.Id 
         + " | " + result.ProfileID
         + " | " + result.RelativeName 
         );
 }
示例#6
0
        public void NUnit_Relatives_Domain_GetById()
        {
            string status = string.Empty;
            Hre_RelativesServices service = new Hre_RelativesServices();
            var model = new Hre_Relatives {
                Id = 10
            };
            var result = service.GetById <Hre_RelativesEntity>(model.Id, ref status) as Hre_RelativesEntity;

            NUnit.Framework.Assert.IsNotNull(result);
            Console.Write("SearchResult: " + result.Id
                          + " | " + result.ProfileID
                          + " | " + result.RelativeName
                          );
        }
示例#7
0
        public void NUnit_Relatives_Domain_Delete()
        {
            Hre_RelativesServices service = new Hre_RelativesServices();
            int rs    = 0;
            var model = new Hre_Relatives {
                Id = 3
            };
            string result = service.Delete <Hre_RelativesEntity>(model.Id);

            if (result != string.Empty)
            {
                rs += 1;
                Console.WriteLine("Process Success >>> Delete >>> " + model.Id);
            }
        }
 public void NUnit_Relatives_Domain_Edit()
 {
     Hre_RelativesServices service = new Hre_RelativesServices();
     var model = new Hre_Relatives
     {
         Id =10,
         ProfileID = 1,
         RelativeName = "Relatives Name ",
     };
     string result = service.Edit(model);
     if (result != string.Empty)
     {
         Console.WriteLine("Process Success >>> Update >>> " + model.Id
                 + " | " + model.ProfileID
                 + " | " + model.RelativeName
                 );
     }
 }
示例#9
0
        public void NUnit_Relatives_Domain_Edit()
        {
            Hre_RelativesServices service = new Hre_RelativesServices();
            var model = new Hre_Relatives
            {
                Id           = 10,
                ProfileID    = 1,
                RelativeName = "Relatives Name ",
            };
            string result = service.Edit(model);

            if (result != string.Empty)
            {
                Console.WriteLine("Process Success >>> Update >>> " + model.Id
                                  + " | " + model.ProfileID
                                  + " | " + model.RelativeName
                                  );
            }
        }
        public Sal_UnusualAllowanceModel Post([Bind] Sal_UnusualAllowanceModel model)
        {
            #region Validate
            string message       = string.Empty;
            var    checkValidate = HRM.Business.Main.Domain.ValidatorService.OnValidateData <Sal_UnusualAllowanceModel>(model, "Sal_UnusualEDChildCareInfo", "Sal_UnusualAllowance", ref message);
            if (!checkValidate)
            {
                model.ActionStatus = message;
                return(model);
            }
            if (model.RelativeID != null)
            {
                checkValidate = HRM.Business.Main.Domain.ValidatorService.OnValidateData <Sal_UnusualAllowanceModel>(model, "Sal_UnusualEDChildCareDuplicate", "Sal_UnusualAllowance", ref message);
                if (!checkValidate)
                {
                    model.ActionStatus = message;
                    return(model);
                }
            }
            else
            {
                checkValidate = HRM.Business.Main.Domain.ValidatorService.OnValidateData <Sal_UnusualAllowanceModel>(model, "Sal_UnusualEDChildCareDuplicate1", "Sal_UnusualAllowance", ref message);
                if (!checkValidate)
                {
                    model.ActionStatus = message;
                    return(model);
                }
            }
            DateTime now = model.DateSubmitDoc.Value;
            int      age = now.Year - model.MonthStart.Value.Year;
            if (now < model.MonthStart.Value.AddYears(age))
            {
                age--;
            }
            if (age > 18 || model.DateSubmitDoc.Value > model.MonthEnd)
            {
                model.ActionStatus = ConstantMessages.WarningRelativeGreaterThan18.TranslateString();
                return(model);
            }

            #endregion

            string status           = string.Empty;
            var    relativeServices = new Hre_RelativesServices();
            var    objRelatives     = new List <object>();
            objRelatives.AddRange(new object[11]);
            objRelatives[9]  = 1;
            objRelatives[10] = int.MaxValue - 1;
            var lstRelatives = relativeServices.GetData <Hre_RelativesEntity>(objRelatives, ConstantSql.hrm_hr_sp_get_Relatives, UserLogin, ref status).ToList();
            if (model.RelativeID != null)
            {
                var dateNow = DateTime.Now;


                var entity = lstRelatives.Where(s => s.ID == model.RelativeID).FirstOrDefault();
                if (entity != null)
                {
                    if (model.DateSubmitDoc != null)
                    {
                        var checkDob = (dateNow.Year - model.DateSubmitDoc.Value.Year) * 12 + dateNow.Month - model.DateSubmitDoc.Value.Month;
                        if (checkDob >= 216)
                        {
                            model.ActionStatus = ConstantMessages.WarningRelativeGreaterThan18.ToString().TranslateString();
                            return(model);
                        }
                    }

                    //if(!string.IsNullOrEmpty(entity.YearOfBirth))
                    //{

                    //    var strDob = entity.YearOfBirth.Split('/');
                    ////    var dob = DateTime.Parse(entity.YearOfBirth);
                    //    var checkDob = (dateNow.Year - int.Parse(strDob[2])) * 12 + dateNow.Month - int.Parse(strDob[1]);
                    //    if (checkDob >= 216)
                    //    {
                    //        model.ActionStatus = ConstantMessages.WarningRelativeGreaterThan18.ToString().TranslateString();
                    //        return model;
                    //    }
                    //}
                }
            }

            ActionService service = new ActionService(UserLogin);
            return(service.UpdateOrCreate <Sal_UnusualAllowanceEntity, Sal_UnusualAllowanceModel>(model));
        }
        public Sal_UnusualAllowanceModel Post([Bind] Sal_UnusualAllowanceModel model)
        {
            #region Validate
            string        message       = string.Empty;
            string        status        = string.Empty;
            ActionService service       = new ActionService(UserLogin);
            var           checkValidate = true;
            checkValidate = HRM.Business.Main.Domain.ValidatorService.OnValidateData <Sal_UnusualAllowanceModel>(model, "Sal_UnusualAllowanceinfoNew", "Sal_UnusualAllowance", ref message);
            if (!checkValidate)
            {
                model.ActionStatus = message;
                return(model);
            }
            if (model != null && model.UnusualEDTypeID != null)
            {
                var entity = service.GetByIdUseStore <Cat_UnusualAllowanceCfgEntity>(model.UnusualEDTypeID.Value, ConstantSql.hrm_cat_sp_get_UnusualAllowanceCfgId, ref status);
                if (entity != null && entity.Code != null)
                {
                    if (entity.Code.Replace(" ", "") == "DEATHOFEMPLOYEE" || entity.Code.Replace(" ", "") == "HOSPITALOFEMPLOYEEMORETHANONEMONTH")
                    {
                        checkValidate = HRM.Business.Main.Domain.ValidatorService.OnValidateData <Sal_UnusualAllowanceModel>(model, "Sal_UnusualAllowanceinfoNew2", "Sal_UnusualAllowance", ref message);
                    }
                    else
                    {
                        checkValidate = HRM.Business.Main.Domain.ValidatorService.OnValidateData <Sal_UnusualAllowanceModel>(model, "Sal_UnusualAllowanceinfoNew1", "Sal_UnusualAllowance", ref message);
                    }
                    if (!checkValidate)
                    {
                        model.ActionStatus = message;
                        return(model);
                    }
                    if (entity.Code.Replace(" ", "") == "BIRTHOFACHILD" || entity.Code.Replace(" ", "") == "DEATHOFEMPLOYEECHILD" || entity.Code.Replace(" ", "") == "DEATHOFEMPLOYEESPOUSE" || entity.Code.Replace(" ", "") == "FUNERALOFPARENT")
                    {
                        checkValidate = HRM.Business.Main.Domain.ValidatorService.OnValidateData <Sal_UnusualAllowanceModel>(model, "Sal_UnusualAllowanceinfo1And2", "Sal_UnusualAllowance", ref message);
                        if (checkValidate == false)
                        {
                            checkValidate = true;
                            //lay thong tin cua quan he
                            var objRelativesModel      = service.GetData <Hre_RelativesModel>(Common.DotNetToOracle(model.RelativeID.ToString()), ConstantSql.hrm_hr_sp_get_RelativesById, ref status).FirstOrDefault();
                            var checkValidateRelatives = true;
                            if (objRelativesModel != null)
                            {
                                //lay all nguoi than cua nv do
                                Hre_RelativesServices hreServiveRelative = new Hre_RelativesServices();
                                var lstRelativeByProfileId = hreServiveRelative.GetRelativeByProfileId(model.ProfileID).ToList();
                                if (lstRelativeByProfileId.Count > 0)
                                {
                                    //if (model.ID == Guid.Empty)
                                    //    objRelativesModel.ID = Guid.Empty;
                                    var lstDuplicateRelativeByProfileID = lstRelativeByProfileId.
                                                                          Where(s => s.ProfileID == objRelativesModel.ProfileID && s.RelativeName == objRelativesModel.RelativeName && s.YearOfBirth == objRelativesModel.YearOfBirth).ToList();
                                    if (lstDuplicateRelativeByProfileID.Count > 0)
                                    {
                                        checkValidateRelatives = false;
                                    }
                                }
                                //  checkValidateRelatives = HRM.Business.Main.Domain.ValidatorService.OnValidateData<Hre_RelativesModel>(objRelativesModel, "Hre_Relativesinfo1And2", "Hre_Relatives", ref message);
                            }
                            if (checkValidateRelatives == false)
                            {
                                model.ActionStatus = message;
                                return(model);
                            }
                        }
                    }
                    else if (entity.Code.Replace(" ", "") == "HOSPITALOFEMPLOYEEMORETHANONEMONTH")
                    {
                        Sal_ReportService salService = new Sal_ReportService();
                        int      _daysInMonth        = System.DateTime.DaysInMonth(model.DateOccur.Value.Year, model.DateOccur.Value.Month);
                        DateTime _datestart          = new DateTime(model.DateOccur.Value.Year, model.DateOccur.Value.Month, 1);
                        DateTime _dateend            = new DateTime(model.DateOccur.Value.Year, model.DateOccur.Value.Month, _daysInMonth);
                        //List<object> paraUnusualAllowance = new List<object>();
                        //paraUnusualAllowance.AddRange(new object[7]);
                        //paraUnusualAllowance[2] = model.UnusualEDTypeID;
                        //paraUnusualAllowance[3] = _datestart;
                        //paraUnusualAllowance[4] = _dateend;
                        //paraUnusualAllowance[5] = 1;
                        //paraUnusualAllowance[6] = int.MaxValue;
                        Sal_UnusualAllowanceServices salServiceUnusualAllowance = new Sal_UnusualAllowanceServices();
                        //var lstUnusualAllowance = salServiceUnusualAllowance.GetData<Sal_UnusualAllowanceEntity>(paraUnusualAllowance, ConstantSql.hrm_sal_sp_get_UnusualAllowanceFilialWedding, ref status);
                        var lstUnusualAllowance = salServiceUnusualAllowance.GetUnusualAllowanceByUnusualEDTypeIDAndDateOccur(model.ProfileID, model.UnusualEDTypeID, _datestart, _dateend);
                        if (lstUnusualAllowance != null)
                        {
                            //lstUnusualAllowance = lstUnusualAllowance.Where(s => s.ProfileID == model.ProfileID).ToList();
                            if ((lstUnusualAllowance.Count > 0 && model.ID == Guid.Empty) || (lstUnusualAllowance.Count > 1 && model.ID != Guid.Empty))
                            {
                                checkValidate = HRM.Business.Main.Domain.ValidatorService.OnValidateData <Sal_UnusualAllowanceModel>(model, "Sal_UnusualAllowanceinfo3", "Sal_UnusualAllowance", ref message);
                                if (!checkValidate)
                                {
                                    model.ActionStatus = message;
                                    return(model);
                                }
                            }
                        }
                    }
                    else if (entity.Code.Replace(" ", "") == "MARRIAGEOFEMPLOYEE" || entity.Code.Replace(" ", "") == "DEATHOFEMPLOYEE")
                    {
                        checkValidate = HRM.Business.Main.Domain.ValidatorService.OnValidateData <Sal_UnusualAllowanceModel>(model, "Sal_UnusualAllowanceinfo5And6And7", "Sal_UnusualAllowance", ref message);
                    }
                }
            }
            if (!checkValidate)
            {
                model.ActionStatus = message;
                return(model);
            }
            #endregion

            return(service.UpdateOrCreate <Sal_UnusualAllowanceEntity, Sal_UnusualAllowanceModel>(model));
        }
 public void NUnit_Relatives_Domain_Delete()
 {
     Hre_RelativesServices service = new Hre_RelativesServices();
     int rs = 0;
     var model = new Hre_Relatives { Id = 3 };
     string result = service.Delete<Hre_RelativesEntity>(model.Id);
     if (result != string.Empty)
     {
         rs += 1;
         Console.WriteLine("Process Success >>> Delete >>> " + model.Id);
     }
 }