public IList<ProductTrackRelation> Select(ProductTrackRelation data)
        {

                IList<ProductTrackRelation> datos = new List<ProductTrackRelation>();
                datos = GetHsql(data).List<ProductTrackRelation>();
                if (!Factory.IsTransactional)
                    Factory.Commit();
                return datos;
            
        }
        public override Boolean Equals(object obj)
        {
            if ((obj == null) || (obj.GetType() != this.GetType()))
            {
                return(false);
            }
            ProductTrackRelation castObj = (ProductTrackRelation)obj;

            return((castObj != null) &&
                   (this.RowID == castObj.RowID));
        }
示例#3
0
 public void UpdateProductTrackRelation(ProductTrackRelation data) { Factory.DaoProductTrackRelation().Update(data); }
示例#4
0
 public void DeleteProductTrackRelation(ProductTrackRelation data) { Factory.DaoProductTrackRelation().Delete(data); }
示例#5
0
 public ProductTrackRelation SaveProductTrackRelation(ProductTrackRelation data) { return Factory.DaoProductTrackRelation().Save(data); }
示例#6
0
 public IList<ProductTrackRelation> GetProductTrackRelation(ProductTrackRelation data) { return Factory.DaoProductTrackRelation().Select(data); }
示例#7
0
        private IList<ProductTrackRelation> GetProductTrack(int trackOption, Product product)
        {
            if (trackOption != 2 && trackOption != 3)
                return null;

            ProductTrackRelation pTrack = null;
            IList<ProductTrackRelation> list = new List<ProductTrackRelation>();

            if (trackOption == 2) //Serial Number
            {
                pTrack = new ProductTrackRelation
                {
                    CreatedBy = WmsSetupValues.SystemUser,
                    CreationDate = DateTime.Now,
                    DisplayName = null,
                    Product = product,
                    IsRequired = true,
                    IsUnique = true,
                    TrackOption = new TrackOption { RowID = STrackOptions.SerialNumber }
                };
                list.Add(pTrack);
            }

            if (trackOption == 3) //LotCode
            {
                pTrack = new ProductTrackRelation
                {
                    CreatedBy = WmsSetupValues.SystemUser,
                    CreationDate = DateTime.Now,
                    DisplayName = null,
                    Product = product,
                    IsRequired = true,
                    IsUnique = false,
                    TrackOption = new TrackOption { RowID = STrackOptions.LotCode }
                };
                list.Add(pTrack);
            }

            return list;

        }
 public ProductTrackRelation SelectById(ProductTrackRelation data)
 {
     return (ProductTrackRelation)base.SelectById(data);
 }
 public Boolean Delete(ProductTrackRelation data)
 {
     return base.Delete(data);
 }
 public Boolean Update(ProductTrackRelation data)
 {
     return base.Update(data);
 }
 public ProductTrackRelation Save(ProductTrackRelation data)
 {
     return (ProductTrackRelation)base.Save(data);
 }
