예제 #1
0
        public void InitializeObject(int docEntry, Model.EnumObjType objType, int baseDocEntry, Model.EnumObjType baseObjType)
        {
            string xml = string.Empty;

            DocumentDI documentBaseDI = new DocumentDI();

            documentBaseDI.InitializeObject(baseDocEntry, baseObjType);
            try
            {
                xml = documentBaseDI.GetXmlForDI();
            }
            finally
            {
                documentBaseDI.FinalizeObject();
            }

            for (int lineNum = 0; lineNum < 100; lineNum++)
            {
                string replaceString = string.Format(@"<LineNum>{0}</LineNum>", lineNum);

                if (xml.IndexOf(replaceString) == -1)
                {
                    break;
                }
                else
                {
                    string newString = string.Format(@"<LineNum>{0}</LineNum>				    
				    <BaseType>{1}</BaseType>
				    <BaseEntry>{2}</BaseEntry>
				    <BaseLine>{3}</BaseLine>"                , lineNum, (int)objType, baseDocEntry, lineNum);

                    xml = xml.Replace(replaceString, newString);
                }
            }

            xml = xml.Replace("<Object>" + ((int)baseObjType).ToString() + "</Object>", "<Object>" + ((int)objType).ToString() + "</Object>");

            xml = xml.Replace("<DocEntry>" + baseDocEntry.ToString() + "</DocEntry>", "");

            _businessObject = GetDIObject(objType);

            if (!_businessObject.GetByKey(docEntry))
            {
                _newObject = true;
            }

            _businessObject.UpdateFromXML(xml);

            if (_newObject)
            {
                _businessObject.DocNum = 0;
            }

            _businessObjectDraft = GetDIObject(Model.EnumObjType.Draft);
            _businessObjectDraft.DocObjectCode = GetObjType(objType);
        }
예제 #2
0
        public void CopyFrom(int baseDocEntry, Model.EnumObjType objType)
        {
            string xml = string.Empty;

            DocumentDI documentBaseDI = new DocumentDI();

            documentBaseDI.InitializeObject(baseDocEntry, objType);
            try
            {
                xml = documentBaseDI.GetXmlForDI();
            }
            finally
            {
                documentBaseDI.FinalizeObject();
            }

            for (int lineNum = 0; lineNum < 100; lineNum++)
            {
                string replaceString = string.Format(@"<LineNum>{0}</LineNum>", lineNum);

                if (xml.IndexOf(replaceString) == -1)
                {
                    break;
                }
                else
                {
                    string newString = string.Format(@"<LineNum>{0}</LineNum>				    
				    <BaseType>{1}</BaseType>
				    <BaseEntry>{2}</BaseEntry>
				    <BaseLine>{3}</BaseLine>"                , lineNum, (int)objType, baseDocEntry, lineNum);

                    xml = xml.Replace(replaceString, newString);
                }
            }

            _businessObject.UpdateFromXML(xml);

            _businessObjectDraft = GetDIObject(Model.EnumObjType.Draft);
            _businessObjectDraft.DocObjectCode = GetObjType(objType);
        }