/// <summary> /// 年間祝祭日設定ロード /// </summary> private void loadYearyHoliday() { this.SuspendLayout(); string strSQL = "select * from holiday_list where strftime('%Y', holiday_date) = '" + dtpHolidayYear.Value.ToString("yyyy") + "' order by holiday_date"; listView1.Items.Clear(); holidayList.Clear(); int index = 0; // 祝祭日DBに該当年のデータがあるかどうか確認 SQLiteDataReader result = sqliteAccess.select(strSQL); if (result != null) { while (result.Read()) { holidays holiday = new holidays(); holiday.date = DateTime.Parse(result.GetDateTime(0).ToString("yyyy/MM/dd")); holiday.type = result.GetInt32(1); holiday.name = result.GetString(2); holidayList.Add(holiday); string[] strHoliday = { holiday.date.ToString("yyyy/MM/dd"), holiday.name }; ListViewItem lvi = new ListViewItem(strHoliday); lvi.Tag = index; listView1.Items.Add(lvi); index++; } } sqliteAccess.readerClose(); this.ResumeLayout(); }
private void saveAndDisplay() { holidays holiday = new holidays(); // 新規登録 if (bNewEntry) { setToContents(ref holiday); insert(holiday); } // 更新 else { lock (holidayList) { // 対象のコンテンツ一覧から検索取得 holidays data = (holidays)holidayList[selectIndex]; holiday = data; setToContents(ref holiday); } update(holiday); } resetInputFields(); // 年間祝祭日設定ロード loadYearyHoliday(); // オーナフォーム(カレンダ)再表示 parentForm.setCalendar(); }
/// <summary> /// SQL接続(destroy) /// </summary> private void destroy(holidays holiday) { string strSQL = "delete from holiday_list" + " where holiday_date = datetime('" + holiday.date.ToString("yyyy-MM-dd 00:00:00") + "')"; sqliteAccess.update(strSQL); }
public IHttpActionResult Postholidays(holidays holidays) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.holidays.Add(holidays); try { db.SaveChanges(); } catch (DbUpdateException) { if (holidaysExists(holidays.id_holiday)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = holidays.id_holiday }, holidays)); }
public IHttpActionResult Putholidays(int id, holidays holidays) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != holidays.id_holiday) { return(BadRequest()); } db.Entry(holidays).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!holidaysExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
/// <summary> /// SQL接続(update) /// </summary> private void update(holidays holiday) { string strSQL = "update holiday_list set " + "holiday_type = " + holiday.type + ", holiday_name = '" + holiday.name + "'" + " where holiday_date = datetime('" + holiday.date.ToString("yyyy-MM-dd 00:00:00") + "')"; sqliteAccess.update(strSQL); }
public IHttpActionResult Getholidays(int id) { holidays holidays = db.holidays.Find(id); if (holidays == null) { return(NotFound()); } return(Ok(holidays)); }
/// <summary> /// 指定されたコンテンツデータより編集領域へ /// </summary> /// <param name="data"></param> private void setInputFields(holidays holiday) { btnNew.Enabled = false; btnCancel.Enabled = true; btnEntry.Enabled = true; btnDelete.Enabled = true; dtpHoliday.Enabled = false; textBox1.Enabled = true; bNewEntry = false; dtpHoliday.Value = holiday.date; textBox1.Text = holiday.name; }
/// <summary> /// SQL接続(insert) /// </summary> private void insert(holidays holiday) { string strSQL = "insert into holiday_list (" + "holiday_date" + ", holiday_type" + ", holiday_name" + ") values (" + "datetime('" + holiday.date.ToString("yyyy-MM-dd 00:00:00") + "')" + ", " + holiday.type + ", '" + holiday.name + "'" + ")"; sqliteAccess.insert(strSQL, null); }
public IHttpActionResult Deleteholidays(int id) { holidays holidays = db.holidays.Find(id); if (holidays == null) { return(NotFound()); } db.holidays.Remove(holidays); db.SaveChanges(); return(Ok(holidays)); }
public bool AddHoliday(holidaysDto dataHoliday, int nodeId) { try { SigesoftEntitiesModel cnx = new SigesoftEntitiesModel(); string newId = Common.Utils.GetNewId(nodeId, Utils.GetNextSecuentialId(nodeId, 51), "FR"); dataHoliday.v_HolidayId = newId; holidays entityHolidays = holidaysAssembler.ToEntity(dataHoliday); cnx.AddToholidays(entityHolidays); return(cnx.SaveChanges() > 0); } catch (Exception) { return(false); } }
public IHttpActionResult PostPricePitch(scheduler scheduler) { if (scheduler == null) { return(BadRequest()); } if (scheduler.hour.Hours == 0 || scheduler.id_pitch == 0 || scheduler.date_insert.Year == 1) { return(BadRequest()); } IQueryable <object> getPrice = null; DateTime dateEntry = scheduler.date_insert.Date; holidays holiday = (from a in db.holidays where a.date == dateEntry select a).FirstOrDefault(); if (holiday != null) { getPrice = (from a in db.scheduler where a.id_day == 8 && a.id_pitch == scheduler.id_pitch && a.hour.Hours == scheduler.hour.Hours select new { id_pitch = a.id_pitch, value = a.value }); } else { int intDayOfWeek = scheduler.date_insert.DayOfWeek.GetHashCode(); if (intDayOfWeek == 0) { intDayOfWeek = 7; } getPrice = (from a in db.scheduler where a.id_day == intDayOfWeek && a.id_pitch == scheduler.id_pitch && a.hour.Hours == scheduler.hour.Hours select new { id_pitch = a.id_pitch, value = a.value }); } return(Ok(getPrice)); }
/// <summary> /// Converts this instance of <see cref="holidays"/> to an instance of <see cref="holidaysDto"/>. /// </summary> /// <param name="entity"><see cref="holidays"/> to convert.</param> public static holidaysDto ToDTO(this holidays entity) { if (entity == null) { return(null); } var dto = new holidaysDto(); dto.v_HolidayId = entity.v_HolidayId; dto.i_Year = entity.i_Year; dto.d_Date = entity.d_Date; dto.v_Reason = entity.v_Reason; dto.i_IsDeleted = entity.i_IsDeleted; entity.OnDTO(dto); return(dto); }
/// <summary> /// Converts this instance of <see cref="holidaysDto"/> to an instance of <see cref="holidays"/>. /// </summary> /// <param name="dto"><see cref="holidaysDto"/> to convert.</param> public static holidays ToEntity(this holidaysDto dto) { if (dto == null) { return(null); } var entity = new holidays(); entity.v_HolidayId = dto.v_HolidayId; entity.i_Year = dto.i_Year; entity.d_Date = dto.d_Date; entity.v_Reason = dto.v_Reason; entity.i_IsDeleted = dto.i_IsDeleted; dto.OnEntity(entity); return(entity); }
private void btnDelete_Click(object sender, EventArgs e) { holidays holiday = new holidays(); lock (holidayList) { // 対象のコンテンツ一覧から検索取得 holiday = (holidays)holidayList[selectIndex]; } destroy(holiday); resetInputFields(); // 年間祝祭日設定ロード loadYearyHoliday(); // オーナフォーム(カレンダ)再表示 parentForm.setCalendar(); }
/// <summary> /// Invoked when <see cref="ToEntity"/> operation is about to return. /// </summary> /// <param name="entity"><see cref="holidays"/> converted from <see cref="holidaysDto"/>.</param> static partial void OnEntity(this holidaysDto dto, holidays entity);
/// <summary> /// Invoked when <see cref="ToDTO"/> operation is about to return. /// </summary> /// <param name="dto"><see cref="holidaysDto"/> converted from <see cref="holidays"/>.</param> static partial void OnDTO(this holidays entity, holidaysDto dto);
public void AddToholidays(holidays holidays) { base.AddObject("holidays", holidays); }
public static holidays Createholidays(global::System.DateTime day_time) { holidays holidays = new holidays(); holidays.day_time = day_time; return holidays; }
private void btnCreate_Click(object sender, EventArgs e) { string year = dtpHolidayYear.Value.ToString("yyyy"); int intYear = int.Parse(year); ArrayList holidayList = new ArrayList(); ArrayList holidayList2 = new ArrayList(); ArrayList holidayList3 = new ArrayList(); // 警告メッセージ if (MessageBox.Show(this, "この処理を実行すると一旦当該年度の祝祭日を消去し作り直します。\r\n手動設定の情報は削除されます。実行してよろしいですか?", "警告", MessageBoxButtons.YesNo) == DialogResult.No) { return; } string strSQL = "select count(*) from holiday_list where strftime('%Y', holiday_date) = '" + year + "' "; // 祝祭日DBに該当年のデータがあるかどうか確認 SQLiteDataReader result = sqliteAccess.select(strSQL); if (result != null && result.Read()) { if (result.GetInt32(0) > 0) { sqliteAccess.readerClose(); strSQL = "delete from holiday_list where strftime('%Y', holiday_date) = '" + year + "' "; sqliteAccess.update(strSQL); } } sqliteAccess.readerClose(); // 祝祭日マスタ読込 strSQL = "select * from holiday_master order by id"; result = sqliteAccess.select(strSQL); if (result != null) { masterList.Clear(); while (result.Read()) { holidayMaster hm = new holidayMaster(); hm.id = result.GetInt32(0); hm.holiday_type = result.GetInt32(1); hm.holiday_name = result.GetString(2); hm.third = result.GetInt32(3); hm.fourth = result.GetInt32(4); hm.fifth = result.GetInt32(5); hm.sixth = result.GetInt32(6); hm.seventh = result.GetInt32(7); masterList.Add(hm); } sqliteAccess.readerClose(); foreach (holidayMaster hm in masterList) { DateTime date = DateTime.Today; int weekCount = 0; bool effective = true; // 有効期日指定があるなら if (hm.seventh != -1) { int effectiveYear = hm.sixth; effective = false; // 判定方法分岐 switch (hm.seventh) { case 0: // < if (intYear < effectiveYear) { effective = true; } break; case 1: // > if (intYear > effectiveYear) { effective = true; } break; case 2: // <= if (intYear <= effectiveYear) { effective = true; } break; case 3: // >= if (intYear >= effectiveYear) { effective = true; } break; case 4: // == if (effectiveYear == intYear) { effective = true; } break; case 5: // >< if (effectiveYear != intYear) { effective = true; } break; } } if (effective == false) { continue; } switch (hm.holiday_type) { case 0: // 固定休日 date = DateTime.Parse(year + "/" + (hm.third + 1).ToString("00") + "/" + (hm.fourth + 1).ToString("00")); break; case 1: // 週指定 date = DateTime.Parse(year + "/" + (hm.third + 1).ToString("00") + "/01"); for (int i = 0; i < 32; i++) { // 曜日が一致したら if (hm.fifth == (int)dayOfWeekToNumber[date.DayOfWeek]) { // 何週目かをカウント weekCount++; } // 週カウンタが週指定に一致したら if (weekCount == (hm.fourth + 1)) { break; } date = date.AddDays(1); } break; case 2: // 春分・秋分の日 // 春分の日(3月) if ((hm.third + 1) == 3) { double dDay = 20.69115; // 春分日の10進法換算値 int day = 0; // 春分日の10進法換算値 double diff = 0.242194; // 年間移動量 double move = ((double)(intYear - 2000) * diff) - ((intYear - 2000) / 4); day = (int)(dDay + move); date = DateTime.Parse(year + "/" + (hm.third + 1).ToString("00") + "/" + day.ToString("00")); } else if ((hm.third + 1) == 9) { double dDay = 23.09; // 春分日の10進法換算値 int day = 0; // 春分日の10進法換算値 double diff = 0.242194; // 年間移動量 double move = ((double)(intYear - 2000) * diff) - ((intYear - 2000) / 4); day = (int)(dDay + move); date = DateTime.Parse(year + "/" + (hm.third + 1).ToString("00") + "/" + day.ToString("00")); } break; } holidays holiday = new holidays(); holiday.date = new DateTime(date.Year, date.Month, date.Day); holiday.type = hm.holiday_type; holiday.name = hm.holiday_name; holidayList.Add(holiday); } holidayList2.Clear(); bool alternative = false; DateTime alternativeDay = new DateTime(intYear, 1, 1); foreach (holidays hd in holidayList) { // 対象日付が俗称"改定振り替え休日"施行日以降なら // (”祝日が日曜にあたるときは、その日後において、その日に最も近い「国民の祝日」でない日を休日”) if (int.Parse(hd.date.ToString("yyyy")) >= 2007) { // 振り替え判定が行われていたら if (alternative == true) { // 次の休日にかぶっていないかを判定 if (alternativeDay < hd.date) { // かぶっていなければ振替休日を設定 holidays holiday = new holidays(); holiday.date = new DateTime(alternativeDay.Year, alternativeDay.Month, alternativeDay.Day); holiday.type = 0; holiday.name = "国民の休日"; holidayList2.Add(holiday); alternative = false; } else { // かぶっていたら、さらに翌日送り alternativeDay = hd.date.AddDays(1); } } if (hd.date.DayOfWeek == DayOfWeek.Sunday) { alternative = true; alternativeDay = hd.date.AddDays(1); } } // 対象日付が俗称"振り替え休日"施行日以降なら // (祝日が日曜にあたるときは、その翌日を休日”) else if (hd.date >= DateTime.Parse("1973/04/12")) { // 振り替え判定が行われていたら if (alternative == true) { // 次の休日にかぶっていないかを判定 if (alternativeDay < hd.date) { holidays holiday = new holidays(); holiday.date = new DateTime(alternativeDay.Year, alternativeDay.Month, alternativeDay.Day); holiday.type = 0; holiday.name = "国民の休日"; holidayList2.Add(holiday); alternative = false; } else { // かぶっていたら、その振替休日はなかったことに(涙) alternative = false; } } if (hd.date.DayOfWeek == DayOfWeek.Sunday) { alternative = true; alternativeDay = hd.date.AddDays(1); } } holidayList2.Add(hd); } holidayList3.Clear(); DateTime beforeDate = new DateTime(intYear, 1, 1); foreach (holidays hd in holidayList2) { // 直前休日と今回休日が一日飛ばしの場合で if (hd.date.Subtract(beforeDate).Days == 2) { beforeDate = beforeDate.AddDays(1); if (beforeDate.DayOfWeek != DayOfWeek.Sunday) { holidays holiday = new holidays(); holiday.date = new DateTime(beforeDate.Year, beforeDate.Month, beforeDate.Day); holiday.type = 0; holiday.name = "国民の休日"; holidayList3.Add(holiday); } } beforeDate = hd.date; holidayList3.Add(hd); } foreach (holidays holiday in holidayList3) { strSQL = "insert into holiday_list (" + "holiday_date" + ", holiday_type" + ", holiday_name" + ") values ( " + "datetime('" + holiday.date.ToString("yyyy-MM-dd 00:00:00") + "')" + ", " + holiday.type + ", '" + holiday.name + "' )"; sqliteAccess.insert(strSQL, null); } sqliteAccess.readerClose(); } loadYearyHoliday(); // オーナフォーム(カレンダ)再表示 parentForm.setCalendar(); }
private void setToContents(ref holidays holiday) { holiday.date = DateTime.Parse(dtpHoliday.Value.ToString("yyyy/MM/dd")); holiday.name = textBox1.Text; }