示例#12
0
        private void ProcessProducts(IList<Product> list)
        {
            if (list == null)
                return;

            Product qProd = null;
            UnitProductRelation curUnit;
            ProductTrackRelation curRecord;
            ProductAccountRelation curPvendor;


            foreach (Product e in list)
            {
                try
                {
                    qProd = new Product();
                    qProd.Company = e.Company;
                    qProd.ProductCode = e.ProductCode;

                    //Evalua si el elemento ya existe 
                    IList<Product> exList = Factory.DaoProduct().Select(qProd,0);
                    e.ModDate = DateTime.Now;
                    e.ModifiedBy = WmsSetupValues.SystemUser;

                    if (exList.Count == 0)
                    {
                        e.CreationDate = DateTime.Now;
                        e.CreatedBy = WmsSetupValues.SystemUser;
                        Factory.DaoProduct().Save(e);
                    }
                    else
                    {
                        e.ProductID = exList.First().ProductID;
                        e.CreatedBy = exList.First().CreatedBy;
                        e.CreationDate = exList.First().CreationDate;

                        //Otros datos del producto que deben preservarse
                        e.UpcCode = exList.First().UpcCode;
                        e.Reference = exList.First().Reference;
                        e.Manufacturer = exList.First().Manufacturer;
                        e.IsBinRestricted = exList.First().IsBinRestricted;
                        e.Comment = exList.First().Comment;
                        //e.AlternateCode1 = exList.First().AlternateCode1;
                        //e.AlternateCode2 = exList.First().AlternateCode2;
                        e.PrintLabel = exList.First().PrintLabel;
                        e.UnitsPerPack = exList.First().UnitsPerPack;
                        e.PickMethod = exList.First().PickMethod;
                        e.DefaultTemplate = exList.First().DefaultTemplate;
                        e.DefVendorNumber = exList.First().DefVendorNumber;

                        //Evaluar los UnitRelations
                        int i = 0;
                        foreach (UnitProductRelation line in e.ProductUnits)
                        {
                            curUnit = new UnitProductRelation();
                            curUnit.Product = line.Product;
                            curUnit.UnitErpCode = line.UnitErpCode;
                            curUnit.Unit = line.Unit;
                            IList<UnitProductRelation> listLines = Factory.DaoUnitProductRelation().Select(curUnit);

                            if (listLines.Count > 0)
                            {
                                e.ProductUnits[i].RowID = listLines.First().RowID;
                                e.ProductUnits[i].CreationDate = listLines.First().CreationDate;
                                e.ProductUnits[i].CreatedBy = listLines.First().CreatedBy;
                                e.ProductUnits[i].ModDate = DateTime.Now;
                                e.ProductUnits[i].ModifiedBy = WmsSetupValues.SystemUser;
                            }
                            else
                            {
                                e.ProductUnits[i].CreationDate = DateTime.Now;
                                e.ProductUnits[i].CreatedBy = WmsSetupValues.SystemUser;
                            }

                            i++;
                        }


                        //Evaluar los ProductTrackOptions
                        if (e.ProductTrack != null)
                        {
                            int y = 0;
                            foreach (ProductTrackRelation line in e.ProductTrack)
                            {
                                curRecord = new ProductTrackRelation();
                                curRecord.Product = line.Product;
                                curRecord.TrackOption = line.TrackOption;
                                IList<ProductTrackRelation> trackLines = Factory.DaoProductTrackRelation().Select(curRecord);

                                if (trackLines.Count > 0)
                                {
                                    e.ProductTrack[y].RowID = trackLines.First().RowID;
                                    e.ProductTrack[y].CreationDate = trackLines.First().CreationDate;
                                    e.ProductTrack[y].CreatedBy = trackLines.First().CreatedBy;
                                    e.ProductTrack[y].ModDate = DateTime.Now;
                                    e.ProductTrack[y].ModifiedBy = WmsSetupValues.SystemUser;
                                }
                                else
                                {
                                    e.ProductTrack[y].CreationDate = DateTime.Now;
                                    e.ProductTrack[y].CreatedBy = WmsSetupValues.SystemUser;
                                }

                                y++;
                            }
                        }


                        //Evaluar los ProductVendor

                        try
                        {
                            IList<ProductAccountRelation> pAlt = Factory.DaoProductAccountRelation()
                                .Select(new ProductAccountRelation { IsFromErp = true, Product = new Product { ProductID = e.ProductID } }); ;

                            if (pAlt != null && pAlt.Count > 0)
                                foreach (ProductAccountRelation pax in pAlt)
                                    Factory.DaoProductAccountRelation().Delete(pax);
                        }
                        catch { }


                        if (e.ProductAccounts != null)
                        {
                            int y = 0;
                            foreach (ProductAccountRelation line in e.ProductAccounts)
                            {
                                curPvendor = new ProductAccountRelation();
                                curPvendor.Product = line.Product;
                                curPvendor.Account = line.Account;
                                curPvendor.ItemNumber = line.ItemNumber;
                                IList<ProductAccountRelation> pVendLines = Factory.DaoProductAccountRelation().Select(curPvendor);

                                if (pVendLines.Count > 0)
                                {
                                    e.ProductAccounts[y].RowID = pVendLines.First().RowID;
                                    e.ProductAccounts[y].CreationDate = pVendLines.First().CreationDate;
                                    e.ProductAccounts[y].CreatedBy = pVendLines.First().CreatedBy;
                                    e.ProductAccounts[y].ModDate = DateTime.Now;
                                    e.ProductAccounts[y].ModifiedBy = WmsSetupValues.SystemUser;
                                }
                                else
                                {
                                    e.ProductAccounts[y].CreationDate = DateTime.Now;
                                    e.ProductAccounts[y].CreatedBy = WmsSetupValues.SystemUser;
                                }

                                y++;
                            }
                        }


                        //Evaluar los ProductAlternate

                        //ProductAlternate curAlt;
                        /*
                        try
                        {
                            IList<ProductAlternate> pAlt = Factory.DaoProductAlternate()
                                .Select(new ProductAlternate { IsFromErp = true, Product = new Product { ProductID = e.ProductID } }); 

                            if (pAlt != null && pAlt.Count > 0)
                                foreach (ProductAlternate pax in pAlt)
                                    try { Factory.DaoProductAlternate().Delete(pax); }
                                    catch (Exception ex) { Console.WriteLine("PA:" + ex.Message); }
                        }
                        catch { }
                        */


                        if (e.AlternProducts != null)
                        {
                            int y = 0;
                            foreach (ProductAlternate line in e.AlternProducts)
                            {
                                e.AlternProducts[y].CreationDate = DateTime.Now;
                                e.AlternProducts[y].CreatedBy = WmsSetupValues.SystemUser;
                                y++;

                                try
                                {
                                    ProductAlternate exist = Factory.DaoProductAlternate()
                                    .Select(new ProductAlternate { 
                                        AlternProduct = new Product { ProductID = line.AlternProduct.ProductID },
                                        Product = new Product { ProductID = e.ProductID } }).First();

                                    Factory.DaoProductAlternate().Delete(exist);
                                }
                                catch { }

                                //curAlt = new ProductAlternate();
                                //curAlt.Product = line.Product;
                                //curAlt.AlternProduct = line.AlternProduct;
                            }
                        }

                        Factory.DaoProduct().Update(e);
                    }


                }
                catch (Exception ex)
                {
                    //Factory.Rollback();
                    ExceptionMngr.WriteEvent("ProcessProducts:" + qProd.ProductCode, ListValues.EventType.Fatal, ex, null, ListValues.ErrorCategory.Business);
                    ////throw;
                }
            }

        }