示例#1
0
        private void viewButton_Click(object sender, EventArgs e)
        {
            datesListBox.Items.Clear();

            int id;

            int.TryParse(iDLabel1.Text, out id);
            //fname = firstTextBox.Text;
            //lname = lastTextBox.Text;

            Bus449_TestDataSetTableAdapters.Oncall_CalendarTableAdapter oncall   = new Bus449_TestDataSetTableAdapters.Oncall_CalendarTableAdapter();
            Bus449_TestDataSetTableAdapters.EmployeeTableAdapter        employee = new Bus449_TestDataSetTableAdapters.EmployeeTableAdapter();


            //int.TryParse(employeeTableAdapter.GetDataByName(lname, fname).ToString(), out id);
            DataView calendar = new DataView(bus449_TestDataSet.Oncall_Calendar);

            calendar.Sort = "Date_ID ASC";
            foreach (DataRowView dr in calendar)
            {
                int am, pm;
                int.TryParse(dr["empid_am"].ToString(), out am);
                int.TryParse(dr["empid_pm"].ToString(), out pm);
                if (am == id || pm == id)
                {
                    DateTime add = new DateTime();
                    add = DateTime.Parse(dr["Date_ID"].ToString());
                    datesListBox.Items.Add(add.ToString("MM/dd/yyyy"));
                }
            }
        }
示例#2
0
        private void addButton_Click(object sender, EventArgs e)
        {
            bool   holiday  = true;
            string holiname = "";

            DateTime day = new DateTime();

            day = holidayTimePicker.Value;

            holiname = holiday_descTextBox.Text;



            Bus449_TestDataSetTableAdapters.Oncall_CalendarTableAdapter oncall = new Bus449_TestDataSetTableAdapters.Oncall_CalendarTableAdapter();
            int x = 0, y = 0;

            //populates the array for holiday am and pm employees
            foreach (DataRow dr in bus449_TestDataSet.Employee.Rows)
            {
                if (dr["shift"].ToString() == "A")
                {
                    holia[x] = int.Parse(dr["ID"].ToString());
                    x++;
                }
                else
                {
                    holip[y] = int.Parse(dr["ID"].ToString());
                    y++;
                }
            }
            int count = 0;

            count = (int)oncall.ScalarCheck(day.Date);
            if (count <= 0)
            {
                //inserts the holiday into the calendar with employees
                oncall.Insert(day.Date, holia[a], holip[p], holiday, holiname);
                //adds the holiday date to the listbox
                holidaysListBox.Items.Add(day.ToString("MM/dd/yyyy") + " " + holiname);


                a++; p++;
            }
            else
            {
                MessageBox.Show("That date already exists.");
            }
            if (a >= holia.Length)
            {
                a = 0;
            }
            if (p >= holip.Length)
            {
                p = 0;
            }
        }
示例#3
0
        private void switchButton_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("Are you sure you want to switch?", "Switch Confirmation", MessageBoxButtons.YesNo);

            if (result == DialogResult.Yes)
            {
                int    oldid = 0, newid = 0;
                string oldname = l_NameComboBox.Text, newname = newlnameComboBox.Text;

                DateTime date = new DateTime();
                date = switchDateTimePicker.Value;

                foreach (DataRow dt in bus449_TestDataSet.Employee.Rows)
                {
                    string check = "";
                    check = dt["L_Name"].ToString();
                    if (oldname == check)
                    {
                        oldid = int.Parse(dt["ID"].ToString());
                    }
                    if (newname == check)
                    {
                        newid = int.Parse(dt["ID"].ToString());
                    }
                }
                //creates usable adapter
                Bus449_TestDataSetTableAdapters.Oncall_CalendarTableAdapter oncall = new Bus449_TestDataSetTableAdapters.Oncall_CalendarTableAdapter();

                //updates the calendar with the switch
                foreach (DataRow dr in bus449_TestDataSet.Oncall_Calendar.Rows)
                {
                    int    am = 0, pm = 0;
                    bool   holiday = bool.Parse(dr["holiday"].ToString());
                    string desc    = dr["holiday_desc"].ToString();
                    am = int.Parse(dr["empid_am"].ToString());
                    pm = int.Parse(dr["empid_pm"].ToString());

                    if (am == oldid)
                    {
                        oncall.Update(newid, pm, holiday, desc, date, oldid, pm, holiday, desc);
                    }
                    if (pm == oldid)
                    {
                        oncall.Update(am, newid, holiday, desc, date, am, oldid, holiday, desc);
                    }
                }
                l_NameComboBox.Text = newname;
                MessageBox.Show("The switch has been successful");
            }
        }
