Пример #1
0
        private IList <DocumentLine> GetLocationTransferDocumentLines(Document doc, Company company, String docID)
        {
            DocumentLine         tmpData;
            IList <DocumentLine> list = new List <DocumentLine>();
            Status lineStatus         = WType.GetStatus(new Status {
                StatusID = DocStatus.New
            });

            int    curLine   = 0;
            string curMaster = "";


            Query = GetErpQuery("TRANSFER_LINE").Replace("__DOCUMENT", docID);

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

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

            try
            {
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    tmpData       = new DocumentLine();
                    tmpData.Date1 = doc.Date1;
                    curMaster     = "";

                    tmpData.LineNumber = (int)double.Parse(dr["f470_rowid"].ToString());
                    tmpData.Sequence   = tmpData.LineNumber;

                    curLine          = tmpData.LineNumber;
                    tmpData.Document = doc;
                    tmpData.IsDebit  = false;
                    tmpData.Quantity = double.Parse(dr["f470_cantidad"].ToString(), new NumberFormatInfo {
                        NumberDecimalSeparator = Separator
                    });
                    tmpData.CreatedBy       = WmsSetupValues.SystemUser;
                    tmpData.CreationDate    = DateTime.Now;
                    tmpData.Note            = dr["f470_notas"].ToString();
                    tmpData.BinAffected     = dr["ubicacion"].ToString();
                    tmpData.PostingUserName = dr["f470_id_un_movto"].ToString();



                    tmpData.LineStatus = lineStatus;

                    //Location de donde proviene la mercancia
                    curMaster        = "Location:" + dr["bodega_entrada"].ToString();
                    tmpData.Location = WType.GetLocation(new Location {
                        Company = company, ErpCode = dr["bodega_entrada"].ToString()
                    });

                    //Lcation a donde va la mercancia
                    curMaster         = "Location To:" + dr["bodega_salida"].ToString();
                    tmpData.Location2 = WType.GetLocation(new Location {
                        Company = company, ErpCode = dr["bodega_salida"].ToString()
                    });


                    try
                    {
                        curMaster       = "Product:" + dr["itemext"].ToString();
                        tmpData.Product = WType.GetProduct(new Product {
                            Company = company, ProductCode = dr["f121_rowid_item"].ToString()
                        });
                        tmpData.LineDescription = tmpData.Product.Name;     //dr["ITEMDESC"].ToString();
                        tmpData.AccountItem     = dr["itemext"].ToString(); //ITEM EXT

                        curMaster    = "Uom:" + dr["f470_id_unidad_medida"].ToString();
                        tmpData.Unit = WType.GetUnit(new Unit {
                            ErpCode = dr["f470_id_unidad_medida"].ToString(), ErpCodeGroup = tmpData.Product.BaseUnit.ErpCodeGroup
                        });
                    }
                    catch (Exception ex)
                    {
                        ExceptionMngr.WriteEvent("GetLocationTransferDocumentLines: " + doc.DocNumber + "," + curLine.ToString() + "," + curMaster,
                                                 ListValues.EventType.Error, ex, null, ListValues.ErrorCategory.ErpConnection);
                        continue;

                        //    //Pone el Default Product
                        //    tmpData.Product = WType.GetProduct(new Product { Company = company, ProductCode = WmsSetupValues.DEFAULT });
                        //    tmpData.LineDescription = "Unknown: " + dr["ITEMNMBR"].ToString();

                        //    curMaster = "Uom:" + dr["UOFM"].ToString();
                        //    tmpData.Unit = WType.GetUnit(new Unit { ErpCode = dr["UOFM"].ToString() });
                    }



                    list.Add(tmpData);
                }

                return((list.Count > 0) ? list : null);
            }
            catch (Exception ex)
            {
                ExceptionMngr.WriteEvent("GetTransferDocumentLines: " + doc.DocNumber + "," + curLine.ToString() + "," + curMaster,
                                         ListValues.EventType.Error, ex, null, ListValues.ErrorCategory.ErpConnection);
                //throw;
                return(null);
            }
        }
