Example #1
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            selected = cbProducts.SelectedItem as StockItem;

            this.Close();
            this.Dispose();
        }
Example #2
0
        private void btnCancel_Click(object sender, EventArgs e)
        {
            selected = null;

            this.Close();
            this.Dispose();
        }
Example #3
0
        public InvoiceItem(WaitingProductEntity waitingEnt)
        {
            this.PairCode = waitingEnt.Sku;
            this.invSKU = waitingEnt.InvSku;
            this.MSG_SKU = waitingEnt.Description;
            this.BuyingPrice = waitingEnt.BuyingPrice;
            this.Datetime = Convert.ToDateTime(waitingEnt.Date);
            this.ItemName = waitingEnt.DescriptionWeb;
            this.PredajnaCena = waitingEnt.SellPrice;
            this.ItemOptions = waitingEnt.Size;
            this.ItemOrigPrice = waitingEnt.ItemOrigPrice;
            this.ItemPrice = waitingEnt.ItemPrice;
            this.ItemTax = waitingEnt.ItemTax;
            this.ItemDiscount = waitingEnt.ItemDiscount;
            this.Zlava_Pohoda = waitingEnt.DiscountPohoda;
            this.ItemTotal = waitingEnt.ItemTotal;
            this.ItemStatus = waitingEnt.ItemStatus;
            this.ItemQtyOrdered = waitingEnt.OrdCount;
            this.itemStorage = waitingEnt.Storage;

            //if (!string.IsNullOrEmpty(waitingEnt.Sku))
            {
                StockItem newitem = new StockItem();
                newitem.State = StockItemState.Paired;
                newitem.ProductCode = waitingEnt.Sku;
                newitem.Description = waitingEnt.Description;
                newitem.IsFromDB = true;

                this.PairProduct = newitem;
            }

            // zapametame si entitu, z ktorej bola polozka vytvorena
            CreatedFromWaiting = waitingEnt;
        }
Example #4
0
        public object Clone()
        {
            StockItem newObj = new StockItem();

            newObj.id = id;
            newObj.ChangeColor = ChangeColor;
            newObj.Currency = Currency;
            newObj.Description = Description;
            newObj.Disp_Qty = Disp_Qty;
            //newObj.EquippedInv = EquippedInv;
            newObj.FictivePrice = FictivePrice;
            newObj.FromFile = FromFile;
            //newObj.Icon = Icon;
            newObj.IsFromDB = IsFromDB;
            newObj.ItemNameInv = ItemNameInv;
            newObj.Ord_Qty = Ord_Qty;
            newObj.OrderDate = OrderDate;
            if (PairProduct != null)
                newObj.PairProduct = PairProduct;
            newObj.PreviousState = PreviousState;
            newObj.Price = Price;
            newObj.PriceEURnoTax = PriceEURnoTax;
            newObj.PriceEURnoTaxEUR = PriceEURnoTaxEUR;
            newObj.PriceWithDelivery = PriceWithDelivery;
            newObj.PriceWithDeliveryEUR = PriceWithDeliveryEUR;
            newObj.ProductCode = ProductCode;
            newObj.SellPriceEUR = SellPriceEUR;
            newObj.SellPriceInv = SellPriceInv;
            newObj.SizeInv = SizeInv;
            newObj.Sklad = Sklad;
            newObj.State = State;
            newObj.Total = Total;
            newObj.TotalEUR = TotalEUR;
            newObj.PairByHand = PairByHand;
            newObj.FromFile = FromFile;
            newObj.Size = Size;

            return newObj;
        }