示例#4
0
        private void viewButton_Click(object sender, EventArgs e)
        {
            datesListView.Items.Clear();

            DateTime start = new DateTime();
            DateTime end   = new DateTime();

            start = startDateTimePicker.Value;
            end   = endDateTimePicker.Value;

            Bus449_TestDataSetTableAdapters.Oncall_CalendarTableAdapter oncall   = new Bus449_TestDataSetTableAdapters.Oncall_CalendarTableAdapter();
            Bus449_TestDataSetTableAdapters.EmployeeTableAdapter        employee = new Bus449_TestDataSetTableAdapters.EmployeeTableAdapter();
            DataView calendar = new DataView(bus449_TestDataSet.Oncall_Calendar);

            calendar.Sort = "Date_ID ASC";
            foreach (DataRowView dr in calendar)
            {
                DateTime date = new DateTime();
                date = DateTime.Parse(dr["Date_ID"].ToString());

                if (date >= start && date <= end)
                {
                    int    am, pm;
                    string amlname = "", pmlname = "", amphone = "", pmphone = "", amshift = "", pmshift = "";

                    int.TryParse(dr["empid_am"].ToString(), out am);
                    int.TryParse(dr["empid_pm"].ToString(), out pm);

                    foreach (DataRow dt in bus449_TestDataSet.Employee.Rows)
                    {
                        int check = int.Parse(dt["ID"].ToString());
                        if (am == check)
                        {
                            amlname = dt["L_Name"].ToString();
                            amphone = dt["phone"].ToString();
                            amshift = dt["shift"].ToString();
                        }
                    }

                    foreach (DataRow dz in bus449_TestDataSet.Employee.Rows)
                    {
                        int check2 = int.Parse(dz["ID"].ToString());
                        if (pm == check2)
                        {
                            pmlname = dz["L_Name"].ToString();
                            pmphone = dz["phone"].ToString();
                            pmshift = dz["shift"].ToString();
                        }
                    }
                    //Create a listview to show all products and purchase amounts
                    string[] fieldsArrayAM = new string[4];
                    fieldsArrayAM[0] = date.ToString("MM/dd/yyyy");
                    fieldsArrayAM[1] = amlname;
                    fieldsArrayAM[2] = amphone;
                    fieldsArrayAM[3] = amshift;
                    ListViewItem showsLVI = new ListViewItem(fieldsArrayAM);
                    datesListView.Items.Add(showsLVI);

                    string[] fieldsArrayPM = new string[4];
                    fieldsArrayPM[0] = date.ToString("MM/dd/yyyy");
                    fieldsArrayPM[1] = pmlname;
                    fieldsArrayPM[2] = pmphone;
                    fieldsArrayPM[3] = pmshift;
                    ListViewItem showsLVI2 = new ListViewItem(fieldsArrayPM);
                    datesListView.Items.Add(showsLVI2);
                    //string addam = date.ToString("MM/dd/yyyy") + " " + amlname + " " + amphone + " " + amshift;
                    //string addpm = date.ToString("MM/dd/yyyy") + " " + pmlname + " " + pmphone + " " + pmshift;
                }
            }
        }