Пример #2
0
        private IList <DocumentLine> GetKitAssemblyDocumentLines(Document doc)
        {
            DocumentLine         tmpData;
            IList <DocumentLine> list = new List <DocumentLine>();
            Status lineStatus         = WType.GetStatus(new Status {
                StatusID = DocStatus.New
            });


            int    curLine   = 1;
            string curMaster = "";


            Query = GetErpQuery("KITDOC_LINE").Replace("__DOCUMENT", doc.ErpMaster.ToString());

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

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


            if (ds.Tables[0].Select("rowid=0").Length == 0)
            {
                return(null);
            }

            try
            {
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    tmpData       = new DocumentLine();
                    tmpData.Date1 = doc.Date1;

                    tmpData.LineNumber        = int.Parse(dr["rowid"].ToString()); //curLine++;
                    tmpData.Sequence          = tmpData.LineNumber;
                    tmpData.LinkDocLineNumber = int.Parse(dr["row_padre"].ToString());
                    tmpData.Note = dr["type"].ToString();

                    //TODO: Revisar el Status en GP para traer el equivalente
                    tmpData.LineStatus   = lineStatus;
                    tmpData.Document     = doc;
                    tmpData.IsDebit      = false;
                    tmpData.Quantity     = double.Parse(dr["f470_cant_base"].ToString(), ListValues.DoubleFormat());
                    tmpData.CreatedBy    = WmsSetupValues.SystemUser;
                    tmpData.CreationDate = DateTime.Now;

                    curMaster        = "Location";
                    tmpData.Location = doc.Location; //WType.GetLocation(new Location { Company = CurCompany, ErpCode = dr["LOCNCODE"].ToString() });

                    try
                    {
                        curMaster       = "Product";
                        tmpData.Product = WType.GetProduct(new Product {
                            Company = CurCompany, ProductCode = dr["item_id"].ToString()
                        });;

                        curMaster    = "Unit";
                        tmpData.Unit = WType.GetUnit(new Unit {
                            ErpCode = dr["unit_id"].ToString(), ErpCodeGroup = tmpData.Product.BaseUnit.ErpCodeGroup
                        });
                    }
                    catch (Exception ex)
                    {
                        ExceptionMngr.WriteEvent("GetKitAssemblyDocumentLines: " + doc.DocNumber + "," + curLine.ToString() + "," + curMaster,
                                                 ListValues.EventType.Error, ex, null, ListValues.ErrorCategory.ErpConnection);
                        continue;
                        //{
                        //    //Pone el Default Product
                        //    tmpData.Product = WType.GetProduct(new Product { Company = CurCompany, ProductCode = WmsSetupValues.DEFAULT });
                        //    tmpData.LineDescription = "Unknown: " + dr["ITEMNMBR"].ToString() + ", " + dr["ITEMDESC"].ToString();

                        //    curMaster = "Unit";
                        //    tmpData.Unit = WType.GetUnit(new Unit { ErpCode = dr["UOFM"].ToString() });
                    }

                    list.Add(tmpData);
                }

                return((list.Count > 0) ? list : null);
            }
            catch (Exception ex)
            {
                ExceptionMngr.WriteEvent("GetKitAssemblyDocumentLines: " + doc.DocNumber + "," + curLine.ToString() + "," + curMaster,
                                         ListValues.EventType.Error, ex, null, ListValues.ErrorCategory.ErpConnection);
                throw;
                //return null;
            }
        }
        private IList <DocumentLine> GetShippingDocumentLines(Document doc, Company company, string docID, bool useRemain)
        {
            DocumentLine         tmpData;
            IList <DocumentLine> list = new List <DocumentLine>();
            Status lineStatus         = WType.GetStatus(new Status {
                StatusID = DocStatus.New
            });


            int    curLine   = 0;
            string curMaster = "";


            try
            {
                Query = GetErpQuery("SALESORDER_LINE").Replace("__DOCUMENT", docID);

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

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



                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    tmpData       = new DocumentLine();
                    tmpData.Date1 = doc.Date1;
                    curMaster     = "";

                    try { tmpData.Date2 = DateTime.Parse(dr["f431_fecha_entrega"].ToString()); }
                    catch { }
                    try { tmpData.Date3 = DateTime.Parse(dr["f431_fecha_cumplido"].ToString()); }
                    catch { }

                    tmpData.LineNumber = int.Parse(dr["f431_rowid"].ToString());
                    tmpData.Sequence   = tmpData.LineNumber;
                    curLine            = tmpData.LineNumber;

                    //TODO: Revisar el Status en GP para traer el equivalente
                    tmpData.LineStatus = GetShippingStatus(0);
                    tmpData.Document   = doc;
                    tmpData.IsDebit    = false;

                    if (useRemain)
                    {
                        tmpData.Quantity = double.Parse(dr["f431_cant_facturada_base"].ToString(), new NumberFormatInfo {
                            NumberDecimalSeparator = Separator
                        });
                    }
                    else
                    {
                        tmpData.Quantity = double.Parse(dr["f431_cant_facturada_base"].ToString(), ListValues.DoubleFormat());
                    }

                    //tmpData.QtyCancel = double.Parse(dr["QTYCANCE"].ToString(), ListValues.DoubleFormat());
                    //tmpData.QtyBackOrder = double.Parse(dr["QTYTBAOR"].ToString(), ListValues.DoubleFormat());
                    //tmpData.QtyPending = tmpData.Quantity - tmpData.QtyCancel - double.Parse(dr["QTYPRINV"].ToString(), ListValues.DoubleFormat());
                    //tmpData.QtyAllocated = double.Parse(dr["ATYALLOC"].ToString(), ListValues.DoubleFormat());
                    tmpData.CreatedBy    = WmsSetupValues.SystemUser;
                    tmpData.CreationDate = DateTime.Now;

                    curMaster        = "Location:" + dr["cod_bodega"].ToString();
                    tmpData.Location = WType.GetLocation(new Location {
                        Company = company, ErpCode = dr["cod_bodega"].ToString()
                    });

                    try
                    {
                        curMaster       = "Product:" + dr["f121_rowid_item"].ToString();
                        tmpData.Product = WType.GetProduct(new Product {
                            Company = company, ProductCode = dr["f121_rowid_item"].ToString()
                        });
                        tmpData.LineDescription = dr["f120_descripcion"].ToString();

                        curMaster    = "Uom:" + dr["f431_id_unidad_medida"].ToString();
                        tmpData.Unit = WType.GetUnit(new Unit {
                            ErpCode = dr["f431_id_unidad_medida"].ToString(), ErpCodeGroup = tmpData.Product.BaseUnit.ErpCodeGroup
                        });
                    }
                    catch
                    {
                        //Pone el Default Product
                        tmpData.Product = WType.GetProduct(new Product {
                            Company = doc.Location.Company, ProductCode = WmsSetupValues.DEFAULT
                        });
                        tmpData.LineDescription = "Unknown: " + dr["f121_rowid_item"].ToString() + ", " + dr["f120_descripcion"].ToString();

                        curMaster    = "Uom:" + dr["f431_id_unidad_medida"].ToString();
                        tmpData.Unit = WType.GetUnit(new Unit {
                            ErpCode = dr["f431_id_unidad_medida"].ToString()
                        });
                    }

                    //Manage Prices
                    curMaster             = "Prices Product:" + dr["f121_rowid_item"].ToString();
                    tmpData.UnitPrice     = double.Parse(dr["f431_precio_unitario_base"].ToString(), ListValues.DoubleFormat());
                    tmpData.ExtendedPrice = double.Parse(dr["subtotal"].ToString(), ListValues.DoubleFormat());

                    //Asignacion de Address
                    curMaster = "Address Doc:" + doc.DocNumber;
                    //tmpData.DocumentLineAddresses = GetShippingDocumentAddress(tmpData.Document, tmpData, dr);


                    list.Add(tmpData);
                }

                return((list.Count > 0) ? list : null);
            }
            catch (Exception ex)
            {
                ExceptionMngr.WriteEvent("GetShippingDocumentLines: " + doc.DocNumber + "," + curLine.ToString() + "," + curMaster,
                                         ListValues.EventType.Error, ex, null, ListValues.ErrorCategory.ErpConnection);
                //throw;
                return(null);
            }
        }