Example #5
0
        internal StockEntity decodeMessage2(string messageBody, FileItem file)
        {
            var lines = messageBody.Split(Environment.NewLine.ToCharArray()).Where(s => s != null && s.Trim().Length > 0).ToList();

            var order = new StockEntity();
            List<StockItem> items = new List<StockItem>();

            file.ProdCount = 0;
            var found = lines.FirstOrDefault(l => l.Contains(orderRef.ToLower()));
            if (found != null)
                order.OrderReference = order.OurReference = found.Substring(found.Trim().LastIndexOf(' ')).Trim();

            var start = lines.FirstOrDefault(l => l.Contains("Processed Qty"));
            if (start == null)
                return null;
            var istart = lines.FindIndex(s => s == start);
            for (int i = istart + 1; i < lines.Count; i += 5)
            {
                if (lines[i].Trim().StartsWith("Total") || lines[i].Trim().StartsWith("Grand Total"))
                    break;

                StockItem item = new StockItem();

                item.Ord_Qty = int.Parse(lines[i].Trim());
                item.Disp_Qty = item.Ord_Qty;
                item.Description = lines[i + 1].Trim();// +" " + lines[i + 2].Trim();
                item.Price = Common.GetPrice(lines[i + 3].Trim());
                item.Total = Common.GetPrice(lines[i + 4].Trim());
                item.Currency = "€";
                item.FromFile = file;
                item.ProductCode = lines[i + 2].Substring(lines[i + 2].Trim().LastIndexOf(' '));

                file.ProdCount++;

                if (item.State == StockItemState.PermanentStorage)
                    item.Sklad = "02";
                else if (item.State == StockItemState.Waiting)
                    item.Sklad = Properties.Settings.Default.Storage;

                items.Add(item);
            }

            DecomposeMultipleItems(items);
            order.Items = items.ToArray();

            return order;
        }
Example #6
0
        /// <summary>
        /// Deprecated..
        /// </summary>
        /// <param name="messageBody"></param>
        /// <param name="file"></param>
        /// <returns></returns>
        private StockEntity decodeMandMMessageOld(string messageBody, FileItem file)
        {
            try
            {
                var order = new StockEntity();
                List<StockItem> items = new List<StockItem>();

                var lines = messageBody.Split(Environment.NewLine.ToCharArray()).Where(s => s != null && s.Trim().Length > 0).ToArray();

                // cislo objednavky
                var orderNum = lines.Where(s => s.Contains("order confirmation number")).FirstOrDefault();
                if (!string.IsNullOrEmpty(orderNum))
                {
                    var from = orderNum.IndexOf(':') + 1;

                    order.OrderReference = orderNum.Substring(from).Trim();
                    order.OurReference = order.OrderReference;
                }

                var relevant = lines.Where(s => s.ToCharArray().Count(c => c == '\t') == 5).ToList();
                file.ProdCount = 0;
                for (int i = 0; i < relevant.Count; i++)
                {
                    string line = relevant[i];
                    if (line.ToLower().StartsWith("item"))
                        continue;

                    var cols = line.Split('\t');

                    StockItem item = new StockItem();
                    item.Description = cols[0];
                    item.ProductCode = item.Description.Split(' ')[0].Trim();
                    item.Size = cols[1].Trim();
                    item.Ord_Qty = int.Parse(cols[2].Trim());
                    item.Disp_Qty = item.Ord_Qty;
                    item.Price = Common.GetPrice(cols[3]);
                    item.Total = Common.GetPrice(cols[4]);
                    item.Currency = cols[3].Substring(0, 1);
                    item.FromFile = file;

                    file.ProdCount++;

                    if (item.State == StockItemState.PermanentStorage)
                        item.Sklad = "02";
                    else if (item.State == StockItemState.Waiting)
                        item.Sklad = Properties.Settings.Default.Storage;

                    items.Add(item);
                }

                DecomposeMultipleItems(items);

                order.Items = items.ToArray();

                return order;
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(this, ex.ToString(), "Error");
            }

            return null;
        }
