Ejemplo n.º 1
0
        public void onDatePicked(object sender, EventArgs e)
        {
            var button = (Button)sender;
            var form = (DatePicker)button.Parent;

            if (form.endDateTimePicker.Value < form.startDateTimePicker.Value)
            {
                MessageBox.Show("Please select a positive amount of time!", "Error picking date", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            var selectedShift = new Schedule.Shift(form.startDateTimePicker.Value, form.endDateTimePicker.Value);

            // datepicker used to modify hours
            if (selectedShift.timeWorked < (DateTime.Now - DateTime.Now.AddDays(-1)))
            {
                if (form.selectedShift.timeWorked.TotalMinutes > 1)
                    ((Users.StudentWorker)selectedUser).updateShift(form.selectedShift, selectedShift);
                else
                    ((Users.StudentWorker)selectedUser).addShift(selectedShift);
                Debug.Log("User {0} hours were modified by {1}", selectedUser.userName, currentUser.userName);
                populateUserInfo(selectedUser);
            }
            // we're printing a report
            else
            {
                try
                {
                    string fileName = Manager.Export.exportHours((Users.StudentWorker)selectedUser, selectedShift);
                    string filePath = Environment.CurrentDirectory + "\\" + fileName;
                    System.Diagnostics.Process.Start(filePath);
                }

                catch (Manager.ExportException E)
                {
                    Debug.Log(Debug.MessageType.Error, "Could not export timesheet - " + E.Message);
                }

                catch (Exception E)
                {
                    Debug.Log(Debug.MessageType.Error, "Could not open timesheet - " + E.Message);
                }
            }

            form.Close();

            Manager.Main.Instance.pendingUpload = true;
        }
Ejemplo n.º 2
0
        public DatePicker(Schedule.Shift selectedShift, Administration admin)
        {
            InitializeComponent();
            this.selectedShift = selectedShift;
            this.admin = admin;
            chooseButton.Parent = this;

            startDateTimePicker.Value = selectedShift.shiftStart;
            endDateTimePicker.Value = selectedShift.shiftEnd;

            chooseButton.Click += admin.onDatePicked;

            if (selectedShift.timeWorked > (DateTime.Now - DateTime.Now.AddDays(-1)))
            {
                startDateTimePicker.Format = DateTimePickerFormat.Short;
                endDateTimePicker.Format = DateTimePickerFormat.Short;
            }
        }