Esempio n. 1
0
        public void UpdateStatus(WareHouseJPDB db)
        {
            //ExportGood
            var lstEX = db.ExportGoods;

            foreach (var item in lstEX)
            {
                if (db.ExportInvoices.Where(n => n.ExportId == item.Id).Count() > 0)
                {
                    item.StatusId = 5;
                }
            }
            //update StorageJP Status
            var lstSJP = db.StorageJPs;

            foreach (var item in lstSJP)
            {
                //check ListIn
                int statusId = 2;
                if (db.TrackingDetails.ToList().Where(n => n.TrackingSubCode.Substring(0, n.TrackingSubCode.LastIndexOf(" -")).Contains(item.TrackingCode)).Count() > 0)
                {
                    statusId = 3;
                }
                if (db.ExportGoodDetails.Where(n => n.TrackingCode.Contains(item.TrackingCode)).Count() > 0)
                {
                    statusId = 4;
                }
                if (db.ExportGoodDetails.Where(n => n.TrackingCode.Contains(item.TrackingCode) && db.ExportInvoices.Where(m => m.ExportGood.Id == n.ExportGoodId).Count() > 0).Count() > 0)
                {
                    statusId = 5;
                }
                item.StatusId = statusId;
            }
            //update AgencyPackage
            var lstAP = db.AgencyPackages;

            foreach (var item in lstAP)
            {
                if (lstSJP.Where(n => n.TrackingCode.Contains(item.TrackingCode)).Count() > 0)
                {
                    item.TrackingStatusId = lstSJP.Where(n => n.TrackingCode.Contains(item.TrackingCode.Trim())).First().StatusId;
                }
            }
            db.SaveChanges();
            db.Dispose();
        }
Esempio n. 2
0
        public void SearchAndSave(SearchProductInfo item, string ItemCode, int SearchQuantity = 1, Guid?StoregeJPId = null)
        {
            StorageItemJP model = new StorageItemJP()
            {
                Amount       = item.PriceTax * SearchQuantity,
                CategoryId   = item.CategoryId,
                CategoryName = item.CategoryName,
                CreatedAt    = DateTime.Now,
                CreatedBy    = user.Staff.UserName,
                Id           = Guid.NewGuid(),
                Image        = item.Image,
                JanCode      = item.JanCode,
                LinkWeb      = item.LinkWeb,
                MadeIn       = "JAPAN",
                Material     = item.Material,
                NameEN       = item.NameEN,
                NameJP       = item.NameJP,
                Notes        = item.Notes,
                PriceTax     = item.PriceTax,
                ProductCode  = item.ProductCode,
                Quantity     = SearchQuantity,
                StatusId     = 1,
                StoregeJPId  = StoregeJPId,
                UpdatedAt    = DateTime.Now,
                UpdatedBy    = user.Staff.UserName
            };

            if (db.StorageItemJPs.Where(n => n.ProductCode == model.ProductCode && n.StoregeJPId == StoregeJPId).Count() == 0)
            {
                db.StorageItemJPs.Add(model);
            }

            WareHouseItem items = new WareHouseItem()
            {
                Amount       = item.PriceTax * SearchQuantity,
                CategoryId   = item.CategoryId,
                CategoryName = item.CategoryName,
                CreatedAt    = DateTime.Now,
                CreatedBy    = user.Staff.UserName,
                Id           = Guid.NewGuid(),
                Image        = item.Image,
                JanCode      = item.JanCode,
                LinkWeb      = item.LinkWeb,
                MadeIn       = "JAPAN",
                Material     = item.Material,
                NameEN       = item.NameEN,
                NameJP       = item.NameJP,
                Notes        = item.Notes,
                PriceTax     = item.PriceTax,
                ProductCode  = item.ProductCode,
                Quantity     = SearchQuantity,
                UpdatedAt    = DateTime.Now,
                UpdatedBy    = user.Staff.UserName
            };

            if (db.WareHouseItems.Where(n => n.ProductCode == model.ProductCode).Count() == 0)
            {
                db.WareHouseItems.Add(items);
            }
            db.SaveChanges();
        }
