コード例 #1
0
ファイル: UtilityFunction.cs プロジェクト: quangphat/TmTech
 private static object ChangeType(object obj, Type t)
 {
     try
     {
         if (string.IsNullOrWhiteSpace(obj.ToString()))
         {
             if (t == typeof(int))
             {
                 return((int)(0));
             }
             if (t == typeof(double))
             {
                 return((double)(0));
             }
             if (t == typeof(decimal))
             {
                 return((decimal)(0));
             }
             if (t == typeof(float))
             {
                 return((float)(0));
             }
         }
         if ((t == typeof(decimal) || t == typeof(Decimal)))
         {
             return(CurrencyUtility.ToDecimal(obj.ToString()));
         }
         return(Convert.ChangeType(obj, t));
     }
     catch
     {
         obj = "";
         return(ChangeType(obj, t));
     }
 }
コード例 #2
0
        private void txtQuantity_TextChanged(object sender, EventArgs e)
        {
            int     soluong   = string.IsNullOrWhiteSpace(txtQuantity.Text) == true ? 0 : Convert.ToInt32(txtQuantity.Text);
            decimal thanhtien = soluong * CurrencyUtility.ToDecimal(txtQuotationPrice.Text);

            txtThanhtien.Text = CurrencyUtility.DecimalToString(thanhtien);
        }
コード例 #3
0
        private void BtnReviseCheckoutStatus_Click(object sender, System.EventArgs e)
        {
            try
            {
                TxtStatus.Text = "";

                ReviseCheckoutStatusCall apicall = new ReviseCheckoutStatusCall(Context);

                apicall.PaymentMethodUsed = (BuyerPaymentMethodCodeType)Enum.Parse(typeof(BuyerPaymentMethodCodeType), CboPaymentMethod.SelectedItem.ToString());
                if (TxtAmountPaid.Text != String.Empty)
                {
                    apicall.AmountPaid            = new AmountType();
                    apicall.AmountPaid.currencyID = CurrencyUtility.GetDefaultCurrencyCodeType(Context.Site);
                    apicall.AmountPaid.Value      = Convert.ToDouble(TxtAmountPaid.Text);
                }

                apicall.ShippingService = CboShipSvc.SelectedItem.ToString();

                if (OptItem.Checked)
                {
                    apicall.ReviseCheckoutStatus(TxtItemId.Text, TxtTransactionId.Text, (CompleteStatusCodeType)Enum.Parse(typeof(CompleteStatusCodeType), CboCheckoutStatus.SelectedItem.ToString()));
                }
                else
                {
                    apicall.ReviseCheckoutStatus(TxtOrderId.Text, (CompleteStatusCodeType)Enum.Parse(typeof(CompleteStatusCodeType), CboCheckoutStatus.SelectedItem.ToString()));
                }
                TxtStatus.Text = apicall.ApiResponse.Ack.ToString();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #4
0
ファイル: frmCreateDebt.cs プロジェクト: quangphat/TmTech
        private void txtThanhtien_TextChanged(object sender, EventArgs e)
        {
            decimal val = CurrencyUtility.ToDecimal(txtThanhtien.Text);

            txtThanhtien.Text           = CurrencyUtility.DecimalToString(val);
            txtThanhtien.SelectionStart = txtThanhtien.Text.Length;
        }
コード例 #5
0
ファイル: frmDebtMain.cs プロジェクト: quangphat/TmTech
        private void gridView1_RowClick(object sender, RowClickEventArgs e)
        {
            gridUtility.SetRowColor();
            Debt debt = gridUtility.GetSelectedItem <Debt>();

            txtCompanyDebt.Text = CurrencyUtility.DecimalToString(debt.RestValuePerCompany);
        }
コード例 #6
0
        private void InititalizeForm(Product product)
        {
            txtPrice.Text    = CurrencyUtility.DecimalToString(product.Price);
            txtQuantity.Text = product.Quantity.ToString();
            decimal customerPrice = product.Price * (decimal)m_Company.Class.CompanyClassRate;

            txtQuotationPrice.Text = CurrencyUtility.DecimalToString(customerPrice);
            txtThanhtien.Text      = (product.Quantity * customerPrice).ToString();
        }
コード例 #7
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (m_QuotationDetail.Quotation.ApproveStatusId == (int)ApproveStatus.Approved)
     {
         lblNotify1.SetText(UI.itemwasapproved, ToolBoxCS.LabelNotify.EnumStatus.Failed);
         return;
     }
     if (m_Product == null)
     {
         return;
     }
     using (IUnitOfWork uow = new UnitOfWork())
     {
         m_Product = uow.ProductRepository.Find(m_Product.ProductId);
         uow.Commit();
     }
     if (m_Product == null)
     {
         lblNotify1.SetText(UI.productnotfound, ToolBoxCS.LabelNotify.EnumStatus.Failed);
         return;
     }
     m_QuotationDetail.ProductId = m_Product.ProductId;
     m_QuotationDetail.Product   = m_Product;
     m_QuotationDetail.Quantity  = string.IsNullOrWhiteSpace(txtQuantity.Text) == true ? 0 : Convert.ToInt32(txtQuantity.Text);
     if (m_QuotationDetail.Quantity == 0)
     {
         lblNotify1.SetText(UI.hasnotquantity, ToolBoxCS.LabelNotify.EnumStatus.Failed);
         return;
     }
     m_QuotationDetail.QuotationPrice = CurrencyUtility.ToDecimal(txtQuotationPrice.Text);
     m_QuotationDetail.BasePrice      = CurrencyUtility.ToDecimal(txtPrice.Text);
     if (m_QuotationDetail.QuotationPrice == 0)
     {
         lblNotify1.SetText(UI.hasnotprice, ToolBoxCS.LabelNotify.EnumStatus.Failed);
         return;
     }
     CoverObjectUtility.GetAutoBindingData(this, m_QuotationDetail);
     try
     {
         using (IUnitOfWork uow = new UnitOfWork())
         {
             uow.QuotationDetailRepository.Update(m_QuotationDetail);
             uow.Commit();
         }
         if (UpdateRow != null)
         {
             UpdateRow(m_QuotationDetail);
         }
         this.Close();
     }
     catch
     {
         lblNotify1.SetText(UI.updatefailed, ToolBoxCS.LabelNotify.EnumStatus.Failed);
     }
 }
コード例 #8
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public override ICollection GetShippingServiceOptions()
        {
            InternationalShippingServiceOptionsTypeCollection ssos = new InternationalShippingServiceOptionsTypeCollection();

            int row = this.Items.Count;
            int col = this.Items[0].SubItems.Count;
            int cnt = 0;

            for (int i = 0; i < row; i++)
            {
                ListViewItem lvi = this.Items[i];
                //ShippingService
                string text = lvi.SubItems[0].Text;
                if (text.Length > 0)
                {
                    if (!text.Equals("NotSelected"))
                    {
                        InternationalShippingServiceOptionsType sso = new InternationalShippingServiceOptionsType();
                        sso.ShippingService         = text;
                        sso.ShippingServicePriority = ++cnt;
                        ssos.Add(sso);
                        if (col > 1)
                        {
                            // ShippingServiceCost
                            text = lvi.SubItems[1].Text;
                            if (text.Length > 0)
                            {
                                sso.ShippingServiceCost = CurrencyUtility.GetAmountType(text);
                            }
                            // ShippingServiceAdditioanlCost
                            text = lvi.SubItems[2].Text;
                            if (text.Length > 0)
                            {
                                sso.ShippingServiceAdditionalCost = CurrencyUtility.GetAmountType(text);
                            }
                            // ShipToLocations
                            text = lvi.SubItems[3].Text;
                            if (text.Length > 0)
                            {
                                sso.ShipToLocation = this.GetShipToLocationCollection(text);
                            }
                            // Import charge
                            text = lvi.SubItems[4].Text;
                            if (text.Length > 0)
                            {
                                sso.ImportCharge = CurrencyUtility.GetAmountType(text);
                            }
                        }
                    }
                }
            }
            return(ssos);
        }
コード例 #9
0
ファイル: frmEditQuotation.cs プロジェクト: quangphat/TmTech
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (ValidationUtility.FieldNotAllowNull(this) == false)
            {
                return;
            }
            if (m_Quotation == null)
            {
                return;
            }
            CoverObjectUtility.GetAutoBindingData(this, m_Quotation);
            if (m_Quotation.ApproveStatusId == (int)ApproveStatus.Approved)
            {
                lblNotify1.SetText(UI.itemwasapproved, ToolBoxCS.LabelNotify.EnumStatus.Failed);
                return;
            }
            m_Quotation.SetModify();
            IList <QuotationDetail> lstQuotationDetail = gridControl1.DataSource as IList <QuotationDetail>;

            try
            {
                using (IUnitOfWork uow = new UnitOfWork())
                {
                    uow.QuotationRepository.Update(m_Quotation);
                    foreach (QuotationDetail p in lstQuotationDetail)
                    {
                        p.QuotationCode = m_Quotation.QuotationCode;
                        if (p.QuotationDetailId != Guid.Empty)
                        {
                            uow.QuotationDetailRepository.Update(p);
                        }
                        else
                        {
                            uow.QuotationDetailRepository.Add(p);
                        }
                    }
                    uow.Commit();
                }
                m_Quotation.TotalValue = CurrencyUtility.ToDecimal(colThanhtien.SummaryText);
                isEdited = false;
                if (UpdateRow != null)
                {
                    UpdateRow(m_Quotation);
                }
                lblNotify1.SetText(UI.success, ToolBoxCS.LabelNotify.EnumStatus.Success);
            }
            catch
            {
                lblNotify1.SetText(UI.failed, ToolBoxCS.LabelNotify.EnumStatus.Failed);
            }
        }
