public IList<ProductAccountRelation> Select(ProductAccountRelation data)
        {

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

            return((castObj != null) &&
                   (this.RowID == castObj.RowID));
        }
Ejemplo n.º 3
0
        public void UpdateIsMainProductAccount(ProductAccountRelation data)
        {

            ProductAccountRelation pa = Factory.DaoProductAccountRelation().Select(data).First();
            pa.IsDefault = data.IsDefault;

            if (data.IsDefault == true)
            {
                IList<ProductAccountRelation> list = Factory.DaoProductAccountRelation().Select(
                    new ProductAccountRelation { Product = pa.Product });

                foreach (ProductAccountRelation r in list.Where(f => f.RowID != pa.RowID))
                {
                    r.IsDefault = false;
                    Factory.DaoProductAccountRelation().Update(r);
                }

                //Actulizando el Default del Producto
                Product p = Factory.DaoProduct().Select(new Product {ProductID = pa.Product.ProductID } ,0).First();
                p.UpcCode = pa.Code1;
                p.DefVendorNumber = pa.ItemNumber;
                Factory.DaoProduct().Update(p);

            }
                        
            Factory.DaoProductAccountRelation().Update(pa);


        }
Ejemplo n.º 4
0
 public void UpdateIsMainProductAccount(ProductAccountRelation data) { BasicMngr.UpdateIsMainProductAccount(data); }
Ejemplo n.º 5
0
 public void UpdateProductAccountRelation(ProductAccountRelation data) { Factory.DaoProductAccountRelation().Update(data); }
Ejemplo n.º 6
0
 public void DeleteProductAccountRelation(ProductAccountRelation data) { Factory.DaoProductAccountRelation().Delete(data); }
Ejemplo n.º 7
0
 public ProductAccountRelation SaveProductAccountRelation(ProductAccountRelation data) { return Factory.DaoProductAccountRelation().Save(data); }
Ejemplo n.º 8
0
 public IList<ProductAccountRelation> GetProductAccountRelation(ProductAccountRelation data) { return Factory.DaoProductAccountRelation().Select(data); }
Ejemplo n.º 9
0
        private IList<ProductAccountRelation> GetProductVendors(Product product)
        {
            IList<ProductAccountRelation> productVendor = new List<ProductAccountRelation>();
            ProductAccountRelation curId = null;
            AccountType accType = WType.GetAccountType(new AccountType { AccountTypeID = AccntType.Vendor });

            string curItemVendor = "";

            try
            {
                Command.Connection = new SqlConnection(CurCompany.ErpConnection.CnnString);

                Query = "SELECT VEND_CODE,VENDOR_PART_NO " +
                  " FROM ITEM_REPLENISH_VENDOR WHERE ITEM_CODE = '" + product.ProductCode+"' ";

                ds = ReturnDataSet(Query, null, "ITEM_REPLENISH_VENDOR", Command.Connection);

                if (ds == null || ds.Tables.Count == 0)
                    return null;

                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    curId = new ProductAccountRelation();

                    curId.ItemNumber = dr["VENDOR_PART_NO"].ToString();

                    //Si esta vacio se sale al proximo
                    if (string.IsNullOrEmpty(curId.ItemNumber))
                        continue;

                    curItemVendor = dr["VEND_CODE"].ToString() + ":" + curId.ItemNumber;

                    curId.IsFromErp = true;
                    curId.AccountType = accType;
                    curId.Account = WType.GetAccount(new Account { AccountCode = dr["VEND_CODE"].ToString(), BaseType = new AccountType { AccountTypeID = AccntType.Vendor } });
                    curId.Product = product;
                    curId.CreatedBy = WmsSetupValues.SystemUser;
                    curId.CreationDate = DateTime.Now;

                    productVendor.Add(curId);
                }


                return productVendor;

            }
            catch (Exception ex)
            {
                ExceptionMngr.WriteEvent("GetProductVendors:" + curItemVendor, ListValues.EventType.Error, ex, null, ListValues.ErrorCategory.ErpConnection);
                //throw;              
                return null;
            }

        }
Ejemplo n.º 10
0
        private IList<ProductAccountRelation> GetProductVendors(Product product)
        {
            IList<ProductAccountRelation> productVendor = new List<ProductAccountRelation>();
            ProductAccountRelation curId = null;
            AccountType accType = WType.GetAccountType(new AccountType { AccountTypeID = 2 });

            string curItemVendor = "";

            try
            {

                //Ask for the vendor Item record
                string sWhere = " ITEMNMBR = '" + product.ProductCode + "'";
                ds = DynamicsGP_ec.GetDataSet(DynamicsGP_ec.RetreiveData("VendorItem", false, 2, 0, sWhere, true));

                if (ds.Tables.Count > 0)
                {

                    foreach (DataRow dr in ds.Tables[1].Rows)
                    {
                        curId = new ProductAccountRelation();   

                        curId.ItemNumber = dr["VNDITNUM"].ToString();

                        //Si esta vacio se sale al proximo
                        if (string.IsNullOrEmpty(curId.ItemNumber))
                            continue;

                        curItemVendor = dr["VENDORID"].ToString() + ":" + curId.ItemNumber; 
     
                        curId.IsFromErp = true;
                        curId.AccountType = accType;
                        curId.Account = WType.GetAccount(new Account { AccountCode = dr["VENDORID"].ToString(), BaseType = new AccountType { AccountTypeID = AccntType.Vendor } });
                        curId.Product = product;
                        curId.CreatedBy = WmsSetupValues.SystemUser;
                        curId.CreationDate = DateTime.Now;

                        productVendor.Add(curId);
                    }

                }

                return productVendor;

            }
            catch (Exception ex)
            {
                ExceptionMngr.WriteEvent("GetProductVendors:" + curItemVendor, ListValues.EventType.Error, ex, null, ListValues.ErrorCategory.ErpConnection);
                //throw;              
                return null;
            }

        }
Ejemplo n.º 11
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;
                }
            }

        }
Ejemplo n.º 12
0
 public ProductAccountRelation SelectById(ProductAccountRelation data)
 {
     return (ProductAccountRelation)base.SelectById(data);
 }
Ejemplo n.º 13
0
 public Boolean Delete(ProductAccountRelation data)
 {
     return base.Delete(data);
 }
Ejemplo n.º 14
0
 public Boolean Update(ProductAccountRelation data)
 {
     return base.Update(data);
 }
Ejemplo n.º 15
0
 public ProductAccountRelation Save(ProductAccountRelation data)
 {
     return (ProductAccountRelation)base.Save(data);
 }