Пример #1
0
        public IList<DocumentAddress> Select(DocumentAddress data)
        {
                IList<DocumentAddress> datos = new List<DocumentAddress>();

                datos = GetHsql(data).List<DocumentAddress>();
                if (!Factory.IsTransactional)
                    Factory.Commit();
                return datos;
           
        }
Пример #2
0
        public override Boolean Equals(object obj)
        {
            if ((obj == null) || (obj.GetType() != this.GetType()))
            {
                return(false);
            }
            DocumentAddress castObj = (DocumentAddress)obj;

            return((castObj != null) &&
                   (this.RowID == castObj.RowID));
        }
Пример #3
0
 public void DeleteDocumentAddress(DocumentAddress data) { Factory.DaoDocumentAddress().Delete(data); }
Пример #4
0
 public void UpdateDocumentAddress(DocumentAddress data) { Factory.DaoDocumentAddress().Update(data); }
Пример #5
0
 public DocumentAddress SaveDocumentAddress(DocumentAddress data) { return Factory.DaoDocumentAddress().Save(data); }
Пример #6
0
 public IList<DocumentAddress> GetDocumentAddress(DocumentAddress data) { return Factory.DaoDocumentAddress().Select(data); }
Пример #7
0
 public DocumentAddress SelectById(DocumentAddress data)
 {
     return (DocumentAddress)base.SelectById(data);
 }
Пример #8
0
 public Boolean Delete(DocumentAddress data)
 {
     return base.Delete(data);
 }
Пример #9
0
 public Boolean Update(DocumentAddress data)
 {
     return base.Update(data);
 }
Пример #10
0
 public DocumentAddress Save(DocumentAddress data)
 {
     return (DocumentAddress)base.Save(data);
 }
Пример #11
0
        private IList<DocumentAddress> GetShippingDocumentAddress(Document doc, DocumentLine docLine, DataRow dr)
        {

            IList<DocumentAddress> list = new List<DocumentAddress>();
            Boolean pass = false;

            if (docLine == null)
                pass = true;
            else if (doc.DocumentAddresses != null && doc.DocumentAddresses.Count > 0 && !doc.DocumentAddresses[0].AddressLine1.Equals(dr["direccion1"].ToString()))
                pass = true;

            try
            {
                //Verificacion solo para Document Lines
                if (pass)
                {

                    DocumentAddress spAddr = new DocumentAddress();
                    spAddr.Document = doc;
                    spAddr.DocumentLine = (docLine == null) ? null : docLine;
                    spAddr.Name = dr["f215_descripcion"].ToString();
                    spAddr.ErpCode = dr["f215_id"].ToString();
                    spAddr.AddressLine1 = dr["direccion1"].ToString();
                    spAddr.AddressLine2 = dr["direccion2"].ToString();
                    spAddr.AddressLine3 = dr["direccion3"].ToString();
                    spAddr.City = dr["ciudad"].ToString();
                    spAddr.State = dr["depto"].ToString();
                    spAddr.ZipCode = dr["cod_postal"].ToString();
                    spAddr.Country = dr["pais"].ToString();

                    if (docLine == null)
                    {
                        spAddr.Phone1 = dr["telefono"].ToString();
                        spAddr.Phone2 = dr["fax"].ToString();
                    }
                    else
                    {
                        spAddr.Phone1 = dr["telefono"].ToString();
                        spAddr.Phone2 = dr["fax"].ToString();
                    }

                    //spAddr.Phone3 = dr["FAXNUMBR"].ToString();
                    spAddr.ContactPerson = dr["contacto"].ToString();
                    spAddr.AddressType = AddressType.Shipping;
                    spAddr.Email = "";
                    //spAddr.ShpMethod = WType.GetShippingMethod(new ShippingMethod { Company = doc.Company, ErpCode = dr["SHIPMTHD"].ToString() }); ;
                    spAddr.CreationDate = DateTime.Now;
                    spAddr.CreatedBy = WmsSetupValues.SystemUser;

                    if (!(string.IsNullOrEmpty(dr["f215_descripcion"].ToString()) && string.IsNullOrEmpty(spAddr.AddressLine1 = dr["direccion1"].ToString())))
                        list.Add(spAddr);

                }

            }
            catch (Exception ex)
            {
                ExceptionMngr.WriteEvent("GetShippingDocumentAddress" + doc.DocNumber, ListValues.EventType.Error, ex, null, ListValues.ErrorCategory.ErpConnection);
                //throw;
            }

            return list;
        }
