コード例 #1
0
        private void AddButton_Click(object sender, EventArgs e)
        {
            string   timestamp   = SqlUpdater.CreateTimestamp();
            int      userId      = SqlUpdater.GetCurrentUserID();
            string   userName    = SqlUpdater.GetCurrentUserName();
            DateTime startTime   = DateTime.Parse(StartTimeBox.Text).ToUniversalTime();
            DateTime endTime     = DateTime.Parse(EndTimeBox.Text).ToUniversalTime();
            string   type        = TypeBox.Text;
            int      teamId      = Convert.ToInt32(TeamIdBox.Text);
            string   st          = DateTime.Parse(StartTimeBox.Text).ToUniversalTime().ToString("yyyy-MM-dd hh:mm:ss");
            string   et          = DateTime.Parse(EndTimeBox.Text).ToUniversalTime().ToString("yyyy-MM-dd hh:mm:ss");
            string   title       = " ";
            string   description = " ";
            string   location    = " ";
            string   url         = " ";
            string   contact     = " ";

            bool pass = Validator();

            if (pass)
            {
                try
                {
                    if (AppHasConflict(startTime, endTime))
                    {
                        throw new ScheduleException();
                    }
                    else
                    {
                        try
                        {
                            if (OutsideBusinessHours(startTime, endTime))
                            {
                                throw new ScheduleException();
                            }
                            else
                            {
                                SqlUpdater.CreateSchedule("appointment", teamId, st, et, type, title, description, location, url, contact, timestamp, userName, userId);
                                mainScheduleObject.UpdateCalendar();


                                Close();
                            }
                        }
                        catch (ScheduleException ex) { ex.BusinessHours(); }
                    }
                }
                catch (ScheduleException ex) { ex.AppOverlap(); }
            }