private void Inventory_Click(object sender, RoutedEventArgs e)
 {
     if (Application.Current.Windows.OfType <InventoryWindow>().Count() == 0)
     {
         InventoryWindow.WindowInfo(2);
         Window inventory = new InventoryWindow();
         inventory.ShowDialog();
     }
 }
Beispiel #2
0
 public static void GetInventory(int WindowID)
 {
     using (StreamReader inventory = new StreamReader(Directory.GetCurrentDirectory() + @"\\databases\\product.txt"))
     {
         if (inventoryTimes == 0)
         {
             int    SKU_temp = 0, Cant_temp = 0;
             string PI_temp = "", PN_temp = "";
             double Price_temp = 0.00;
             inventoryTimes++;
             string ReadLine = "";
             do
             {
                 ReadLine = inventory.ReadLine();
                 if (ReadLine != null)
                 {
                     if (!ReadLine.Contains("#"))
                     {
                         SKU_temp   = int.Parse(ReadLine.Substring(0, ReadLine.IndexOf(".")));
                         PN_temp    = ReadLine.Substring(ReadLine.IndexOf(".") + 1, ReadLine.IndexOf("-") - ReadLine.IndexOf(".") - 1);
                         PI_temp    = ReadLine.Substring(ReadLine.IndexOf("-") + 1, ReadLine.IndexOf(",") - ReadLine.IndexOf("-") - 1);
                         Price_temp = double.Parse(ReadLine.Substring(ReadLine.IndexOf(",") + 1, ReadLine.IndexOf("/") - ReadLine.IndexOf(",") - 1));
                         Cant_temp  = int.Parse(ReadLine.Substring(ReadLine.IndexOf("/") + 1));
                         items.Add(new InventoryInfo()
                         {
                             SKU         = SKU_temp,
                             ProductName = PN_temp,
                             ProductInfo = PI_temp,
                             Price       = Price_temp,
                             Cant        = Cant_temp
                         });
                     }
                 }
             }while (ReadLine != null);
         }
         inventory.Close();
         if (Application.Current.Windows.OfType <InventoryWindow>().Count() == 0 && WindowID == 0)
         {
             if (Proyecto.MainWindow.user_class == "Administrador")
             {
                 InventoryWindow.WindowInfo(0);
                 Window invWin = new InventoryWindow();
                 invWin.Show();
             }
             if (Proyecto.MainWindow.user_class == "Usuario")
             {
                 InventoryWindow.WindowInfo(1);
                 Window invWin = new InventoryWindow();
                 invWin.Show();
             }
         }
         if (Application.Current.Windows.OfType <InvoiceWindow>().Count() == 0 && WindowID == 1)
         {
             if (Application.Current.Windows.OfType <InventoryWindow>().Count() == 0)
             {
                 Window invoiceWin = new InvoiceWindow();
                 invoiceWin.Show();
             }
             else
             {
                 MessageBox.Show("No puedes abrir la ventana 'Facturar' sin haber cerrado primero la ventana 'Inventariar'.\nTranquilo, puedes abrirla en la ventana 'Facturar'", "Facturar", MessageBoxButton.OK, MessageBoxImage.Error);
             }
         }
     }
 }