Example #7
0
        internal StockEntity decodeMessage(string messageBody, FileItem file)
        {
            var lines = messageBody.Split(Environment.NewLine.ToCharArray()).Where(s => s != null && s.Trim().Length > 0).ToArray();
            var positionQTY = 5;
            if (lines.Contains("\tConfirmation Note\t "))
                positionQTY = 4;

            var order = new StockEntity();
            List<StockItem> items = new List<StockItem>();

            file.ProdCount = 0;
            for (int i = 0; i < lines.Length; i++)
            {
                string line = lines[i];

                if (line.Contains(productCode))
                {
                    StockItem item = new StockItem();

                    item.ProductCode = line.Substring(line.IndexOf(':') + 1).Trim();
                    line = lines[i - positionQTY];//i - 5
                    item.Ord_Qty = int.Parse(line.Trim());
                    line = lines[i - 4];
                    item.Disp_Qty = int.Parse(line.Trim());
                    line = lines[i - 3];
                    item.Description = line.Trim();
                    line = lines[i - 2];
                    item.Price = Common.GetPrice(line);
                    line = lines[i - 1];
                    item.Total = Common.GetPrice(line);
                    item.Currency = line.Substring(0, 1);

                    item.FromFile = file;
                    file.ProdCount++;

                    if (item.State == StockItemState.PermanentStorage)
                        item.Sklad = "02";
                    else if (item.State == StockItemState.Waiting)
                        item.Sklad = Properties.Settings.Default.Storage;

                    items.Add(item);
                }

                if (line.Trim() == delivery || line.Trim() == deliveryText)
                {
                    StockItem item = new StockItem();

                    line = lines[i + 1];
                    line = line.Replace(".", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator);
                    item.Price = Common.GetPrice(line);
                    item.Total = item.Price;
                    item.Currency = line.Substring(0, 1);

                    item.Description = deliveryText;
                    item.Disp_Qty = 1;
                    item.Ord_Qty = 1;
                    item.ProductCode = item.Description;

                    item.FromFile = file;

                    file.Delivery += item.Price;
                    //file.ProdCount++;
                    //items.Add(item);  // doprava nebude polozka ale spojena so suborom
                }

                if (line.Contains(orderRef))
                {
                    line = lines[i + 1];
                    order.OrderReference = line.Trim();
                }

                if (line.Contains(ourRef))
                {
                    line = lines[i + 1];
                    order.OurReference = line.Trim();
                }
            }

            DecomposeMultipleItems(items);

            order.Items = items.ToArray();

            return order;
        }
Example #8
0
        private StockEntity decodeGTLMessage(string messageBody, FileItem file)
        {
            try
            {
                var order = new StockEntity();
                List<StockItem> items = new List<StockItem>();

                var lines = messageBody.Split(Environment.NewLine.ToCharArray()).Where(s => s != null && s.Trim().Length > 0).ToArray();

                // cislo objednavky
                var orderNum = lines.Where(s => s.ToUpper().Contains("ORDER NUMBER:")).FirstOrDefault();
                if (!string.IsNullOrEmpty(orderNum))
                {
                    var from = orderNum.IndexOf(':') + 1;

                    order.OrderReference = orderNum.Substring(from).Trim();
                    order.OurReference = order.OrderReference;
                }

                var relevant = lines.Where(s => s.ToCharArray().Count(c => c == '\t') == 5).ToList();
                file.ProdCount = 0;
                for (int i = 0; i < relevant.Count; i++)
                {
                    string line = relevant[i];
                    if (line.ToLower().StartsWith("item"))
                        continue;

                    var cols = line.Split('\t');

                    StockItem item = new StockItem();
                    item.Description = cols[0];

                    item.Description = item.Description.Remove(0, item.Description.IndexOf(" ") + 1);
                    item.ProductCode = item.Description;
                    //item.ProductCode = item.ProductCode.Remove(0,item.ProductCode.IndexOf(" ")+1);//odstranime prve slovo Mens,Womens.. aby sa dalo porovnať s náazvom v csv
                    item.Ord_Qty = int.Parse(cols[1].Trim());
                    item.Disp_Qty = item.Ord_Qty;
                    item.Price = Common.GetPrice(cols[4]);
                    item.Total = Common.GetPrice(cols[4]) / item.Ord_Qty;   // suma deleno pocet = jednotkova cena
                    item.Currency = "EUR";
                    item.FromFile = file;
                    item.Size = cols[2].Trim();

                    file.ProdCount++;

                    if (item.State == StockItemState.PermanentStorage)
                        item.Sklad = "02";
                    else if (item.State == StockItemState.Waiting)
                        item.Sklad = Properties.Settings.Default.Storage;

                    items.Add(item);
                }

                DecomposeMultipleItems(items);

                order.Items = items.ToArray();

                return order;
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(this, ex.ToString(), "Error");
            }

            return null;
        }
