Esempio n. 1
0
        /*
         * Admin - 1
         * Research - 2
         * IT Dev't/IE - 3
         * IT Infra - 4
         * 
         * Single - 1
         * Married - 2
         * 
         * Date: MM/DD/YYYY
         * 
         * Jan - 1
         * Feb - 2
         * Mar - 3
         * Apr - 4
         * May - 5
         * Jun - 6
         * Jul - 7
         * Aug - 8
         * Sep - 9
         * Oct - 10
         * Nov - 11
         * Dec - 12
         * 
         * new AdditionalInfo() { IDNO = "10", Gender = "ale", Email = "@Savvysherpa.com", HireDate = "//", RegularizationDate = "//", DepartmentID = "", CivilStatusID = ""},
         * 
         * */

        public bool InsertLeaveCredit(LeaveCreditModel model)
        {
            using(DataContext _context = new DataContext())
            {
                int _rowsAffected = _context.Database.ExecuteSqlCommand("pInsertLeaveCredit @xIDNO, @xLeaveType, @xBeginningDate, @xCutOffDate, " + 
                                                                        "@xCreditsAtCutOffInDays, @xCreditsAtCutOffInMonths, @xLeaveCreditsPerMonth, " + 
                                                                        "@xUnusedLeavesDays, @xUnusedLeavesHours, @xLessLeaveAvailmentHours, @xConvertibleLeavesHours",
                                    new SqlParameter("@xIDNO", model.IDNO),
                                    new SqlParameter("@xLeaveType", model.LeaveType),
                                    new SqlParameter("@xBeginningDate", model.BeginningDate),
                                    new SqlParameter("@xCutOffDate", model.CutOffDate),
                                    new SqlParameter("@xCreditsAtCutOffInDays", model.CreditsAtCutOffInDays),
                                    new SqlParameter("@xCreditsAtCutOffInMonths", model.CreditsAtCutOffInMonths),
                                    new SqlParameter("@xLeaveCreditsPerMonth", model.LeaveCreditsPerMonth),
                                    new SqlParameter("@xUnusedLeavesDays", model.UnusedLeavesDays),
                                    new SqlParameter("@xUnusedLeavesHours", model.UnusedLeavesHours),
                                    new SqlParameter("@xLessLeaveAvailmentHours", model.LessLeaveAvailmentHours),
                                    new SqlParameter("@xConvertibleLeavesHours", model.ConvertibleLeavesHours));

                _context.Database.Connection.Close();
                _context.Database.Connection.Dispose();

                if(_rowsAffected == 1)
                {
                    return true;
                }
            }

            return false;
        }
Esempio n. 2
0
        public ActionResult InsertLeaveCredit()
        {
            BLLLeave _leave = new BLLLeave();
            LeaveCreditModel model = new LeaveCreditModel();

            //int[] idnos = {10001, 10002, 10003, 10004, 10005, 10006, 10007, 10009, 10012, 10014, 10016, 10018, 10020, 10023, 10025, 
            //               10027, 10028, 10029, 10030, 10032, 10033, 10035, 10038, 10042, 10043, 10047, 10051, 10054, 10057, 10058, 10059,
            //               10060, 10061, 10062, 10063, 10064, 10065, 10067, 10069, 10070, 10071, 10074, 10075, 10076, 10077, 10081,
            //               10083, 10084, 10085, 10086, 10087, 10090, 10091, 10092, 10093, 10094, 10095, 10096, 10099, 10101, 10102, 10103, 10104,
            //               10105, 10106, 10107, 10108, 10109, 10111, 10112, 10113, 10114, 10115, 10116, 10117, 10118, 10119, 10120, 10121, 10122,
            //               10123, 10124, 10125, 10126, 10127, 10128, 10129, 10130, 10131, 10132, 10133, 10134};

            var idnos = _leave.GetIDNOs();

            foreach (string idno in idnos)
            {
                model.IDNO = Convert.ToInt32(idno);
                model.HireDate = _leave.GetHireDate(idno);
                model.LeaveType = 1;
                _leave.InsertLeaveCredit(model);

                model.LeaveType = 3;
                _leave.InsertLeaveCredit(model);
            }

            //if (_leave.InsertLeaveCredit(model))
            //{
            //    TempData["insertLeaveCredit_result"] = "LeaveCredit information was added.";
            //}

            return View();
        }
Esempio n. 3
0
        public bool InsertLeaveCredit(LeaveCreditModel model)
        {
            DALLeave _leave = new DALLeave();

            model.BeginningDate = CalculateBeginningDate(model.HireDate);
            model.CutOffDate = new DateTime(2016, 11, 30);

            model.CreditsAtCutOffInDays = Days360.CalculateDays360(model.BeginningDate, model.CutOffDate);
            model.CreditsAtCutOffInMonths = (float)model.CreditsAtCutOffInDays / 30f;

            float _creditsPerMonth = CalculateCreditsPerMonth(model.IDNO, model.LeaveType);
            model.LeaveCreditsPerMonth = _creditsPerMonth / 12f;

            model.UnusedLeavesDays = model.CreditsAtCutOffInMonths * model.LeaveCreditsPerMonth;
            model.UnusedLeavesHours = model.UnusedLeavesDays * 8f;
            model.LessLeaveAvailmentHours = 0;
            model.ConvertibleLeavesHours = model.UnusedLeavesHours - model.LessLeaveAvailmentHours;

            return _leave.InsertLeaveCredit(model);
        }