private void txtNewItem_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.Key == Key.Enter)
     {
         AddItemToList();
         e.Handled = true;
         AddItem.Focus();
     }
 }
        public InvoiceWindow()
        {
            InitializeComponent();
            DispatcherTimer timer = new DispatcherTimer();

            timer.Tick    += new EventHandler(timer_Tick);
            timer.Interval = new TimeSpan(0, 0, 0, 0, 1);
            timer.Start();
            ItemList.ItemsSource = items;
            //Maximizar
            this.MaxHeight = SystemParameters.MaximizedPrimaryScreenHeight;
            this.MaxWidth  = SystemParameters.MaximizedPrimaryScreenWidth;
            AddItem.Focus();
        }
        private void LookRemoveItem_Click(object sender, RoutedEventArgs e)
        {
            bool  error        = false;
            bool  found        = false;
            int   LookSKU      = -1;
            Items itemToRemove = new Items();

            try
            {
                LookSKU = int.Parse(RemoveItem.Text);
                error   = false;
            }
            catch (FormatException err)
            {
                MessageBox.Show("Ocurrio un error. " + err.Message, "Añadir Item", MessageBoxButton.OK, MessageBoxImage.Error);
                error = true;
            }
            if (!error)
            {
                foreach (Items element in items)
                {
                    if (element.SKU == LookSKU)
                    {
                        itemToRemove = element;
                        found        = true;
                    }
                }
                if (found)
                {
                    if (MessageBoxResult.Yes == MessageBox.Show("¿Esta seguro que quiere eliminar este elemento?", "Eliminar elemento", MessageBoxButton.YesNo, MessageBoxImage.Question))
                    {
                        items.Remove(itemToRemove);
                        ItemList.Items.Refresh();
                        RemoveItem.Text = null;
                        AddItem.Focus();
                        RefreshTotal();
                    }
                }
                else
                {
                    MessageBox.Show("Ocurrio un error.\nNo se encontro el elemento.", "Añadir Item", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            else
            {
                MessageBox.Show("Ocurrio un error.\nNo se encontro el elemento.", "Eliminar Item", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Example #4
0
 private void toolStripMenuItem20_Click(object sender, EventArgs e)
 {
     try
     {
         if (_AddItems.IsDisposed)
         {
             _AddItems = new AddItem();
         }
         Home.Home_pnl.Visible = false;
         _AddItems.MdiParent   = this;
         _AddItems.WindowState = FormWindowState.Maximized;
         _AddItems.Show();
         _AddItems.Focus();
     }
     catch (Exception ex)
     {
         notifyIcon1.ShowBalloonTip(1000, this.Name, ex.Message, ToolTipIcon.Info);;
     }
 }
        private void ModifyItem_Click(object sender, RoutedEventArgs e)
        {
            bool   error        = false;
            bool   found        = false;
            bool   error1       = true;
            int    LookSKU      = -1;
            string cant_temp    = "";
            Items  itemToModify = new Items();

            try
            {
                LookSKU = int.Parse(Interaction.InputBox("Ingrese el SKU del producto:", "Modificar Item"));
                error   = false;
            }
            catch (FormatException err)
            {
                error = true;
                MessageBox.Show("Ocurrio un error. " + err.Message, "Añadir Item", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            if (!error)
            {
                foreach (Items element in items)
                {
                    if (element.SKU == LookSKU)
                    {
                        itemToModify = element;
                        found        = true;
                    }
                }
                if (found)
                {
                    int cant = 0;
                    while (error1)
                    {
                        cant_temp = Interaction.InputBox("Ingrese la cantidad a modificar: (Deje en blanco para cancelar o presione Cancelar)", "Modificar productos", "0");
                        if (cant_temp != "")
                        {
                            try
                            {
                                cant   = int.Parse(cant_temp);
                                error1 = false;
                            }
                            catch (FormatException err)
                            {
                                error1 = true;
                                MessageBox.Show("Ocurrio un error. " + err.Message, "Añadir Item", MessageBoxButton.OK, MessageBoxImage.Error);
                            }
                            if (!error1)
                            {
                                Items itemToParcialRemove = new Items();
                                if (cant > 0)
                                {
                                    itemToModify.Cant        = cant;
                                    itemToModify.PriceAll    = cant * itemToModify.Unit;
                                    itemToModify.PriceAllStr = String.Format("{0:$#.00}", itemToModify.PriceAll);
                                    foreach (Items element in items)
                                    {
                                        if (element.SKU == LookSKU)
                                        {
                                            itemToParcialRemove = element;
                                        }
                                    }
                                    items.Remove(itemToParcialRemove);
                                    items.Add(itemToModify);
                                    ItemList.Items.Refresh();
                                    AddItem.Focus();
                                    RefreshTotal();
                                }
                                else if (cant <= 0)
                                {
                                    MessageBox.Show("Ocurrio un error.\nLa cantidad de productos no puede ser inferior o igual a 0", "Añadir productos", MessageBoxButton.OK, MessageBoxImage.Error);
                                }
                            }
                        }
                        else if (cant_temp == "")
                        {
                            return;
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Ocurrio un error.\nNo se encontro el elemento.", "Añadir Item", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
        }