Example #9
0
        private StockEntity decodeMandMMessage(string messageBody, FileItem file)
        {
            try
            {
                var order = new StockEntity();
                List<StockItem> items = new List<StockItem>();

                var lines = messageBody.Split(Environment.NewLine.ToCharArray()).Where(s => s != null && s.Trim().Length > 0).ToList();

                // cislo objednavky
                var orderNum = lines.Where(s => s.Contains("order confirmation number")).FirstOrDefault();
                if (!string.IsNullOrEmpty(orderNum))
                {
                    var from = orderNum.IndexOf(':') + 1;

                    order.OrderReference = orderNum.Substring(from).Trim();
                    order.OurReference = order.OrderReference;
                }

                var start = lines.IndexOf("Items for delivery: ");
                var stop = false;
                var i = start + 1;
                file.ProdCount = 0;
                file.Currency = "GBP";
                var delivery = (lines.FirstOrDefault(l => l.Trim().StartsWith("Standard Delivery")) ?? "£0.00").Trim();
                file.Delivery = Common.GetPrice(delivery.Substring(delivery.LastIndexOf('£') + 1));
                if (double.IsNaN(file.Delivery))
                    file.Delivery = 0;

                while (!stop || i >= lines.Count)
                {
                    var hypl_qty = lines[i++];
                    if (hypl_qty.ToLower().Trim().StartsWith("total items"))
                        break;

                    var props = lines[i++];

                    StockItem item = new StockItem();
                    var si = hypl_qty.LastIndexOf('"') + 1;
                    var ei = hypl_qty.LastIndexOf("Qty.");
                    item.Description = hypl_qty.Substring(si, ei - si).Trim();
                    var di = hypl_qty.IndexOf("details/") + 8;
                    var edi = hypl_qty.IndexOf('/', di);
                    item.ProductCode = hypl_qty.Substring(di, edi - di);
                    item.Ord_Qty = Convert.ToInt32(hypl_qty.Substring(ei + 5).Trim());
                    item.Disp_Qty = item.Ord_Qty;
                    var prop = props.Split('\t');
                    item.Size = prop[0].Substring(6);
                    item.Total = Convert.ToDouble(Common.CleanPrice(prop[2].Trim('£')));
                    item.Price = item.Total / item.Ord_Qty;

                    item.Currency = "GBP";
                    item.FromFile = file;

                    while (lines[i].Trim().StartsWith("_") && lines[i].Trim().EndsWith("_"))
                        i++; //= 2; // 2 riadky ______

                    file.ProdCount++;

                    if (item.State == StockItemState.PermanentStorage)
                        item.Sklad = "02";
                    else if (item.State == StockItemState.Waiting)
                        item.Sklad = Properties.Settings.Default.Storage;

                    items.Add(item);
                }

                DecomposeMultipleItems(items);

                order.Items = items.ToArray();

                return order;
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(this, ex.ToString(), "Error");
            }

            return null;
        }
Example #10
0
        private StockEntity decode5PoundsMessage(string messageBody, FileItem file)
        {
            try
            {
                var order = new StockEntity();
                List<StockItem> items = new List<StockItem>();

                var lines = messageBody.Split(Environment.NewLine.ToCharArray()).Where(s => s != null && s.Trim().Length > 0).ToArray();

                // cislo objednavky
                var orderNum = lines.Where(s => s.ToUpper().Contains("ORDER NUMBER:")).FirstOrDefault();
                if (!string.IsNullOrEmpty(orderNum))
                {
                    var from = orderNum.IndexOf(':') + 1;

                    order.OrderReference = orderNum.Substring(from).Trim();
                    order.OurReference = order.OrderReference;
                }

                // order date
                var orderDate = lines.Where(s => s.ToUpper().Contains("DATE ORDERED:")).FirstOrDefault();

                var start = lines.Where(s => s.Contains("Item") && s.Contains("Qty") && s.Contains("Price") && s.Contains("Total")).FirstOrDefault();
                var end = lines.Where(s => s.Trim() == "Billing Address").FirstOrDefault();
                if (string.IsNullOrEmpty(start) || string.IsNullOrEmpty(end))
                    return order;
                var istart = lines.ToList().FindIndex(s => s == start);
                var iend= lines.ToList().FindIndex(s => s == end);

                file.ProdCount = 0;
                var offset = 5;
                for (int i = istart + 1; i < iend; i += offset)
                {
                    if (i + 4 > iend)
                        break;

                    string[] tmp;
                    StockItem item = new StockItem();
                    offset = 0;

                    // description
                    tmp = lines[i + offset].Split(new string[] { "\\n" }, StringSplitOptions.None);
                    item.Description = tmp[1].Split('\t')[0];
                    item.ProductCode = item.Description;
                    offset++;

                    for (int j = 0; j < 3; j++)
                    {
                        if (lines[i + offset].Contains("Size:"))
                        {
                            // size
                            tmp = lines[i + offset].Split(':');
                            item.Size = tmp[1].Trim();
                            offset++;
                        }
                        else if (lines[i + offset].Contains("Style Number:"))
                        {
                            // product code
                            /*tmp = lines[i + offset].Split(':');
                            item.ProductCode = tmp[1].Trim();*/
                            offset++;
                        }
                        else if (lines[i + offset].Contains("Colour(s):"))
                        {
                            // color
                            tmp = lines[i + offset].Split(':');
                            item.Color = tmp[1].Trim();
                            offset++;
                        }
                    }

                    // qauntity
                    tmp = lines[i + offset].Split(new string[] { "\\n" }, StringSplitOptions.None);
                    item.Ord_Qty = 1;
                    try
                    {
                        item.Ord_Qty = Convert.ToInt32(tmp[3].Split('\t')[1].Trim());
                    } catch (System.Exception) { }
                    item.Disp_Qty = item.Ord_Qty;
                    offset++;

                    item.Total = 5;
                    item.Price = item.Total * item.Ord_Qty;
                    item.Currency = "GBP";
                    //item.OrderDate = orderDate;
                    item.FromFile = file;

                    if (item.State == StockItemState.PermanentStorage)
                        item.Sklad = "02";
                    else if (item.State == StockItemState.Waiting)
                        item.Sklad = Properties.Settings.Default.Storage;
                    items.Add(item);

                    file.ProdCount++;
                }

                DecomposeMultipleItems(items);
                order.Items = items.ToArray();

                return order;
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(this, ex.ToString(), "Error");
            }

            return null;
        }