Пример #12
0
        private DocumentAddress GetBillAddress(Document doc, string addressCode, string customerCode, short AccnType)
        {
            DocumentAddress billAddress = null;

            AccountAddress accountAddress = new AccountAddress
            {
                Account = new Account { AccountCode = customerCode, BaseType = new AccountType { AccountTypeID = AccnType } },
                ErpCode = addressCode
            };

            accountAddress = WType.GetAccountAddress(accountAddress);

            if (accountAddress != null)
            {
                billAddress = new DocumentAddress();
                billAddress.Document = doc;
                billAddress.DocumentLine = null;
                billAddress.Name = accountAddress.Name;
                billAddress.AddressLine1 = accountAddress.AddressLine1;
                billAddress.AddressLine2 = accountAddress.AddressLine2;
                billAddress.AddressLine3 = accountAddress.AddressLine3;
                billAddress.City = accountAddress.City;
                billAddress.State = accountAddress.State;
                billAddress.ZipCode = accountAddress.ZipCode;
                billAddress.Country = accountAddress.Country;
                billAddress.Phone1 = accountAddress.Phone1;
                billAddress.Phone2 = accountAddress.Phone2;
                billAddress.Phone3 = accountAddress.Phone3;
                billAddress.ContactPerson = accountAddress.ContactPerson;
                billAddress.AddressType = AddressType.Billing;
                billAddress.Email = accountAddress.Email;
                billAddress.CreationDate = DateTime.Now;
                billAddress.CreatedBy = WmsSetupValues.SystemUser;
                billAddress.ErpCode = addressCode;
            }

            return billAddress;      
        }
