public IList<UnitProductRelation> Select(UnitProductRelation data) { IList<UnitProductRelation> datos = new List<UnitProductRelation>(); datos = GetHsql(data).List<UnitProductRelation>(); if (!Factory.IsTransactional) Factory.Commit(); return datos; }
public override Boolean Equals(object obj) { if ((obj == null) || (obj.GetType() != this.GetType())) { return(false); } UnitProductRelation castObj = (UnitProductRelation)obj; return((castObj != null) && (this.RowID == castObj.RowID)); }
public void DeleteUnitProductRelation(UnitProductRelation data) { Factory.DaoUnitProductRelation().Delete(data); }
public void UpdateUnitProductRelation(UnitProductRelation data) { Factory.DaoUnitProductRelation().Update(data); }
public UnitProductRelation SaveUnitProductRelation(UnitProductRelation data) { return Factory.DaoUnitProductRelation().Save(data); }
public IList<UnitProductRelation> GetUnitProductRelation(UnitProductRelation data) { return Factory.DaoUnitProductRelation().Select(data); }
private IList<UnitProductRelation> GetProductUnits(Product product, IList<Unit> unitList) { IList<UnitProductRelation> productUnits = new List<UnitProductRelation>(); UnitProductRelation curId; try { foreach (Unit e in unitList) { curId = new UnitProductRelation(); curId.BaseAmount = e.BaseAmount; curId.IsBasic = (e.BaseAmount == 1) ? true : false; curId.Product = product; curId.Unit = WType.GetUnit(e); curId.UnitErpCode = e.ErpCode; curId.Status = product.Status; curId.CreatedBy = WmsSetupValues.SystemUser; curId.CreationDate = DateTime.Now; productUnits.Add(curId); } return productUnits; } catch (Exception ex) { ExceptionMngr.WriteEvent("GetProductUnits", ListValues.EventType.Error, ex, null, ListValues.ErrorCategory.ErpConnection); //throw; return null; } }
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; } } }
public UnitProductRelation SelectById(UnitProductRelation data) { return (UnitProductRelation)base.SelectById(data); }
public Boolean Delete(UnitProductRelation data) { return base.Delete(data); }
public Boolean Update(UnitProductRelation data) { return base.Update(data); }
public UnitProductRelation Save(UnitProductRelation data) { return (UnitProductRelation)base.Save(data); }
private IList<UnitProductRelation> GetProductUnits(Product product, IList<Unit> unitList) { IList<UnitProductRelation> productUnits = new List<UnitProductRelation>(); UnitProductRelation curId; try { Command.Connection = new SqlConnection(CurCompany.ErpConnection.CnnString); Query = GetErpQuery("ITEM_UNITS").Replace("__ITEM", product.ProductCode); ds = ReturnDataSet(Query, null, "ITEM_UNITS", Command.Connection); if (ds == null || ds.Tables.Count == 0) return null; Unit e; foreach (DataRow row in ds.Tables[0].Rows) { e = unitList.Where(f => f.ErpCode == row["f101_id"].ToString()).First(); curId = new UnitProductRelation(); curId.BaseAmount = e.BaseAmount; curId.IsBasic = (e.BaseAmount == 1) ? true : false; curId.Product = product; curId.Unit = WType.GetUnit(e); curId.UnitErpCode = e.ErpCode; curId.Status = product.Status; curId.CreatedBy = WmsSetupValues.SystemUser; curId.CreationDate = DateTime.Now; productUnits.Add(curId); } return productUnits; } catch (Exception ex) { ExceptionMngr.WriteEvent("GetProductUnits", ListValues.EventType.Error, ex, null, ListValues.ErrorCategory.ErpConnection); //throw; return null; } }