コード例 #10
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (ValidationUtility.FieldNotAllowNull(this) == false)
            {
                return;
            }
            if (m_Quotation == null)
            {
                return;
            }
            CoverObjectUtility.GetAutoBindingData(this.tableLayoutPanel1, m_Quotation);
            IList <QuotationDetail> lstQuottionDetail = gridControl1.DataSource as IList <QuotationDetail>;

            if (lstQuottionDetail == null)
            {
                return;
            }

            m_Quotation.Company    = m_Company;
            m_Quotation.TotalValue = CurrencyUtility.ToDecimal(colThanhtien.SummaryText);
            try
            {
                using (IUnitOfWork uow = new UnitOfWork())
                {
                    uow.QuotationRepository.Add(m_Quotation);
                    foreach (QuotationDetail quotationDetail in lstQuottionDetail)
                    {
                        quotationDetail.QuotationCode = m_Quotation.QuotationCode;
                        uow.QuotationDetailRepository.Add(quotationDetail);
                    }
                    uow.Commit();
                }
                if (AddRow != null)
                {
                    AddRow(m_Quotation, CRUD.Insert);
                }
                lblNotify1.SetText(UI.createsuccess, ToolBoxCS.LabelNotify.EnumStatus.Success);
                //();
                isEdited = false;
                this.Close();
            }
            catch
            {
                lblNotify1.SetText(UI.createfailed, ToolBoxCS.LabelNotify.EnumStatus.Failed);
            }
        }
