protected void gvwDay_RowUpdating(object sender, GridViewUpdateEventArgs e) { if (Page.IsValid) { int dayid = Convert.ToInt32(gvwDay.DataKeys[e.RowIndex].Value); DropDownList ddlwk = gvwDay.Rows[e.RowIndex].FindControl("ddlWeek") as DropDownList; TextBox txtwd = gvwDay.Rows[e.RowIndex].FindControl("txtDate") as TextBox; TextBox txtwc = gvwDay.Rows[e.RowIndex].FindControl("txtWorkContent") as TextBox; TextBox txtrs = gvwDay.Rows[e.RowIndex].FindControl("txtResult") as TextBox; try { DayInfo day = new DayInfo(dayid); day.WeekId = Convert.ToInt32(ddlwk.SelectedValue.ToString()); day.WorkDate = DateTime.Parse(txtwd.Text.Trim()); day.WorkContent = txtwc.Text.ToString(); day.Result = txtrs.Text.ToString(); day.Save(); gvwDay.EditIndex = -1; gvwBind(); } catch (Exception Ex) { ClientScript.RegisterStartupScript(this.GetType(), "Save", "alert('更新失败:" + Ex.Message + "');", true); } } }
protected void gvwDay_RowDeleting(object sender, GridViewDeleteEventArgs e) { int dayid = Convert.ToInt32(gvwDay.DataKeys[e.RowIndex].Value); DayInfo.DelDay(dayid); gvwBind(); }
public IEnumerable <GoalInfo> Get(int rangeID, string strDateStart, string strDateEnd, bool isGetPresentValues) { DateTime dtStart = DateTime.Today; DateTime dtEnd = DateTime.Today; DTC.RangeEnum range = (DTC.RangeEnum)rangeID; if (strDateStart != string.Empty) { dtStart = DTC.Date.GetDateFromString(strDateStart, DTC.Date.DateStyleEnum.Universal); } if (strDateEnd != string.Empty) { dtEnd = DTC.Date.GetDateFromString(strDateEnd, DTC.Date.DateStyleEnum.Universal); } List <GoalInfo> goals = DB.Goals.GetImportantGoals(range, dtStart, dtEnd, isGetPresentValues).FindAll(i => i.IsFocus); DayInfo day = DB.Days.GetDay(DateTime.Today, true); foreach (GoalInfo goal in goals) { goal.PresentPercentage = goal.GetPerformance(false, day); goal.DesiredValue = goal.GetDesiredValue(day); } goals = goals.OrderByDescending(i => i.PresentPercentage).ToList(); return(goals); }
public void ShouldTick() { DayInfo day = new DayInfo(";;"); day.tick(); Assert.AreEqual <string>(DateTime.Now.ToString("HHmmss") + ";", day.ToCSV().Substring(16)); }
private void OnGameReset() { CurrentDayInfo = new DayInfo(); CurrentDayInfo.day = 0; CurrentDayInfo.time = LevelTime.DayStart; GameStarted = false; }
public override void Update(DayInfo info) { info.Status = ModifyStatus(info.Status, info.Conditional); base.Update(info); Update(info.Conditional.Reward); int textId; switch (info.Conditional.Condition.Type) { case PPIDailyRewards.E_ConditionType.GainExperience: textId = info.Conditional.Condition.Value == 1 ? 00502096 : 00502096; break; case PPIDailyRewards.E_ConditionType.PlayNumberOfMatches: textId = info.Conditional.Condition.Value == 1 ? 00502097 : 00502098; break; case PPIDailyRewards.E_ConditionType.WinNumberOfMatches: textId = info.Conditional.Condition.Value == 1 ? 00502099 : 00502100; break; default: textId = 0; break; } string text = textId > 0 ? string.Format(TextDatabase.instance[textId], info.Conditional.Condition.Value) : string.Empty; m_ConditionLabel.SetNewText(text); }
public override string ToString() { var sb = new StringBuilder(); sb.AppendLine($"User Name: {AuthenticatedUserName}"); sb.AppendLine($"IP Address: {IpAddress}"); if (ClientName != null) { sb.AppendLine($"Client Name: {ClientName}"); } sb.AppendLine($"Insert Date: {InsertDate:yyyy-MM-dd HH:mm:ss.fffffff}"); sb.AppendLine($"Last Access Date: {LastAccess:yyyy-MM-dd HH:mm:ss.fffffff}"); sb.AppendLine($"Tenant Id {TenantId}"); if (DayInfo.Any()) { foreach (var dayEntry in DayInfo) { sb.AppendLine(dayEntry.ToString()); } } else { sb.AppendLine("No day info present"); } return(sb.ToString()); }
static void Main(string[] args) { init(); var a = events.FirstOrDefault(); var now = DateTime.Now; var days = new ObservableCollection <DayInfo>(); var calendar = new GregorianCalendar(); var thismonthdaycount = calendar.GetDaysInMonth(now.Year, now.Month); for (int i = 1; i <= thismonthdaycount; i++) { var d = new DateTime(now.Year, now.Month, i); var di = new DayInfo() { Date = d, }; foreach (var eventBase in events) { if (eventBase.CheckDate(d)) { di.Events.Add(eventBase); } } days.Add(di); } Console.WriteLine("Hello World!"); }
private void OnTrackBarScrolled(object sender, EventArgs args) { Dictionary <string, double> newValues = new Dictionary <string, double>(); DayInfo info = new DayInfo(); foreach (CountryInfoEx country in _countries) { try { info = country.DaysInfo[country.DaysInfo.Count + _trackBar.Value - 1]; int active = info.Confirmed - info.Deaths - info.Recovered; double activeLog = (active > 1) ? Math.Log(active) : 0; newValues[country.CountryCode] = activeLog; } catch (Exception) { // ignore } } _geoMap.HeatMap = newValues; _labelDate.Text = $"{info.Date.Day:00}." + $"{info.Date.Month:00}." + info.Date.Year; }
/// <summary> /// 判断是否为农历节假日,包括节气 /// </summary> /// <param name="currentDayInfo"></param> /// <returns></returns> private bool IsLunarHoliday(ref DayInfo currentDayInfo) { bool result = false; if (currentDayInfo.term != null) { if (currentDayInfo.term.Contains("清明")) { return(true); } } HolidayInfo info = new HolidayInfo(); foreach (string cHoliday in lunarHolidays) { info = GetHoliday(2, cHoliday); if (currentDayInfo.lunarM == info.month && currentDayInfo.lunarD == info.day) { currentDayInfo.lunarHoliday = info.name.Replace("*", "") + "\n"; if (info.name.Contains("*")) { result = true; } } } return(result); }
/// <summary> /// Получить матчи с m.FlashScore.com.ua /// </summary> /// <param name="newInfo">За какой временной промежуток получаем матчи. По умолчанию за сегодня</param> /// <returns></returns> public async Task <List <MatchModels> > GetAllMatchesAsync(DayInfo newInfo = DayInfo.Today, bool addOneHour = false) { NewInfo = newInfo; FlurlClient client = new FlurlClient(); client.Headers.Add("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8"); client.Headers.Add("Accept-Encoding", "gzip, deflate"); client.Headers.Add("Accept-Language", "ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7,af;q=0.6"); client.Headers.Add("Cache-Control", "max-age=0"); client.Headers.Add("Host", "m.FlashScore.com.ua"); client.Headers.Add("Upgrade-Insecure-Requests", "1"); string response = null; if (newInfo == DayInfo.Tomorrow) { response = await client.Request("https://m.flashscore.com.ua/" + "?d=1").GetStringAsync(); } else if (newInfo == DayInfo.Today) { response = await client.Request("https://m.flashscore.com.ua/").GetStringAsync(); } else if (newInfo == DayInfo.Yesterday) { response = await client.Request("https://m.flashscore.com.ua/" + "?d=-1").GetStringAsync(); } Matches = Parsing.MFlashScore(response, addOneHour).ToList(); return(Matches); }
public PhongInfo RowToInfo(DataRow row) { PhongInfo phong = new PhongInfo(); phong.MaPhong = row["MAPHG"].ToString(); phong.TenPhong = row["TENPHG"].ToString(); phong.SoLuongToiDa = Convert.ToInt32(row["SOLUONGTOIDA"].ToString()); phong.PhongNam = Convert.ToBoolean(row["PhongNam"].ToString()); DayInfo day = new DayInfo(); day.MaDay = row["MADAY"].ToString(); day.TenDay = row["TENDAY"].ToString(); phong.Day = day; TrangThaiPhongInfo trangthai = new TrangThaiPhongInfo(); trangthai.MaTrangThai = Convert.ToInt32(row["MATRANGTHAI"].ToString()); trangthai.TenTrangThai = row["TENTRANGTHAI"].ToString(); phong.TrangThai = trangthai; return(phong); }
public void Update(GuessStrategyArgs args) { // 実行結果のクリア isSuccess = false; guessList.Clear(); // 初日は実行失敗 if (args.Agi.Day <= 1) { return; } DayInfo dayInfo = args.Agi.DayInfo[1]; foreach (ExtTalk talk in dayInfo.TalkList) { if (talk.Content.Operator == Operator.NOP && talk.Content.Topic == Topic.ESTIMATE && talk.Content.Role == Role.WEREWOLF) { BitCondition con = new BitCondition(); con.AddWerewolf(talk.Agent); con.AddWerewolf(talk.Content.Target); guessList.Add(new PartGuess() { Condition = con, Correlation = 0.95, }); } } // 実行成功にする isSuccess = true; }
private void AssignSprite(DayInfo info) { int spriteIndex = info.day * 3; switch (info.time) { case LevelTime.DayStart: break; case LevelTime.NightEnd: //transform.rotation = Quaternion.identity; spriteIndex += 1; break; case LevelTime.Level: //transform.rotation = Quaternion.Euler(0f, 0f, -90f); spriteIndex++; break; default: break; } spriteIndex = Mathf.Clamp(spriteIndex, 0, allSprites.Length); if (spriteIndex < allSprites.Length) { _spriteRenderer.sprite = allSprites[spriteIndex]; } }
public virtual void Update(DayInfo info) { ShowWidget(m_BackgroundIdle, info.Status == E_Status.Idle); ShowWidget(m_BackgroundCurrent, info.Status == E_Status.Current); ShowWidget(m_BackgroundGained, info.Status == E_Status.Gained); ShowWidget(m_BackgroundMissed, info.Status == E_Status.Missed); }
public void RefreshToday() { DateTime today = DateTime.Now; int dayCount = Days.m_Instance.Count; for (int i = 0; i < dayCount; i++) { DayInfo day = Days.m_Instance.Get(i); if (day.IsDay(today)) { m_Today = day; RefreshDay(day); return; } } int starUsageCount = CustomStarUsage.m_Instance.m_StarUsageCount - 1; if (starUsageCount < 0) { m_Today = new DayInfo(); return; } for (int i = 0; i < starUsageCount; i++) { m_StringBuilder.Append("|0"); m_StringBuilder.Append("."); } m_StringBuilder.Append("|0"); string stars = m_StringBuilder.ToString(); m_StringBuilder.Clear(); m_Today = new DayInfo(today.Year, today.Month, today.Day, stars); RefreshDay(m_Today); }
void UpdateDays(DayInfo[] infos) { int lastDay = PPIDailyRewards.DAYS_PER_CYCLE - 1; for (int idx = 0, last = PPIDailyRewards.DAYS_PER_CYCLE - 1; idx <= last; ++idx) { DayInfo info = infos[idx]; // should we display magic box? if (idx == lastDay) { if (info.Status != E_Status.Current && info.Status != E_Status.Gained) { info.Instant.Reward.Value = -1; } if (info.Conditional.Received == false) { info.Conditional.Reward.Value = -1; } } // update day m_Days[idx].Update(info); } }
private static string GenerateItemBody(DayInfo dayChangeInfo, IEnumerable <string> productFilter, string functionAppDirectory) { var bodyHtml = new StringBuilder(); bodyHtml.Append("<ul>"); var docChangesPerProducts = dayChangeInfo.DocChanges .Where(_ => productFilter.Count() == 0 || productFilter.Contains(_.Product)) .GroupBy(_ => _.Product) .OrderBy(_ => ProductTitleRepository.MapFolderToProductTitle(_.Key, functionAppDirectory)); foreach (var docChangesPerProduct in docChangesPerProducts) { var added = docChangesPerProduct.Sum(i => i.Commits.Count(commit => commit.Status == ChangeStatus.Added)); var modified = docChangesPerProduct.Sum(i => i.Commits.Count(commit => commit.Status == ChangeStatus.Modified)); var deleted = docChangesPerProduct.Sum(i => i.Commits.Count(commit => commit.Status == ChangeStatus.Removed)); bodyHtml.Append("<li>"); bodyHtml.Append($"{ProductTitleRepository.MapFolderToProductTitle(docChangesPerProduct.Key, functionAppDirectory)}: "); bodyHtml.Append(added > 0 ? $"{added} added, " : ""); bodyHtml.Append(deleted > 0 ? $"{deleted} deleted, " : ""); bodyHtml.Append(modified > 0 ? $"{modified} modified, " : ""); bodyHtml.Remove(bodyHtml.Length - 2, 2); bodyHtml.Append(" articles"); bodyHtml.AppendLine("</li>"); } bodyHtml.Append("</ul>"); return(bodyHtml.ToString()); }
protected override void OnInitialized() { Start = new DateTime(Year, Month, 1); while (Start.DayOfWeek != DayOfWeek.Monday) { Start = Start.AddDays(-1); } End = new DateTime(Year, Month, 1).LastDayOfMonth(); while (End.DayOfWeek != DayOfWeek.Sunday) { End = End.AddDays(1); } Current = Start; Weeks = new List <WeekInfo>(); while (Start <= End) { var current = Start; var week = new WeekInfo(); while (current.DayOfWeek != DayOfWeek.Sunday) { var d = new DayInfo { Day = current }; week.Days.Add(d); current = current.AddDays(1); } Weeks.Add(week); Start = Start.AddDays(7); } }
/// <summary> /// ay 2015年11月19日17:31:25 /// 增加 /// </summary> /// <param name="Cyear"></param> /// <param name="Cmonth"></param> /// <param name="Cday"></param> /// <returns></returns> public static DayInfo GetNongLi(int Cyear, int Cmonth, int Cday) { DateTime dt = new DateTime(Cyear, Cmonth, Cday); DayInfo result = new DayInfo(); result.Day = GetDay(dt); result.TitleType = 0; result.Title = result.Day; result.Month = GetMonth(dt); result.MonthAndDay = result.Month + result.Day; if (result.Day == "初一") { result.Title = result.Month; result.TitleType = 1; } //获得节气,节日,中国农历节日 string strJQ = GetSolarTerm(dt); if (strJQ != "") { result.JieQi = strJQ; result.Title = result.JieQi; result.TitleType = 2; } string strHoliday = GetHoliday(dt); if (strHoliday != "") { result.GongHoliday = strHoliday; result.Title = result.GongHoliday; result.TitleType = 3; } string strChinaHoliday = GetChinaHoliday(dt); if (strChinaHoliday != "") { result.NongHoliday = strChinaHoliday; result.Title = result.NongHoliday; result.TitleType = 4; } int yearIndex = china.GetSexagenaryYear(dt); string yearTG = " 甲乙丙丁戊己庚辛壬癸"; string yearDZ = " 子丑寅卯辰巳午未申酉戌亥"; string yearSX = " 鼠牛虎兔龙蛇马羊猴鸡狗猪"; int year = china.GetYear(dt); int yTG = china.GetCelestialStem(yearIndex); int yDZ = china.GetTerrestrialBranch(yearIndex); result.Year = year; result.TianGan = yearTG[yTG].ToString(); result.DiGan = yearDZ[yDZ].ToString(); result.ShengXiao = yearSX[yDZ].ToString(); return(result); }
private void reset() { _lastSelectedIdx = -1; for (var i = 0; i <= 41; i++) { DaysInfo[i + 7] = new DayInfo(); } }
public void DefaultCtorTest() { var di = new DayInfo(); Assert.IsFalse(di.IsWorkingDay); Assert.IsNull(di.Description); Assert.IsNull(di.WorkingPeriods); }
public void Load() { string line = io.ReadFromFile(today.getSubDirectory(), today.getFilename()); today = line.Length > 0 ? new DayInfo(line) : new DayInfo(); Tick(); PersistData(); }
public override void Update(DayInfo info) { info.Status = ModifyStatus(info.Status, info.Date, info.Instant); base.Update(info); Update(info.Instant.Reward); }
private List <string> GetAllFiles(DayInfo dayInfo) { return(dayInfo.DocChanges .Where(_ => _.Commits[0].Status != ChangeStatus.Removed) .Select(_ => _.Url) .Distinct() .ToList()); }
public void ShouldInstantiateFromInvalidCSVLine() { DayInfo day = new DayInfo("20100101;;"); Assert.AreEqual <string>("20100101.csv", day.getFilename()); Assert.AreEqual <string>("2010\\01\\", day.getSubDirectory()); Assert.IsNull(day.getFirstActivity()); Assert.IsNull(day.getLastActivity()); }
public ActionResult Index() { DateTime today = DateTime.Today; DateTime startOfWeek = DateTime.Today.AddDays(-(int)DateTime.Today.DayOfWeek + (int)DayOfWeek.Monday); DateTime endOfWeek = startOfWeek.AddDays(7); // getting events events that are within range of current start and end day of the week // pulling active events only var activities = db.Activities.Include(a => a.events) .Where(a => a.events.Any(e => e.StartDate >= startOfWeek && e.EndDate <= endOfWeek && e.IsActive == true)) .Select(a => a).ToList(); var WeekInfo = new List <DayInfo>(); foreach (var a in activities) { foreach (var e in a.events) { // check if event is within the current week and isActive if (!(e.StartDate >= startOfWeek && e.EndDate <= endOfWeek && e.IsActive == true)) { continue; } var day = e.StartDate.Date; var dayInfo = WeekInfo.FirstOrDefault(d => d.Day == day); // check if dayInfo is empty before adding events // we don't want duplicate days for each event if (dayInfo == null) { dayInfo = new DayInfo { Day = day, Events = new List <EventInfo>() }; WeekInfo.Add(dayInfo); } dayInfo.Events.Add(new EventInfo { StartDate = e.StartDate, EndDate = e.EndDate, ActivityDescription = a.ActivityDescription }); } } WeekInfo = WeekInfo.OrderBy(w => w.Day).ToList(); foreach (var day in WeekInfo) { day.Events = day.Events.OrderBy(e => e.StartDate).ToList(); } // Passing a list of Days which contains Events which contains StartDate, EndDate, and desc. return(View(WeekInfo)); }
IEnumerator ShowCurrentRewards_Coroutine(PPIDailyRewards rewards, bool instant, bool conditional) { int currDay = rewards.CurrentDay; DateTime date = CloudDateTime.UtcNow.Date - TimeSpan.FromDays(currDay); DayInfo[] infos = new DayInfo[PPIDailyRewards.DAYS_PER_CYCLE]; for (int idx = 0; idx < PPIDailyRewards.DAYS_PER_CYCLE; ++idx) { E_Status status = E_Status.Idle; if (idx < currDay) { status = E_Status.Gained; } else if (idx == currDay) { status = E_Status.Current; } infos[idx] = new DayInfo() { Date = date + TimeSpan.FromDays(idx), Status = status, Scale = Vector2.one, Instant = rewards.Instant[idx].DeepCopy(), Conditional = rewards.Conditional[idx].DeepCopy() }; infos[idx].Instant.Received = idx <= currDay ? true : false; } UpdateDays(infos); yield return(new WaitForSeconds(0.5f)); if (MFGuiManager.Instance != null) { MFGuiManager.Instance.PlayOneShot(m_GainedAudio); } // highlight current reward if (instant == true || conditional == true) { bool blinkInstant = instant; bool blinkConditional = conditional; for (int idx = 0; idx < 6; ++idx) { yield return(new WaitForSeconds(0.15f)); m_Days[currDay].SetHighlight(blinkInstant, blinkConditional); blinkInstant = instant ? !blinkInstant : false; blinkConditional = conditional ? !blinkConditional : false; } m_Days[currDay].SetHighlight(instant, conditional); } }
public void OnlyDescriptionTest() { var desc = "description"; var di = new DayInfo(desc); Assert.IsFalse(di.IsWorkingDay); Assert.AreEqual(desc, di.Description); Assert.IsNull(di.WorkingPeriods); }
public IActionResult GetDayInfo(int year, int month, int day, string roomId) { var dayInfo = new DayInfo { Meetings = DummyDataProvider.GetRoomTimeline(roomId) }; return(Ok(dayInfo)); }
public static MonthInfo GetMonthInfo(HttpContext context) { var modelContext = new Models.YouthTechProgramContext(); var ymd = DateTime.Today; var dayInfoItems = new List<DayInfo>(); if (!DateTime.TryParse(context.Request["ymd"], out ymd)) ymd = DateTime.Today; // adjust to first date of target month ymd = ymd.AddDays(1 - ymd.Day); for (var dayNumber = 1; dayNumber <= DateTime.DaysInMonth(ymd.Year, ymd.Month); dayNumber++) { var dayInfoItem = new DayInfo { Date = new DateTime(ymd.Year, ymd.Month, dayNumber), IsEnabled = false, IsInput = false, MethodMorning = "No Commute", MethodEvening = "No Commute", Points = 0 }; dayInfoItem.IsInput = true; dayInfoItem.IsEnabled = dayInfoItem.Date <= DateTime.Today; dayInfoItems.Add(dayInfoItem); } var prefixDay = dayInfoItems.First().Date; while (prefixDay.DayOfWeek != DayOfWeek.Sunday) { prefixDay = prefixDay.AddDays(-1); var dayInfoItem = new DayInfo { Date = prefixDay, IsEnabled = false, IsInput = false, MethodMorning = "No Commute", MethodEvening = "No Commute", Points = 0 }; dayInfoItem.Date = prefixDay; dayInfoItem.IsInput = false; dayInfoItems.Insert(0, dayInfoItem); } var suffixDay = dayInfoItems.Last().Date; while (suffixDay.DayOfWeek != DayOfWeek.Saturday) { suffixDay = suffixDay.AddDays(1); var dayInfoItem = new DayInfo { Date = suffixDay, IsEnabled = false, IsInput = false, MethodMorning = "No Commute", MethodEvening = "No Commute", Points = 0 }; dayInfoItem.Date = suffixDay; dayInfoItem.IsInput = false; dayInfoItems.Add(dayInfoItem); } var thisMonth = modelContext.Months.SingleOrDefault(item => item.Date.Equals(ymd)); if (thisMonth != null) { foreach (var dayInfoItem in dayInfoItems) { var day = thisMonth.Days.SingleOrDefault(item => item.Date.Equals(dayInfoItem.Date)); if (day != null) { dayInfoItem.MethodMorning = day.MethodMorning.Description; dayInfoItem.MethodEvening = day.MethodEvening.Description; dayInfoItem.Points = day.MethodMorning.Points + day.MethodEvening.Points; } } } var monthInfo = new MonthInfo(); monthInfo.MethodCollection = modelContext.Methods.Select(item => new MethodInfo { Text = item.Description, Value = item.Points }).ToArray(); monthInfo.DayInfoCollection = dayInfoItems.ToArray(); return monthInfo; }
private void Button_Click(object sender, RoutedEventArgs e) { if (DelegatesData.HandlerAchCloseMW != null) DelegatesData.HandlerAchCloseMW(); DayInfo di; if (From.SelectedDate.Value > To.SelectedDate.Value) { di = new DayInfo(To.SelectedDate.Value, To.SelectedDate.Value); } else { di = new DayInfo(From.SelectedDate.Value, To.SelectedDate.Value); } di.Show(); this.Close(); }
public DayInfo GetDayInfo(DateTime dtNow, Line line) { DayInfo dayDayInfo = null; if (dtNow.Hour == 19) //白班 { string strday = dtNow.ToString("yyyyMMdd"); dayDayInfo = DALLib<DayInfo>.DataAccess.GetOneBySQL(string.Format("select * from tbDayInfo where LineId={0} and [day]='{1}' and DayShiftFlag={2}", line.Id, strday, (int)EDayShiftFlag.DayShift)); if (dayDayInfo == null) { dayDayInfo = new DayInfo(); dayDayInfo.LineId = line.Id; dayDayInfo.DayShiftFlag = (int)EDayShiftFlag.DayShift; dayDayInfo.Day = strday; dayDayInfo.Shift = DALLib<ShiftType>.DataAccess.GetOne("ShiftName", ShiftCalendarInfo.GetInstance().GetShiftInfo(dtNow.AddHours(-1))).Id; DALLib<DayInfo>.DataAccess.SaveOne(dayDayInfo); } dayDayInfo._dtBegin = new DateTime(dtNow.Year, dtNow.Month, dtNow.Day, 7, 0, 0); dayDayInfo._dtEnd = new DateTime(dtNow.Year, dtNow.Month, dtNow.Day, 19, 0, 0); } else if (dtNow.Hour == 7) //晚班 { string strday = dtNow.AddDays(-1).ToString("yyyyMMdd"); dayDayInfo = DALLib<DayInfo>.DataAccess.GetOneBySQL(string.Format("select * from tbDayInfo where LineId={0} and [day]='{1}' and DayShiftFlag={2}", line.Id, strday, (int)EDayShiftFlag.NightShift)); if (dayDayInfo == null) { dayDayInfo = new DayInfo(); dayDayInfo.LineId = line.Id; dayDayInfo.Day = strday; dayDayInfo.DayShiftFlag = (int)EDayShiftFlag.NightShift; dayDayInfo.Shift = DALLib<ShiftType>.DataAccess.GetOne("ShiftName", ShiftCalendarInfo.GetInstance().GetShiftInfo(new DateTime(dtNow.AddDays(-1).Year, dtNow.AddDays(-1).Month, dtNow.AddDays(-1).Day, 20, 0, 0))).Id; DALLib<DayInfo>.DataAccess.SaveOne(dayDayInfo); } dayDayInfo._dtBegin = new DateTime(dtNow.AddDays(-1).Year, dtNow.AddDays(-1).Month, dtNow.AddDays(-1).Day, 19, 0, 0); dayDayInfo._dtEnd = new DateTime(dtNow.Year, dtNow.Month, dtNow.Day, 7, 0, 0); } return dayDayInfo; }
/// <summary> /// 设置显示文字和TAG /// </summary> /// <param name="cell"></param> /// <param name="info"></param> private void SetCellText(CalendarCell cell,DayInfo info) { cell.label1.Text = info.date.Day.ToString(); cell.label2.Text = info.lunarMS+info.lunarDS; if (info.holiday!=null && info.holiday.Trim()!="") { cell.label2.Text = info.holiday; } if (info.term != "") { cell.label2.Text = info.term; } if (info.lunarHoliday!=null && info.lunarHoliday!="") { cell.label2.Text = info.lunarHoliday; } cell.Tag = (object)info; if (cell.label2.Text.IndexOf("\n")>0) { cell.label2.Text = cell.label2.Text.Remove(cell.label2.Text.Length - (cell.label2.Text.Length - cell.label2.Text.IndexOf("\n"))); } }
/// <summary> /// 方向键被按下 /// </summary> /// <param name="direction">方向:1.上;2.右;3.下;4.左</param> private void ArrowKeyPressed(int direction) { DayInfo info = new DayInfo(); CalendarCell cell = new CalendarCell(); switch (direction) { case 1: if (cRow == 0) { cell = (CalendarCell)MainPanel.GetControlFromPosition(cColumn, cRow); info = (DayInfo)cell.Tag; displayDate = info.date.Date.AddDays(-7); CheckDateChange(); return; } else { cRow--; } break; case 2: if (cColumn == 6) { if (cRow == 5) { cell = (CalendarCell)MainPanel.GetControlFromPosition(cColumn, cRow); info = (DayInfo)cell.Tag; displayDate = info.date.Date.AddDays(1); CheckDateChange(); return; } else { cColumn = 0; cRow++; } } else { cColumn++; } break; case 3: if (cRow == 5) { cell = (CalendarCell)MainPanel.GetControlFromPosition(cColumn, cRow); info = (DayInfo)cell.Tag; displayDate = info.date.Date.AddDays(7); CheckDateChange(); return; } else { cRow++; } break; case 4: if (cColumn == 0) { if (cRow == 0) { cell = (CalendarCell)MainPanel.GetControlFromPosition(cColumn, cRow); info = (DayInfo)cell.Tag; displayDate = info.date.Date.AddDays(-1); CheckDateChange(); return; } else { cColumn = 6; cRow--; } } else { cColumn--; } break; } cell = (CalendarCell)MainPanel.GetControlFromPosition(cColumn, cRow); CellClicked(cell, new EventArgs()); }
/// <summary> /// 有单元格被点 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void CellClicked(object sender, EventArgs e) { CalendarCell cell = (CalendarCell)sender; DayInfo cellInfo = new DayInfo(); cellInfo = (DayInfo)cell.Tag; if(cellInfo.date.Month!=displayDate.Month) { displayDate = cellInfo.date; CheckDateChange(); return; } else { DisplayCellInfo(cellInfo); } displayDate = cellInfo.date; foreach(CalendarCell cCell in MainPanel.Controls) { try { if (cCell == cell) { cCell.Clicked = true; } else { cCell.Clicked = false; } cCell.ResetColor(); } catch { } } cell.ResetColor(); cColumn = MainPanel.GetColumn(cell); cRow = MainPanel.GetRow(cell); }
/// <summary> /// 将单击的单元格的信息显示到右边和上边 /// </summary> /// <param name="Cellinfo"></param> private void DisplayCellInfo(DayInfo cellInfo) { LblYearInfo.Text = cellInfo.date.ToString("yyyy年M月d日 dddd"); LblLunarYM.Text = "农历 " + cellInfo.animal + "年\n" + cellInfo.lunarMS; LblLunarDay.Text = cellInfo.lunarDS; LblLunarGanZhi.Text = cellInfo.ganZhi + " " + cellInfo.ganZhiM + " " + cellInfo.ganZhiD; LblHoliday.Text = ""; if (cellInfo.term!="") { LblHoliday.Text = "今日" + cellInfo.term + "\n"; } LblHoliday.Text += cellInfo.holiday; LblHoliday.Text += cellInfo.lunarHoliday; }
/// <summary> /// 判断是否为农历节假日,包括节气 /// </summary> /// <param name="currentDayInfo"></param> /// <returns></returns> private bool IsLunarHoliday(ref DayInfo currentDayInfo) { bool result = false; if (currentDayInfo.term!=null) { if (currentDayInfo.term.Contains("清明")) { return true; } } HolidayInfo info = new HolidayInfo(); foreach (string cHoliday in lunarHolidays) { info = GetHoliday(2, cHoliday); if (currentDayInfo.lunarM==info.month && currentDayInfo.lunarD==info.day) { currentDayInfo.lunarHoliday = info.name.Replace("*", "") + "\n"; if (info.name.Contains("*")) { result = true; } } } return result; }
/// <summary> /// 重新设置单元格 /// </summary> private void InitCells() { int column = 0; int row = 0; MainPanel.RowCount = 6; DateTime currMonth = new DateTime(displayDate.Year, displayDate.Month, 1); DateTime currDay = new DateTime(); currDay = currMonth.AddDays((double)(0 - currMonth.DayOfWeek)); CalendarCell currCell = new CalendarCell(); #region 填充单元格 while (column<7 && row<6) { HFDate lunarProcessor = new HFDate(currDay); DayInfo currDayInfo = new DayInfo(); currDayInfo.date = currDay; currDayInfo.animal = animalNames[lunarProcessor.LunarYear.Zhi.IntValue - 1]; currDayInfo.lunarM = lunarProcessor.LunarCalendarMonth; currDayInfo.lunarD = lunarProcessor.LunarCalendarDay; currDayInfo.ganZhi = lunarProcessor.LunarYear.Name + "年"; currDayInfo.ganZhiM = lunarProcessor.LunarMonth.Name + "月"; currDayInfo.ganZhiD = lunarProcessor.LunarDay.Name + "日"; currDayInfo.lunarMS = lunarProcessor.LunarCalendarMonthString; currDayInfo.lunarDS = lunarProcessor.LunarCalendarDayString; currDayInfo.term = lunarProcessor.SolarTermInfo; currDayInfo.isHoliday = IsHoliday(ref currDayInfo); //加入节假日判断 currDayInfo.isLunarHoliday = IsLunarHoliday(ref currDayInfo); currCell = (CalendarCell)MainPanel.GetControlFromPosition(column, row); currCell.Visible = true; SetCellText(currCell, currDayInfo); SetCellColor(currCell); if (currDayInfo.date.Date==displayDate.Date) { cColumn = column; cRow = row; CellClicked(currCell, new EventArgs()); } column++; if (column > 6) { column = 0; row++; } currDay = currDay.AddDays(1); } CalendarCell tmpCell = (CalendarCell)MainPanel.GetControlFromPosition(0, 5); if (((DayInfo)tmpCell.Tag).date.Month != displayDate.Date.Month) { for (int i = 0; i < 7; i++) { tmpCell = (CalendarCell)MainPanel.GetControlFromPosition(i, 5); tmpCell.Visible = false; } } #endregion oldDate = displayDate; return; }
/// <summary> /// 判断是否为阳历的节假日,包括周末 /// </summary> /// <param name="currentDayInfo"></param> /// <returns></returns> private bool IsHoliday(ref DayInfo currentDayInfo) { bool result = false; if (currentDayInfo.date.DayOfWeek == DayOfWeek.Saturday || currentDayInfo.date.DayOfWeek == DayOfWeek.Sunday) { result = true; } HolidayInfo info=new HolidayInfo(); foreach (string cHoliday in holidays) { info = GetHoliday(1, cHoliday); if (info.month==currentDayInfo.date.Month && info.day ==currentDayInfo.date.Day) { currentDayInfo.holiday += info.name.Replace("*", "") + "\n"; if (info.name.Contains("*")) { result = true; } } } foreach (string cHoliday in nDayHolidays) { info = GetHoliday(3, cHoliday); if (info.month != currentDayInfo.date.Month) { continue; } if (Convert.ToInt32(currentDayInfo.date.DayOfWeek)!=info.day) { continue; } else { DateTime tmpDate = currentDayInfo.date; int count = 0; if (info.count==5) { do { tmpDate = tmpDate.AddDays(7); if (tmpDate.Month != currentDayInfo.date.Month) { break; } count++; } while (true); if (count == 0) { currentDayInfo.holiday += info.name.Replace("*", "") + "\n"; if (info.name.Contains("*")) { result = true; } } return result; } do { count++; tmpDate = tmpDate.AddDays(-7); } while (tmpDate.Month == displayDate.Month); if (count==info.count) { currentDayInfo.holiday += info.name.Replace("*", "") + "\n"; if (info.name.Contains("*")) { result = true; } } } } return result; }