Esempio n. 3
0
        static void Main1(string[] args)
        {
            string[] fileArray = Directory.GetFiles(@"C:\FILES\");
            foreach (var itemFile in fileArray)
            {
                try
                {
                    // Opening the Excel template...
                    FileStream fs = new FileStream(itemFile, FileMode.Open, FileAccess.Read);
                    // Getting the complete workbook...
                    ISheet sheet     = null;
                    string flighCode = "";
                    if (itemFile.Contains(".xlsx"))
                    {
                        XSSFWorkbook templateWorkbook = new XSSFWorkbook(itemFile);
                        sheet     = templateWorkbook.GetSheet("INVOICE");
                        flighCode = templateWorkbook.GetSheet("INFO").GetRow(4).Cells[8].StringCellValue.Trim();
                    }
                    else if (itemFile.Contains(".xls"))
                    {
                        HSSFWorkbook templateWorkbook = new HSSFWorkbook(fs, true);
                        sheet     = templateWorkbook.GetSheet("INVOICE");
                        flighCode = templateWorkbook.GetSheet("INFO").GetRow(4).Cells[8].StringCellValue.Trim();
                    }
                    WebsiteHelpers     websiteHelper = new WebsiteHelpers();
                    string             namejp        = "";
                    List <ProductItem> lst           = new List <ProductItem>();
                    for (int row = 11; row <= sheet.LastRowNum; row++)
                    { // Ignoring first row as headers.
                        namejp = sheet.GetRow(row).GetCell(1).StringCellValue;
                        if (namejp != "" && namejp != null && namejp.Trim().Length > 0)
                        {
                            ProductItem p = new ProductItem();
                            p.NameJP       = namejp;
                            p.NameEN       = sheet.GetRow(row).GetCell(2).StringCellValue;
                            p.CategoryName = sheet.GetRow(row).GetCell(3).StringCellValue;
                            p.Link         = sheet.GetRow(row).GetCell(4).StringCellValue;
                            p.Price        = sheet.GetRow(row).GetCell(5).NumericCellValue;
                            try
                            {
                                string ImageUrl = websiteHelper.GetImage(p.Link);
                                p.ImageUrl    = ImageUrl;
                                p.ImageBase64 = ImageUtils.Images(ImageUrl);
                            }
                            catch { }
                            p.ShippingMark = sheet.GetRow(row).GetCell(6).StringCellValue;
                            try
                            {
                                p.JanCode = sheet.GetRow(row).GetCell(7).NumericCellValue + "";
                            }
                            catch
                            {
                                p.JanCode = sheet.GetRow(row).GetCell(7) == null ? "" : sheet.GetRow(row).GetCell(7).StringCellValue;
                            }
                            p.Quantity = (int)sheet.GetRow(row).GetCell(8).NumericCellValue;
                            p.MadeIn   = sheet.GetRow(row).GetCell(9).StringCellValue;
                            try
                            {
                                p.Note1 = sheet.GetRow(row).GetCell(10).NumericCellValue + "";
                            }
                            catch
                            {
                                p.Note1 = sheet.GetRow(row).GetCell(10).StringCellValue;
                            }
                            try
                            {
                                p.Note2 = sheet.GetRow(row).GetCell(11).NumericCellValue + "";
                            }
                            catch
                            {
                                p.Note2 = sheet.GetRow(row).GetCell(11).StringCellValue;
                            }
                            p.Amount = sheet.GetRow(row).GetCell(12).NumericCellValue;
                            lst.Add(p);
                        }
                    }
                    foreach (var item in lst)
                    {
                        WareHouseItem warehouse = new WareHouseItem()
                        {
                            Amount         = item.Amount,
                            CategoryId     = getCategory(item.CategoryName).Id,
                            CategoryName   = item.CategoryName,
                            CreatedAt      = DateTime.Now,
                            CreatedBy      = "blf",
                            Id             = Guid.NewGuid(),
                            Image          = item.ImageUrl,
                            JanCode        = item.JanCode,
                            LinkWeb        = item.Link,
                            ImageBase64    = item.ImageBase64,
                            Component      = "",
                            ComponentImage = "",
                            MadeIn         = getMadeIn(item.MadeIn).Id + "",
                            Material       = item.Note1,
                            NameEN         = item.NameEN,
                            NameJP         = item.NameJP,
                            Notes          = item.Note1,
                            PriceTax       = item.Price,
                            ProductCode    = item.JanCode,
                            Quantity       = item.Quantity,
                            UpdatedAt      = DateTime.Now,
                            UpdatedBy      = "blf",
                            ProductTypeId  = 1,
                            IsDeny         = false,
                            FlightCode     = flighCode
                        };
                        db.WareHouseItems.Add(warehouse);
                    }

                    db.SaveChanges();
                }
                catch { }
            }
            Console.WriteLine("finished");
            Console.ReadLine();
        }