private void LoadTargetYearsDDL()
 {
     try
     {
         ddlTargetYear.Items.Clear();
         SalesTarget target = new SalesTarget();
         target.Where.Active.Value  = 1;
         target.Where.Year.Value    = DateTime.Now.Year;
         target.Where.Year.Operator = WhereParameter.Operand.GreaterThanOrEqual;
         target.Query.AddOrderBy(SalesTarget.ColumnNames.Year, WhereParameter.Dir.ASC);
         target.Query.Load();
         if (target.RowCount > 0)
         {
             target.Rewind();
             do
             {
                 ddlTargetYear.Items.Add(new ListItem(target.Year.ToString(), target.ID.ToString()));
             } while (target.MoveNext());
         }
         if (TargetID != -1)
         {
             ddlTargetYear.SelectedValue = TargetID.ToString();
         }
         else
         {
             ddlTargetYear.SelectedIndex = 0;
             TargetID = int.Parse(ddlTargetYear.SelectedValue);
         }
         ddlTargetYear_SelectedIndexChanged(null, null);
     }
     catch (Exception ex)
     {
         //Logger.LogException(ex);
     }
 }
        private string getLast5YearsTargetIDs()
        {
            string targetIDs = "";

            try
            {
                string      targetYears = "";
                SalesTarget thisTarget  = new SalesTarget();
                thisTarget.LoadByPrimaryKey(TargetID);
                int         targetYear = thisTarget.Year;
                SalesTarget target     = new SalesTarget();
                target.Where.Active.Value  = true;
                target.Where.Year.Value    = targetYear;
                target.Where.Year.Operator = WhereParameter.Operand.LessThan;
                target.Query.AddOrderBy(SalesTarget.ColumnNames.Year, WhereParameter.Dir.DESC);
                target.Query.Top = 5;
                if (target.Query.Load())
                {
                    if (target.DefaultView != null && target.DefaultView.Count > 0)
                    {
                        do
                        {
                            if (targetIDs == "")
                            {
                                targetIDs = "'" + target.ID + "'";
                            }
                            else
                            {
                                targetIDs += ",'" + target.ID + "'";
                            }

                            if (targetYears == "")
                            {
                                targetYears = "'" + target.Year + "'";
                            }
                            else
                            {
                                targetYears += ",'" + target.Year + "'";
                            }
                        } while (target.MoveNext());
                    }
                }
            }
            catch (Exception ex)
            {
                //Logger.LogException(ex);
            }
            return(targetIDs);
        }