Пример #1
0
 public void ValueChanged(object param)
 {
     if (Value != null)
     {
         if (param is CurrencyTextBox)
         {
             CurrencyTextBox textBox = param as CurrencyTextBox;
             if (Value.Value > MaximumValue && !textBox.IsFocused && textBox.MaxValidation != MaxValidation.OnLostFocus)
             {
                 AddLog("Value Changed: " + MaximumValue.ToString());
             }
             else if (Value.Value < MinimumValue && !textBox.IsFocused && textBox.MinValidation != MinValidation.OnLostFocus)
             {
                 AddLog("Value Changed: " + MinimumValue.ToString());
             }
             else
             {
                 AddLog("Value Changed: " + Value.ToString());
             }
         }
         else
         {
             AddLog("Value Changed: " + Value.ToString());
         }
     }
     else
     {
         AddLog("Value Changed: NULL");
     }
 }
        /// <summary>
        /// Determines whether the command can be executed
        /// </summary>
        /// <param name="parameter">An array containing the TextBox the value is supplied to and the ListBox displaying the value</param>
        /// <returns>True if the textbox parameter is not empty, false otherwise</returns>
        public bool CanExecute(object parameter)
        {
            VerifyParameter(parameter);
            object[]        parameterValues = parameter as object[];
            CurrencyTextBox addTextBox      = parameterValues[0] as CurrencyTextBox;

            return(addTextBox.Text.Length > 0);
        }
Пример #3
0
 public virtual Decimal DecimalValue()
 {
     // HACK
     var currencytextbox = new CurrencyTextBox();
     if (textBox1.Text.Trim() == "")
         currencytextbox.Text = "0";
     else currencytextbox.Text = textBox1.Text;
     return currencytextbox.DecimalValue;
 }
        public override void OnInitializeEditElement(DataColumnBase dataColumn, CurrencyTextBox uiElement, object dataContext)
        {
            base.OnInitializeEditElement(dataColumn, uiElement, dataContext);
            var binding = new Binding {
                Converter = new CurrencyConverter()
            };

            uiElement.SetBinding(CurrencyTextBox.CurrencySymbolProperty, binding);
        }
Пример #5
0
 public object Create(PropertyInfo propertyInfo)
 {
     currencyEditor = new CurrencyTextBox()
     {
         ApplyZeroColor        = false,
         CurrencyDecimalDigits = 2,
         MinValue        = 500,
         BorderThickness = new Thickness(0)
     };
     return(currencyEditor);
 }
Пример #6
0
 public override Decimal DecimalValue()
 {
     // HACK
     var currencytextbox = new CurrencyTextBox();
     if (textBox1.Text == "")
         currencytextbox.Text = "0";
     else{
         formatear();
         currencytextbox.Text = textBoxSinSignoPeso();
     }
     return currencytextbox.DecimalValue;
 }
        public void TestCanExecuteNonEmptyTextBox()
        {
            CurrencyTextBox textBox = new CurrencyTextBox()
            {
                Text = "15.00"
            };
            ListBox listBox = new ListBox();

            object[] parameters = { textBox, listBox };

            Assert.IsTrue(addItemCommand.CanExecute(parameters));
        }
        public CurrencyTextBoxRenderingTests()
        {
            textWriter = new Mock<TextWriter>();

            tagBuilder = new Mock<ITextBoxBaseHtmlBuilder>();
            rootTag = new Mock<IHtmlNode>();
            rootTag.SetupGet(t => t.Children).Returns(() => new List<IHtmlNode>());

            tagBuilder.Setup(t => t.Build("t-numerictextbox")).Returns(rootTag.Object);

            input = TextBoxBaseTestHelper.CreateCurrencyTextBox(tagBuilder.Object);
            input.Name = "CurrencyTextBox";
        }
Пример #9
0
        public CurrencyTextBoxRenderingTests()
        {
            textWriter = new Mock <TextWriter>();

            tagBuilder = new Mock <ITextBoxBaseHtmlBuilder>();
            rootTag    = new Mock <IHtmlNode>();
            rootTag.SetupGet(t => t.Children).Returns(() => new List <IHtmlNode>());

            tagBuilder.Setup(t => t.Build("t-numerictextbox")).Returns(rootTag.Object);

            input      = TextBoxBaseTestHelper.CreateCurrencyTextBox(tagBuilder.Object);
            input.Name = "CurrencyTextBox";
        }