Example #11
0
 void CompleteOrderItem(InvoiceItem toComplete, StockItem product)
 {
     if (toComplete == null || product == null)
         return;
     // vzajomne prepojenie
     toComplete.PairProduct = product;
     //product.PairProduct = toComplete; // odstranene 3.11.2012 - produkt bude sparovany automaticky v setteri invoiceitemu (predch. riadok)
 }
Example #12
0
        /// <summary>
        /// Fake produkt cena za dopravu
        /// </summary>
        /// <param name="allInvoices"></param>
        private void AddShippingItems(List<Invoice> allInvoices)
        {
            foreach (var inv in allInvoices)
            {
                InvoiceItem shipping = new InvoiceItem(inv);
                StockItem shippingStock = new StockItem();

                shipping.PairProduct = shippingStock;   // previazanie poloziek

                var config = new CountrySetting(inv.Country);
                var price = inv.OrderShipping;

                if (Common.GetPrice(price) == 0.0)
                    shipping.ItemPrice = price;
                else
                    shipping.ItemPrice = config.ShipPrice.ToString();

                inv.OrderShipping = shipping.ItemPrice;

                shippingStock.Description = config.ShipText;
                shippingStock.ProductCode = Properties.Settings.Default.ShippingCode;

                shipping.ItemQtyOrdered = "1";
                shippingStock.OrderDate = DateTime.Now;

                inv.InvoiceItems.Add(shipping);
            }
        }
Example #13
0
 internal void Unpair(StockItem orderItem)
 {
     var allInvoices = GetInvoiceDS();
     var paired = allInvoices.Where(i => i.InvoiceItems != null).SelectMany(i => i.InvoiceItems).Where(ii => ii.PairProduct != null && ii.PairProduct.ProductCode == orderItem.ProductCode).ToList();
     foreach (var order in paired)
     {
         order.PairProduct = null;
     }
 }
Example #14
0
        internal StockEntity ProcessCSVX(FileItem file)
        {
            if (file == null)
                return null;

            StockEntity ret = new StockEntity();
            try
            {
                string fileContent = File.ReadAllText(file.FullFileName);

                var lines = fileContent.Split(Environment.NewLine.ToCharArray());
                var orderItems = new List<StockItem>();
                foreach (var line in lines)
                {
                    if (line == null || line.Trim().Length == 0)
                        continue;

                    var split = line.Split(';');

                    StockItem newItem = new StockItem();
                    newItem.ProductCode = split[0];
                    newItem.Description = split[1];
                    newItem.Ord_Qty = int.Parse(split[2]);
                    newItem.Disp_Qty = int.Parse(split[3]);
                    newItem.Price = double.Parse(split[4]);
                    newItem.Total = double.Parse(split[5]);
                    newItem.Currency = split[6];
                    newItem.FromFile = file;

                    orderItems.Add(newItem);
                }
                ret.Items = orderItems.ToArray();
            }
            catch (System.Exception ex)
            {
                log(ex.Message);
                return null;
            }

            return ret;
        }