Beispiel #1
0
        private void applyBtn_Click(object sender, RoutedEventArgs e)
        {
            //dien day du
            if (cancelledTxb.Text != "")
            {
                //neu khong phai 1 so <10000 thi return
                if (!InputTester.IsANumber(cancelledTxb.Text, 4))
                {
                    notify.Text = "Only cancel < 10000 unit";
                    notify.ShowDialog();
                    return;
                }

                //SUCCESS CASE: la mot so va <= storage quantity
                if (Convert.ToInt32(cancelledTxb.Text) <= Convert.ToInt32(storageQuantityTbl.Text))
                {
                    confirmer.Text = "Do you sure to save change ?";
                    confirmer.ShowDialog();

                    if (confirmer.result == _401UC.iNotifierOKCancel.Result.OK)
                    {
                        foreach (Product prod in DataField.Instance.products)
                        {
                            if (prod.idProduct == idProduct)
                            {
                                #region Product receive new changes
                                prod.storageQuantity -= Convert.ToInt32(cancelledTxb.Text);
                                prod.cancelQuantity  += Convert.ToInt32(cancelledTxb.Text);
                                #endregion
                                break;
                            }
                        }

                        notify.Text = "Change success !!";
                        notify.ShowDialog();
                        cancelledTxb.Text = "";
                        this.Hide();
                    }
                }
                else
                {
                    notify.Text = "Cancelled Quantity is larger than Storage Quantity";
                    notify.ShowDialog();
                    return;
                }
            }
            else
            {
                notify.Text = "Please fill all the insert boxes";
                notify.ShowDialog();
            }
        }
        private void ApplyButton_Click(object sender, RoutedEventArgs e)
        {
            if (searchProductNameTxb.Text != "" &&
                importQuantityTxb.Text != "")
            {
                foreach (Product product in DataField.Instance.products)
                {
                    if (searchProductNameTxb.Text == product.nameProduct)
                    {
                        if (!InputTester.IsANumber(importQuantityTxb.Text, 4))
                        {
                            notify.Text = "Quantity Textbox inserted incorrect format";
                            notify.ShowDialog();
                            return;
                        }

                        #region Import Unit receive data to create
                        _401UC.ImportUnit unit = new _401UC.ImportUnit();
                        unit.Margin = new Thickness(15, 20, 15, 20);
                        BitmapImage bimage = new BitmapImage();
                        bimage.BeginInit();
                        bimage.UriSource = new Uri(product.imagePath, UriKind.Relative);
                        bimage.EndInit();
                        unit.productImg.Source       = bimage;
                        unit.productNameTbl.Text     = searchProductNameTxb.Text;
                        unit.productQuantityTbl.Text = importQuantityTxb.Text;
                        unit.productPriceTbl.Text    = product.exportPrice.ToString();
                        unit.border.ToolTip          = (Convert.ToInt32(unit.productQuantityTbl.Text) * Convert.ToInt32(unit.productPriceTbl.Text));
                        unit.RemoveUnitBtn.Tag       = reviewPanel.Children.Count.ToString();
                        unit.RemoveUnitBtn.Click    += WrapUnitCloseButton_Click;
                        #endregion

                        reviewPanel.Children.Add(unit);

                        searchProductNameTxb.Text = "";
                        importQuantityTxb.Text    = "";
                        totalTbl.Text             = (Convert.ToInt32(totalTbl.Text) + (Convert.ToInt32(unit.productQuantityTbl.Text) * Convert.ToInt32(unit.productPriceTbl.Text))).ToString();
                        return;
                    }
                }
                notify.Text = "Incorrect Product's Name";
                notify.ShowDialog();
                searchProductNameTxb.Text = "";
                importQuantityTxb.Text    = "";
            }
            else
            {
                notify.Text = "Please fill all the insert boxes";
                notify.ShowDialog();
            }
        }
 private void NumberTxb_PreviewKeyDown(object sender, KeyEventArgs e)
 {
     //only allows number (above QWERTY and right-side numberpad and del,backspace,tab key)
     e.Handled = !InputTester.IsNumberKey(e.Key) && !InputTester.IsDelOrBackspaceOrTabKey(e.Key);
 }