public override Boolean Equals(object obj) { if ((obj == null) || (obj.GetType() != this.GetType())) { return(false); } LabelMissingComponent castObj = (LabelMissingComponent)obj; return((castObj != null) && (this.RowID == castObj.RowID)); }
public IList<LabelMissingComponent> Select(LabelMissingComponent data) { IList<LabelMissingComponent> datos = new List<LabelMissingComponent>(); try { datos = GetHsql(data).List<LabelMissingComponent>(); if (!Factory.IsTransactional) Factory.Commit(); } catch (Exception e) { NHibernateHelper.WriteEventLog(WriteLog.GetTechMessage(e)); } return datos; }
public void UpdateLabelMissingComponent(LabelMissingComponent data) { Factory.DaoLabelMissingComponent().Update(data); }
public void DeleteLabelMissingComponent(LabelMissingComponent data) { Factory.DaoLabelMissingComponent().Delete(data); }
public LabelMissingComponent SaveLabelMissingComponent(LabelMissingComponent data) { return Factory.DaoLabelMissingComponent().Save(data); }
public IList<LabelMissingComponent> GetLabelMissingComponent(LabelMissingComponent data) { return Factory.DaoLabelMissingComponent().Select(data); }
public LabelMissingComponent SelectById(LabelMissingComponent data) { return (LabelMissingComponent)base.SelectById(data); }
public Boolean Delete(LabelMissingComponent data) { return base.Delete(data); }
public Boolean Update(LabelMissingComponent data) { return base.Update(data); }
public LabelMissingComponent Save(LabelMissingComponent data) { return (LabelMissingComponent)base.Save(data); }
public void ProcessKitAssemblyAddRemove(Label label, int operation, Product Component, int qty, SysUser user, long labelSourceID) { Factory.IsTransactional = true; Node node = WType.GetNode(new Node { NodeID = NodeType.Stored }); Status active = WType.GetStatus(new Status { StatusID = EntityStatus.Active }); Status lockStatus = WType.GetStatus(new Status { StatusID = EntityStatus.Locked }); //Bin donde Sucede la transaccion Label binLocation = Factory.DaoLabel().Select( new Label { Bin = label.Bin, LabelType = new DocumentType { DocTypeID = LabelType.BinLocation } } ).First(); Rules.ValidateBinStatus(binLocation.Bin, true); //Documento de Ajuste Document curDocument = null; int pos = 0; //Posicion de avance del proceso #region Operation 1 - Remove Component LabelMissingComponent lblMissing = null; //IList<Label> labelsCreated = null; if (operation == 1) //Remove Component { try { //Unit logisticUnit = null; DocumentLine line = null; //Crear N missing components for (int i = 0; i < qty; i++) { lblMissing = new LabelMissingComponent { FatherLabel = label, Component = Component, CreatedBy = user.UserName, CreationDate = DateTime.Now, Quantity = 1, Status = active }; Factory.DaoLabelMissingComponent().Save(lblMissing); } #region Option 1 - Inventory Adjustment //Positive Adjustment Del Componente, Negative del Kit Si es la primera vez, //Si no solo positive del componente // Creando el Ajuste de inventario Adiciona la parte y disminuye el kit, si es la primera pieza. curDocument = new Document { DocType = new DocumentType { DocTypeID = SDocType.InventoryAdjustment }, CreatedBy = user.UserName, Location = label.Bin.Location, Company = Component.Company, IsFromErp = false, CrossDocking = false, Comment = "Kit/Assembly Remove Component " + label.LabelCode + ", " + user.UserName, Notes = "Extract Component " + Component.ProductCode, Date1 = DateTime.Now }; curDocument = DocMngr.CreateNewDocument(curDocument, false); //Adiciona la Linea del Componente Removido. line = new DocumentLine { Product = Component, Unit = Component.BaseUnit, Quantity = qty, CreatedBy = user.UserName, Document = curDocument, LineStatus = new Status { StatusID = DocStatus.New }, IsDebit = false, UnitBaseFactor = Component.BaseUnit.BaseAmount, BinAffected = binLocation.Bin.BinCode, Location = label.Bin.Location, LineNumber = 1 }; line = SaveAdjustmentTransaction(line, binLocation, false); if (line.Note != "Adjust OK.") throw new Exception(line.Note); curDocument.DocumentLines.Add(line); //Quiere decir que es la primera vez que se extrae //entonces hace el ajuste negativo del Kit if (label.Status.StatusID == EntityStatus.Active) { DocumentLine kitAdj = new DocumentLine { Product = label.Product, Unit = label.Product.BaseUnit, Quantity = 1, CreatedBy = user.UserName, LineStatus = new Status { StatusID = DocStatus.New }, IsDebit = true, UnitBaseFactor = label.Product.BaseUnit.BaseAmount, BinAffected = binLocation.Bin.BinCode, Location = label.Bin.Location, LineNumber = 2, Document = curDocument }; kitAdj = SaveAdjustmentTransaction(kitAdj, label, false); if (kitAdj.Note != "Adjust OK.") throw new Exception(kitAdj.Note); curDocument.DocumentLines.Add(kitAdj); } ErpMngr.CreateInventoryAdjustment(curDocument, false); Factory.Commit(); #endregion label.Status = lockStatus; label.ModDate = DateTime.Now; label.ModifiedBy = user.UserName; Factory.DaoLabel().Update(label); Factory.Commit(); return; } catch (Exception ex) { Factory.Rollback(); throw new Exception(ex.Message); } } #endregion if (operation == 2) //ADD component { { try { Label sourceLabel; try { sourceLabel = Factory.DaoLabel().Select(new Label { LabelID = labelSourceID }).First(); } catch { throw new Exception("Source location not defined."); } Status inactive = WType.GetStatus(new Status { StatusID = EntityStatus.Inactive }); //Recorrer la lista de Missing Components activos e ir los desactivando. List<LabelMissingComponent> missingComps = label.MissingComponents .Where(f => f.Status.StatusID == EntityStatus.Active && f.Component.ProductID == Component.ProductID) .Take(qty).ToList(); if (missingComps == null) //Si no hya nada que ajustar siplemente sale return; //Ajusta los componentes missing indicando que fueron adicionados foreach (LabelMissingComponent component in missingComps) { component.ModifiedBy = user.UserName; component.ModDate = DateTime.Now; component.Status = inactive; Factory.DaoLabelMissingComponent().Update(component); } //Si el label esta completo. Lo pone el Label en status activo. if (label.MissingComponents.Where(f => f.Status.StatusID == EntityStatus.Active).Count() == 0) { label.Status = active; label.ModDate = DateTime.Now; label.ModifiedBy = user.UserName; Factory.DaoLabel().Update(label); } //Negative Adjustment del componente y Positive Adjustment del Kit solo si el kit se completo. #region Option 2 - Inventory Adjustment // Creando el Ajuste de inventario Adiciona la parte y disminuye el kit, si es la primera pieza. curDocument = new Document { DocType = new DocumentType { DocTypeID = SDocType.InventoryAdjustment }, CreatedBy = user.UserName, Location = label.Bin.Location, Company = Component.Company, IsFromErp = false, CrossDocking = false, Comment = "Kit/Assembly Add Component " + label.LabelCode + ", " + user.UserName, Notes = "Add Component " + Component.ProductCode, Date1 = DateTime.Now }; curDocument = DocMngr.CreateNewDocument(curDocument, false); //Adiciona la Linea del Componente Adicionado. DocumentLine addLine = new DocumentLine { Product = Component, Quantity = qty, CreatedBy = user.UserName, Unit = Component.BaseUnit, LineStatus = new Status { StatusID = DocStatus.New }, IsDebit = true, UnitBaseFactor = Component.BaseUnit.BaseAmount, BinAffected = binLocation.Bin.BinCode, Location = label.Bin.Location, LineNumber = 1, Document = curDocument }; addLine = SaveAdjustmentTransaction(addLine, sourceLabel, false); if (addLine.Note != "Adjust OK.") throw new Exception(addLine.Note); curDocument.DocumentLines.Add(addLine); //Quiere decir que es la primera vez que se extrae //entonces hace el ajuste negativo del Kit if (label.Status.StatusID == EntityStatus.Active) { DocumentLine kitAdj = new DocumentLine { Product = label.Product, Unit = label.Product.BaseUnit, Quantity = 1, CreatedBy = user.UserName, LineStatus = new Status { StatusID = DocStatus.New }, IsDebit = false, UnitBaseFactor = label.Product.BaseUnit.BaseAmount, BinAffected = binLocation.Bin.BinCode, Location = label.Bin.Location, LineNumber = 2, Document = curDocument }; kitAdj = SaveAdjustmentTransaction(kitAdj, label, false); if (kitAdj.Note != "Adjust OK.") throw new Exception(kitAdj.Note); curDocument.DocumentLines.Add(kitAdj); } ErpMngr.CreateInventoryAdjustment(curDocument, false); #endregion Factory.Commit(); return; } catch (Exception ex) { Factory.Rollback(); throw new Exception(ex.Message); } } }