public ActionResult CrudeFinancialCurrencyEdit(
            System.Guid financialCurrencyId
            )
        {
            CrudeFinancialCurrencyContract contract = new CrudeFinancialCurrencyServiceClient().FetchByFinancialCurrencyId(financialCurrencyId);

            ViewBag.FinancialCurrencyTypeRcd =
                new SelectList(new CrudeFinancialCurrencyTypeRefServiceClient().FetchAll(),
                               "FinancialCurrencyTypeRcd",
                               "FinancialCurrencyTypeName",
                               contract.FinancialCurrencyTypeRcd
                               );

            ViewBag.FinancialCurrencyAgainstFinancialCurrencyTypeRcd =
                new SelectList(new CrudeFinancialCurrencyTypeRefServiceClient().FetchAll(),
                               "FinancialCurrencyTypeRcd",
                               "FinancialCurrencyTypeName",
                               contract.FinancialCurrencyAgainstFinancialCurrencyTypeRcd
                               );

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


            return(View(
                       "~/Views/Crude/Financial/CrudeFinancialCurrency/CrudeFinancialCurrencyEdit.cshtml",
                       contract
                       ));
        }
        // shows the form in edit modus
        // links:
        //  docLink: http://sql2x.org/documentationLink/49afd26c-4f21-4992-967b-be190eacef77
        public void ShowAsEdit(System.Guid financialCurrencyId)
        {
            var service = new CrudeFinancialCurrencyServiceClient();

            _isNew = false;
            try {
                _contract = service.FetchByFinancialCurrencyId(financialCurrencyId);
                financialCurrencyTypeRefCombo.Text    = _contract.FinancialCurrencyTypeRcd != null ? _contract.FinancialCurrencyTypeRcd : String.Empty;
                textBoxFinancialCurrencyTypeCode.Text = _contract.FinancialCurrencyTypeCode;
                textBoxFinancialCurrencyTypeName.Text = _contract.FinancialCurrencyTypeName;
                financialCurrencyAgainstFinancialCurrencyTypeRefCombo.Text = _contract.FinancialCurrencyAgainstFinancialCurrencyTypeRcd != null ? _contract.FinancialCurrencyAgainstFinancialCurrencyTypeRcd : String.Empty;
                dateTimePickerValidFromDateTime.Value    = _contract.ValidFromDateTime != DateTime.MinValue ? _contract.ValidFromDateTime : dateTimePickerValidFromDateTime.MinDate;
                dateTimePickerValidFromDateTime.Checked  = _contract.ValidFromDateTime != DateTime.MinValue;
                dateTimePickerValidUntilDateTime.Value   = _contract.ValidUntilDateTime != DateTime.MinValue ? _contract.ValidUntilDateTime : dateTimePickerValidUntilDateTime.MinDate;
                dateTimePickerValidUntilDateTime.Checked = _contract.ValidUntilDateTime != DateTime.MinValue;
                maskedTextBoxAmount.Text       = _contract.Amount.ToString();
                maskedTextBoxEqualsAmount.Text = _contract.EqualsAmount.ToString();
                maskedTextBoxDecimalCount.Text = _contract.DecimalCount.ToString();
                userPicker.SelectedValue       = _contract.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();
            }
        }
        public ActionResult CrudeFinancialCurrencyEdit(
            System.Guid financialCurrencyId
            )
        {
            CrudeFinancialCurrencyContract contract = new CrudeFinancialCurrencyServiceClient().FetchByFinancialCurrencyId(financialCurrencyId);

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


            return(View(
                       "~/Views/Crude/Financial/CrudeFinancialCurrency/CrudeFinancialCurrencyEdit.cshtml",
                       contract
                       ));
        }
示例#4
0
        public ActionResult Order(
            Guid productId
            )
        {
            Guid userId = Logging.UserId(User.Identity, ViewBag);

            // get currency
            List <CrudeFinancialCurrencyContract> financialCurrencyContracts = new
                                                                               CrudeFinancialCurrencyServiceClient( ).FetchAllWithLimit(1);

            var cartProductContract = new CrudeCartProductContract( );

            cartProductContract.ProductId = productId;

            // our internal default_user_id becomes the client id... hmm
            cartProductContract.ClientId = userId;

            // save it if we got it
            if (!string.IsNullOrEmpty(Session.SessionID))
            {
                cartProductContract.SessionIdentificator = Session.SessionID;
            }

            // oauth id
            if (!string.IsNullOrEmpty(User.Identity.GetUserId()))
            {
                cartProductContract.AspId = Guid.Parse(User.Identity.GetUserId());
            }

            cartProductContract.Amount = 66;
            cartProductContract.FinancialCurrencyId = financialCurrencyContracts[0].FinancialCurrencyId;
            cartProductContract.StateRcd            = DefaultStateRef.Created;
            cartProductContract.UserId   = userId;
            cartProductContract.DateTime = DateTime.UtcNow;

            new CrudeCartProductServiceClient( ).Insert(cartProductContract);

            Response.Redirect("../CartProduct/CartProductIndexLive", true);

            return(null);
        }
