// saves the form
        // links:
        //  docLink: http://sql2x.org/documentationLink/c9522930-91f8-4468-a936-8030bb2a6482
        private void buttonSave_Click(object sender, EventArgs e)
        {
            var service = new CrudeClientEventTypeRefServiceClient();

            try {
                _contract.ClientEventTypeRcd         = textBoxClientEventType.Text;
                _contract.ClientEventTypeName        = textBoxClientEventTypeName.Text;
                _contract.ClientEventTypeDescription = textBoxClientEventTypeDescription.Text;
                _contract.ActiveFlag = Convert.ToBoolean(checkBoxActiveFlag.Checked);
                _contract.SortOrder  = maskedTextBoxSortOrder.Text == String.Empty ? 0 : Convert.ToInt32(maskedTextBoxSortOrder.Text);

                if (_isNew)
                {
                    service.Insert(_contract);
                }
                else
                {
                    service.Update(_contract);
                }
            } catch (Exception ex) {
                if (ex == null)
                {
                }
                else
                {
                    System.Diagnostics.Debugger.Break();
                }
            } finally {
                service.Close();
            }

            Close();
        }
        // shows the form in edit modus
        // links:
        //  docLink: http://sql2x.org/documentationLink/49afd26c-4f21-4992-967b-be190eacef77
        public void ShowAsEdit(string clientEventTypeRcd, System.Guid userId)
        {
            var service = new CrudeClientEventTypeRefServiceClient();

            _isNew = false;
            try {
                _contract = service.FetchByClientEventTypeRcd(clientEventTypeRcd);
                textBoxClientEventType.Text            = _contract.ClientEventTypeRcd;
                textBoxClientEventTypeName.Text        = _contract.ClientEventTypeName;
                textBoxClientEventTypeDescription.Text = _contract.ClientEventTypeDescription;
                checkBoxActiveFlag.Checked             = _contract.ActiveFlag;
                maskedTextBoxSortOrder.Text            = _contract.SortOrder.ToString();
                _contract.UserId            = userId;
                _contract.DateTime          = DateTime.UtcNow;
                dateTimePickerDateTime.Text = _contract.DateTime.ToString();

                Show();
            } catch (Exception ex) {
                if (ex == null)
                {
                }
                else
                {
                    System.Diagnostics.Debugger.Break();
                }
            } finally {
                service.Close();
            }
        }
        // refresh the grid
        // links:
        //  docLink: http://sql2x.org/documentationLink/a90065e7-8ace-4de7-9367-d4653a7c637f
        public void RefreshCrudeClientEventTypeRef()
        {
            var clientEventTypeRef = new CrudeClientEventTypeRefServiceClient();

            try {
                var bindingSource = new BindingSource();
                bindingSource.DataSource = clientEventTypeRef.FetchWithFilter(
                    textBoxClientEventType.Text
                    , textBoxClientEventTypeName.Text
                    , Guid.Empty
                    , DateTime.MinValue
                    );
                dataGridViewCrudeClientEventTypeRef.AutoGenerateColumns = false;
                dataGridViewCrudeClientEventTypeRef.DataSource          = bindingSource;
                dataGridViewCrudeClientEventTypeRef.AutoResizeColumns();
                dataGridViewCrudeClientEventTypeRef.Refresh();
            } catch (Exception ex) {
                if (ex == null)
                {
                }
                else
                {
                    System.Diagnostics.Debugger.Break();
                }
            } finally {
                clientEventTypeRef.Close();
            }
        }
        // saves the form
        // links:
        //  docLink: http://sql2x.org/documentationLink/c9522930-91f8-4468-a936-8030bb2a6482
        private void buttonSave_Click(object sender, EventArgs e)
        {
            var service = new CrudeClientEventTypeRefServiceClient();

            try {
                _contract.ClientEventTypeRcd  = textBoxClientEventType.Text;
                _contract.ClientEventTypeName = textBoxClientEventTypeName.Text;

                if (_isNew)
                {
                    service.Insert(_contract);
                }
                else
                {
                    service.Update(_contract);
                }
            } catch (Exception ex) {
                if (ex == null)
                {
                }
                else
                {
                    System.Diagnostics.Debugger.Break();
                }
            } finally {
                service.Close();
            }

            Close();
        }
        // refresh the grid
        // links:
        //  docLink: http://sql2x.org/documentationLink/a90065e7-8ace-4de7-9367-d4653a7c637f
        public void RefreshCrudeClientEventTypeRef()
        {
            var clientEventTypeRef = new CrudeClientEventTypeRefServiceClient();

            try {
                var bindingSource = new BindingSource();
                bindingSource.DataSource = clientEventTypeRef.FetchWithFilter(
                    textBoxClientEventType.Text
                    , textBoxClientEventTypeName.Text
                    , textBoxClientEventTypeDescription.Text
                    , Convert.ToBoolean(checkBoxActiveFlag.Checked)
                    , maskedTextBoxSortOrder.Text == String.Empty ? 0 : Convert.ToInt32(maskedTextBoxSortOrder.Text)
                    , Guid.Empty
                    , DateTime.MinValue
                    );
                dataGridViewCrudeClientEventTypeRef.AutoGenerateColumns = false;
                dataGridViewCrudeClientEventTypeRef.DataSource          = bindingSource;
                dataGridViewCrudeClientEventTypeRef.AutoResizeColumns();
                dataGridViewCrudeClientEventTypeRef.Refresh();
            } catch (Exception ex) {
                if (ex == null)
                {
                }
                else
                {
                    System.Diagnostics.Debugger.Break();
                }
            } finally {
                clientEventTypeRef.Close();
            }
        }
        // fetch all rows from the SOAP layer and populate the ComboBox with it
        public void PopulateCombo()
        {
            if (!DesignMode && cboRef.DataSource == null)
            {
                CrudeClientEventTypeRefServiceClient clientEventTypeRef = null;

                try {
                    clientEventTypeRef = new CrudeClientEventTypeRefServiceClient();
                    List <CrudeClientEventTypeRefContract> contracts = clientEventTypeRef.FetchAll();

                    cboRef.DataSource    = contracts;
                    cboRef.DisplayMember = "ClientEventTypeName";
                    cboRef.ValueMember   = "ClientEventTypeRcd";
                } catch (Exception ex) {
                    if (ex != null)
                    {
                    }
                } finally {
                    if (clientEventTypeRef != null)
                    {
                        clientEventTypeRef.Close();
                    }
                }
            }
        }