Beispiel #1
0
        void EditEntity()
        {
            Absence absence = FocusedEntity;

            if (absence == null)
            {
                return;
            }
            AbsenceType ate = absence.AbsenceTypeID;

            switch (ate)
            {
            case AbsenceType.Holiday:
                EditHoliday();
                break;

            case AbsenceType.Absence:
                EditAbsence();
                break;

            case AbsenceType.Illness:
                EditIllness();
                break;
            }
        }
Beispiel #2
0
        void DeleteEntity()
        {
            Absence absence = FocusedEntity;

            if (absence == null)
            {
                return;
            }
            AbsenceType ate = absence.AbsenceTypeID;

            switch (ate)
            {
            case AbsenceType.Holiday:
                DeleteHoliday();
                break;

            case AbsenceType.Absence:
                DeleteAbsence();
                break;

            case AbsenceType.Illness:
                DeleteIllness();
                break;
            }
        }
Beispiel #3
0
        private void gridViewAbsence_CustomUnboundColumnData(object sender, CustomColumnDataEventArgs e)
        {
            if (AbsenceList != null)
            {
                if (e.Column == gridColumn_AbsenceType)
                {
                    int idx = e.ListSourceRowIndex;
                    if (idx >= 0 && idx < AbsenceList.Count && e.IsGetData)
                    {
                        AbsenceType ate = AbsenceList[idx].AbsenceTypeID;

                        switch (ate)
                        {
                        case AbsenceType.Holiday: e.Value = holidayTranslation;
                            break;

                        case AbsenceType.Absence: e.Value = absenceTranslation;
                            break;

                        case AbsenceType.Illness: e.Value = illnessTranslation;
                            break;

                        default:
                            Debug.Assert(false);
                            break;
                        }
                    }
                }
            }
        }
