コード例 #1
0
        private void loadPeriods()
        {
            using (var rep = new Lib.Repositories.PeriodRepository(this.ActiveUser))
            {
                var periods = rep.getAll();

                if (periods != null && periods.Count > 0)
                {

                    var list = periods.OrderBy(p => p.InitialDate).ToList().Select(p => new
                    {
                        IdCrypt = Commons.SecurityUtils.criptografar(p.Id.ToString()),
                        Name = p.Open ? String.Format("{0} (Aberto)", String.Format(Resources.Label.list_item_period_label, p.Name, p.InitialDate, p.FinalDate)) : String.Format(Resources.Label.list_item_period_label, p.Name, p.InitialDate, p.FinalDate),
                        Open = p.Open
                    }).ToList();

                    ddlPeriods.DataSource = list;
                    ddlPeriods.DataBind();

                    var periodOpen = list.Where(a => a.Open == true).FirstOrDefault();

                    if (periodOpen != null)
                        ddlPeriods.SelectedIndex = list.IndexOf(periodOpen);
                }
                else
                {
                    ddlPeriods.Items.Add(new ListItem(Resources.Message.no_period_has_found, ""));
                }
            }
        }
コード例 #2
0
        private void verifyWarnings()
        {
            using (Lib.Repositories.PeriodRepository rep = new Lib.Repositories.PeriodRepository(this.ActiveUser))
            {
                var periodOpen = rep.getPeriodOpen();
                DateTime lastDate = DateTime.MinValue;

                var allPeriods = rep.getAll();
                if (allPeriods.Count > 0)
                {
                    lastDate = allPeriods.Max(p => p.FinalDate);
                }

                if (periodOpen != null)
                {
                    phMessageWarning.Visible = true;
                    ltMessageWarning.Text = String.Format(Resources.Message.exists_an_open_period_from_to, periodOpen.InitialDate, periodOpen.FinalDate);
                }

                if (lastDate != DateTime.MinValue)
                {
                    phMessageWarning2.Visible = true;
                    ltMessageWarning2.Text = String.Format(Resources.Message.need_create_period_from, lastDate);
                }
            }
        }