public void SetLoopValue(TransformationTreeItem loop) { String name = loop.name; RPeriodNamePanel panel = GetPeriodNamePanel(loop); if (panel != null) { int position = Period != null ? Period.itemListChangeHandler.Items.Count : 0; //panel.UpdateInterval(interval, position); } else { int position = Period != null ? Period.itemListChangeHandler.Items.Count : 0; List <PeriodItem> items = new List <PeriodItem>(0); PeriodItem item = new PeriodItem(); item.name = name; item.loop = loop; item.position = position++; item.operatorSign = DateOperator.EQUALS.sign; items.Add(item); panel = new RPeriodNamePanel(name, items); if (loop.IsPeriod) { panel.ItemPanel1.OperatorCol.Width = new GridLength(200, GridUnitType.Auto); panel.ItemPanel2.OperatorCol.Width = new GridLength(200, GridUnitType.Auto); panel.ItemPanel1.SignComboBox.Width = 100; } AddNamePanel(panel); OnAdded(panel.ItemPanel1); } }
public void RateMonthCommon() { // 183 days of 2004 = 0.5 year = 6 months var y1 = new PeriodItem(new DateTime(2004, 1, 1), 182, Rounding.AwayFromZero); Assert.AreEqual(y1.Months, 6); // 182 days of 2004 = almost 0.5 year = almost 6 months var y2 = new PeriodItem(new DateTime(2004, 1, 1), 181, Rounding.AwayFromZero); Assert.AreEqual(y2.Months, 6); // 184 days of 2004 = slightly more than 0.5 year = slightly more than 6 months var y3 = new PeriodItem(new DateTime(2004, 1, 1), 183, Rounding.AwayFromZero); Assert.AreEqual(y3.Months, 6); // 15 days of 2004 = almost 0.5 month var y4 = new PeriodItem(new DateTime(2004, 1, 1), 14, Rounding.AwayFromZero); Assert.AreEqual(y4.Months, 0); // 16 days of 2004 = slightly more than 0.5 month var y5 = new PeriodItem(new DateTime(2004, 1, 1), 15, Rounding.AwayFromZero); Assert.AreEqual(y5.Months, 1); }
/// <summary> /// Définit la valeur du TargetItem en cour d'édition /// et affiche cette valeur dans le TextBox /// </summary> /// <param name="value">La valeur du TargetItem en cour d'édition</param> public void SetPeriodItemName(string name) { if (this.ActiveItemPanel == null) { this.ActiveItemPanel = (PeriodItemPanel)this.panel.Children[this.panel.Children.Count - 1]; } if (!forReport) { if (GetPeriodItemPanel(name) != null) { Kernel.Util.MessageDisplayer.DisplayInfo("Duplicate Period name", "Item named: " + name + " already exist!"); return; } } PeriodItem currentPeriodItem = this.Period != null?this.Period.GetPeriodItemByName(name) : null; bool duplicatePeriodItem = currentPeriodItem != null && name.ToUpper().Equals(currentPeriodItem.name.ToUpper()); if (duplicatePeriodItem) { this.ActiveItemPanel = (PeriodItemPanel)this.panel.Children[currentPeriodItem.position]; } else { this.ActiveItemPanel.PeriodItem = null; } this.ActiveItemPanel.SetPeriodName(name); }
public void RateYearExactUp() { // 366 days = 1 leap year var y = new PeriodItem(new DateTime(2004, 1, 1), 365, Rounding.Up); Assert.AreEqual(y.Years, 1); }
public void RateMonthUp() { // 73 days of 2003 and 183 days of 2004 = 0.2 + 0.5 year = 8.4 months var y = new PeriodItem(new DateTime(2003, 10, 20), new DateTime(2004, 07, 1), Rounding.Up); Assert.AreEqual(y.Months, 9); }
public void RateMonthExactUp() { // 183 days = 6 months of a leap year var y = new PeriodItem(new DateTime(2004, 1, 1), 182, Rounding.Up); Assert.AreEqual(y.Months, 6); }
public void RateYearExactCommon() { // 366 days = 1 leap year var y = new PeriodItem(new DateTime(2004, 1, 1), 365, Rounding.AwayFromZero); Assert.AreEqual(y.Years, 1); }
public void Constructor3a() { var period = new PeriodItem(new DateTime(2018, 1, 1), 0); Assert.AreEqual(period.Start, period.End); Assert.AreEqual(period.Days, 1); }
public void RateMonthNone() { // 73 days of 2002 and 146 days of 2003 = 0.2 + 0.4 year = 7.2 months var y = new PeriodItem(new DateTime(2002, 10, 20), new DateTime(2003, 5, 26)); Assert.AreEqual(y.Months, 7.2m); }
public void Constructor3b() { var period = new PeriodItem(new DateTime(2018, 1, 1), 1); Assert.AreEqual(new DateTime(2018, 1, 2), period.End); Assert.AreEqual(period.Days, 2); }
public void SetPeriodInterval(PeriodInterval interval) { if (!forReport) { if (interval.periodName == null) { Kernel.Util.MessageDisplayer.DisplayInfo("Unvalid Period interval", "Period name cannot be null !"); return; } if (GetPeriodItemPanelForInterval(interval.periodName.name) != null) { Kernel.Util.MessageDisplayer.DisplayInfo("Duplicate Period name", "Item named: " + interval.periodName.name + " already exist!"); return; } } PeriodItem item = interval.getFromPeriodItem((forReport ? DateOperator.AFTER_OR_EQUALS.sign : "")); SetPeriodItemValue(item); if (forReport) { item = interval.getToPeriodItem(DateOperator.BEFORE_OR_EQUALS.sign); SetPeriodItemValue(item); } }
/// <summary> /// Définit la valeur du TargetItem en cour d'édition /// et affiche cette valeur dans le TextBox /// </summary> /// <param name="value">La valeur du TargetItem en cours d'édition</param> public void SetValue(PeriodItem item, bool forreport = false) { bool added = forreport; update = false; if (this.PeriodItem == null) { this.PeriodItem = new PeriodItem(Index - 1); added = true; } this.PeriodItem.name = item.name; this.PeriodItem.value = item.value; this.PeriodItem.formula = item.formula; this.PeriodItem.period = item.period; this.PeriodItem.operationDate = item.operationDate; this.PeriodItem.operationGranularity = item.operationGranularity; this.NameTextBox.Text = this.PeriodItem != null ? this.PeriodItem.name : ""; DateTime result; if (this.PeriodItem != null && DateTime.TryParse(this.PeriodItem.value, out result)) { this.ValueDatePicker.SelectedDate = this.PeriodItem.valueDateTime; } this.FormulaTextBox.Text = this.PeriodItem != null ? this.PeriodItem.formula : ""; this.SignComboBox.SelectedItem = this.PeriodItem != null ? this.PeriodItem.operatorSign : DateOperator.EQUALS.sign; if (Added != null && added) { Added(this); } if (Updated != null && !added) { Updated(this); } }
public void Display(PeriodItem item) { update = false; throwevent = false; bool enableForLoop = item.loop != null; if (enableForLoop) { this.SignComboBox.Width = 100; this.SignComboBox.ItemsSource = new String[] { DateOperator.DURING_PERIOD.sign, DateOperator.BEFORE_START_PERIOD.sign, DateOperator.BEFORE_END_PERIOD.sign, DateOperator.AFTER_START_PERIOD.sign, DateOperator.AFTER_END_PERIOD.sign }; this.SignComboBox.SelectedItem = DateOperator.DURING_PERIOD.sign; this.Label.Foreground = Brushes.Red; this.FormulaTextBox.IsEnabled = !enableForLoop; this.ValueDatePicker.IsEnabled = !enableForLoop; this.SignComboBox.IsEnabled = true; } this.PeriodItem = item; if (item == null) { return; } this.Index = item.position + 1; this.Label.Content = item.name != null ? item.name : ""; if (item.value != null) { this.ValueDatePicker.SelectedDate = item.valueDateTime; } this.FormulaTextBox.Text = item.formula != null ? item.formula : ""; if (!String.IsNullOrEmpty(item.operatorSign)) { this.SignComboBox.SelectedItem = item.operatorSign; } if (!String.IsNullOrEmpty(item.operationGranularity)) { this.granulartityComBox.SelectedItem = item.operationGranularity; } if (!String.IsNullOrEmpty(item.operation)) { this.operationComboBox.SelectedItem = item.operation; } if (!String.IsNullOrEmpty(item.operationNumber)) { int number; if (!TagFormulaUtil.isFormula(item.operationNumber)) { bool ok = int.TryParse(item.operationNumber, out number); item.operationNumber = (ok && number > 0) ? "" + number : ""; } this.numberValueTextBox.Text = item.operationNumber; } update = true; throwevent = true; }
public void RateYear2016_183days() { var year2016_183days = new PeriodItem(new DateTime(2016, 1, 1), new DateTime(2016, 07, 1)); Assert.IsTrue(MathExtensions.AlmostEquals(year2016_183days.AmountOf(PeriodUnit.Month), 6)); Assert.IsTrue(MathExtensions.AlmostEquals(year2016_183days.AmountOf(PeriodUnit.Year), 0.5m)); }
/// <summary> /// Définit la valeur du TargetItem en cour d'édition /// et affiche cette valeur dans le TextBox /// </summary> /// <param name="value">La valeur du TargetItem en cour d'édition</param> public void SetPeriodItem(PeriodItem item) { PeriodItem t = new PeriodItem(item.position, item.name, item.value, item.formula); SetPeriodItemValue(t); //this.ActiveItemPanel.Display(t); //this.ActiveItemPanel.SetTagName(item.name); }
public void RateYear2017_73days() { var year2017_73days = new PeriodItem(new DateTime(2017, 1, 1), new DateTime(2017, 03, 14)); Assert.IsTrue(MathExtensions.AlmostEquals(year2017_73days.AmountOf(PeriodUnit.Month), 2.4m)); Assert.IsTrue(MathExtensions.AlmostEquals(year2017_73days.AmountOf(PeriodUnit.Year), 0.2m)); }
public void RateYear2018() { var year2018 = new PeriodItem(new DateTime(2018, 1, 1), new DateTime(2018, 12, 31)); Assert.IsTrue(MathExtensions.AlmostEquals(year2018.AmountOf(PeriodUnit.Month), 12)); Assert.IsTrue(MathExtensions.AlmostEquals(year2018.AmountOf(PeriodUnit.Year), 1)); }
public void Leap1Year() { // 0.5 year = 6 months = 183 days (0.5 * 366) var y = new PeriodItem(new DateTime(2004, 1, 1), 182); Assert.AreEqual(y.Years, 0.5m); Assert.AreEqual(y.Months, 6); Assert.AreEqual(y.Days, 183); }
/// <summary> /// Définit la valeur du TargetItem en cour d'édition /// et affiche cette valeur dans le TextBox /// </summary> /// <param name="value">La valeur du TargetItem en cour d'édition</param> public void SetPeriodItemValue(PeriodItem value) { if (this.ActiveItemPanel == null) { this.ActiveItemPanel = (PeriodItemPanel)this.panel.Children[this.panel.Children.Count - 1]; } this.ActiveItemPanel.SetValue(value); this.ActiveItemPanel = null; }
public void Leap2Years() { // 73 days of 2003 and 183 days of 2004 = 0.2 + 0.5 year = 8.4 months var y = new PeriodItem(new DateTime(2003, 10, 20), new DateTime(2004, 07, 1)); Assert.AreEqual(y.Years, 0.7m); Assert.AreEqual(y.Months, 8.4m); Assert.AreEqual(y.Days, 256); }
public void Regular2Years() { // 73 days of 2002 and 146 days of 2003 = 0.2 + 0.4 year = 7.2 months var y = new PeriodItem(new DateTime(2002, 10, 20), new DateTime(2003, 5, 26)); Assert.AreEqual(y.Years, 0.6m); Assert.AreEqual(y.Months, 7.2m); Assert.AreEqual(y.Days, 219); }
public void Regular1Year() { // 73 days = 0.2 year = 2.4 months var y = new PeriodItem(new DateTime(2003, 10, 20), new DateTime(2003, 12, 31)); Assert.AreEqual(y.Years, 0.2m); Assert.AreEqual(y.Months, 2.4m); Assert.AreEqual(y.Days, 73); }
private Price DiscountReturn(Subscription subscription, DateTime date) { var item = new PeriodItem(subscription.Start, date); var unit = new UnitPrice(subscription.Discount, 20, CurrencyUnit.EUR, PeriodUnit.Month); return(new ItemPrice(unit, item) { Description = $"Discount return for period {subscription.Start} to {date}" }); }
/// <summary> /// Construit une nouvelle instance de PeriodItemPnel /// </summary> /// <param name="index">Index du panel</param> /// <param name="item">PeriodItem à afficher</param> public PeriodItemPanel(PeriodItem item, bool forReport, bool forAutomaticSourcing = false, bool isTableView = false) : this() { Display(item); setForReport(forReport, isTableView); setForAutomaticSourcing(forAutomaticSourcing); if (!isTableView) { customizeCellView(); } }
private Price FeeReturn(Subscription subscription, DateTime date) { var last = date.LastOfThisMonth(); var item = new PeriodItem(date, last); var unit = new UnitPrice(subscription.MonthlyFee + subscription.Discount, 20, CurrencyUnit.EUR, PeriodUnit.Month); return(new ItemPrice(unit, item) { Description = $"Discount return for period {date} to {last}" }); }
public void RateYearUp() { // 1 day of 2004 var y1 = new PeriodItem(new DateTime(2004, 1, 1), 0, Rounding.Up); Assert.AreEqual(y1.Years, 1); // 365 days of 2004 var y2 = new PeriodItem(new DateTime(2004, 1, 1), 364, Rounding.Up); Assert.AreEqual(y2.Years, 1); }
private void OnPeriodItemDeleted(object item) { if (GrilleFilter == null || GrilleFilter.filterPeriod == null || item == null || !(item is PeriodItem)) { return; } PeriodItem periodItem = (PeriodItem)item; GrilleFilter.filterPeriod.SynchronizeDeletePeriodItem(periodItem); this.Display(GrilleFilter); OnChange(); }
public void Display(PeriodItem item) { update = false; this.PeriodItem = item; if (item == null) { return; } this.Index = item.position + 1; this.NameTextBox.Text = item.name != null ? item.name : ""; if (item.value != null) { this.ValueDatePicker.SelectedDate = item.valueDateTime; } this.FormulaTextBox.Text = item.formula != null ? item.formula : ""; if (!String.IsNullOrEmpty(item.operatorSign)) { this.SignComboBox.SelectedItem = item.operatorSign; } if (!String.IsNullOrEmpty(item.operationGranularity)) { this.granulartityComBox.SelectedItem = item.operationGranularity; } if (!String.IsNullOrEmpty(item.operation)) { this.operationComboBox.SelectedItem = item.operation; } if (!String.IsNullOrEmpty(item.operationNumber)) { int number; if (!TagFormulaUtil.isFormula(item.operationNumber)) { bool ok = int.TryParse(item.operationNumber, out number); item.operationNumber = (ok && number > 0) ? "" + number : ""; } this.numberValueTextBox.Text = item.operationNumber; } bool enableForLoop = item.loop != null; if (enableForLoop) { this.NameTextBox.Text = item.loop.name; this.NameTextBox.Foreground = Brushes.Red; this.numberValueTextBox.IsEnabled = !enableForLoop; this.FormulaTextBox.IsEnabled = !enableForLoop; this.granulartityComBox.IsEnabled = !enableForLoop; this.operationComboBox.IsEnabled = !enableForLoop; this.ValueDatePicker.IsEnabled = !enableForLoop; this.SignComboBox.IsEnabled = !enableForLoop; } update = true; }
/// <summary> /// Generate main content table. /// </summary> /// <param name="workbook">The npoi workbook interface.</param> /// <param name="sheet1">The npoi sheet interface.</param> /// <param name="summaryList">The evaluation summary result. </param> /// <param name="evaluationList">The evaluation data collection.</param> /// <param name="rowIndex">The row data index.</param> /// <param name="cellHeaderIndex">The max cell table generate.</param> private void GenerateContentTable(IWorkbook workbook, ISheet sheet1, SummaryEvaluationViewModel summary, Data.Pocos.Evaluation evaluation, ref int rowIndex, PeriodItem periodItem, IEnumerable <Hremployee> empList) { rowIndex++; IRow contentRow = sheet1.CreateRow(rowIndex); int cellContentIndex = 0; string[] mainContent = new string[] { evaluation.DocNo, evaluation.ComCode, UtilityService.DateTimeToString(periodItem.StartEvaDate.Value, "dd.MM.yyyy"), UtilityService.DateTimeToString(periodItem.EndEvaDate.Value, "dd.MM.yyyy"), periodItem.PeriodName, evaluation.VendorNo, summary.VendorName, summary.WeightingKey, summary.PurchasingOrgName, }; foreach (var content in mainContent) { ExcelService.CreateContentCell(workbook, sheet1, contentRow, cellContentIndex, content); cellContentIndex++; } rowIndex += 2; var evaTemplate = _evaluationTemplateBll.LoadTemplate(evaluation.EvaluationTemplateId.Value); this.GenerateScoreHeader(workbook, sheet1, ref rowIndex, summary); foreach (var user in summary.UserLists) { var emp = empList.FirstOrDefault(x => x.Aduser == user.AdUser); string evaluatorName = $" คุณ{emp?.FirstnameTh} {emp?.LastnameTh}"; IRow userContent = sheet1.CreateRow(rowIndex); ExcelService.CreateContentCell(workbook, sheet1, userContent, 1, evaluatorName, horizontalAlignment: HorizontalAlignment.Left); ExcelService.SetCellContentStyle(workbook, userContent, 2, 2); sheet1.AddMergedRegion(new CellRangeAddress(rowIndex, rowIndex, 1, 2)); var evaLogs = user.EvaluationLogs.FirstOrDefault(); this.GenerateCriteriaContent(workbook, sheet1, ref rowIndex, evaluation.WeightingKey, summary, evaTemplate, evaLogs); rowIndex += 2; } }
public async Task <VkGetStatisticsResponseModel> GetStatistics( DataTableName table, PeriodItem period, long accountId, string accessToken, bool onlyActive) { VkGetStatisticsResponseModel statistics; switch (table) { case DataTableName.Client: var clients = await GetAllClients(accountId, accessToken); break; case DataTableName.Ad: var ads = await GetAllAds(accountId, accessToken, onlyActive); statistics = await GetStatics(table, period, accountId, accessToken, ads.response); statistics.response.ForEach(s => s.name = ads.response.FirstOrDefault(a => a.id == s.id)?.name); return(statistics); case DataTableName.Campaign: var comps = await GetAllCampaigns(accountId, accessToken, onlyActive); statistics = await GetStatics(table, period, accountId, accessToken, comps.response); statistics.response.ForEach(s => s.name = comps.response.FirstOrDefault(a => a.id == s.id)?.name); return(statistics); default: statistics = await GetStatics( DataTableName.Office, period, accountId, accessToken, new List <BaseTableItem> { new BaseTableItem { id = accountId.ToString() } }); statistics.response[0].name = "Рекламный кабинет"; return(statistics); } return(null); }