Пример #10
0
        }//end CurrencyTextBox_TextChanged

        /// <summary>
        /// This method starts off by determining if the entered number in the CurrencyTextBox
        /// is a number. If not, a message box is shown, telling them what is wrong, then clears the CurrencyTextBox
        /// and focuses it for the user and disables the button.
        /// If it is a number, it saves the number into original money.
        /// The program then grabs the selected indexs for the originalCurrencyComboBox and
        /// newCurrencyComboBox. These values are then passed through a method in the
        /// Currency_Exchange_Class which converts the currency the user has chosen.
        /// The wanted currency enum name is passed into the wantType label and displayed for the user.
        /// The converted money is then passed into the ConvertedCurrencyTextBox to be displayed for the user.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void equalsButton_Click(object sender, EventArgs e)
        {
            int originalType, newType;

            double originalMoney, newMoney;

            if (!double.TryParse(CurrencyTextBox.Text, out originalMoney))
            {
                if (originalMoney < 1)
                {
                    MessageBox.Show("Please only use numbers");
                    CurrencyTextBox.Text = "";
                    CurrencyTextBox.Focus();

                    equalsButton.Enabled = false;
                }
                else
                {
                    originalType  = originalCurrencyComboBox.SelectedIndex;
                    newType       = newCurrencyComboBox.SelectedIndex;
                    originalMoney = double.Parse(CurrencyTextBox.Text);

                    newMoney = Currency_Exchange_Class.conversion(originalType, newType, originalMoney);

                    Currencies newCountry = (Currencies)newType;

                    wantType.Text = newCountry.ToString();


                    ConvertedCurrencyTextBox.Enabled = true;
                    ConvertedCurrencyTextBox.Text    = newMoney.ToString();
                    ConvertedCurrencyTextBox.Enabled = false;

                    CurrencyTextBox.Enabled           = false;
                    AnotherConversionGroupBox.Visible = true;
                }
            }
            else
            {
                MessageBox.Show("Please use a number greater than 0");
                CurrencyTextBox.Text = "";
                CurrencyTextBox.Focus();

                equalsButton.Enabled = false;
            }
        }// end equalsButton_Click
Пример #11
0
        public override void DetachEditingControl()
        {
            System.Windows.Forms.DataGridView dataGridView = this.DataGridView;
            if (dataGridView == null || dataGridView.EditingControl == null)
            {
                throw new InvalidOperationException("Cell is detached or its grid has no editing control.");
            }

            CurrencyTextBox editBox = dataGridView.EditingControl as CurrencyTextBox;

            if (editBox != null)
            {
                editBox.ClearUndo();  // avoid interferences between the editing sessions
            }

            base.DetachEditingControl();
        }
        public void TestExecute()
        {
            TextBox textBox = new CurrencyTextBox()
            {
                Text = "15.00"
            };
            ListBox listBox = new ListBox()
            {
                ItemsSource = itemList
            };

            object[] parameters = { textBox, listBox };
            addItemCommand.Execute(parameters);

            Assert.AreEqual("", textBox.Text);
            Assert.AreEqual(1, itemList.Count);
            Assert.AreEqual(15.00M, itemList[0]);
        }
Пример #13
0
        public override void InitializeEditingControl(int rowIndex, object initialFormattedValue, DataGridViewCellStyle dataGridViewCellStyle)
        {
            base.InitializeEditingControl(rowIndex, initialFormattedValue, dataGridViewCellStyle);
            CurrencyTextBox editBox = this.DataGridView.EditingControl as CurrencyTextBox;

            if (editBox != null)
            {
                editBox.BorderStyle = BorderStyle.None;

                string initialFormattedValueStr = initialFormattedValue as string;

                if (string.IsNullOrEmpty(initialFormattedValueStr))
                {
                    editBox.Text = "";
                }
                else
                {
                    editBox.Text = initialFormattedValueStr;
                }
            }
        }
Пример #14
0
        //Popup save button
        private async void PopUpSaveBT_Click(object sender, RoutedEventArgs e)
        {
            //List controls
            foreach (var item in PriceStack.Children)
            {
                Grid container = (Grid)item;

                foreach (var Grid_Childs in container.Children)
                {
                    var control = (Control)Grid_Childs;
                    if (control.Name.Contains("value"))
                    {
                        //Save price content
                        CurrencyTextBox PriceBox = (CurrencyTextBox)control;

                        string Price_id = PriceBox.Name.Replace("value", "");

                        var Data = new NovaAPI.APIProdructPrice.PriceModify
                        {
                            price_id    = Price_id,
                            price_value = PriceBox.Number.ToString(),
                            product_id  = ProductSelectIndex
                        };

                        string requestData = JsonConvert.SerializeObject(Data);

                        //Send modify request
                        await NovaAPI.APIProdructs.GetValues("6", DataConfig.LocalAPI, requestData);
                    }
                }
            }

            //Exit
            ProductPopUp.IsOpen  = false;
            ProductTab.IsEnabled = true;
            //Clear container
            PriceStack.Children.Clear();
            ErrorMessage.Visibility = Visibility.Collapsed;
            PopUpSaveBT.IsEnabled   = false;
        }
