//private void OnConfiguration(object sender, RoutedEventArgs e)
        //{

        //}

        private void OnImportInventory(object sender, RoutedEventArgs e)
        {
            OpenFileDialog diag = new OpenFileDialog();

            diag.Title           = "Select File for Import";
            diag.Filter          = "Comma Delimited|*.csv|All Files|*.*";
            diag.CheckFileExists = true;
            diag.CheckPathExists = true;
            diag.DefaultExt      = "csv";
            diag.Multiselect     = false;



            if (diag.ShowDialog() == true)
            {
                using (StreamReader sr = new StreamReader(diag.FileName))
                {
                    LumenWorks.Framework.IO.Csv.CsvReader csv = new LumenWorks.Framework.IO.Csv.CsvReader(sr, true);

                    int      fieldCount = csv.FieldCount;
                    string[] headers    = csv.GetFieldHeaders();

                    while (csv.ReadNextRecord())
                    {
                        ActiveInventoryObject Inv = new ActiveInventoryObject();

                        int i = 0;

                        Inv.UPC = csv[0];

                        Inv.Distributor = csv[1];
                        Inv.SKU         = csv[2];
                        Inv.Description = csv[3];
                        Inv.Category    = csv[4];
                        if (int.TryParse(csv[5], out i))
                        {
                            Inv.Quantity = i;
                        }


                        Inv.WholeSalePrice = Configuration.CurrencyToDecimal(csv[6]);


                        Inv.MSRP = Configuration.CurrencyToDecimal(csv[7]);


                        Inv.AdditionalOverhead = Configuration.CurrencyToDecimal(csv[8]);

                        Inv.DescriptionShort = Inv.Description;
                        Inv.Manufacturer     = csv[14];

                        Cache.Current.Inventory.Add(Inv);
                    }
                }
                MessageBox.Show("Process Complete.");
            }
        }
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            decimal retVal            = 0;
            ActiveInventoryObject val = value as ActiveInventoryObject;

            if (val != null)
            {
                retVal = val.AdditionalOverhead + val.WholeSalePrice;
            }
            return(retVal.ToString("C", System.Globalization.CultureInfo.CurrentCulture));
        }
示例#3
0
        private void OnDelete(object sender, RoutedEventArgs e)
        {
            Button btn = sender as Button;

            if (btn != null)
            {
                ActiveInventoryObject aio = btn.CommandParameter as ActiveInventoryObject;
                if (aio != null && Inventory.Contains(aio))
                {
                    Inventory.Remove(aio);
                }
            }
        }