示例#5
0
        private void deleteButton_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("Are you sure want to delete this employee?", "Delete Confirmation", MessageBoxButtons.YesNo);

            if (result == DialogResult.Yes)
            {
                delete   = true;
                delid    = int.Parse(iDTextBox.Text);
                delshift = shiftComboBox.Text;

                int   a = 0, p = 0;
                int[] empam, emppm;

                empam = new int[(int)this.employeeTableAdapter.AMCount()];
                emppm = new int[(int)this.employeeTableAdapter.PMCount()];

                foreach (DataRow dt in bus449_TestDataSet.Employee.Rows)
                {
                    if (dt["shift"].ToString() == "A")
                    {
                        empam[a] = int.Parse(dt["ID"].ToString());
                        a++;
                    }
                    else
                    {
                        emppm[p] = int.Parse(dt["ID"].ToString());
                        p++;
                    }
                }

                /* DateTime update = new DateTime();
                 * var form2 = new Form8();
                 * form2.Show();
                 *
                 * //gets the date from the popup form
                 * update = form2.getDate();*/

                //creates usable adapter
                Bus449_TestDataSetTableAdapters.Oncall_CalendarTableAdapter oncall = new Bus449_TestDataSetTableAdapters.Oncall_CalendarTableAdapter();

                int count = 0;
                foreach (DataRow dr in bus449_TestDataSet.Oncall_Calendar.Rows)
                {
                    if (delid == empam[count] || delid == emppm[count])
                    {
                        count++;
                    }

                    if (delid == int.Parse(dr["empid_am"].ToString()))
                    {
                        oncall.Update(empam[count], int.Parse(dr["empid_pm"].ToString()), bool.Parse(dr["holiday"].ToString()), dr["holiday_desc"].ToString(),
                                      DateTime.Parse(dr["Date_ID"].ToString()), delid, int.Parse(dr["empid_pm"].ToString()), bool.Parse(dr["holiday"].ToString()), dr["holiday_desc"].ToString());
                        count++;
                    }
                    if (delid == int.Parse(dr["empid_pm"].ToString()))
                    {
                        oncall.Update(int.Parse(dr["empid_am"].ToString()), emppm[count], bool.Parse(dr["holiday"].ToString()), dr["holiday_desc"].ToString(),
                                      DateTime.Parse(dr["Date_ID"].ToString()), int.Parse(dr["empid_am"].ToString()), delid, bool.Parse(dr["holiday"].ToString()), dr["holiday_desc"].ToString());
                        count++;
                    }
                    if (count >= empam.Length || count >= emppm.Length)
                    {
                        count = 0;
                    }
                }
                foreach (DataRow dt in bus449_TestDataSet.Employee.Rows)
                {
                    if (delid == int.Parse(dt["ID"].ToString()))
                    {
                        dt.Delete();
                    }
                }
                //saves any changes made to an employee

                this.Validate();
                this.employeeBindingSource.EndEdit();
                this.tableAdapterManager.UpdateAll(this.bus449_TestDataSet);
                MessageBox.Show("The employee has been deleted");
            }
        }
