public static void GeneratePeriods( )
        {
            GEPeriodsController periodCtrl = new GEPeriodsController();

            for (int year = ABCApp.ABCDataGlobal.WorkingDate.Year; year <= ABCApp.ABCDataGlobal.WorkingDate.Year + 1; year++)
            {
                String strQuery = String.Format(@"SELECT COUNT(*) FROM GEPeriods WHERE Year = {0}", year);
                object objAmt   = BusinessObjectController.GetData(strQuery);
                if (objAmt == null || objAmt == DBNull.Value || Convert.ToInt32(objAmt) != 12)
                {
                    strQuery = String.Format(@"DELETE  FROM GEPeriods WHERE Year = {0}", year);
                    BusinessObjectController.RunQuery(strQuery);

                    for (int i = 1; i <= 12; i++)
                    {
                        GEPeriodsInfo period = new GEPeriodsInfo();
                        period.Month  = i;
                        period.Year   = year;
                        period.Period = new DateTime(period.Year.Value, period.Month.Value, 1);
                        if (i >= 10)
                        {
                            period.No = String.Format("Tháng {0}/{1}", period.Month.Value, period.Year.Value);
                        }
                        else
                        {
                            period.No = String.Format("Tháng  0{0}/{1}", period.Month.Value, period.Year.Value);
                        }

                        period.Closed = false;
                        periodCtrl.CreateObject(period);
                    }
                }
            }
        }
        public static Guid GetPeriod(int year, int month)
        {
            if (year < 2000 || month <= 0)
            {
                return(Guid.Empty);
            }

            String        strQuery = String.Format(@"SELECT * FROM GEPeriods WHERE Year = {0} AND Month = {1} ", year, month);
            GEPeriodsInfo period   = new GEPeriodsController().GetObject(strQuery) as GEPeriodsInfo;

            if (period != null)
            {
                return(period.GEPeriodID);
            }
            else
            {
                period        = new GEPeriodsInfo();
                period.Month  = month;
                period.Year   = year;
                period.Period = new DateTime(period.Year.Value, period.Month.Value, 1);
                if (month >= 10)
                {
                    period.No = String.Format("Tháng {0}/{1}", period.Month.Value, period.Year.Value);
                }
                else
                {
                    period.No = String.Format("Tháng  0{0}/{1}", period.Month.Value, period.Year.Value);
                }

                period.Closed = false;
                new GEPeriodsController().CreateObject(period);

                return(period.GetID());
            }

            return(Guid.Empty);
        }