示例#1
0
        private void createButton_Click(object sender, EventArgs e)
        {
            string timestamp = SqlUpdater.CreateTimestamp();
            string userName  = SqlUpdater.GetCurrentUserName();

            if (string.IsNullOrEmpty(nameTextBox.Text) ||
                string.IsNullOrEmpty(phoneNumberTextBox.Text) ||
                string.IsNullOrEmpty(cityTextBox.Text) ||
                string.IsNullOrEmpty(countryTextBox.Text) ||
                string.IsNullOrEmpty(zipCodeTextBox.Text) ||
                string.IsNullOrEmpty(addressTextBox.Text))
            {
                MessageBox.Show("Please complete all fields");
            }
            else
            {
                int countryId = SqlUpdater.CreateRecord(timestamp, userName, "country", $"'{countryTextBox.Text}'");
                int cityId    = SqlUpdater.CreateRecord(timestamp, userName, "city", $"'{cityTextBox.Text}', '{countryId}'");
                int addressId = SqlUpdater.CreateRecord(timestamp, userName, "address", $"'{addressTextBox.Text}', '', '{cityId}', '{zipCodeTextBox.Text}', '{phoneNumberTextBox.Text}'");
                SqlUpdater.CreateRecord(timestamp, userName, "customer", $"'{ nameTextBox.Text}', '{addressId}', '{(activeRadio.Checked ? 1 : 0)}'");

                MessageBox.Show("Customer created.");
                Close();
            }
        }
示例#2
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(startTextBox.Text).ToUniversalTime();
            DateTime endTime   = DateTime.Parse(endTextBox.Text).ToUniversalTime();

            bool pass = Validator();

            if (pass)
            {
                try
                {
                    if (AppHasConflict(startTime, endTime))
                    {
                        throw new AppointmentExceptions();
                    }
                    else
                    {
                        try
                        {
                            if (OutsideBusinessHours(startTime, endTime))
                            {
                                throw new AppointmentExceptions();
                            }
                            else
                            {
                                SqlUpdater.CreateRecord(timestamp, username, "appointment", $"'{custIDTextBox.Text}', '{DateTime.Parse(startTextBox.Text).ToUniversalTime():u}', '{DateTime.Parse(endTextBox.Text).ToUniversalTime():u}', '{typeTextBox.Text}'", userId);
                                mainFormObject.UpdateCalendar();


                                Close();
                            }
                        }
                        catch (AppointmentExceptions ex) { ex.BusinessHours(); }
                    }
                }
                catch (AppointmentExceptions ex) { ex.ApptOverlap(); }
            }