示例#6
0
        private void shiftButton_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("Are you sure want to change the shift of this employee?", "Shift Confirmation", MessageBoxButtons.YesNo);

            if (result == DialogResult.Yes)
            {
                this.Validate();
                this.employeeBindingSource.EndEdit();
                this.tableAdapterManager.UpdateAll(this.bus449_TestDataSet);

                int   a = 0, p = 0, la, lp;
                int[] empam, emppm;

                string checker = "", old = "";
                int    checkers = shiftComboBox.SelectedIndex;

                la = (int)this.employeeTableAdapter.AMCount();
                lp = (int)this.employeeTableAdapter.PMCount();



                empam = new int[la];
                emppm = new int[lp];
                //creates usable adapter
                Bus449_TestDataSetTableAdapters.Oncall_CalendarTableAdapter oncall = new Bus449_TestDataSetTableAdapters.Oncall_CalendarTableAdapter();

                int holicountx = 0, holicounty = 0, x = 0, y = 0;

                //populates am and pm employees
                foreach (DataRow dt in bus449_TestDataSet.Employee.Rows)
                {
                    if (dt["shift"].ToString() == "A")
                    {
                        empam[a] = int.Parse(dt["ID"].ToString());
                        a++;
                    }
                    else
                    {
                        emppm[p] = int.Parse(dt["ID"].ToString());
                        p++;
                    }
                }
                checker = shiftComboBox.Text;
                foreach (DataRow dr in bus449_TestDataSet.Oncall_Calendar.Rows)
                {
                    //weights holidays
                    if (bool.Parse(dr["holiday"].ToString()))
                    {
                        oncall.Update(empam[holicountx], int.Parse(dr["empid_pm"].ToString()), bool.Parse(dr["holiday"].ToString()), dr["holiday_desc"].ToString(),
                                      DateTime.Parse(dr["Date_ID"].ToString()), int.Parse(dr["empid_am"].ToString()), int.Parse(dr["empid_pm"].ToString()), bool.Parse(dr["holiday"].ToString()), dr["holiday_desc"].ToString());
                        holicountx++;


                        oncall.Update(int.Parse(dr["empid_am"].ToString()), emppm[holicounty], bool.Parse(dr["holiday"].ToString()), dr["holday_desc"].ToString(),
                                      DateTime.Parse(dr["Date_ID"].ToString()), int.Parse(dr["empid_am"].ToString()), int.Parse(dr["empid_pm"].ToString()), bool.Parse(dr["holiday"].ToString()), dr["holiday_desc"].ToString());
                        holicounty++;
                    }
                    if (holicountx >= empam.Length)
                    {
                        holicountx = 0;
                    }
                    if (holicounty >= emppm.Length)
                    {
                        holicounty = 0;
                    }
                    //does the other days

                    else
                    {
                        oncall.Update(empam[x], int.Parse(dr["empid_pm"].ToString()), bool.Parse(dr["holiday"].ToString()), dr["holiday_desc"].ToString(),
                                      DateTime.Parse(dr["Date_ID"].ToString()), int.Parse(dr["empid_am"].ToString()), int.Parse(dr["empid_pm"].ToString()), bool.Parse(dr["holiday"].ToString()), dr["holiday_desc"].ToString());
                        x++;

                        oncall.Update(int.Parse(dr["empid_am"].ToString()), emppm[y], bool.Parse(dr["holiday"].ToString()), dr["holiday_desc"].ToString(),
                                      DateTime.Parse(dr["Date_ID"].ToString()), int.Parse(dr["empid_am"].ToString()), int.Parse(dr["empid_pm"].ToString()), bool.Parse(dr["holiday"].ToString()), dr["holiday_desc"].ToString());
                        y++;
                    }
                    if (x >= empam.Length)
                    {
                        x = 0;
                    }
                    if (y >= emppm.Length)
                    {
                        y = 0;
                    }
                }

                this.Validate();
                this.employeeBindingSource.EndEdit();
                this.tableAdapterManager.UpdateAll(this.bus449_TestDataSet);
                MessageBox.Show("The shift has been changed.");
            }
        }
示例#7
0
        private void createButton_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("Have you entered all of the desired holidays?", "Holiday Confirmation", MessageBoxButtons.YesNo);

            if (result == DialogResult.Yes)
            {
                //creates and sets start and end date variables
                DateTime startdate = new DateTime();
                DateTime enddate   = new DateTime();
                startdate = startdateTimePicker.Value;
                enddate   = enddateTimePicker.Value;

                //creates usable adapter
                Bus449_TestDataSetTableAdapters.Oncall_CalendarTableAdapter oncall = new Bus449_TestDataSetTableAdapters.Oncall_CalendarTableAdapter();



                //creates and populates arrays for employees IDs
                int x = 0, y = 0;
                foreach (DataRow dr in bus449_TestDataSet.Employee.Rows)
                {
                    if (dr["shift"].ToString() == "A")
                    {
                        amid[x] = int.Parse(dr["ID"].ToString());
                        x++;
                    }
                    else
                    {
                        pmid[y] = int.Parse(dr["ID"].ToString());
                        y++;
                    }
                }


                int    loopa = 0, loopp = 0; bool holiday = false;
                string holiname = "";
                //loops from startdate to enddate
                for (var day = startdate.Date; day.Date <= enddate.Date; day = day.AddDays(1))
                {
                    int count = 0;
                    count = (int)oncall.ScalarCheck(day.Date);
                    if (count <= 0)
                    {
                        //inserts the day into the calendar with an am and pm oncall employee
                        oncall.Insert(day.Date, amid[loopa], pmid[loopp], holiday, holiname);

                        //rotates to next employee
                        loopa++; loopp++;
                    }

                    //resets the array to prevent errors
                    if (loopa >= amid.Length)
                    {
                        loopa = 0;
                    }
                    if (loopp >= pmid.Length)
                    {
                        loopp = 0;
                    }
                }
                this.tableAdapterManager.UpdateAll(this.bus449_TestDataSet);
                MessageBox.Show("Your schedule has been created!");
            }
        }