示例#1
0
        private void customerCreateButton_Click(object sender, EventArgs e)
        {
            string timestamp = SqlUpdater.createTimestamp();
            string userName  = SqlUpdater.getCurrentUserName();

            if (string.IsNullOrEmpty(customerNameText.Text) ||
                string.IsNullOrEmpty(customerPhoneText.Text) ||
                string.IsNullOrEmpty(customerCityText.Text) ||
                string.IsNullOrEmpty(customerCountryText.Text) ||
                string.IsNullOrEmpty(customerZipText.Text) ||
                string.IsNullOrEmpty(customerAddressText.Text) ||
                (activeYes.Checked == false && activeNo.Checked == false))
            {
                MessageBox.Show("Please complete all fields");
            }
            else
            {
                int countryId = SqlUpdater.createRecord(timestamp, userName, "country", $"'{customerCountryText.Text}'");
                int cityId    = SqlUpdater.createRecord(timestamp, userName, "city", $"'{customerCityText.Text}', '{countryId}'");
                int addressId = SqlUpdater.createRecord(timestamp, userName, "address", $"'{customerAddressText.Text}', '', '{cityId}', '{customerZipText.Text}', '{customerPhoneText.Text}'");
                SqlUpdater.createRecord(timestamp, userName, "customer", $"'{ customerNameText.Text}', '{addressId}', '{(activeYes.Checked ? 1 : 0)}'");

                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 = startTimeBox.Value.ToUniversalTime();
            DateTime endTime   = endTimeBox.Value.ToUniversalTime();


            try
            {
                if (appHasConflict(startTime, endTime))
                {
                    throw new appointmentException();
                }
                else
                {
                    try
                    {
                        if (outsideBusinessHours(startTime, endTime))
                        {
                            throw new appointmentException();
                        }
                        else
                        {
                            SqlUpdater.createRecord(timestamp, username, "appointment", $"'{customerIdBox.Text}', '{startTimeBox.Value.ToUniversalTime().ToString("u")}', '{endTimeBox.Value.ToUniversalTime().ToString("u")}', '{typeBox.Text}'", userId);
                            mainFormObject.updateCalendar();


                            Close();
                        }
                    }
                    catch (appointmentException ex) { ex.businessHours(); }
                }
            }
            catch (appointmentException ex) { ex.appOverlap(); }
        }