Пример #4
0
        /// <summary>
        /// Crea a new label package for a specific document, this package will contain product picked for the order.
        /// </summary>
        /// <param name="line"></param>
        /// <param name="picker"></param>
        /// <returns></returns>
        public DocumentPackage CreateNewPackage(Document document, SysUser picker, bool isOpen,
                                                DocumentPackage parent, string packageType)
        {
            Factory.IsTransactional = true;

            Node node = WType.GetNode(new Node {
                NodeID = NodeType.Picked
            });
            Status status = WType.GetStatus(new Status {
                StatusID = EntityStatus.Active
            });
            DocumentType labelType = WType.GetLabelType(new DocumentType {
                DocTypeID = LabelType.CustomerLabel
            });
            Unit logisticUnit = WType.GetUnit(new Unit {
                Company = document.Company, Name = WmsSetupValues.CustomUnit
            });
            Bin destLocation = WType.GetBin(new Bin {
                Location = document.Location, BinCode = DefaultBin.PICKING
            });

            int sequence = Factory.DaoDocumentPackage().Select(new DocumentPackage
            {
                Document = document,
                //PostingDocument = new Document {DocID = -1 }
            }).Count + 1;

            //Generate new logistig labels located in MAIN
            //Labels shouldbe activated the next transaction
            try
            {
                //Funcion para obtener siguiente Label
                //DocumentTypeSequence initSequence = GetNextDocSequence(document.Company, labelType);

                Label packLabel = new Label();
                packLabel.Node             = node;
                packLabel.Bin              = destLocation;
                packLabel.CreatedBy        = picker.UserName;
                packLabel.Status           = status;
                packLabel.LabelType        = labelType;
                packLabel.CreationDate     = DateTime.Now;
                packLabel.Printed          = false;
                packLabel.Unit             = logisticUnit;
                packLabel.IsLogistic       = true;
                packLabel.LabelCode        = ""; // initSequence.NumSequence.ToString() + GetRandomHex(picker.UserName, initSequence.NumSequence);
                packLabel.Notes            = "Package label for Document # " + document.DocNumber;
                packLabel.ShippingDocument = document;

                //Added on 14/ENE/09
                if (parent != null && parent.PackLabel != null && parent.PackLabel.LabelID != 0)
                {
                    try { packLabel.FatherLabel = parent.PackLabel; }
                    catch { }
                }



                //Creado el document Package Asociado al Label
                DocumentPackage docPack = new DocumentPackage
                {
                    Document     = document,
                    CreatedBy    = picker.UserName,
                    CreationDate = DateTime.Now,
                    IsClosed     = !isOpen,
                    PackLabel    = packLabel,
                    Picker       = picker,
                    StartTime    = DateTime.Now,
                    EndTime      = DateTime.Now,
                    Sequence     = (short)sequence,
                    Dimension    = "",
                    ShipToName   = document.Customer.Name,
                    //Added on 14/ENE/09
                    ParentPackage = (parent != null && parent.PackID != 0) ? parent : null,
                    PackageType   = packageType
                };

                //Address Line for package 16/oct/09

                DocumentAddress ShipTo_address = null;
                try
                {
                    ShipTo_address = Factory.DaoDocumentAddress().Select(
                        new DocumentAddress
                    {
                        Document    = document,
                        AddressType = AddressType.Shipping
                    })
                                     .Where(f => f.DocumentLine == null).First();

                    docPack.AddressLine1 = ShipTo_address.AddressLine1 + " " + ShipTo_address.AddressLine2;
                    docPack.AddressLine2 = ShipTo_address.City + ", " + ShipTo_address.State + " " + ShipTo_address.ZipCode;
                    docPack.AddressLine3 = ShipTo_address.Country;
                }
                catch { }

                packLabel.DocumentPackages = new List <DocumentPackage> {
                    docPack
                };
                packLabel           = Factory.DaoLabel().Save(packLabel);
                packLabel.LabelCode = packLabel.LabelID.ToString();

                //Registra el movimiento del nodo

                SaveNodeTrace(
                    new NodeTrace
                {
                    Node      = node,
                    Document  = document,
                    Label     = packLabel,
                    Quantity  = packLabel.CurrQty,
                    IsDebit   = false,
                    CreatedBy = picker.UserName
                }
                    );

                //initSequence.NumSequence;
                //Factory.DaoDocumentTypeSequence().Update(initSequence);
                Factory.Commit();


                //actualizando el documento
                try
                {
                    if (string.IsNullOrEmpty(document.UserDef3))
                    {
                        //document.UserDef3 = picker.UserName;
                        Factory.DaoDocument().Update(document);
                    }
                }
                catch { }

                return(docPack);
            }
            catch { throw; }
        }
