public ActionResult Details(int?_ID) { // 如果沒有修改 /App_Start/RouteConfig.cs,網址輸入 http://xxxxxx/UserDB/Details/2 會報錯! if (_ID == null || _ID.HasValue == false) { return(new HttpStatusCodeResult(System.Net.HttpStatusCode.BadRequest)); } // 第四種寫法:透過 .Find() 函數 Hr ut = _db.Hrs.Find(_ID); // 翻譯成SQL指令的結果,同上(第一種方法) //如果有老闆 if (!string.IsNullOrEmpty(ut.Boss)) { var BossName = from _hr in _db.Hrs where _hr.MemberID == ut.Boss select _hr.Name; ViewBag.BossName = BossName.FirstOrDefault().ToString(); } else { ViewBag.BossName = ""; } DateTime Today = DateTime.Now; var age = CalculationDate.AGE(ut.Birthday, Today); ViewBag.age = age; //在職 if (ut.Status != 2) { var service = CalculationDate.Seniority(ut.StartDate, Today); ViewBag.service = service; } else { var service = CalculationDate.Seniority(ut.StartDate, ut.EndDate); ViewBag.service = service; } if (ut == null) { // 找不到這一筆記錄 return(HttpNotFound()); } else { return(View(ut)); } }
/// <summary> /// Фильтр на дату расчетов /// </summary> /// <param name="obj"></param> public void CalulationDateToFilter(CalculationDate Date) { //Trace("CreateCalcForm: Открываем фильтр Расчет на дату"); //var Date = obj as CalculationDate; // AppManager.Instance.MainWindow.ModalWindow(SearchCriteria.ByAutomationId("formCalculationRegistryNew")); var chageDate = new DateTime(int.Parse(Date.Year), int.Parse(Date.Month), int.Parse(Date.Day)); //Дата обновляется два раза для того что бы обновить день Trace("CreateCalcForm: Заполняем фильтр Расчет на дату = " + chageDate); _dtCalculationDateTo.SetDate(chageDate, DateFormat.DayMonthYear); _dtCalculationDateTo.SetDate(chageDate, DateFormat.DayMonthYear); //SetDate(DateTime.Now.AddMonths(int.Parse(Date.Month)) //, DateFormat.DayMonthYear); }
/// <summary> /// Период страхового взноса /// </summary> /// <param name="obj1">DateStart</param> /// <param name="obj2">DateEnd</param> public void InsurancePremiumPeriod(CalculationDate DateStart, CalculationDate DateEnd) { Trace("CreateCalcForm: Заполнение периода страхового взноса"); _chkFilterPaymentsDate.Select(); var chageDateStart = new DateTime(int.Parse(DateStart.Year), int.Parse(DateStart.Month), int.Parse(DateStart.Day)); var changeDateEnd = new DateTime(int.Parse(DateEnd.Year), int.Parse(DateEnd.Month), int.Parse(DateEnd.Day)); //Дата обновляется два раза для того что бы обновить день Trace("CreateCalcForm: Устанавливаем дату начала = " + chageDateStart.ToString()); _dtFilterPaymentsDateStart.SetDate(chageDateStart, DateFormat.DayMonthYear); _dtFilterPaymentsDateStart.SetDate(chageDateStart, DateFormat.DayMonthYear); Trace("CreateCalcForm: Устанавливаем дату оконвания = " + changeDateEnd.ToString()); _dtFilterPaymentsDateEnd.SetDate(changeDateEnd, DateFormat.DayMonthYear); _dtFilterPaymentsDateEnd.SetDate(changeDateEnd, DateFormat.DayMonthYear); }
/// <summary> /// تعدادي مرخصي براي شخص در يک ماه خاص منظور ميکند /// اولويت:1-باقيمانده ماه جاري 2-طلب ساليانه 3-ماههاي گذشته 4-ماههاي آينده /// </summary> /// <param name="remainMinutes">به روز و دقيقه تبديل ميشود</param> /// <param name="date"></param> public virtual void AddUsedLeave(int value) { try { if (value != 0) { PersianDateTime pdateTime = CalculationDate; int month = pdateTime.Month; int monthDayRemain = Convert.ToInt32(value / MinutesInDay); decimal monthMinuteRemain = value - monthDayRemain * MinutesInDay; int requestedLeave = value; #region addUsedLeave int allowedLeave = BudgetYear[month - 1] - UsedBudget[month - 1]; //کسر از مانده ماه جاري if (value <= allowedLeave) { UsedBudget[month - 1] += value; value = 0; } else { UsedBudget[month - 1] += allowedLeave; value -= allowedLeave; } //کسر از طلب سالانه if (value > 0) { int demandLeave = GetDemandLeave(); if (value <= demandLeave) { UsedBudget[month - 1] += value; BudgetYear[month - 1] += value; CalculatedDemandLeave -= value; value = 0; } else { UsedBudget[month - 1] += demandLeave; BudgetYear[month - 1] += demandLeave; value -= CalculatedDemandLeave; CalculatedDemandLeave = 0; } } //کسر از طلب ماههاي قبل if (value > 0) { for (int i = 0; i < month - 1; i++) { allowedLeave = BudgetYear[i] - UsedBudget[i]; if (value <= allowedLeave) { UsedBudget[month - 1] += value; BudgetYear[i] -= value; BudgetYear[month - 1] += value; value = 0; break; } else { UsedBudget[month - 1] += allowedLeave; BudgetYear[i] -= allowedLeave; BudgetYear[month - 1] += allowedLeave; value -= allowedLeave; } } } //کسر از باقيمانده ماههاي آينده if (value > 0 && !LeaveSettings.DoNotUseFutureMounthLeave) { for (int i = month; i < BudgetYear.Length; i++) { allowedLeave = BudgetYear[i] - UsedBudget[i]; if (value <= allowedLeave) { UsedBudget[month - 1] += value; BudgetYear[i] -= value; BudgetYear[month - 1] += value; value = 0; break; } else { UsedBudget[month - 1] += allowedLeave; BudgetYear[i] -= allowedLeave; BudgetYear[month - 1] += allowedLeave; value -= allowedLeave; } } } //افزودن به بدهکاری سالیانه if (value > 0) { this.Debit += value; value = 0; } #endregion #region Add UsedDetail if (value == 0) { UsedLeaveDetail detail = new UsedLeaveDetail(); detail.UsedBudget = UsedBudget; detail.Date = CalculationDate.GregorianDate; detail.Value = requestedLeave; UsedBudget.DetailList.Add(detail); } #endregion if (value > 0) { throw new OutOfExpectedRangeException("0", GetRemainLeave(CalculationDate.GregorianDate).ToString(), value.ToString(), "GTS.Clock.Model.Concepts.BudgetYear.AddUsedLeave(end of method) Date:" + CalculationDate.ToString(), "The Total Remain Leave Is Less Than Value. \n the value checked at the top of the function but at the end of it value is not valid.there is a bad problem at the checking session \n rollback is needed here", ExceptionType.FATAL); } } } catch (Exception ex) { throw new Exception("خطا در بخش مدیریت مرخصی ها.کد 102", ex); } }