Beispiel #1
0
        public JsonResult Create(ClassApplication dto)
        {
            dto.OperatorId = AuthorityHelper.OperatorId.Value;
            OperationResult oper = _classApplicationContract.Insert(dto);

            return(Json(oper));
        }
Beispiel #2
0
        public JsonResult AddClassApplication(ClassApplication dto)
        {
            if (!_administratorContract.CheckExists(a => a.Id == dto.AdminId && !a.IsDeleted && a.IsEnabled))
            {
                return(Json(new OperationResult(OperationResultType.Error, "用户不存在")));
            }
            OperationResult oper = _classApplicationContract.Insert(dto);

            return(Json(oper));
        }
Beispiel #3
0
        public ActionResult Create()
        {
            AdvanceDay = Convert.ToInt32(GetXmlNodeByXpath("AdvanceDay"));
            var admin = _administratorContract.Administrators.FirstOrDefault(x => !x.IsDeleted && x.IsEnabled && x.Id == AuthorityHelper.OperatorId.Value);
            List <SelectListItem> workDayList = new List <SelectListItem>();
            List <SelectListItem> offDayList  = new List <SelectListItem>();

            workDayList.Add(new SelectListItem()
            {
                Value = "", Text = "请选择"
            });
            offDayList.Add(new SelectListItem()
            {
                Value = "", Text = "请选择"
            });
            int days = DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month);

            if (admin.IsPersonalTime && admin.WorkTime != null)
            {
                int currentDay   = DateTime.Now.Day + AdvanceDay;
                int currentYear  = DateTime.Now.Year;
                int currentMonth = DateTime.Now.Month;
                int workTimrId   = admin.WorkTime.Id;
                var monthList    = _workTimeDetaileContract.WorkTimeDetailes.Where(x => x.WorkTimeId == workTimrId).GroupBy(x => x.Month).Select(x => x.Key).ToList();
                if (monthList.Count == 2)
                {
                    int minMonth = monthList.Min();
                    int minYear  = _workTimeDetaileContract.WorkTimeDetailes.FirstOrDefault(x => x.WorkTimeId == workTimrId && x.Month == minMonth).Year;
                    int maxMonth = monthList.Max();
                    int maxYear  = _workTimeDetaileContract.WorkTimeDetailes.FirstOrDefault(x => x.WorkTimeId == workTimrId && x.Month == maxMonth).Year;
                    //if (monthList.Contains(currentMonth))
                    //{
                    if (!(minMonth == currentMonth && minYear == currentYear) && !(maxMonth == currentMonth && maxYear == currentYear))
                    {
                        currentMonth = minMonth;
                    }
                    else
                    {
                        if (minYear > maxYear)
                        {//如果最小月的年份儿大于最大月的年份儿,那么最大月与最小月反过来(即最大月为最小月,最小月为最大月)
                            currentMonth = maxMonth;
                            currentYear  = maxYear;
                        }
                        else
                        {
                            currentMonth = minMonth;
                            currentYear  = minYear;
                        }
                    }
                    //if ((minMonth == currentMonth && minYear == currentYear) || (maxMonth == currentMonth && maxYear == currentYear))
                    //{
                    //    //if (monthList.Contains(12) && monthList.Contains(1))
                    //    //{
                    //    //}
                    //    //else
                    //    //{
                    //    //if (currentMonth == maxMonth)
                    //    //{
                    //    //    currentMonth = maxMonth;
                    //    //}
                    //    //else
                    //    //{
                    //    //    currentMonth = minMonth;
                    //    //}
                    //    //}
                    //}
                    //else
                    //{
                    //    currentMonth = minMonth;
                    //}
                }
                var WtdArry = _workTimeDetaileContract.WorkTimeDetailes.Where(x => x.WorkTimeId == workTimrId && x.Year == currentYear &&
                                                                              x.Month == currentMonth && x.WorkTimeType != 2).ToList();
                currentDay = DateTime.Now.Day + AdvanceDay;
                if (WtdArry != null && WtdArry.Count() > 0)
                {
                    var dayArry = WtdArry.Select(w => w.WorkDay);
                    foreach (var item in dayArry)
                    {
                        if (Convert.ToInt32(item) > currentDay && Convert.ToInt32(item) <= days)
                        {
                            workDayList.Add(new SelectListItem()
                            {
                                Value = item.ToString(), Text = item + "号"
                            });
                        }
                    }
                    var offDay = _workTimeDetaileContract.WorkTimeDetailes.Where(x => x.WorkTimeId == admin.WorkTime.Id && x.WorkTimeType == 2 && x.Year == currentYear &&
                                                                                 x.Month == currentMonth)
                                 .Select(x => x.WorkDay);
                    foreach (var item in offDay)
                    {
                        if (item > currentDay && item <= days)
                        {
                            offDayList.Add(new SelectListItem()
                            {
                                Value = item.ToString(), Text = item + "号"
                            });
                        }
                    }
                }
            }
            var DepList         = new List <SelectListItem>();
            ClassApplication ca = new ClassApplication();

            DepList.AddRange(_departmentContract.Departments.Where(x => !x.IsDeleted && x.IsEnabled).Select(x => new SelectListItem()
            {
                Value = x.Id.ToString(),
                Text  = x.DepartmentName
            }));
            ViewBag.workDayList = workDayList;
            ViewBag.offDayList  = offDayList;
            ViewBag.DepList     = DepList;
            ViewBag.RealName    = AuthorityHelper.RealName;
            ViewBag.adminId     = AuthorityHelper.OperatorId ?? 0;
            return(PartialView());
        }
Beispiel #4
0
 public static void log( ClassApplication app, ClassString mesg )
 {
     Bard.log(mesg.data);
 }