Пример #5
0
        private IList <DocumentLine> GetKitAssemblyDocumentLines(Document doc)
        {
            DocumentLine         tmpData;
            IList <DocumentLine> list = new List <DocumentLine>();
            Status lineStatus         = WType.GetStatus(new Status {
                StatusID = DocStatus.New
            });


            int    curLine   = 1;
            string curMaster = "";

            // BM10300 - KitAssembly Document Lines
            DataSet ds = ReturnDataSet("SELECT * FROM BM10300 WHERE 1=1 ", "TRX_ID='" + doc.DocNumber + "'", "BM10300", Command.Connection);


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


            try
            {
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    tmpData       = new DocumentLine();
                    tmpData.Date1 = doc.Date1;

                    tmpData.LineNumber        = int.Parse(dr["Component_ID"].ToString()); //curLine++;
                    tmpData.Sequence          = tmpData.LineNumber;
                    tmpData.LinkDocLineNumber = int.Parse(dr["Parent_Component_ID"].ToString());
                    tmpData.Note = dr["BM_Component_Type"].ToString();

                    //TODO: Revisar el Status en GP para traer el equivalente
                    tmpData.LineStatus   = lineStatus;
                    tmpData.Document     = doc;
                    tmpData.IsDebit      = false;
                    tmpData.Quantity     = double.Parse(dr["Extended_Standard_Quantity"].ToString(), ListValues.DoubleFormat());
                    tmpData.CreatedBy    = WmsSetupValues.SystemUser;
                    tmpData.CreationDate = DateTime.Now;

                    curMaster        = "Location";
                    tmpData.Location = WType.GetLocation(new Location {
                        Company = CurCompany, ErpCode = dr["LOCNCODE"].ToString()
                    });

                    try
                    {
                        curMaster       = "Product";
                        tmpData.Product = WType.GetProduct(new Product {
                            Company = CurCompany, ProductCode = dr["ITEMNMBR"].ToString()
                        });;

                        curMaster    = "Unit";
                        tmpData.Unit = WType.GetUnit(new Unit {
                            ErpCode = dr["UOFM"].ToString(), ErpCodeGroup = tmpData.Product.BaseUnit.ErpCodeGroup
                        });
                    }
                    catch (Exception ex)
                    {
                        ExceptionMngr.WriteEvent("GetKitAssemblyDocumentLines: " + doc.DocNumber + "," + curLine.ToString() + "," + curMaster,
                                                 ListValues.EventType.Error, ex, null, ListValues.ErrorCategory.ErpConnection);
                        continue;
                        //{
                        //    //Pone el Default Product
                        //    tmpData.Product = WType.GetProduct(new Product { Company = CurCompany, ProductCode = WmsSetupValues.DEFAULT });
                        //    tmpData.LineDescription = "Unknown: " + dr["ITEMNMBR"].ToString() + ", " + dr["ITEMDESC"].ToString();

                        //    curMaster = "Unit";
                        //    tmpData.Unit = WType.GetUnit(new Unit { ErpCode = dr["UOFM"].ToString() });
                    }

                    list.Add(tmpData);
                }

                return((list.Count > 0) ? list : null);
            }
            catch (Exception ex)
            {
                ExceptionMngr.WriteEvent("GetKitAssemblyDocumentLines: " + doc.DocNumber + "," + curLine.ToString() + "," + curMaster,
                                         ListValues.EventType.Error, ex, null, ListValues.ErrorCategory.ErpConnection);
                throw;
                //return null;
            }
        }