Пример #15
0
        public static CurrencyTextBox CreateCurrencyTextBox(ITextBoxBaseHtmlBuilder renderer)
        {
            Mock <HttpContextBase> httpContext = TestHelper.CreateMockedHttpContext();

            httpContext.Setup(c => c.Request.Browser.CreateHtmlTextWriter(It.IsAny <TextWriter>())).Returns(new HtmlTextWriter(TextWriter.Null));

            Mock <ITextBoxBaseHtmlBuilderFactory <decimal> > inputRendererFactory = new Mock <ITextBoxBaseHtmlBuilderFactory <decimal> >();

            Mock <IClientSideObjectWriterFactory> clientSideObjectWriterFactory = new Mock <IClientSideObjectWriterFactory>();

            clientSideObjectWriter = new Mock <IClientSideObjectWriter>();

            ViewContext viewContext = TestHelper.CreateViewContext();

            clientSideObjectWriterFactory.Setup(c => c.Create(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <TextWriter>())).Returns(clientSideObjectWriter.Object);

            CurrencyTextBox input = new CurrencyTextBox(viewContext, clientSideObjectWriterFactory.Object, inputRendererFactory.Object);

            renderer = renderer ?? new TextBoxBaseHtmlBuilder <decimal>(input);
            inputRendererFactory.Setup(f => f.Create(It.IsAny <CurrencyTextBox>())).Returns(renderer);

            return(input);
        }
 public CurrencyTextBoxBuilderTests()
 {
     input   = TextBoxBaseTestHelper.CreateCurrencyTextBox(null);
     builder = new CurrencyTextBoxBuilder(input);
 }
 public CurrencyTextBoxBuilderTests()
 {
     input = TextBoxBaseTestHelper.CreateCurrencyTextBox(null);
     builder = new CurrencyTextBoxBuilder(input);
 }
Пример #18
0
        //Set popup content
        private async void ProductPopUp_Opened(object sender, EventArgs e)
        {
            //Get/Set product parameters
            var Data = new NovaAPI.APIPrice.PriceClass();

            Data.id = ProductSelectIndex;
            //rol json data
            string requestData = JsonConvert.SerializeObject(Data);

            try
            {
                NovaAPI.APIProdructPrice.price.Clear();
            }
            catch (Exception) { }
            //Load prices data
            bool Response = await NovaAPI.APIProdructPrice.GetValues("5", DataConfig.LocalAPI, requestData);

            if (Response)
            {
                SolidColorBrush ContainerColor = (SolidColorBrush)Application.Current.TryFindResource("PanelLightBackground");
                //Create prices controls
                for (int i = 0; i < NovaAPI.APIProdructPrice.price.Count; i++)
                {
                    ContainerColor = ContainerColor == (SolidColorBrush)Application.Current.TryFindResource("PanelLightBackground") ? new SolidColorBrush(Colors.White) : (SolidColorBrush)Application.Current.TryFindResource("PanelLightBackground");

                    Grid Container = new Grid
                    {
                        Height     = 30,
                        Background = ContainerColor
                    };

                    //Price Name
                    Label Name = new Label
                    {
                        Content             = NovaAPI.APIProdructPrice.price[i].type == "0" ? $"{NovaAPI.APIProdructPrice.price[i].name}:" : $"{NovaAPI.APIProdructPrice.price[i].name} ({NovaAPI.APIProdructPrice.price[i].value}%):",
                        FontSize            = 14,
                        Opacity             = .7,
                        HorizontalAlignment = HorizontalAlignment.Right,
                        Margin = new Thickness(0, 0, (PriceStack.ActualWidth / 2) + 50, 0)
                    };

                    Label           PercentValue = new Label();
                    CurrencyTextBox GeneralValue = new CurrencyTextBox();

                    //If price type 0
                    if (NovaAPI.APIProdructPrice.price[i].type == "0")
                    {
                        GeneralValue.Name         = $"value{NovaAPI.APIProdructPrice.price[i].id}";
                        GeneralValue.Number       = Convert.ToInt32(NovaAPI.APIProdructPrice.price[i].value);
                        GeneralValue.StringFormat = "C0";
                        GeneralValue.FontSize     = 14;
                        GeneralValue.HorizontalContentAlignment = HorizontalAlignment.Left;
                        GeneralValue.Width = 100;
                        GeneralValue.HorizontalAlignment = HorizontalAlignment.Left;
                        GeneralValue.Margin = new Thickness(PriceStack.ActualWidth / 2, 3, 0, 3);

                        Container.Children.Add(GeneralValue);
                    }//If price type 1
                    else
                    {
                        double ProductValue  = Convert.ToInt32(NovaAPI.APIProdructs.products.Find(x => x.id == Data.id).pSell);
                        double DiscountValue = Convert.ToInt32(NovaAPI.APIProdructPrice.price[i].value);

                        double TotalDiscount = ProductValue != 0 && DiscountValue != 0 ? Math.Round((ProductValue * DiscountValue) / 100) : 0;


                        string price = string.Format("{0:C0}", ProductValue - TotalDiscount);

                        PercentValue.Content  = $"{price} \t \t (Descuento: {string.Format("{0:C0}",TotalDiscount)})";
                        PercentValue.FontSize = 14;
                        PercentValue.Opacity  = .7;
                        PercentValue.Margin   = new Thickness(PriceStack.ActualWidth / 2, 0, 0, 0);

                        Container.Children.Add(PercentValue);
                    }

                    Container.Children.Add(Name);
                    PriceStack.Children.Add(Container);
                }

                PopUpSaveBT.IsEnabled = true;
            }
            else
            {
                ErrorMessage.Content    = NovaAPI.APIProdructPrice.Message;
                ErrorMessage.Visibility = Visibility.Visible;
            }
        }
 public void Setup()
 {
     currencyTextBox = new CurrencyTextBox();
 }