Пример #13
0
        private void ProcessDocuments(IList<Document> list, Company company)
        {
            if (list == null)
                return;

            Document qDoc;
            DocumentLine curLine;
            Factory.Commit();
            Factory.IsTransactional = true;
            Status cancell = WType.GetStatus(new Status { StatusID = DocStatus.Cancelled });
            string flag = "";

            //pregunta si sobre escribe las cantidades ya guardadas con las nuevas del ERP
            string overWriteQtys = "T";

            try { overWriteQtys = GetCompanyOption(company, "OVERWQTY"); }
            catch { overWriteQtys = "T"; }



            int i, y;
            foreach (Document e in list)
            {
                try
                {

                    flag = "Document";

                    qDoc = new Document
                    {
                        DocNumber = e.DocNumber,
                        //DocType = new DocumentType { DocTypeID = e.DocType.DocTypeID },
                        Company = new Company { CompanyID = e.Company.CompanyID }
                    };

                    //Evalua si el documento ya existe 
                    IList<Document> exList = Factory.DaoDocument().Select(qDoc);
                    e.ModDate = DateTime.Now;
                    e.ModifiedBy = WmsSetupValues.SystemUser;
                    Factory.Commit();

                    //Si No existe
                    if (exList.Count == 0)
                    {
                        e.CreationDate = DateTime.Now;
                        e.CreatedBy = string.IsNullOrEmpty(e.CreatedBy) ? WmsSetupValues.SystemUser : e.CreatedBy;
                        Factory.DaoDocument().Save(e);
                        Factory.Commit();
                    }
                    else
                    {

                        //Si el documento esta completado no puede ser actualizado por el DEL ERP
                        //13 Oct 2009
                        //if (exList.First().DocStatus.StatusID == DocStatus.Completed)
                        //continue;

                        //Si el last change del document e sdiferente de nulo y no es mayor al ultimo las change
                        if (exList.First().LastChange != null && exList.First().LastChange >= e.LastChange)
                            continue;

                        //Console.WriteLine("Document:" + e.DocNumber);

                        //Valores que no pueden cambiar asi se reciban de nuevo del ERP
                        e.DocID = exList.First().DocID;
                        e.CreationDate = exList.First().CreationDate;
                        e.CreatedBy = exList.First().CreatedBy;
                        e.Priority = exList.First().Priority;
                        e.Notes = exList.First().Notes;
                        e.CrossDocking = exList.First().CrossDocking;

                        if (!string.IsNullOrEmpty(exList.First().Comment))
                            e.Comment = exList.First().Comment;

                        e.PickMethod = exList.First().PickMethod;
                        e.AllowPartial = exList.First().AllowPartial;
                        e.ModDate = DateTime.Now;
                        e.ModifiedBy = e.CreatedBy;

                        //Conserva el status si el actual es mayor al que viene del el ERP.
                        if (exList.First().DocStatus.StatusID > e.DocStatus.StatusID)
                            e.DocStatus = exList.First().DocStatus;


                        flag = "Address";

                        #region DocAddress
                        if (e.DocumentAddresses != null)
                        {
                            //Evaluar los document Address
                            i = 0;
                            DocumentAddress curAddr;
                            foreach (DocumentAddress addr in e.DocumentAddresses)
                            {
                                curAddr = new DocumentAddress();
                                curAddr.Document = new Document { DocID = e.DocID };
                                curAddr.Name = addr.Name;
                                curAddr.DocumentLine = new DocumentLine { LineID = -1 };
                                IList<DocumentAddress> listAddrs = Factory.DaoDocumentAddress().Select(curAddr);
                                Factory.Commit();

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

                                i++;
                            }
                        }

                        //Factory.DaoDocument().Update(e);

                        #endregion


                        flag = "Lines";
                        //Evaluar los document Lines
                        #region DocLines

                        if (e.DocumentLines != null)
                        {


                            IList<DocumentLine> currentLines = Factory.DaoDocumentLine().Select(new DocumentLine { Document = new Document { DocID = e.DocID } });

                            //Elimina la lineas que no sean de procesos originale del ERP
                            //Para recrealas en pasos posteriores
                            if (currentLines != null && currentLines.Count > 0)
                            {

                                //foreach (DocumentLine curxLine in currentLines.Where(f=>f.Note != "1" && f.Note != "2" && f.LinkDocLineNumber == 0 ))
                                foreach (DocumentLine curxLine in currentLines.Where(f => f.LinkDocLineNumber <= 0))
                                {
                                    //Borra las lineas que no existan ya y que no sean de tipo kit assembly.
                                    //if (!e.DocumentLines.Any(f => f.LineNumber == curxLine.LineNumber || ((f.Note == "1" || f.Note == "2") && f.LinkDocLineNumber > 0))) 

                                    //Console.WriteLine("\t" + curxLine.LineNumber);
                                    if (!e.DocumentLines.Any(f => f.LineNumber == curxLine.LineNumber))
                                    {
                                        //if (curxLine.Note != "1" && curxLine.Note != "2" && curxLine.LinkDocLineNumber == 0)
                                        Factory.DaoDocumentLine().Delete(curxLine);
                                        //Console.WriteLine("\tDeleted " + curxLine.LineNumber);
                                    }
                                    //curxLine.LineStatus = cancell;
                                    //Factory.DaoDocumentLine().Update(curxLine);
                                }

                                Factory.Commit();
                            }




                            i = 0;
                            IList<DocumentLine> linesToRemove = new List<DocumentLine>();

                            foreach (DocumentLine line in e.DocumentLines)
                            {
                                curLine = new DocumentLine { Document = new Document { DocID = e.DocID }, LineNumber = line.LineNumber };

                                IList<DocumentLine> listLines = Factory.DaoDocumentLine().Select(curLine);
                                Factory.Commit();

                                //Console.WriteLine(e.DocNumber + "," + e.DocID + "," + line.LineNumber + "," + listLines.Count.ToString());

                                if (listLines.Count > 0)
                                {

                                    //if (listLines.First().LineStatus.StatusID == DocStatus.InProcess || listLines.First().LineStatus.StatusID == DocStatus.Completed)
                                    if (listLines.First().LineStatus.StatusID != DocStatus.New)
                                    {
                                        linesToRemove.Add(e.DocumentLines[i]);
                                        i++;
                                        continue;
                                    }

                                    e.DocumentLines[i].ModDate = DateTime.Now;
                                    e.DocumentLines[i].ModifiedBy = WmsSetupValues.SystemUser;
                                    e.DocumentLines[i].LineID = listLines.First().LineID;
                                    e.DocumentLines[i].CreationDate = listLines.First().CreationDate;
                                    e.DocumentLines[i].CreatedBy = listLines.First().CreatedBy;
                                    e.DocumentLines[i].QtyShipped = listLines.First().QtyShipped;
                                    e.DocumentLines[i].LinkDocLineNumber = listLines.First().LinkDocLineNumber;
                                    e.DocumentLines[i].LinkDocNumber = listLines.First().LinkDocNumber;

                                    if (overWriteQtys.Equals("F"))
                                    {
                                        if (e.DocumentLines[i].QtyAllocated > 0 && listLines.First().QtyAllocated == 0)
                                            e.DocumentLines[i].QtyAllocated = listLines.First().QtyAllocated;

                                        if (e.DocumentLines[i].QtyBackOrder > 0 && listLines.First().QtyBackOrder == 0)
                                            e.DocumentLines[i].QtyBackOrder = listLines.First().QtyBackOrder;

                                        if (e.DocumentLines[i].QtyCancel > 0 && listLines.First().QtyCancel == 0)
                                            e.DocumentLines[i].QtyCancel = listLines.First().QtyCancel;
                                    }


                                    #region Document Line Address
                                    //Evaluar los document Line Address
                                    if (line.DocumentLineAddresses != null)
                                    {
                                        y = 0;
                                        DocumentAddress curLineAddr;
                                        foreach (DocumentAddress lineAddr in line.DocumentLineAddresses)
                                        {
                                            curLineAddr = new DocumentAddress();
                                            curLineAddr.Document = new Document { DocID = line.Document.DocID };
                                            curLineAddr.DocumentLine = line;
                                            curLineAddr.Name = lineAddr.Name;
                                            IList<DocumentAddress> listLineAddrs = Factory.DaoDocumentAddress().Select(curLineAddr);
                                            Factory.Commit();

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

                                            y++;
                                        }
                                    }
                                    #endregion

                                }
                                else
                                {
                                    e.DocumentLines[i].CreationDate = DateTime.Now;
                                    e.DocumentLines[i].CreatedBy = WmsSetupValues.SystemUser;
                                }

                                i++;
                            }

                            //Remueve las lineas que no van a ser procesadas.
                            foreach(DocumentLine lr in linesToRemove)                                                            
                                e.DocumentLines.Remove(lr);

                        }
                        #endregion

                        flag = "Update Document";


                        Factory.DaoDocument().Update(e);
                        Factory.Commit();
                    }

                    flag = "Explode Kit";
                    //Incluido Mayo 14 de 2009 Evalua si el documento de Venta tiene lineas de assembly y debe mostrar 
                    //Los componentes
                    //e.DocType.DocClass.DocClassID == SDocClass.Shipping - Removido ON Sep 17/09
                    //Console.WriteLine("\tDocument Before Explode:" + e.DocNumber);
                    if (e.DocType.DocTypeID == SDocType.SalesOrder && GetCompanyOption(e.Company, "SHOWCOMP").Equals("T"))
                    {
                        //Console.WriteLine("\tDocument Explode:" + e.DocNumber);
                        ExplodeKitAssemblyComponents(e, true);
                    }


                    //Incluido Mayo 26 de 2009 Evalua si el documento de Return tiene lineas de assembly y debe mostrar 
                    //Los componentes, pero no recibirlos, recibe el asembli, por eso el parametro en false.
                    if (e.DocType.DocTypeID == SDocType.Return && GetCompanyOption(e.Company, "RETURNCOMP").Equals("T"))
                        ExplodeKitAssemblyComponents(e, false);


                }
                catch (Exception ex)
                {
                    Factory.Rollback();
                    if (e.DocType.DocTypeID != SDocType.KitAssemblyTask) //&& !ex.Message.Contains("Problem updating the record.")
                        ExceptionMngr.WriteEvent("ProcessDocuments:" + flag + ":" + e.DocNumber, ListValues.EventType.Fatal, ex, null, ListValues.ErrorCategory.Business);
                    //throw;
                }

            }
        }
        private IList<DocumentAddress> GetShippingDocumentAddress(Document doc, DocumentLine docLine, DataRow dr)
        {

            IList<DocumentAddress> list = new List<DocumentAddress>();
            Boolean pass = false;

            if (docLine == null)
                pass = true;
            else if (doc.DocumentAddresses != null && doc.DocumentAddresses.Count > 0 && !doc.DocumentAddresses[0].AddressLine1.Equals(dr["ADDRESS1"].ToString()))
                pass = true;

            try
            {
                //Verificacion solo para Document Lines
                if (pass)
                {

                    DocumentAddress spAddr = new DocumentAddress();
                    spAddr.Document = doc;
                    spAddr.DocumentLine = (docLine == null) ? null : docLine;
                    spAddr.Name = dr["ShipToName"].ToString();
                    spAddr.ErpCode = dr["PRSTADCD"].ToString();
                    spAddr.AddressLine1 = dr["ADDRESS1"].ToString();
                    spAddr.AddressLine2 = dr["ADDRESS2"].ToString();
                    spAddr.AddressLine3 = dr["ADDRESS3"].ToString();
                    spAddr.City = dr["CITY"].ToString();
                    spAddr.State = dr["STATE"].ToString();
                    spAddr.ZipCode = dr["ZIPCODE"].ToString();
                    spAddr.Country = dr["COUNTRY"].ToString();

                    if (docLine == null)
                    {
                        spAddr.Phone1 = dr["PHNUMBR1"].ToString();
                        spAddr.Phone2 = dr["PHNUMBR2"].ToString();
                    }
                    else
                    {
                        spAddr.Phone1 = dr["PHONE1"].ToString();
                        spAddr.Phone2 = dr["PHONE2"].ToString();
                    }
                    spAddr.Phone3 = dr["FAXNUMBR"].ToString();
                    spAddr.ContactPerson = dr["CNTCPRSN"].ToString(); 
                    spAddr.AddressType = AddressType.Shipping;
                    spAddr.Email = "";
                    spAddr.ShpMethod = WType.GetShippingMethod(new ShippingMethod { Company = doc.Company, ErpCode = dr["SHIPMTHD"].ToString() }); ;
                    spAddr.CreationDate = DateTime.Now;
                    spAddr.CreatedBy = WmsSetupValues.SystemUser;

                    if (!(string.IsNullOrEmpty(dr["ShipToName"].ToString()) && string.IsNullOrEmpty(spAddr.AddressLine1 = dr["ADDRESS1"].ToString())))
                        list.Add(spAddr);

                }

            }
            catch (Exception ex)
            {
                ExceptionMngr.WriteEvent("GetShippingDocumentAddress" + doc.DocNumber, ListValues.EventType.Error, ex, null, ListValues.ErrorCategory.ErpConnection);
                //throw;
            }

            return list;
        }