コード例 #1
0
        private void btAdd_Click(object sender, EventArgs e)
        {
            string        factQuery;
            FormWorkHours fwh = new FormWorkHours();

            factQuery = "(`employees_id_employee`, `dates_of_month`) VALUES('" +
                        currentIdEmployee + "', '" + currentDate + "');";
            db.Add("work_hours", factQuery, fwh.dgvWorkHours);
            Hide();
        }
コード例 #2
0
        private void btAddRegularity_Click(object sender, EventArgs e)
        {
            string        factQuery;
            FormWorkHours fwh = new FormWorkHours();

            List <DateTime> datesRegularity = new List <DateTime>();
            int             checkRegularity = 1;

            string values = "";

            switch (cbRegularity.SelectedItem)
            {
            case "2 через 2":
                for (int i = cbDateStart.SelectedIndex; i < globalDates.Count; i++)
                {
                    if (checkRegularity < 3)
                    {
                        datesRegularity.Add(globalDates[i]);
                        checkRegularity++;
                    }
                    else
                    {
                        checkRegularity = 1; i++;
                    }
                }

                for (int i = 0; i < datesRegularity.Count() - 1; i++)
                {
                    values += "('" + currentIdEmployee + "' , '" + datesRegularity[i].ToString("yyyy-MM-dd") + "'), ";
                }

                values += "('" + currentIdEmployee + "' , '" + datesRegularity[datesRegularity.Count() - 1].ToString("yyyy-MM-dd") + "')";
                break;

            case "2 через 1":
                for (int i = cbDateStart.SelectedIndex; i < globalDates.Count; i++)
                {
                    if (checkRegularity < 3)
                    {
                        datesRegularity.Add(globalDates[i]);
                        checkRegularity++;
                    }
                    else
                    {
                        checkRegularity = 1;
                    }
                }

                for (int i = 0; i < datesRegularity.Count() - 1; i++)
                {
                    values += "('" + currentIdEmployee + "' , '" + datesRegularity[i].ToString("yyyy-MM-dd") + "'), ";
                }

                values += "('" + currentIdEmployee + "' , '" + datesRegularity[datesRegularity.Count() - 1].ToString("yyyy-MM-dd") + "')";
                break;

            case "3 через 3":
                for (int i = cbDateStart.SelectedIndex; i < globalDates.Count; i++)
                {
                    if (checkRegularity < 4)
                    {
                        datesRegularity.Add(globalDates[i]);
                        checkRegularity++;
                    }
                    else
                    {
                        checkRegularity = 1; i = i + 2;
                    }
                }

                for (int i = 0; i < datesRegularity.Count() - 1; i++)
                {
                    values += "('" + currentIdEmployee + "' , '" + datesRegularity[i].ToString("yyyy-MM-dd") + "'), ";
                }

                values += "('" + currentIdEmployee + "' , '" + datesRegularity[datesRegularity.Count() - 1].ToString("yyyy-MM-dd") + "')";
                break;
            }
            factQuery = "(`employees_id_employee`, `dates_of_month`) VALUES" + values + ";";
            db.Add("work_hours", factQuery, fwh.dgvWorkHours);
            Hide();
        }