示例#5
0
        // populates the Picker with the first match from the SOAP service
        // links:
        //  docLink: http://sql2x.org/documentationLink/3e8b9e1a-39eb-444f-9632-ce3406db3534
        private void txtFinancialCurrencyCode_Validating(object sender, CancelEventArgs e)
        {
            if (!DesignMode)
            {
                // empty picker on no code
                if (string.IsNullOrEmpty(txtFinancialCurrencyCode.Text))
                {
                    _financialCurrencyId          = Guid.Empty;
                    txtFinancialCurrencyName.Text = string.Empty;
                    txtFinancialCurrencyCode.Text = string.Empty;
                    return;
                }

                CrudeFinancialCurrencyServiceClient financialCurrency = null;

                try {
                    financialCurrency = new CrudeFinancialCurrencyServiceClient();
                    CrudeFinancialCurrencyContract contract = financialCurrency.FetchByFinancialCurrencyTypeCode(txtFinancialCurrencyCode.Text);

                    if (contract != null)
                    {
                        txtFinancialCurrencyCode.Text = contract.FinancialCurrencyTypeCode;
                        txtFinancialCurrencyName.Text = contract.FinancialCurrencyTypeName;
                        _financialCurrencyId          = contract.FinancialCurrencyId;
                    }
                } catch (Exception ex) {
                    MessageBox.Show(ex.Message);
                } finally {
                    if (financialCurrency != null)
                    {
                        financialCurrency.Close();
                    }
                }

                if (this.Picked != null)
                {
                    this.Picked(new object(), new EventArgs());
                }
            }
        }
        // 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 CrudeFinancialCurrencyServiceClient();

            try {
                _contract.FinancialCurrencyTypeRcd  = financialCurrencyTypeRefCombo.Text;
                _contract.FinancialCurrencyTypeCode = textBoxFinancialCurrencyTypeCode.Text;
                _contract.FinancialCurrencyTypeName = textBoxFinancialCurrencyTypeName.Text;
                _contract.FinancialCurrencyAgainstFinancialCurrencyTypeRcd = financialCurrencyAgainstFinancialCurrencyTypeRefCombo.Text;
                _contract.ValidFromDateTime  = dateTimePickerValidFromDateTime.Checked ? Convert.ToDateTime(dateTimePickerValidFromDateTime.Value): DateTime.MinValue;
                _contract.ValidUntilDateTime = dateTimePickerValidUntilDateTime.Checked ? Convert.ToDateTime(dateTimePickerValidUntilDateTime.Value): DateTime.MinValue;
                _contract.Amount             = maskedTextBoxAmount.Text == String.Empty ? 0 : Convert.ToDecimal(maskedTextBoxAmount.Text);
                _contract.EqualsAmount       = maskedTextBoxEqualsAmount.Text == String.Empty ? 0 : Convert.ToDecimal(maskedTextBoxEqualsAmount.Text);
                _contract.DecimalCount       = maskedTextBoxDecimalCount.Text == String.Empty ? 0 : Convert.ToInt32(maskedTextBoxDecimalCount.Text);
                _contract.UserId             = (Guid)userPicker.SelectedValue;

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

            Close();
        }
示例#7
0
        public void ShowAsAdd(
            Guid bookingId,
            Guid financialCurrencyId,
            Guid financialCostcentreId,
            Guid userId
            )
        {
            _financialPaymentContract = new CrudeFinancialPaymentContract();
            _isNew                             = true;
            _bookingId                         = bookingId;
            _financialCostcentreId             = financialCostcentreId;
            _financialCurrencyId               = financialCurrencyId;
            _financialPaymentContract.UserId   = userId;
            _financialPaymentContract.DateTime = DateTime.UtcNow;

            financialCurrencyPickerBookingBalance.SelectedValue  = financialCurrencyId;
            financialCurrencyPickerPayment.SelectedValue         = financialCurrencyId;
            financialCurrencyPickerBookingCurrency.SelectedValue = financialCurrencyId;

            // amount
            CrudeFinancialCurrencyContract currency =
                new CrudeFinancialCurrencyServiceClient().FetchByFinancialCurrencyId(
                    financialCurrencyPickerPayment.SelectedValue
                    );

            _balanceAmount                  = new BookingServiceClient().BookingFinancialBalance(bookingId);
            maskedTextBoxBalance.Text       = _balanceAmount.ToString("F4");
            maskedTextBoxPaymentAmount.Text = _balanceAmount.ToString("F" + currency.DecimalCount.ToString());
            maskedTextBoxPaymentAmount.Focus();

            _roundingAmountInBookingCurrency = _balanceAmount - Math.Round(_balanceAmount, currency.DecimalCount);
            maskedTextBoxRoundingAmount.Text = _roundingAmountInBookingCurrency.ToString();

            CashCalc();

            Show();
        }