コード例 #11
0
        private ItemType FillItem()
        {
            ItemType item = new ItemType();

            item.ItemID = TxtOriginalId.Text;

            item.ListingDuration = CboDuration.SelectedItem.ToString();


            if (TxtBuyItNowPrice.Text.Length > 0)
            {
                item.BuyItNowPrice            = new AmountType();
                item.BuyItNowPrice.currencyID = CurrencyUtility.GetDefaultCurrencyCodeType(Context.Site);
                item.BuyItNowPrice.Value      = Double.Parse(this.TxtBuyItNowPrice.Text, NumberStyles.Currency);
            }

            return(item);
        }
コード例 #12
0
        public virtual GetMyDetailsResponse GetMyDetails()
        {
            var details = _accountApiProxy.GetMyDetails(CultureCode, _userContext.UserId);

            if (details == null)
            {
                return(new GetMyDetailsResponse {
                    Code = ResponseCode.UserDetailsNotFound
                });
            }

            string symbol;

            if (!CurrencyUtility.TryGetCurrencySymbol(_userContext.Currency, out symbol))
            {
                symbol = "$";
            }

            return(new GetMyDetailsResponse
            {
                Code = ResponseCode.Success,
                User = new UserModel
                {
                    Username = _userContext.Username,
                    FirstName = details.FirstName,
                    LastName = details.LastName,
                    AddressLine1 = details.AddressLine1,
                    AddressLine2 = details.AddressLine2,
                    AddressLine3 = details.AddressLine3,
                    PostalCode = details.PostalCode,
                    MobileNumber = details.MobileNumber,
                    Email = details.Email,
                    City = details.City,
                    Country = details.Country,
                    CurrencySymbol = symbol,
                    Status = details.Status,
                    LowDeposit = details.LowDeposit
                },

                // Should not be doing this because the token is not sharable between mobile and desktop
                //SportsbookUrl = _sportsbookApiProxy.GetSbTechUrl(CultureCode, _userContext.Username),
                //SportsbookMobileUrl = _sportsbookApiProxy.GetSbTechMobileUrl(CultureCode, _userContext.Username)
            });
        }
コード例 #13
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public virtual ICollection GetShippingServiceOptions()
        {
            ShippingServiceOptionsTypeCollection ssos = new ShippingServiceOptionsTypeCollection();

            int row = this.Items.Count;
            int col = this.Items[0].SubItems.Count;

            int cnt = 0;

            for (int i = 0; i < row; i++)
            {
                ListViewItem lvi = this.Items[i];
                //ShippingService
                string text = lvi.SubItems[0].Text;
                if (text.Length > 0)
                {
                    if (!text.Equals("NotSelected"))
                    {
                        cnt++;
                        ShippingServiceOptionsType sso = new ShippingServiceOptionsType();
                        sso.ShippingService         = text;
                        sso.ShippingServicePriority = cnt;
                        ssos.Add(sso);
                        if (col > 1)
                        {
                            // ShippingServiceCost
                            text = lvi.SubItems[1].Text;
                            if (text.Length > 0)
                            {
                                sso.ShippingServiceCost = CurrencyUtility.GetAmountType(text);
                            }
                            // ShippingServiceAdditioanlCost
                            text = lvi.SubItems[2].Text;
                            if (text.Length > 0)
                            {
                                sso.ShippingServiceAdditionalCost = CurrencyUtility.GetAmountType(text);
                            }
                        }
                    }
                }
            }
            return(ssos);
        }
コード例 #14
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (m_Product == null)
            {
                return;
            }
            m_QuotationDetail = new QuotationDetail();
            using (IUnitOfWork uow = new UnitOfWork())
            {
                m_Product = uow.ProductRepository.Find(m_Product.ProductId);
                uow.Commit();
            }
            if (m_Product == null)
            {
                lblNotify1.SetText(UI.productnotfound, ToolBoxCS.LabelNotify.EnumStatus.Failed);
                return;
            }
            m_QuotationDetail.ProductId = m_Product.ProductId;
            m_QuotationDetail.Product   = m_Product;
            m_QuotationDetail.Quantity  = string.IsNullOrWhiteSpace(txtQuantity.Text) == true ? 0 : Convert.ToInt32(txtQuantity.Text);
            if (m_QuotationDetail.Quantity == 0)
            {
                lblNotify1.SetText(UI.hasnotquantity, ToolBoxCS.LabelNotify.EnumStatus.Failed);
                return;
            }
            m_QuotationDetail.QuotationPrice = CurrencyUtility.ToDecimal(txtQuotationPrice.Text);
            m_QuotationDetail.BasePrice      = CurrencyUtility.ToDecimal(txtPrice.Text);
            if (m_QuotationDetail.QuotationPrice == 0)
            {
                lblNotify1.SetText(UI.hasnotprice, ToolBoxCS.LabelNotify.EnumStatus.Failed);
                return;
            }
            CoverObjectUtility.GetAutoBindingData(this, m_QuotationDetail);

            if (SaveSelectedProperty != null)
            {
                SaveSelectedProperty(m_QuotationDetail);
            }
            ((Form)this.TopLevelControl).Close();
        }
コード例 #15
0
ファイル: frmCreatePo.cs プロジェクト: quangphat/TmTech
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (ValidationUtility.FieldNotAllowNull(this) == false)
            {
                return;
            }
            IList <QuotationDetail> lstProduct = gridControl1.DataSource as IList <QuotationDetail>;

            if (m_Po == null)
            {
                return;
            }
            if (lstProduct == null)
            {
                return;
            }
            CoverObjectUtility.GetAutoBindingData(this.tableLayoutPanel3, m_Po);
            try
            {
                using (IUnitOfWork uow = new UnitOfWork())
                {
                    uow.PoRepository.Add(m_Po);
                    uow.Commit();
                }
                isEdited = false;
                lblNotify1.SetText(UI.createsuccess, ToolBoxCS.LabelNotify.EnumStatus.Success);
                if (AddRow != null)
                {
                    m_Po.Quantity   = Convert.ToInt32(colQuantity.SummaryText);
                    m_Po.TotalValue = CurrencyUtility.ToDecimal(colThanhtien.SummaryText);
                    AddRow(m_Po, CRUD.Insert);
                }
                Close();
            }
            catch
            {
                lblNotify1.SetText(UI.createfailed, ToolBoxCS.LabelNotify.EnumStatus.Failed);
            }
        }
