Пример #1
0
 private void Form1_Load(object sender, EventArgs e)
 {
     foreach (ComboBox cb in tabPage2.Controls.OfType <ComboBox>())
     {
         cb.Items.Add("---Not Open---");
         cb.Items.Add("Every Week");
         cb.Items.Add("First and Third Week of the Month");
         cb.Items.Add("Second and Forth Week of the Month");
         cb.Items.Add("First Week of the Month");
         cb.Items.Add("Second Week of the Month");
         cb.Items.Add("Third Week of the Month");
         cb.Items.Add("Forth Week of the Month");
     }
     CCFBOpenDayOfWeek.OpenDOW();
     for (int i = 0; i < CCFBOpenDayOfWeek.DSetDOWRowsCount; i++)
     {
         for (int j = 0; j < cbList.Count; j++)
         {
             if (cbList[j].Tag.ToString() == CCFBOpenDayOfWeek.DSetDOW.Tables[0].Rows[i]["EditLabel"].ToString())
             {
                 cbList[j].SelectedIndex = Int32.Parse(CCFBOpenDayOfWeek.DSetDOW.Tables[0].Rows[i]["FldVal"].ToString());
                 break;
             }
         }
     }
     ChangeMode(1);
 }
Пример #2
0
 private void selctionCommited(ComboBox cb)
 {
     for (int i = 0; i < CCFBOpenDayOfWeek.DSetDOWRowsCount; i++)
     {
         if (cb.Tag.ToString() == CCFBOpenDayOfWeek.DSetDOW.Tables[0].Rows[i]["EditLabel"].ToString())
         {
             CCFBOpenDayOfWeek.DSetDOW.Tables[0].Rows[i]["FldVal"] = cb.SelectedIndex;
             break;
         }
     }
     CCFBOpenDayOfWeek.updateDOW();
 }
Пример #3
0
        private void YearlyForm_Load(object sender, EventArgs e)
        {
            DateTime dateTest;

            foreach (ComboBox cb in tabPage2.Controls.OfType <ComboBox>())
            {
                cb.Items.Add("---Not Open---");
                cb.Items.Add("Every Week");
                cb.Items.Add("First and Third Week of the Month");
                cb.Items.Add("Second and Forth Week of the Month");
                cb.Items.Add("First Week of the Month");
                cb.Items.Add("Second Week of the Month");
                cb.Items.Add("Third Week of the Month");
                cb.Items.Add("Forth Week of the Month");
            }
            CCFBOpenDayOfWeek.OpenDOW();
            for (int i = 0; i < CCFBOpenDayOfWeek.DSetDOWRowsCount; i++)
            {
                for (int j = 0; j < cbList.Count; j++)
                {
                    if (cbList[j].Tag.ToString() == CCFBOpenDayOfWeek.DSetDOW.Tables[0].Rows[i]["EditLabel"].ToString())
                    {
                        cbList[j].SelectedIndex = Int32.Parse(CCFBOpenDayOfWeek.DSetDOW.Tables[0].Rows[i]["FldVal"].ToString());
                        break;
                    }
                }
            }
            clsDaysOpen.openWhere("date = (SELECT MAX(date) From DaysOpen)");
            if (clsDaysOpen.RowCount > 0)
            {
                dateTest = clsDaysOpen.date;
            }
            else
            {
                dateTest = DateTime.Today;
            }
            dateTest = dateTest.AddMonths(1);
            string tmp = dateTest.Month.ToString() + "/01/" + dateTest.Year.ToString();

            dtpPeriodStart.Value = DateTime.Parse(tmp);
            dateTest             = dtpPeriodStart.Value.AddYears(1).AddDays(-1);
            dtpPeriodEnd.Value   = dateTest;
            ChangeMode(1);
        }
Пример #4
0
        public void BatchProcess(DateTime FirstDate, DateTime LastDate, int InsertMode, bool ForceIsCommodity)
        {
            int NbrRowsCleared = 0;

            if (InsertMode == 0) //Clear All Dates
            {
                NbrRowsCleared = DeleteDateRange(FirstDate.ToString(), LastDate.ToString());
                dset.Tables[tbName].Clear();
            }
            int[] DOWRules = new int[7];

            //For each day of week
            for (int i = 0; i < CCFBOpenDayOfWeek.DSetDOW.Tables[0].Rows.Count; i++)
            {
                DOWRules[i] = Convert.ToInt32(CCFBOpenDayOfWeek.DSetDOW.Tables[0].Rows[i]["FldVal"]);
            }

            DateTime WorkDate    = FirstDate;
            int      myDOW       = 0;
            int      WeekofMonth = 0;

            do
            {
                myDOW = CCFBOpenDayOfWeek.findRow(WorkDate.DayOfWeek.ToString());
                if (DOWRules[myDOW] > 0)
                {
                    if (FindDate(WorkDate) > 0)
                    {
                        if (InsertMode == 1)
                        {
                            IsCommodity  = ForceIsCommodity;
                            SpecialItems = "";
                        }
                    }
                    else
                    {
                        switch (DOWRules[myDOW])
                        {
                        case 1:     //Sets day of week for every week
                        {
                            AddDate(WorkDate, ForceIsCommodity, "");
                            break;
                        }

                        case 2:     //Sets for 1st and 3rd weeks
                        {
                            WeekofMonth = CalculateWeekofMonth(WorkDate);
                            if (WeekofMonth == 1 || WeekofMonth == 3)
                            {
                                AddDate(WorkDate, ForceIsCommodity, "");
                            }
                            break;
                        }

                        case 3:     //Sets for 2nd and 4th weeks
                        {
                            WeekofMonth = CalculateWeekofMonth(WorkDate);
                            if (WeekofMonth == 2 || WeekofMonth == 4)
                            {
                                AddDate(WorkDate, ForceIsCommodity, "");
                            }
                            break;
                        }

                        case 4:     //Sets for 1st week
                        {
                            WeekofMonth = CalculateWeekofMonth(WorkDate);
                            if (WeekofMonth == 1)
                            {
                                AddDate(WorkDate, ForceIsCommodity, "");
                            }
                            break;
                        }

                        case 5:     //Sets for 2nd week
                        {
                            WeekofMonth = CalculateWeekofMonth(WorkDate);
                            if (WeekofMonth == 2)
                            {
                                AddDate(WorkDate, ForceIsCommodity, "");
                            }
                            break;
                        }

                        case 6:     //Sets for 3rd week
                        {
                            WeekofMonth = CalculateWeekofMonth(WorkDate);
                            if (WeekofMonth == 3)
                            {
                                AddDate(WorkDate, ForceIsCommodity, "");
                            }
                            break;
                        }

                        case 7:     //Sets for 4th week
                        {
                            WeekofMonth = CalculateWeekofMonth(WorkDate);
                            if (WeekofMonth == 4)
                            {
                                AddDate(WorkDate, ForceIsCommodity, "");
                            }
                            break;
                        }
                        }
                    }
                }
                WorkDate = WorkDate.AddDays(1);
            } while (WorkDate <= LastDate);
            update();
        }