Beispiel #4
0
        public JsonResult Create([Bind(Include = "Name,code, remark")] AbsenceType model)
        {
            ResultMessage msg = new ResultMessage();

            try
            {
                msg = DoValidation(model);

                if (!msg.Success)
                {
                    return(Json(msg, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    IAbsenceTypeService cs = new AbsenceTypeService(Settings.Default.db);
                    bool isSucceed         = cs.Create(model);

                    msg.Success = isSucceed;
                    msg.Content = isSucceed ? "" : "添加失败";

                    return(Json(msg, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception ex)
            {
                return(Json(new ResultMessage()
                {
                    Success = false, Content = ex.Message
                }, JsonRequestBehavior.AllowGet));
            }
        }
Beispiel #5
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name")] AbsenceType absenceType)
        {
            if (id != absenceType.Id)
            {
                return(BadRequest());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(absenceType);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AbsenceTypeExists(absenceType.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(absenceType));
        }
Beispiel #6
0
        public void AbsenceType()
        {
            IQueryable <AbsenceType> AbsenceTypeCollection = Enumerable.Empty <AbsenceType>().AsQueryable();
            AbsenceType at = new AbsenceType {
                AbsenceTypeID = 1, AbsenceTypeName = "Test AT"
            };

            Mock <IAbsenceTypeRepository> AbsenceTypeService = new Mock <IAbsenceTypeRepository>();

            try
            {
                AbsenceTypeService.Setup(x => x.GetAll()).Returns(AbsenceTypeCollection);
                AbsenceTypeService.Setup(x => x.Get(It.IsAny <int>())).Returns(at);
                AbsenceTypeService.Setup(x => x.Add(It.IsAny <AbsenceType>())).Returns(at);

                var AbsenceTypeObject = AbsenceTypeService.Object;
                var p1 = AbsenceTypeObject.GetAll();
                var p2 = AbsenceTypeObject.Get(1);
                var p3 = AbsenceTypeObject.Add(at);

                Assert.IsAssignableFrom <IQueryable <AbsenceType> >(p1);
                Assert.IsAssignableFrom <AbsenceType>(p2);
                Assert.Equal("Test AT", p2.AbsenceTypeName);

                AbsenceTypeService.VerifyAll();

                AbsenceTypeObject.Dispose();
            }
            finally
            {
                AbsenceTypeService = null;
            }
        }
 protected AbstractCalendarEntry(DateTime from, DateTime to, EmployeeCalendar user, AbsenceType type)
 {
     From             = from;
     To               = to;
     AbsenceType      = type;
     CalendarEmployee = user;
 }
Beispiel #8
0
        public async Task <AbsenceType> UpdateAbsenceType(AbsenceType absenceType)
        {
            if (AbsenceTypeExists(absenceType.Name))
            {
                return(null);
            }

            absenceType.Name.Trim().ToLower();
            _context.Entry(absenceType).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!AbsenceTypeExists(absenceType.Id))
                {
                    return(null);
                }
                else
                {
                    throw;
                }
            }

            return(absenceType);
        }
Beispiel #9
0
        private void gridControl_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            if (!isUserWriteRight)
            {
                return;
            }
            GridHitInfo info = gridViewAbsence.CalcHitInfo(e.X, e.Y);

            if (info.InRowCell && gridViewAbsence.IsDataRow(info.RowHandle))
            {
                Absence absence = GetEntityByRowHandle(info.RowHandle);
                // if (CheckUsedAbsence(absence)) return;
                if (absence != null)
                {
                    AbsenceType absType = absence.AbsenceTypeID;
                    if (absType == AbsenceType.Absence)
                    {
                        EditAbsence();
                    }
                    else
                    if (absType == AbsenceType.Holiday)
                    {
                        EditHoliday();
                    }
                    else
                    if (absType == AbsenceType.Illness)
                    {
                        EditIllness();
                    }
                }
            }
        }
Beispiel #10
0
 public Absence(Employee employee, AbsenceType absenceType, DateTime beginDate, DateTime endDate)
 {
     Employee = employee;
     AbsenceType = absenceType;
     BeginDate = beginDate;
     EndDate = endDate;
     AbsenceStatus = AbsenceStatus.Pending;
 }
Beispiel #11
0
 public Absence(DateTime date, AbsenceType type, bool excused, long student, ITeachingHour hour)
 {
     this.Date = date;
     this.Type = type;
     this.Excused = excused;
     this.Student = student;
     this.Hour = hour;
 }
Beispiel #12
0
        // GET: AbsenceType/Delete/5
        public ActionResult Delete(int id)
        {
            IAbsenceTypeService cs = new AbsenceTypeService(Settings.Default.db);

            AbsenceType cp = cs.FindById(id);

            //SetDropDownList(cp);
            return(View(cp));
        }
Beispiel #13
0
        // GET: AbsenceType/Edit/5
        public ActionResult Edit(int id)
        {
            IAbsenceTypeService cs = new AbsenceTypeService(Settings.Default.db);

            AbsenceType jt = cs.FindById(id);

            //SetDropDownList(jt);
            return(View(jt));
        }
Beispiel #14
0
        public AbsenceType CreateAbsenceType(int organisationId, AbsenceType absenceType)
        {
            using (var context = _databaseFactory.Create(organisationId))
            {
                absenceType = context.AbsenceTypes.Add(absenceType);
                context.SaveChanges();

                return(absenceType);
            }
        }
Beispiel #15
0
        public RedirectToActionResult Delete(string id)
        {
            AbsenceType absenceType = data.AbsenceTypes.Get(id);

            data.AbsenceTypes.Delete(absenceType);
            data.Save();

            TempData["SucessMessage"] = "The Absence Type, " + absenceType.Name + ", was deleted successfully.";
            return(RedirectToAction("List"));
        }
Beispiel #16
0
        private void gridViewAbsence_CustomUnboundColumnData(object sender, CustomColumnDataEventArgs e)
        {
            if (e.Column == gridColumn_AbsenceType)
            {
                int idx = e.ListSourceRowIndex;
                if (idx >= 0 && idx < _bindingAbsences.Count && e.IsGetData)
                {
                    AbsenceType ate = _bindingAbsences[idx].AbsenceTypeID;

                    switch (ate)
                    {
                    case AbsenceType.Holiday: e.Value = holidayTranslation;
                        break;

                    case AbsenceType.Absence: e.Value = absenceTranslation;
                        break;

                    case AbsenceType.Illness: e.Value = illnessTranslation;
                        break;

                    default:
                        Debug.Assert(false);
                        break;
                    }
                }
            }

            if (e.Column == gridColumn_availablein)
            {
                int idx = e.ListSourceRowIndex;
                if (idx >= 0 && idx < _bindingAbsences.Count && e.IsGetData)
                {
                    IsShowAbsence ate = _bindingAbsences[idx].IsShow;

                    switch (ate)
                    {
                    case IsShowAbsence.PlanningRecording: e.Value = GetLocalized("PlanningTimeRecording");
                        break;

                    case IsShowAbsence.Planning: e.Value = GetLocalized("PlanningOnly");
                        break;

                    case IsShowAbsence.Recording: e.Value = GetLocalized("TimeRecordingOnly");
                        break;

                    case IsShowAbsence.None: e.Value = GetLocalized("AvailableNone");
                        break;

                    default:
                        Debug.Assert(false);
                        break;
                    }
                }
            }
        }
 private Vacations GetNewInstance(Vacations vacations, AbsenceType absenceType, DateTime date)
 {
     return(new Vacations
     {
         AbsenseType = absenceType,
         AbsenseTypeId = vacations.AbsenseTypeId,
         CreatedAt = DateTimeOffset.Now,
         Date = date,
         State = vacations.State
     });
 }
Beispiel #18
0
        public async Task <IActionResult> Create([Bind("Id,Name")] AbsenceType absenceType)
        {
            if (ModelState.IsValid)
            {
                _context.Add(absenceType);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(absenceType));
        }
Beispiel #19
0
        //4.7	缺勤类别管理
        //(列表(分页)、新建、编辑、删除(存在员工时不可删除)
        //):代码(不可空,唯一性),名称(不可空),备注(可空)
        //        数据例子如:A;小病假;小病假的备注

        public ResultMessage DoValidation(AbsenceType model)
        {
            ResultMessage msg = new ResultMessage();

            if (string.IsNullOrEmpty(model.code))
            {
                msg.Success = false;
                msg.Content = "编码不能为空";

                return(msg);
            }

            if (string.IsNullOrEmpty(model.name))
            {
                msg.Success = false;
                msg.Content = "名称不能为空";

                return(msg);
            }

            IAbsenceTypeService cs    = new AbsenceTypeService(Settings.Default.db);
            List <AbsenceType>  shift = cs.GetAll();

            if (model.id <= 0)
            {
                bool isRecordExists = shift.Where(p => p.name == model.name || p.code == model.code).ToList().Count() > 0;

                if (isRecordExists)
                {
                    msg.Success = false;
                    msg.Content = "数据已经存在!";

                    return(msg);
                }
            }
            else
            {
                bool isRecordExists = shift.Where(p => (p.name == model.name || p.code == model.code) && p.id != model.id).ToList().Count() > 0;

                if (isRecordExists)
                {
                    msg.Success = false;
                    msg.Content = "数据已经存在!";

                    return(msg);
                }
            }

            return(new ResultMessage()
            {
                Success = true, Content = ""
            });
        }
Beispiel #20
0
        public ViewResult Edit(string id)
        {
            AbsenceType absenceType = data.AbsenceTypes.Get(id);

            AbsenceTypeViewModel model = new AbsenceTypeViewModel
            {
                AbsenceTypeId = absenceType.AbsenceTypeId,
                Name          = absenceType.Name
            };

            return(View("AbsenceType", model));
        }
        public IActionResult Update(int id)
        {
            AbsenceType absenceType = absenceTypeService.GetById(id);

            AbsenceTypeViewModel model = new AbsenceTypeViewModel
            {
                Id       = absenceType.Id,
                IsHourly = absenceType.IsHourly,
                Name     = absenceType.Name
            };

            return(View(model));
        }
Beispiel #22
0
 public IActionResult Create([FromBody] AbsenceType newmodel)
 {
     if (ModelState.IsValid)
     {
         _context.AbsenceType.Add(newmodel);
         _context.SaveChanges();
         return(CreatedAtRoute("GetAbsenceType", new { id = newmodel.AbsenceTypeID }, newmodel));
     }
     else
     {
         return(BadRequest());
     }
 }
Beispiel #23
0
        public async Task <IActionResult> CreateAbsenceType(AbsenceType absenceType)
        {
            if (ModelState.IsValid)
            {
                _context.Add(absenceType);

                await _context.SaveChangesAsync();

                return(RedirectToAction("ListAbsenceType"));
            }


            return(View(absenceType));
        }
        public IActionResult Add(AbsenceTypeViewModel model)
        {
            if (ModelState.IsValid)
            {
                AbsenceType absenceType = new AbsenceType
                {
                    Name     = model.Name,
                    IsHourly = model.IsHourly
                };

                absenceTypeService.Add(absenceType);
                return(RedirectToAction("Index"));
            }
            return(View(model));
        }
Beispiel #25
0
        public async Task <AbsenceType> CreateAbsenceType([FromBody] AbsenceType absenceType)
        {
            var aType = await _context.AbsenceTypes.AnyAsync(a => a.Name == absenceType.Name.Trim().ToLower());

            if (aType == true)
            {
                return(null);
            }

            absenceType.Name.Trim().ToLower();
            _context.AbsenceTypes.Add(absenceType);
            await _context.SaveChangesAsync();

            return(absenceType);
        }
        public async Task <ActionResult> CreateAbsenceType([FromBody] AbsenceType absenceType)
        {
            if (absenceType == null)
            {
                return(BadRequest());
            }

            var aType = await _repository.CreateAbsenceType(absenceType);

            if (aType == null)
            {
                return(Conflict());
            }

            return(CreatedAtAction(nameof(GetAbsenceType), new { id = absenceType.Id }, absenceType));
        }
        public async Task <ActionResult> UpdateAbsenceType(int id, [FromBody] AbsenceType absenceType)
        {
            if (absenceType == null || absenceType.Id != id)
            {
                return(BadRequest());
            }

            var aType = await _repository.UpdateAbsenceType(absenceType);

            if (aType == null)
            {
                return(NotFound());
            }

            return(NoContent());
        }
Beispiel #28
0
        private string GetAbsenceType(AbsenceType type)
        {
            switch (type)
            {
            case AbsenceType.Grade:
                return("study_group");

            case AbsenceType.Room:
                return("room");

            case AbsenceType.Teacher:
                return("teacher");
            }

            throw new Exception("Unknown absence type.");
        }
Beispiel #29
0
        public IActionResult Add(AbsenceTypeViewModel model)
        {
            if (ModelState.IsValid)
            {
                AbsenceType absenceType = new AbsenceType
                {
                    Name = model.Name
                };

                data.AbsenceTypes.Insert(absenceType);
                data.Save();

                TempData["SucessMessage"] = "The Absence Type, " + model.Name + ", was created successfully.";
                return(RedirectToAction("List"));
            }

            return(View("AbsenceType", model));
        }
Beispiel #30
0
        public IActionResult Edit(AbsenceTypeViewModel model)
        {
            if (ModelState.IsValid)
            {
                AbsenceType absenceType = new AbsenceType
                {
                    AbsenceTypeId = model.AbsenceTypeId,
                    Name          = model.Name
                };

                data.AbsenceTypes.Update(absenceType);
                data.Save();

                TempData["SucessMessage"] = "The Absence Type with ID# " + model.AbsenceTypeId + ", was updated successfully.";
                return(RedirectToAction("List"));
            }

            return(View("AbsenceType", model));
        }
Beispiel #31
0
 public ActionResult Edit([Bind(Include = "AbsenceTypeId,Name,ColourId")] AbsenceType absenceType)
 {
     if (ModelState.IsValid)
     {
         var result = HRBusinessService.UpdateAbsenceType(UserOrganisationId, absenceType);
         if (result.Succeeded)
         {
             return(RedirectToAction("Index"));
         }
         foreach (var error in result.Errors)
         {
             ModelState.AddModelError("", error);
         }
     }
     return(View(new AbsenceTypeViewModel {
         AbsenceType = absenceType,
         ColoursList = HRBusinessService.RetrieveColours().ToList()
     }));
 }
        public ActionResult Edit([Bind(Include = "AbsenceTypeId,Name,ColourId")] AbsenceType absenceType)
        {
            //if (ModelState.IsValid)
            //{
            //    var result = NidanBusinessService.UpdateAbsenceType(UserOrganisationId, absenceType);
            //    if (result.Succeeded)
            //    {
            //        return RedirectToAction("Index");
            //    }
            //    foreach (var error in result.Errors)
            //    {
            //        ModelState.AddModelError("", error);
            //    }

            //}
            return(View(new AbsenceTypeViewModel {
                AbsenceType = new Entity.AbsenceType(),
                ColoursList = NidanBusinessService.RetrieveColours().ToList()
            }));
        }
Beispiel #33
0
 public static AbsenceTypeDTO Convert(AbsenceType absenceType)
 {
     return (AbsenceTypeDTO)absenceType;
 }