コード例 #16
0
ファイル: frmEditPO.cs プロジェクト: quangphat/TmTech
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (m_Po.ApproveStatusId == (int)ApproveStatus.Approved)
     {
         lblNotify1.SetText(UI.itemwasapproved, ToolBoxCS.LabelNotify.EnumStatus.Failed, 5000);
         return;
     }
     if (ValidationUtility.FieldNotAllowNull(this.tableLayoutPanel3) == false)
     {
         return;
     }
     if (m_Po == null)
     {
         return;
     }
     CoverObjectUtility.GetAutoBindingData(this.tableLayoutPanel3, m_Po);
     m_Po.Quantity   = Convert.ToInt32(colQuantity.SummaryText);
     m_Po.TotalValue = CurrencyUtility.ToDecimal(colThanhtien.SummaryText);
     m_Po.SetModify();
     try
     {
         using (IUnitOfWork uow = new UnitOfWork())
         {
             uow.PoRepository.Update(m_Po);
             uow.Commit();
         }
         lblNotify1.SetText(UI.updatesuccess, ToolBoxCS.LabelNotify.EnumStatus.Success);
         isEdited = false;
         if (UpdateRow != null)
         {
             UpdateRow(m_Po, CRUD.Update);
         }
     }
     catch
     {
         lblNotify1.SetText(UI.updatefailed, ToolBoxCS.LabelNotify.EnumStatus.Failed);
     }
 }
コード例 #17
0
ファイル: TradeManager.cs プロジェクト: HasanOZER1/Poloniex
        public static void SellCurrencyToUsdt(string currencyPair, ref TradeSignalOrder tradeSignalOrder)
        {
            lock (_syncRoot)
            {
                decimal percentToTrade = 1.00M; // always sell 100%

                bool isMoving     = false;
                int  attemptCount = 0;
                Dictionary <string, decimal> balances = PoloniexExchangeService.Instance.ReturnBalances();
                decimal currencyBalance = balances[CurrencyUtility.GetCurrencyFromUsdtCurrencyPair(currencyPair)] * percentToTrade;
                long    orderNumber     = 0;

                while (true)
                {
                    attemptCount++;
                    Dictionary <string, Dictionary <string, decimal> > res = PoloniexExchangeService.Instance.ReturnTicker();
                    var latestUsdtBtcTicker = res[currencyPair];

                    // weighted average
                    decimal usdtCurrencyLastPrice  = latestUsdtBtcTicker[TickerResultKeys.last];       // 3
                    decimal usdtCurrencyHighestBid = latestUsdtBtcTicker[TickerResultKeys.highestBid]; // 2
                    decimal usdtCurrencyLowestAsk  = latestUsdtBtcTicker[TickerResultKeys.lowestAsk];  // 1

                    /* TESTING CODE : BEGIN */
                    //decimal sellRate = (1.25M) * usdtBtcLastPrice; // TODO: FIX!!!
                    //if (isMoving)
                    //{
                    //    sellRate = sellRate * 1.25M;
                    //}
                    /* TESTING CODE : END */

                    /* PRODUCTION CODE : BEGIN */
                    decimal sellRate = ((3M * usdtCurrencyLastPrice) + (2M * usdtCurrencyHighestBid) + (1M * usdtCurrencyLowestAsk)) / 6M;;
                    /* PRODUCTION CODE : END */

                    decimal sellAmount = currencyBalance;

                    if (!isMoving)
                    {
                        tradeSignalOrder.PlaceValueTradedAt = sellRate;
                        // SELL
                        Thread.Sleep(1000); // guarantee nonce (unix timestamp)
                        var sellResult = PoloniexExchangeService.Instance.Sell(currencyPair, sellRate, sellAmount);
                        orderNumber = sellResult.orderNumber;
                        Logger.Write($"Order: Selling {currencyPair} to USDT; sellRate: {sellRate}, sellAmount: {sellAmount}, _numberOfTraders: {_numberOfTraders}, _numberOfHoldings: {_numberOfHoldings}", Logger.LogType.TransactionLog);
                        isMoving = true;
                    }
                    else
                    {
                        tradeSignalOrder.MoveValueTradedAt = sellRate;
                        // MOVE
                        Thread.Sleep(1000); // guarantee nonce (unix timestamp)
                        var moveResult = PoloniexExchangeService.Instance.MoveOrder(orderNumber, sellRate, sellAmount);
                        orderNumber = moveResult.orderNumber;
                        Logger.Write($"Order: Moving (attemptCount:{attemptCount}) {currencyPair} to USDT; sellRate: {sellRate}, sellAmount: {sellAmount}, _numberOfTraders: {_numberOfTraders}, _numberOfHoldings: {_numberOfHoldings}", Logger.LogType.TransactionLog);
                    }

                    Thread.Sleep(10 * 1000); // allow exchange to resolve order

                    // Get open orders
                    var openOrders       = PoloniexExchangeService.Instance.ReturnOpenOrders(currencyPair);
                    var originalBuyOrder = openOrders.SingleOrDefault(x => x[OpenOrderKeys.orderNumber] == orderNumber.ToString());

                    Logger.Write($"openOrders: {JsonConvert.SerializeObject(openOrders)}", Logger.LogType.TransactionLog);

                    bool isTradeComplete = originalBuyOrder == null;
                    if (isTradeComplete)
                    {
                        tradeSignalOrder.LastValueAtProcessing = sellRate;
                        _numberOfHoldings--;
                        break;
                    }
                }
            }
        }
