private bool DayIsEmpty(Day day) { if (schedule == null || schedule.periods == null || schedule.periods.Length == 0) { return(true); } int emptyPeriodCount = 0; int periodCount = schedule.periods.Length; for (int i = 0; i < periodCount; i++) { PeriodGroup period = schedule.periods[i]; ScheduleEntry entry = period.GetEntry(day); if (entry == null) { continue; } if (entry.isEmpty) { emptyPeriodCount++; } } return(emptyPeriodCount >= periodCount); }
public void Set(PeriodGroup period) { if (period == null) { return; } this.period = period; SetTime(period.period); }
/// <summary> /// Returns a grouped list of period data based on test rules /// </summary> /// <param name="seedDate"></param> /// <param name="numberOrPeriods"></param> /// <returns></returns> public static List <PeriodGroup> CreatePeriodData(DateTime seedDate, int numberOrPeriods) { // Setup the console display for the test Console.WriteLine("Start Date: " + seedDate.ToString("yyyy/MM/dd") + "\n"); Console.WriteLine("Start Period End Period Period Number"); List <PeriodGroup> periodGroups = new List <PeriodGroup>(); PeriodGroup periodGroup = new PeriodGroup(); DateTime currentEndOfLastFinancialYear = new DateTime(1900, 1, 1); try { // Call the infinte period generator with the seed date and number of periods required. foreach (Period period in GetNextPeriod(seedDate, numberOrPeriods)) { // Display the infinate periods used in this test. Console.WriteLine(period.PeriodStart.ToString("yyyy/MM/dd") + " " + period.PeriodStart.ToString("yyyy/MM/dd") + " " + period.PeriodNumber.ToString()); // Create a PeriodGroup object and populate it with the returned periods until a financial year is completed. var eofyDate = GetEndOfLastFinancialYearDate(period.PeriodStart); if (currentEndOfLastFinancialYear != eofyDate) { if (currentEndOfLastFinancialYear != new DateTime(1900, 1, 1)) { periodGroups.Add(periodGroup); } currentEndOfLastFinancialYear = eofyDate; periodGroup = new PeriodGroup(); periodGroup.Periods = new List <Period>(); periodGroup.EndOfLastFinancialYear = eofyDate; periodGroup.NumberOfDaysInFinancialYear = DateTime.IsLeapYear(period.PeriodStart.Year) ? 366 : 365; periodGroup.Periods.Add(period); } else { periodGroup.Periods.Add(period); } } // Add the last period group to the list of period groups if (periodGroup?.Periods?.Count > 0) { periodGroups.Add(periodGroup); } } catch (Exception) { // Do nothing and fall through to return and empty period group. } return(periodGroups); }
private void SetPeriods() { if (items == null || items.Count == 0 || schedule == null) { return; } for (int i = 0; i < items.Count; i++) { ScheduleItem item = items[i]; PeriodGroup period = schedule.periods[i]; item.Set(period); } }
private PeriodGroup GetData() { PeriodGroup entity = new PeriodGroup(); entity.period_group_id = Converts.ParseLong(keyCode); entity.period_group_code = txtPeriodGrCode.Text; entity.period_group_name = txtPeriodGrName.Text; entity.period_group_description = txtPeriodGrDesc.Text; entity.active = chkActive.Checked; entity.created_by = "SYSTEM"; entity.created_date = DateTime.Now; entity.updated_by = "SYSTEM"; entity.updated_date = DateTime.Now; return(entity); }
private void AddEditSetupPeriodGroup_saveHandler() { try { PeriodGroup entity = GetData(); if (mode == ObjectState.Add) { ServiceProvider.PeriodGroupService.Insert(entity, new string[] { ValidationRuleset.Insert }); } else { ServiceProvider.PeriodGroupService.Update(entity, new string[] { ValidationRuleset.Update }); } base.formBase.ShowMessage(GeneralMessage.SaveComplete); } catch (ValidationException ex) { throw ex; } }
private void LoadData() { PeriodGroup entity = new PeriodGroup(); if (mode == ObjectState.Edit && !string.IsNullOrEmpty(keyCode)) { entity.period_group_id = Converts.ParseLong(keyCode); entity = ServiceProvider.PeriodGroupService.FindByKeys(entity, true); txtPeriodGrCode.Text = entity.period_group_code; txtPeriodGrName.Text = entity.period_group_name; txtPeriodGrDesc.Text = entity.period_group_description; chkActive.Checked = entity.active; } else { txtPeriodGrCode.Text = String.Empty; txtPeriodGrName.Text = String.Empty; txtPeriodGrDesc.Text = String.Empty; chkActive.Checked = false; } EnableMode(); }
// Use this for initialization void Start() { group = (PeriodGroup) gameObject.transform.parent.gameObject.GetComponent (typeof(PeriodGroup)); activities = new List<Activity>(); addActivities(); }
// Use this for initialization void Start() { periodGroup = (PeriodGroup)periodGroupHolder.GetComponent(typeof(PeriodGroup)); personSet = (PersonSetModel)personSetHolder.GetComponent(typeof(PersonSetModel)); setCurrentPeriod(); }
// Use this for initialization void Start() { group = (PeriodGroup)gameObject.transform.parent.gameObject.GetComponent(typeof(PeriodGroup)); activities = new List <Activity>(); addActivities(); }
private void LoadHeadData() { StockHead entity = new StockHead(); if (base.FormMode == ObjectState.Edit && !string.IsNullOrEmpty(base.FormKeyCode)) { entity.stock_head_id = Converts.ParseLong(base.FormKeyCode); entity = ServiceProvider.StockHeadService.FindByKeys(entity, true); Period periodEntity = new Period() { period_id = entity.period_id }; periodEntity = ServiceProvider.PeriodService.FindByKeys(periodEntity, false); PeriodGroup periodGroupEntity = new PeriodGroup() { period_group_id = periodEntity.period_group_id }; ddlPeriodGroup.DataSource = ServiceProvider.PeriodGroupService.FindByActiveOrID(periodGroupEntity); ddlPeriodGroup.ValueMember = "Value"; ddlPeriodGroup.DisplayMember = "Display"; ddlPeriodGroup.SelectedValue = periodGroupEntity.period_group_id.ToString(); DataSet ds = ServiceProvider.PeriodService.FindDataSetByParentKey(periodEntity); List <ComboBoxDTO> lstComboboxDTO = new List <ComboBoxDTO>(); foreach (DataRow dr in ds.Tables[0].Rows) { ComboBoxDTO dto = new ComboBoxDTO(); dto.Value = dr["period_id"].ToString(); dto.Display = dr["period_code"].ToString() + ":" + DateTime.Parse(dr["period_date"].ToString()).ConvertDateToDisplay(); lstComboboxDTO.Add(dto); } lstComboboxDTO.SetPleaseSelect(); ddlPeriod.DataSource = lstComboboxDTO; ddlPeriod.ValueMember = "Value"; ddlPeriod.DisplayMember = "Display"; ddlPeriod.SelectedValue = entity.period_id.ToString(); ddlWarehouse.DataSource = ServiceProvider.WareHouseService.FindByActiveOrID(new WareHouse() { warehouse_id = entity.warehouse_id }); ddlWarehouse.ValueMember = "Value"; ddlWarehouse.DisplayMember = "Display"; ddlWarehouse.SelectedValue = entity.warehouse_id.ToString(); txtRemark.Text = entity.remark; lblDocumentNo.Text = entity.transaction_no; lblDocumentDate.Text = entity.transaction_date.ConvertDateToDisplay(); lblStatus.Text = (entity.transaction_status == TransactionStatus.IN.FinalCode) ? TransactionStatus.IN.FinalText : TransactionStatus.IN.NormalText; this._documentStatus = entity.transaction_status; } else { ddlPeriodGroup.DataSource = ServiceProvider.PeriodGroupService.FindByActiveOrID(); ddlPeriodGroup.ValueMember = "Value"; ddlPeriodGroup.DisplayMember = "Display"; List <ComboBoxDTO> lstCombobox = new List <ComboBoxDTO>(); lstCombobox.SetPleaseSelect(); ddlPeriod.DataSource = lstCombobox; ddlPeriod.ValueMember = "Value"; ddlPeriod.DisplayMember = "Display"; ddlWarehouse.DataSource = ServiceProvider.WareHouseService.FindByActiveOrID(); ddlWarehouse.ValueMember = "Value"; ddlWarehouse.DisplayMember = "Display"; txtRemark.Text = string.Empty; lblDocumentNo.Text = GeneralMessage.AutoRunningDocumentNo; lblDocumentDate.Text = DateTime.Now.ConvertDateToDisplay(); lblStatus.Text = TransactionStatus.IN.FinalText; } InitialDetailData(); EnableModeHead(); EnableModeDetail(); }