Esempio n. 1
0
        public static DB.ORG_TRX_Header CopyDocument(DB.ORG_TRX_Header entry)
        {
            //DB.SYS_DOC_Header newDocument = BL.SYS.SYS_DOC_Document.New;
            DB.ORG_TRX_Header newTransaction = BL.ORG.ORG_TRX_Header.New;// newDocument.ORG_TRX_Header.FirstOrDefault();

            //BL.ApplicationDataContext.DeepClone(entry, newDocument);
            ////BL.ApplicationDataContext.DeepClone(entry.ORG_TRX_Header.FirstOrDefault(), newTransaction);
            //foreach (DB.SYS_DOC_Line line in entry.SYS_DOC_Line)
            //{
            //    DB.SYS_DOC_Line newLine = BL.SYS.SYS_DOC_Line.New;
            //    BL.ApplicationDataContext.DeepClone(line, newLine);
            //    newDocument.SYS_DOC_Line.Add(newLine);
            //}
            return(newTransaction);
        }
Esempio n. 2
0
        internal static String Save(DB.ORG_TRX_Header entry, DataContext dataContext)
        {
            try
            {
                if (dataContext.EntityOrganisationContext.GetEntityState(entry) == System.Data.Entity.EntityState.Detached)
                {
                    dataContext.EntityOrganisationContext.ORG_TRX_Header.Add(entry);
                }
            }
            catch (System.Data.Entity.Validation.DbEntityValidationException)
            {
                return(dataContext.PackageValidationException());
            }

            return("Success");
        }
Esempio n. 3
0
        private static DB.SYS_DOC_Header CopyDocument(DB.SYS_DOC_Header entity, DataContext dataContext)
        {
            DB.SYS_DOC_Header docHeader = ApplicationDataContext.DeepClone <DB.SYS_DOC_Header>(entity, SYS.SYS_DOC_Document.New(SYS.SYS_DOC_Type.Quote));
            docHeader.DocumentNumber = null;
            DB.ORG_TRX_Header trxHeader = null;
            if (entity.ORG_TRX_Header != null)
            {
                trxHeader = ApplicationDataContext.DeepClone <DB.ORG_TRX_Header>(entity.ORG_TRX_Header, ORG.ORG_TRX_Header.New);
            }
            DB.JOB_Header jobHeader = null;
            if (entity.JOB_Header != null)
            {
                jobHeader = ApplicationDataContext.DeepClone <DB.JOB_Header>(entity.JOB_Header, JOB.JOB_Header.New);
            }

            foreach (DB.SYS_DOC_Line line in entity.SYS_DOC_Line)
            {
                DB.SYS_DOC_Line newLine = ApplicationDataContext.DeepClone <DB.SYS_DOC_Line>(line, SYS.SYS_DOC_Line.New);

                //Werner: Wanted to do this here but some of the document needs these values to generate another document
                ////Need to clear these when copying a documents lines
                //newLine.QtyReceived = 0;
                //newLine.QtyOutstanding = 0;
                //TODO : Just check but this should always be null as the DeepCopy
                //ignores all DB.* types
                if (line.LineItem != null)
                {
                    newLine.LineItem = line.LineItem;
                }
                else
                {
                    if (!dataContext.ReadonlyContext.VW_LineItem.Any(n => n.Id == newLine.ItemId && n.TypeId == (byte)SYS.SYS_Type.Account))
                    {
                        newLine.LineItem    = dataContext.ReadonlyContext.VW_LineItem.FirstOrDefault(n => n.Id == newLine.ItemId);
                        newLine.UnitAverage = newLine.LineItem.UnitAverage;
                        newLine.UnitCost    = newLine.LineItem.UnitCost;
                    }
                }

                docHeader.SYS_DOC_Line.Add(newLine);
            }

            docHeader.ORG_TRX_Header = trxHeader;
            docHeader.JOB_Header     = jobHeader;

            return(docHeader);
        }