示例#8
0
        // refresh the grid
        // links:
        //  docLink: http://sql2x.org/documentationLink/a90065e7-8ace-4de7-9367-d4653a7c637f
        public void RefreshCrudeFinancialCurrency()
        {
            var financialCurrency = new CrudeFinancialCurrencyServiceClient();

            try {
                var bindingSource = new BindingSource();
                bindingSource.DataSource = financialCurrency.FetchWithFilter(
                    Guid.Empty
                    , textBoxFinancialCurrencyType.Text
                    , textBoxFinancialCurrencyAgainstFinancialCurrencyType.Text
                    , Guid.Empty
                    , DateTime.MinValue
                    , dateTimePickerValidFromDateTime.Checked ? Convert.ToDateTime(dateTimePickerValidFromDateTime.Value): DateTime.MinValue
                    , dateTimePickerValidUntilDateTime.Checked ? Convert.ToDateTime(dateTimePickerValidUntilDateTime.Value): DateTime.MinValue
                    , maskedTextBoxAmount.Text == String.Empty ? 0 : Convert.ToDecimal(maskedTextBoxAmount.Text)
                    , maskedTextBoxEqualsAmount.Text == String.Empty ? 0 : Convert.ToDecimal(maskedTextBoxEqualsAmount.Text)
                    , maskedTextBoxDecimalCount.Text == String.Empty ? 0 : Convert.ToInt32(maskedTextBoxDecimalCount.Text)
                    , textBoxFinancialCurrencyTypeCode.Text
                    , textBoxFinancialCurrencyTypeName.Text
                    );
                dataGridViewCrudeFinancialCurrency.AutoGenerateColumns = false;
                dataGridViewCrudeFinancialCurrency.DataSource          = bindingSource;
                dataGridViewCrudeFinancialCurrency.AutoResizeColumns();
                dataGridViewCrudeFinancialCurrency.Refresh();
            } catch (Exception ex) {
                if (ex == null)
                {
                }
                else
                {
                    System.Diagnostics.Debugger.Break();
                }
            } finally {
                financialCurrency.Close();
            }
        }