コード例 #18
0
ファイル: frmCreateDebt.cs プロジェクト: quangphat/TmTech
        private void autoTextBox1_TextChanged(object sender, EventArgs e)
        {
            double percent = string.IsNullOrWhiteSpace(autoTextBox1.Text) == true ? 0 : Convert.ToDouble(autoTextBox1.Text);

            textBox9.Text = CurrencyUtility.DecimalToString(CurrencyUtility.PercentToMoney(percent / 100, m_Debt.TotalValue));
        }
コード例 #19
0
        private void BtnSendInvoice_Click(object sender, System.EventArgs e)
        {
            try
            {
                SendInvoiceCall apicall = new SendInvoiceCall(Context);

                TxtStatus.Text = "";
                string ItemID        = TxtItemId.Text;
                string TransactionID = TxtTransactionId.Text;

                ShippingServiceOptionsType ShippingServiceOption = new ShippingServiceOptionsType();

                ShippingServiceOption.ShippingInsuranceCost            = new AmountType();
                ShippingServiceOption.ShippingInsuranceCost.currencyID = CurrencyUtility.GetDefaultCurrencyCodeType(Context.Site);
                ShippingServiceOption.ShippingInsuranceCost.Value      = Convert.ToDouble(TxtShippingInsuranceCost.Text);

                ShippingServiceOption.ShippingService = CboShippingService.SelectedItem.ToString();

                ShippingServiceOption.ShippingServiceCost            = new AmountType();
                ShippingServiceOption.ShippingServiceCost.currencyID = CurrencyUtility.GetDefaultCurrencyCodeType(Context.Site);
                ShippingServiceOption.ShippingServiceCost.Value      = Convert.ToDouble(TxtShippingServiceCost.Text);


                ShippingServiceOption.ShippingServiceAdditionalCost = new AmountType();

                ShippingServiceOption.ShippingServiceAdditionalCost.Value      = Convert.ToDouble(TxtShippingServiceAdditionalCost.Text);
                ShippingServiceOption.ShippingServiceAdditionalCost.currencyID = CurrencyUtility.GetDefaultCurrencyCodeType(Context.Site);
                ShippingServiceOption.ShippingServicePriority = Int32.Parse(TxtShippingServicePriority.Text);

                //SaleTaxType related
                apicall.SalesTax = new SalesTaxType();
                apicall.SalesTax.SalesTaxPercent       = (float)Convert.ToDouble(TxtSalesTaxPercent.Text);
                apicall.SalesTax.SalesTaxState         = TxtSalesTaxState.Text;
                apicall.SalesTax.ShippingIncludedInTax = ChkShippingIncludedInTax.Checked;

                apicall.SalesTax.SalesTaxAmount            = new AmountType();
                apicall.SalesTax.SalesTaxAmount.currencyID = CurrencyUtility.GetDefaultCurrencyCodeType(Context.Site);
                apicall.SalesTax.SalesTaxAmount.Value      = Convert.ToDouble(TxtSalesTaxAmount.Text);


                apicall.InsuranceOption = (InsuranceOptionCodeType)Enum.Parse(typeof(InsuranceOptionCodeType), CboInsuranceOption.SelectedItem.ToString());

                apicall.InsuranceFee            = new AmountType();
                apicall.InsuranceFee.currencyID = CurrencyUtility.GetDefaultCurrencyCodeType(Context.Site);
                apicall.InsuranceFee.Value      = Convert.ToDouble(TxtInsuranceFee.Text);

                apicall.PaymentMethodsList = new BuyerPaymentMethodCodeTypeCollection();
                apicall.PaymentMethodsList.Add((BuyerPaymentMethodCodeType)Enum.Parse(typeof(BuyerPaymentMethodCodeType), CboPaymentMethod.SelectedItem.ToString()));

                apicall.PayPalEmailAddress   = TxtPayPalEmailAddress.Text;
                apicall.CheckoutInstructions = TxtCheckoutInstructions.Text;
                apicall.EmailCopyToSeller    = ChkEmailCopyToSeller.Checked;

                ShippingServiceOptionsTypeCollection ShippingServiceOptionsList = new ShippingServiceOptionsTypeCollection();
                ShippingServiceOptionsList.Add(ShippingServiceOption);

                apicall.SendInvoice(ItemID, TransactionID, ShippingServiceOptionsList);
                TxtStatus.Text = apicall.ApiResponse.Ack.ToString();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #20
0
        private void BtnAddOrder_Click(object sender, System.EventArgs e)
        {
            try
            {
                TxtOrderId.Text = "";

                AddOrderCall apicall = new AddOrderCall(Context);


                OrderType order = new OrderType();
                order.TransactionArray = new TransactionTypeCollection();
                order.ShippingDetails  = new ShippingDetailsType();
                order.PaymentMethods   = new BuyerPaymentMethodCodeTypeCollection();

                TransactionType tr1 = new TransactionType();
                tr1.Item          = new ItemType();
                tr1.Item.ItemID   = TxtItemIdOne.Text;
                tr1.TransactionID = TxtTransactionIdOne.Text;
                order.TransactionArray.Add(tr1);

                TransactionType tr2 = new TransactionType();
                tr2.Item          = new ItemType();
                tr2.Item.ItemID   = TxtItemIdTwo.Text;
                tr2.TransactionID = TxtTransactionIdTwo.Text;
                order.TransactionArray.Add(tr2);

                order.ShippingDetails.PaymentInstructions = TxtPaymentInstructions.Text;
                ShippingServiceOptionsType shpopt = new ShippingServiceOptionsType();
                shpopt.ShippingService         = CboShipSvc.SelectedItem.ToString();
                shpopt.ShippingServicePriority = 1;

                order.ShippingDetails.ShippingServiceOptions = new ShippingServiceOptionsTypeCollection();
                shpopt.ShippingServiceCost            = new AmountType();
                shpopt.ShippingServiceCost.currencyID = CurrencyUtility.GetDefaultCurrencyCodeType(Context.Site);

                if (TxtShipCost.Text.Length > 0)
                {
                    shpopt.ShippingServiceCost.Value = Convert.ToDouble(TxtShipCost.Text);
                }
                order.ShippingDetails.ShippingServiceOptions.Add(shpopt);

                order.Total            = new AmountType();
                order.Total.currencyID = CurrencyUtility.GetDefaultCurrencyCodeType(Context.Site);
                if (TxtTotal.Text.Length > 0)
                {
                    order.Total.Value = Convert.ToDouble(TxtTotal.Text);
                }
                order.CreatingUserRole = (TradingRoleCodeType)Enum.Parse(typeof(TradingRoleCodeType), CboRole.SelectedItem.ToString());

                order.PaymentMethods.AddRange(new BuyerPaymentMethodCodeType[] { BuyerPaymentMethodCodeType.PaymentSeeDescription });

                string orderid = apicall.AddOrder(order);


                TxtOrderId.Text = orderid;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #21
0
        private void BtnRespondToBestOffer_Click(object sender, System.EventArgs e)
        {
            try
            {
                if (TxtBestOfferID.Text.Trim().Length == 0)
                {
                    MessageBox.Show("Please input best offer id!");
                    return;
                }

                if (TxtItemID.Text.Trim().Length == 0)
                {
                    MessageBox.Show("Please input item id!");
                    return;
                }


                TxtStatus.Text = "";
                RespondToBestOfferCall apicall = new RespondToBestOfferCall(Context);

                StringCollection BestOfferIDList = new StringCollection();
                BestOfferIDList.Add(TxtBestOfferID.Text);
                string cboActionChoice = CboAction.SelectedItem.ToString();
                if (cboActionChoice == "Counter")
                {
                    if (txtCounterOfferPrice.Text.Trim().Length == 0)
                    {
                        MessageBox.Show("Please counter offer price!");
                        return;
                    }

                    if (txtCounterOfferQuantity.Text.Trim().Length == 0)
                    {
                        MessageBox.Show("Please input counter offer quanity!");
                        return;
                    }

                    AmountType CounterOfferPrice = new AmountType();
                    CounterOfferPrice.currencyID = CurrencyUtility.GetDefaultCurrencyCodeType(Context.Site);
                    CounterOfferPrice.Value      = Convert.ToDouble(txtCounterOfferPrice.Text);
                    int quantity = Convert.ToInt32(txtCounterOfferQuantity.Text);
                    apicall.RespondToBestOffer(TxtItemID.Text,
                                               BestOfferIDList,
                                               (BestOfferActionCodeType)Enum.Parse(typeof(BestOfferActionCodeType),
                                                                                   CboAction.SelectedItem.ToString()),
                                               TxtSellerResponse.Text,
                                               CounterOfferPrice,
                                               quantity);
                }
                else
                {
                    apicall.RespondToBestOffer(TxtItemID.Text,
                                               BestOfferIDList,
                                               (BestOfferActionCodeType)Enum.Parse(typeof(BestOfferActionCodeType),
                                                                                   CboAction.SelectedItem.ToString()),
                                               TxtSellerResponse.Text);
                }
                TxtStatus.Text = apicall.ApiResponse.Ack.ToString();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #22
0
ファイル: frmCreatePo.cs プロジェクト: quangphat/TmTech
        private void autoTextBox1_TextChanged(object sender, EventArgs e)
        {
            double percent = string.IsNullOrWhiteSpace(autoTextBox1.Text) == true ? 0 : Convert.ToDouble(autoTextBox1.Text);

            autoTextBox15.Text = CurrencyUtility.DecimalToString(CurrencyUtility.PercentToMoney(percent / 100, colThanhtien.SummaryText));
        }
コード例 #23
0
ファイル: frmCreateProduct.cs プロジェクト: quangphat/TmTech
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (ValidationUtility.FieldNotAllowNull(this) == false)
            {
                return;
            }
            if (cbbCategory.SelectedValue == null || cbbSubCate.SelectedValue == null || cbbSerie.SelectedValue == null)
            {
                lblNotify1.SetText(UI.hasnoinfomation, LabelNotify.EnumStatus.Failed);
                return;
            }
            Product product = new Product();

            FormUtility.BindTextBoxToObj <Product>(this, product);
            product.SeriesId    = int.Parse(cbbSerie.SelectedValue.ToString());
            product.ProductCode = txtCode.Text;
            product.ProductName = txtName.Text;
            //product.BranchOfLed = txtLed.Text;
            //product.IPRate = txtIPRate.Text;
            product.DataSheet  = ValidationUtility.StringIsNull(txtDatasheet.Text) == false ? txtDatasheet.Text : "";
            product.Note       = txtNote.Text;
            product.CreateBy   = UserManagement.UserSession.UserName;
            product.CreateDate = DateTime.Now;
            ProductPrice productPrice = new ProductPrice();

            productPrice.Price      = CurrencyUtility.ToDecimal(txtPrice.Text);
            productPrice.ActiveDate = DateTime.Today;
            productPrice.CreateBy   = UserManagement.UserSession.UserName;
            productPrice.CreateDate = DateTime.Now;
            if (ptPicture.Tag != null)
            {
                product.PhotoPath = PictureUtility.SaveImg(ptPicture.Tag.ToString());
            }
            if (ptPhotometer.Tag != null)
            {
                product.PhotoMeter = PictureUtility.SaveImg(ptPhotometer.Tag.ToString());
            }
            try
            {
                using (IUnitOfWork uow = new UnitOfWork())
                {
                    Product exists = uow.ProductRepository.FindByCode(product.ProductCode);
                    if (exists != null)
                    {
                        lblNotify1.SetText(UI.codehasexist, LabelNotify.EnumStatus.Failed);
                        uow.Commit();
                        return;
                    }
                    if (product.Barcode != null)
                    {
                        exists = uow.ProductRepository.FindByBarcode(product.Barcode);
                        if (exists != null)
                        {
                            lblNotify1.SetText(UI.barcodehasexists, LabelNotify.EnumStatus.Failed);
                            uow.Commit();
                            return;
                        }
                    }

                    //Guid id = uow.ProductRepository.Add(product);
                    //product.ProductId = id;
                    ////product.Barcode = BarcodeUtility.generateBarcode(id);
                    //productPrice.ProductId = id;
                    //uow.ProductPriceRepository.Update(productPrice);
                    //uow.ProductRepository.Update(product);
                    //uow.Commit();
                }
                lblNotify1.SetText(UI.createsuccess, LabelNotify.EnumStatus.Success);
            }
            catch
            {
                lblNotify1.SetText(UI.createfailed, LabelNotify.EnumStatus.Failed);
            }
        }
コード例 #24
0
 private void txtMoneyOut_TextChanged(object sender, EventArgs e)
 {
     //AutoTextBox text = sender as AutoTextBox;
     //txtMoneyNumWrite.Text = Translate(text.Text).Normalize();
     txtMoneyNumWrite.Text = MoneyToString.ReadMoney.MoneyToText(CurrencyUtility.ToDecimal(txtMoneyOut.Text));
 }
コード例 #25
0
        private ItemType FillItem(RecommendationEngineCodeType engine)
        {
            ItemType item = new ItemType();

            if (TxtTitle.Text.Length > 0)
            {
                item.Title = TxtTitle.Text;
            }

            CurrencyCodeType currencyID = CurrencyUtility.GetDefaultCurrencyCodeType(Context.Site);

            item.Currency = currencyID;
            if (TxtStartPrice.Text.Length > 0)
            {
                item.StartPrice            = new AmountType();
                item.StartPrice.Value      = Convert.ToDouble(TxtStartPrice.Text);
                item.StartPrice.currencyID = currencyID;
            }

            if (TxtReservePrice.Text.Length > 0)
            {
                item.ReservePrice            = new AmountType();
                item.ReservePrice.Value      = Convert.ToDouble(TxtReservePrice.Text);
                item.ReservePrice.currencyID = currencyID;
            }
            ;

            if (TxtBuyItNowPrice.Text.Length > 0)
            {
                item.BuyItNowPrice            = new AmountType();
                item.BuyItNowPrice.Value      = Convert.ToDouble(TxtBuyItNowPrice.Text);
                item.BuyItNowPrice.currencyID = currencyID;
            }

            if (TxtPrimaryCategory.Text.Length > 0)
            {
                item.PrimaryCategory            = new CategoryType();
                item.PrimaryCategory.CategoryID = TxtPrimaryCategory.Text;
            }

            if (TxtSecondaryCategory.Text.Length > 0)
            {
                item.SecondaryCategory            = new CategoryType();
                item.SecondaryCategory.CategoryID = TxtSecondaryCategory.Text;
            }

            if (TxtItemID.Visible)
            {
                item.ItemID = TxtItemID.Text;
            }
            if (engine == RecommendationEngineCodeType.ProductPricing)
            {
                string s = TxtExternalProductID.Text;
                if (s.Length > 0)
                {
                    ProductListingDetailsType pld = new ProductListingDetailsType();
                    pld.ProductID = s;
                    item.ProductListingDetails = pld;
                }
            }

            return(item);
        }
コード例 #26
0
        private void BtnReviseItem_Click(object sender, System.EventArgs e)
        {
            try
            {
                TxtItemId.Text     = "";
                TxtListingFee.Text = "";
                BtnGetItem.Visible = false;

                // Populate the Item
                ItemType item = new ItemType();
                item.ItemID = TxtReviseItemId.Text;

                CurrencyCodeType currencyCode = CurrencyUtility.GetDefaultCurrencyCodeType(Context.Site);


                if (TxtTitle.Text.Length > 0)
                {
                    item.Title = this.TxtTitle.Text;
                }

                if (TxtDescription.Text.Length > 0)
                {
                    item.Description = this.TxtDescription.Text;
                }

                if (CboDuration.SelectedIndex != -1)
                {
                    item.ListingDuration = CboDuration.SelectedItem.ToString();
                }

                if (TxtStartPrice.Text.Length > 0)
                {
                    item.StartPrice            = new AmountType();
                    item.StartPrice.currencyID = currencyCode;
                    item.StartPrice.Value      = Double.Parse(this.TxtStartPrice.Text, NumberStyles.Currency);
                }
                if (TxtReservePrice.Text.Length > 0)
                {
                    item.ReservePrice            = new AmountType();
                    item.ReservePrice.currencyID = currencyCode;
                    item.ReservePrice.Value      = Double.Parse(this.TxtReservePrice.Text, NumberStyles.Currency);
                }
                if (TxtBuyItNowPrice.Text.Length > 0)
                {
                    item.BuyItNowPrice            = new AmountType();
                    item.BuyItNowPrice.currencyID = currencyCode;
                    item.BuyItNowPrice.Value      = Double.Parse(this.TxtBuyItNowPrice.Text, NumberStyles.Currency);
                }

                if (CboEnableBestOffer.SelectedIndex != -1)
                {
                    item.BestOfferDetails = new BestOfferDetailsType();
                    item.BestOfferDetails.BestOfferEnabled = Boolean.Parse(CboEnableBestOffer.SelectedItem.ToString());
                }

                StringCollection deletedFields = new StringCollection();

                if (ChkPayPalEmailAddress.Checked)
                {
                    deletedFields.Add("Item.payPalEmailAddress");
                }

                if (ChkApplicationData.Checked)
                {
                    deletedFields.Add("Item.applicationData");
                }

                ReviseItemCall apicall = new ReviseItemCall(Context);
                if (ListPictures.Items.Count > 0)
                {
                    apicall.PictureFileList          = new StringCollection();
                    item.PictureDetails              = new PictureDetailsType();
                    item.PictureDetails.PhotoDisplay = (PhotoDisplayCodeType)Enum.Parse(typeof(PhotoDisplayCodeType), CboPicDisplay.SelectedItem.ToString());
                }

                foreach (string pic in ListPictures.Items)
                {
                    apicall.PictureFileList.Add(pic);
                }
                apicall.DeletedFieldList = deletedFields;

                apicall.ReviseItem(item, deletedFields, false);
                TxtItemId.Text = item.ItemID;

                FeeTypeCollection fees = apicall.FeeList;

                BtnGetItem.Visible = true;

                foreach (FeeType fee in fees)
                {
                    if (fee.Name == "ListingFee")
                    {
                        TxtListingFee.Text = fee.Fee.Value.ToString();
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #27
0
 private void txtMoneyBack_TextChanged(object sender, EventArgs e)
 {
     txtReturnMoneyNumWrite.Text = MoneyToString.ReadMoney.MoneyToText(CurrencyUtility.ToDecimal(txtMoneyBack.Text));
 }
コード例 #28
0
ファイル: FrmAddItem.cs プロジェクト: nunezger/berkeleyshoe
        private ItemType FillItem()
        {
            BtnGetItem.Visible = false;

            ItemType item = new ItemType();

            // Set UP Defaults
            item.Currency = CurrencyUtility.GetDefaultCurrencyCodeType(Context.Site);
            item.Country  = SiteUtility.GetCountryCodeType(Context.Site);

            item.PaymentMethods = new BuyerPaymentMethodCodeTypeCollection();
            item.PaymentMethods.AddRange(new BuyerPaymentMethodCodeType[] { BuyerPaymentMethodCodeType.PayPal });
            item.RegionID = "0";

            // Set specified values from the form
            item.Title       = this.TxtTitle.Text;
            item.Description = this.TxtDescription.Text;

            item.Quantity = Int32.Parse(TxtQuantity.Text, NumberStyles.None);
            item.Location = TxtLocation.Text;

            item.ListingDuration = CboDuration.SelectedItem.ToString();


            item.PrimaryCategory            = new CategoryType();
            item.PrimaryCategory.CategoryID = this.TxtCategory.Text;;
            if (TxtStartPrice.Text.Length > 0)
            {
                item.StartPrice            = new AmountType();
                item.StartPrice.currencyID = item.Currency;
                item.StartPrice.Value      = Convert.ToDouble(this.TxtStartPrice.Text);
            }

            if (TxtReservePrice.Visible && TxtReservePrice.Text.Length > 0)
            {
                item.ReservePrice            = new AmountType();
                item.ReservePrice.currencyID = item.Currency;
                item.ReservePrice.Value      = Convert.ToDouble(this.TxtReservePrice.Text);
            }
            if (TxtBuyItNowPrice.Visible && TxtBuyItNowPrice.Text.Length > 0)
            {
                item.BuyItNowPrice            = new AmountType();
                item.BuyItNowPrice.currencyID = item.Currency;
                item.BuyItNowPrice.Value      = Convert.ToDouble(this.TxtBuyItNowPrice.Text);
            }

            ListingEnhancementsCodeTypeCollection enhancements = new ListingEnhancementsCodeTypeCollection();

            if (this.ChkBoldTitle.Checked)
            {
                enhancements.Add(ListingEnhancementsCodeType.BoldTitle);
            }
            if (this.ChkHighLight.Checked)
            {
                enhancements.Add(ListingEnhancementsCodeType.Highlight);
            }

            if (enhancements.Count > 0)
            {
                item.ListingEnhancement = enhancements;
            }

            item.ListingType = (ListingTypeCodeType)Enum.Parse(typeof(ListingTypeCodeType), CboListType.SelectedItem.ToString());

            if (ChkEnableBestOffer.Visible)
            {
                item.BestOfferDetails = new BestOfferDetailsType();
                item.BestOfferDetails.BestOfferEnabled = ChkEnableBestOffer.Checked;
            }

            if (TxtCategory2.Text.Length > 0)
            {
                item.SecondaryCategory            = new CategoryType();
                item.SecondaryCategory.CategoryID = TxtCategory2.Text;
            }

            if (TxtPayPalEmailAddress.Text.Length > 0)
            {
                item.PayPalEmailAddress = TxtPayPalEmailAddress.Text;
            }

            if (TxtApplicationData.Text.Length > 0)
            {
                item.ApplicationData = TxtApplicationData.Text;
            }

            int condition = ((ComboxItem)CboCondition.SelectedItem).Value;

            item.ConditionID = condition;

            //add shipping information
            item.ShippingDetails = getShippingDetails();
            //add handling time
            item.DispatchTimeMax = 1;
            //add policy
            item.ReturnPolicy = GetPolicyForUS();

            return(item);
        }