// 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 CrudeProductGatherServiceClient();

            try {
                _contract.StartDateTime  = dateTimePickerStartDateTime.Checked ? Convert.ToDateTime(dateTimePickerStartDateTime.Value): DateTime.MinValue;
                _contract.FinishDateTime = dateTimePickerFinishDateTime.Checked ? Convert.ToDateTime(dateTimePickerFinishDateTime.Value): DateTime.MinValue;

                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(System.Guid productGatherId)
        {
            var service = new CrudeProductGatherServiceClient();

            _isNew = false;
            try {
                _contract = service.FetchByProductGatherId(productGatherId);
                dateTimePickerStartDateTime.Value    = _contract.StartDateTime != DateTime.MinValue ? _contract.StartDateTime : dateTimePickerStartDateTime.MinDate;
                dateTimePickerStartDateTime.Checked  = _contract.StartDateTime != DateTime.MinValue;
                dateTimePickerFinishDateTime.Value   = _contract.FinishDateTime != DateTime.MinValue ? _contract.FinishDateTime : dateTimePickerFinishDateTime.MinDate;
                dateTimePickerFinishDateTime.Checked = _contract.FinishDateTime != DateTime.MinValue;
                _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 RefreshCrudeProductGather()
        {
            var productGather = new CrudeProductGatherServiceClient();

            try {
                var bindingSource = new BindingSource();
                bindingSource.DataSource = productGather.FetchWithFilter(
                    Guid.Empty
                    , dateTimePickerStartDateTime.Checked ? Convert.ToDateTime(dateTimePickerStartDateTime.Value): DateTime.MinValue
                    , dateTimePickerFinishDateTime.Checked ? Convert.ToDateTime(dateTimePickerFinishDateTime.Value): DateTime.MinValue
                    , Guid.Empty
                    , DateTime.MinValue
                    );
                dataGridViewCrudeProductGather.AutoGenerateColumns = false;
                dataGridViewCrudeProductGather.DataSource          = bindingSource;
                dataGridViewCrudeProductGather.AutoResizeColumns();
                dataGridViewCrudeProductGather.Refresh();
            } catch (Exception ex) {
                if (ex == null)
                {
                }
                else
                {
                    System.Diagnostics.Debugger.Break();
                }
            } finally {
                productGather.Close();
            }
        }
Example #4
0
        public ActionResult CrudeProductGatherEdit(
            System.Guid productGatherId
            )
        {
            CrudeProductGatherContract contract = new CrudeProductGatherServiceClient().FetchByProductGatherId(productGatherId);

            ViewBag.DefaultUserName =
                new CrudeDefaultUserServiceClient().FetchByDefaultUserId(contract.UserId).DefaultUserName;


            return(View(
                       "~/Views/Crude/Product/CrudeProductGather/CrudeProductGatherEdit.cshtml",
                       contract
                       ));
        }