コード例 #1
0
        private void btnSubmit_Click(object sender, RoutedEventArgs e)
        {
            int?   nullable;
            string numberSerial;
            string numberSAP;
            string numberSection;
            int?   nullable1;
            string numberActivity;
            double num = double.Parse(txtHours.Text);
            string text;
            string code;
            string str;

            if (cbxTimeCode.SelectedItem != null)
            {
                code = ((TimesheetCode)cbxTimeCode.SelectedItem).Code;
                if (cbxTaskType.SelectedItem != null)
                {
                    if (!(cbxTaskType.SelectedValue.ToString() == "(N/A)"))
                    {
                        str = cbxTaskType.SelectedValue.ToString();
                        if (cbxJob.SelectedValue != null)
                        {
                            Project selectedItem = (Project)cbxJob.SelectedItem;
                            numberSerial = selectedItem.Number_Serial;
                            numberSAP    = selectedItem.Number_SAP;
                            if (cbxSection.SelectedValue == null)
                            {
                                MessageBox.Show("You must select a section");
                                return;
                            }
                            Section section = cbxSection.SelectedItem as Section;
                            numberSection  = section.Number_Section;
                            nullable       = new int?(section.Id);
                            nullable1      = new int?(int.Parse(section.Number_ProjectNetwork));
                            numberActivity = section.Number_Activity;
                        }
                        else
                        {
                            MessageBox.Show("You must select a project");
                            return;
                        }
                    }
                    else
                    {
                        str            = cbxTaskType.SelectedValue.ToString();
                        numberSerial   = "";
                        numberSAP      = "";
                        numberSection  = "";
                        nullable       = null;
                        nullable1      = null;
                        numberActivity = "";
                    }
                    if (dtpDate.SelectedDate.HasValue)
                    {
                        DateTime value = dtpDate.SelectedDate.Value;
                        int      month = value.Month;
                        int      year  = value.Year;
                        if (!queries.Period_Open(month, year))
                        {
                            MessageBox.Show("Date Must Be Within The Period");
                            return;
                        }

                        if (!string.IsNullOrEmpty(txtDescription.Text))
                        {
                            text                  = txtDescription.Text;
                            entry.section_id      = nullable;
                            entry.project_serial  = numberSerial;
                            entry.project_sap     = numberSAP;
                            entry.number_section  = numberSection;
                            entry.number_network  = nullable1;
                            entry.number_activity = numberActivity;
                            entry.date            = value;
                            entry.period          = month;
                            entry.year            = year;
                            entry.hours           = num;
                            entry.description     = text;
                            entry.timesheet_code  = code;
                            entry.task_type       = str;
                            queries.UpdateTimeEntry(entry);
                            tsEntry.RefreshDGHoursFromClassList();
                            tsEntry.RefreshSummaryByDate(functions.WeekEnding(entry.date));
                            Close();
                        }
                        else
                        {
                            MessageBox.Show("You must enter a description");
                        }
                    }
                    else
                    {
                        MessageBox.Show("You must select a date");
                    }
                }
                else
                {
                    MessageBox.Show("You must select a task type");
                }
            }
            else
            {
                MessageBox.Show("You must select a timecode");
            }
        }
 private void Window_Closing(object sender, CancelEventArgs e)
 {
     tsEntryScreen.RefreshDGHoursFromClassList();
     tsEntryScreen.RefreshSummaryByDate(functions.WeekEnding(DateTime.Now));
 }