示例#4
0
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            ActiveInventoryObject item = value as ActiveInventoryObject;

            if (item != null)
            {
                decimal retVal = item.GetTotalPrice(PricingModelObject.GetPricingModel(Configuration.Current.CurrentPricingModel)) * item.Quantity;
                return(retVal.ToString("C", System.Globalization.CultureInfo.CurrentUICulture));
            }
            else
            {
                return(null);
            }
        }
        private void OnDelete(object sender, RoutedEventArgs e)
        {
            Button btn = sender as Button;

            if (btn != null)
            {
                ActiveInventoryObject aio = btn.Command as ActiveInventoryObject;
                if (aio != null)
                {
                    Activity.Remove(aio);
                    aio.TotalDollarChanged -= newItem_TotalDollarChanged;
                }
            }
        }
        private void OnDelete(object sender, RoutedEventArgs e)
        {
            Button btn = sender as Button;

            if (btn != null)
            {
                ActiveInventoryObject aio = btn.CommandParameter as ActiveInventoryObject;
                if (aio != null)
                {
                    this.Activity.Remove(aio);
                    RefreshTotals();
                }
            }
        }
        void AddEntry()
        {
            //First, get item from Inventory.
            if (!string.IsNullOrEmpty(SearchKey))
            {
                foreach (ActiveInventoryObject aio in Cache.Current.Inventory.GetByUPCorSKU(SearchKey.ToUpperInvariant()))
                {
                    ActiveInventoryObject newItem = new ActiveInventoryObject();

                    newItem.CopyProperties(aio);
                    newItem.Quantity = this.Quantity;
                    newItem.Price    = 0;
                    newItem.AcceptChanges();
                    newItem.TotalDollarChanged += newItem_TotalDollarChanged;
                    Activity.Add(newItem);
                }
                RefreshTotals();
                SetStartFocus();
            }
        }
        private void OnPost(object sender, RoutedEventArgs e)
        {
            ReceiptID = Configuration.BuildReceiptID();


            foreach (ActiveInventoryObject aio in Activity)
            {
                aio.TotalDollarChanged -= newItem_TotalDollarChanged;
            }

            foreach (ActiveInventoryObject aio in Activity)
            {
                aio.TotalDollarChanged -= newItem_TotalDollarChanged;
                List <ActiveInventoryObject> aioList = Cache.Current.Inventory.GetByUPCorSKU(aio.UPC);
                if (aioList.Count > 1)
                {
                    aioList.Clear();
                    ActiveInventoryObject newio = Cache.Current.Inventory.GetByProductID(aio.ProductID);
                    if (newio != null)
                    {
                        aioList.Add(newio);
                    }
                }
                if (aioList.Count == 1)
                {
                    aioList[0].Quantity += aio.Quantity;
                }
            }

            TransactionEngine.ReceiveInventory(Activity, ReceiptID);


            Configuration.Current.ReceiptIDNumber++;
            ReceiptID = Configuration.BuildReceiptID();
            Configuration.Current.Save();
            ResetPage();

            Activity.Clear();
            SetStartFocus();
        }
        void AddEntry()
        {
            //First, get item from Inventory.
            if (!string.IsNullOrEmpty(SearchKey))
            {
                foreach (ActiveInventoryObject aio in Cache.Current.Inventory.GetByUPCorSKU(SearchKey))
                {
                    ActiveInventoryObject newItem = new ActiveInventoryObject();

                    newItem.CopyProperties(aio);
                    newItem.Quantity = this.Quantity;
                    newItem.Price = newItem.GetPriceEach(SelectedPricingModel);
                    newItem.AcceptChanges();
                    newItem.TotalDollarChanged += newItem_TotalDollarChanged;
                    Activity.Add(newItem);
                }
                RefreshTotals();
                SetStartFocus();
            }
        }
 private void OnAdd(object sender, RoutedEventArgs e)
 {
     ActiveInventoryObject aio = new ActiveInventoryObject();
     aio.Model = "New Item";
     Inventory.Add(aio);
     FilteredInventory.Add(aio);
 }
 void Import(ActiveInventoryCollection newInventory, bool MatchFirstbyProductID, bool OverlayExistingData, bool updateQuantityOnly)
 {
     if (newInventory != null)
     {
         foreach (ActiveInventoryObject aio in newInventory)
         {
             bool matched = false;
             if (MatchFirstbyProductID && aio.ProductID > 0)
             {
                 ActiveInventoryObject oAio = Cache.Current.Inventory.GetByProductID(aio.ProductID);
                 if (oAio != null)
                 {
                     matched = true;
                     if (updateQuantityOnly)
                     {
                         oAio.Quantity = aio.Quantity;
                     }
                     else
                     {
                         oAio.CopyProperties(aio, OverlayExistingData);
                     }
                 }
             }
             if (!matched)
             {
                 if (!string.IsNullOrEmpty(aio.UPC))
                 {
                     List <ActiveInventoryObject> oAioList = Cache.Current.Inventory.GetByUPCorSKU(aio.UPC);
                     if (oAioList.Count == 1)
                     {
                         matched = true;
                         if (updateQuantityOnly)
                         {
                             oAioList[0].Quantity = aio.Quantity;
                         }
                         else
                         {
                             oAioList[0].CopyProperties(aio, OverlayExistingData);
                         }
                     }
                 }
             }
             if (!matched)
             {
                 if (!string.IsNullOrEmpty(aio.SKU))
                 {
                     List <ActiveInventoryObject> oAioList = Cache.Current.Inventory.GetByUPCorSKU(aio.SKU);
                     if (oAioList.Count == 1)
                     {
                         matched = true;
                         if (updateQuantityOnly)
                         {
                             oAioList[0].Quantity = aio.Quantity;
                         }
                         else
                         {
                             oAioList[0].CopyProperties(aio, OverlayExistingData);
                         }
                     }
                 }
             }
             if (!matched)
             {
                 Cache.Current.Inventory.Add(aio);
             }
         }
         Cache.Current.SaveInventory();
     }
 }