示例#9
0
        BookingFinancialPaymentContract BookingFinancialPaymentsNew(
            Guid bookingId,
            string financialPaymentTypeRcd,
            Guid?financialPaymentId,
            Guid?financialCurrencyId,
            Guid?financialVoucherId
            )
        {
            // fix null's
            if (financialPaymentId == null)
            {
                financialPaymentId = Guid.Empty;
            }
            if (financialCurrencyId == null)
            {
                financialCurrencyId = Guid.Empty;
            }
            if (financialVoucherId == null)
            {
                financialVoucherId = Guid.Empty;
            }

            // fetch booking data
            var bookingFinancialPayment =
                new BookingFinancialPaymentContract(
                    bookingId,
                    Logging.UserId(User.Identity, ViewBag)
                    );

            // booking
            bookingFinancialPayment.BookingId = bookingId;

            bookingFinancialPayment.BookingBalanceFinancialCurrencyId =
                bookingFinancialPayment.BookingContract.Booking.FinancialCurrencyId;

            ViewBag.BookingBalanceFinancialCurrencyName =
                new CrudeFinancialCurrencyServiceClient().FetchByFinancialCurrencyId(
                    bookingFinancialPayment.BookingBalanceFinancialCurrencyId
                    ).FinancialCurrencyTypeName;

            // new payment
            if (financialPaymentId == Guid.Empty)
            {
                // get booking balance
                bookingFinancialPayment.BookingBalanceAmount =
                    new BookingServiceClient().BookingFinancialBalance(
                        bookingId);

                if (financialCurrencyId != Guid.Empty)
                {
                    // payment in new(selected) currency
                    bookingFinancialPayment.PaymentFinancialCurrencyId =
                        ( Guid )financialCurrencyId;

                    CrudeFinancialCurrencyContract currency =
                        new CrudeFinancialCurrencyServiceClient().FetchByFinancialCurrencyId(
                            bookingFinancialPayment.PaymentFinancialCurrencyId);

                    CrudeFinancialCurrencyTypeRefContract paymentCurrency =
                        new CrudeFinancialCurrencyTypeRefServiceClient().FetchByFinancialCurrencyTypeRcd(
                            currency.FinancialCurrencyAgainstFinancialCurrencyTypeRcd);

                    ViewBag.PaymentFinancialCurrencyName = paymentCurrency.FinancialCurrencyTypeName;

                    bookingFinancialPayment.PaymentAmount =
                        bookingFinancialPayment.BookingBalanceAmount * currency.EqualsAmount;

                    bookingFinancialPayment.PaymentBookingCurrencyAmount =
                        bookingFinancialPayment.BookingBalanceAmount;
                }
                else
                {
                    // payment in booking currency
                    bookingFinancialPayment.PaymentFinancialCurrencyId =
                        bookingFinancialPayment.BookingContract.Booking.FinancialCurrencyId;

                    bookingFinancialPayment.PaymentAmount =
                        bookingFinancialPayment.BookingBalanceAmount;

                    bookingFinancialPayment.PaymentBookingCurrencyAmount =
                        bookingFinancialPayment.BookingBalanceAmount;

                    ViewBag.PaymentFinancialCurrencyName =
                        new CrudeFinancialCurrencyServiceClient().FetchByFinancialCurrencyId(
                            bookingFinancialPayment.PaymentFinancialCurrencyId
                            ).FinancialCurrencyTypeName;
                }

                bookingFinancialPayment.PaymentFinancialCostcentreId =
                    bookingFinancialPayment.BookingContract.Booking.FinancialCostcentreId;
            }

            // payments
            bookingFinancialPayment.Payments =
                new BookingSearchService().BookingFinancialPayments(bookingId);

            bookingFinancialPayment.PaymentFinancialPaymentTypeRcd = financialPaymentTypeRcd;

            // get previous payment ( for viewing )
            if (financialPaymentId != Guid.Empty)
            {
                bookingFinancialPayment.PaymentContract =
                    new CrudeFinancialPaymentServiceClient().FetchByFinancialPaymentId(
                        ( Guid )financialPaymentId);
            }
            else
            {
                // get available currencies
                bookingFinancialPayment.PaymentSelectedFinancialCurrencyId =
                    bookingFinancialPayment.PaymentFinancialCurrencyId;

                ViewBag.PaymentSelectedFinancialCurrencyId =
                    new SelectList(new FinancialSearchService().
                                   GetAvailableCurrencies(
                                       bookingFinancialPayment.BookingBalanceFinancialCurrencyId,
                                       DateTime.UtcNow
                                       ),
                                   "FinancialCurrencyId",
                                   "FinancialCurrencyTypeName",
                                   bookingFinancialPayment.PaymentSelectedFinancialCurrencyId
                                   );
            }

            // payment type specific
            if (financialPaymentTypeRcd.Contains(FinancialPaymentTypeRef.Card))
            {
                // card
                if (financialPaymentId != Guid.Empty)
                {
                    bookingFinancialPayment.CardContract =
                        new CrudeFinancialPaymentCardServiceClient().FetchByFinancialPaymentCardId(
                            bookingFinancialPayment.PaymentContract.FinancialPaymentCardId);
                }

                ViewBag.FinancialCardTypeRcd =
                    new SelectList(new CrudeFinancialCardTypeRefServiceClient().FetchAll(),
                                   "FinancialCardTypeRcd",
                                   "FinancialCardTypeName",
                                   bookingFinancialPayment.FinancialCardTypeRcd);
            }
            else if (financialPaymentTypeRcd.Contains(FinancialPaymentTypeRef.Cash))
            {
                // cash
                if (financialPaymentId != Guid.Empty)
                {
                    bookingFinancialPayment.CashContract =
                        new CrudeFinancialPaymentCashServiceClient().FetchByFinancialPaymentCashId(
                            bookingFinancialPayment.PaymentContract.FinancialPaymentCashId);
                }
            }
            else if (financialPaymentTypeRcd.Contains(FinancialPaymentTypeRef.Bank))
            {
                // bank
                if (financialPaymentId != Guid.Empty)
                {
                    bookingFinancialPayment.BankContract =
                        new CrudeFinancialPaymentBankServiceClient().FetchByFinancialPaymentBankId(
                            bookingFinancialPayment.PaymentContract.FinancialPaymentBankId);
                }

                ViewBag.FinancialBankAccountNumberTypeRcd =
                    new SelectList(new CrudeFinancialBankAccountNumberTypeRefServiceClient().FetchAll(),
                                   "FinancialBankAccountNumberTypeRcd",
                                   "FinancialBankAccountNumberTypeName",
                                   bookingFinancialPayment.FinancialBankAccountNumberTypeRcd);
            }
            else if (financialPaymentTypeRcd.Contains(FinancialPaymentTypeRef.Voucher))
            {
                // voucher
                if (financialPaymentId == Guid.Empty)
                {
                    bookingFinancialPayment.Vouchers =
                        new FinancialSearchService().VoucherSearchWithRemainingAmount(DateTime.UtcNow);
                }
            }

            return(bookingFinancialPayment);
        }