Exemple #1
0
        public IActionResult Record(Models.o23RecordViewModel v, bool change_entity_only)
        {
            if (change_entity_only)
            {
                v.Rec.o23RecordPid   = 0;
                v.Rec.RecordPidAlias = "";

                RefreshState(v);

                return(View(v));
            }
            if (ModelState.IsValid)
            {
                BO.o23Doc c = new BO.o23Doc();
                if (v.Rec.pid > 0)
                {
                    c = Factory.o23DocBL.Load(v.Rec.pid);
                }

                c.o23Code      = v.Rec.o23Code;
                c.o23Name      = v.Rec.o23Name;
                c.o23Entity    = v.Rec.o23Entity;
                c.o23RecordPid = v.Rec.o23RecordPid;

                c.o23Memo = v.Rec.o23Memo;
                c.o23Date = v.Rec.o23Date;
                c.b02ID   = v.Rec.b02ID;

                c.j02ID_Owner = v.Rec.j02ID_Owner;

                c.ValidUntil = v.Toolbar.GetValidUntil(c);
                c.ValidFrom  = v.Toolbar.GetValidFrom(c);

                string strTempDir   = _app.TempFolder;
                string strUploadDir = _app.UploadFolder;

                List <BO.o27Attachment> lisO27 = BO.BASFILE.CopyTempFiles2Upload(_app.TempFolder, v.Guid, _app.UploadFolder);

                v.Rec.pid = Factory.o23DocBL.Save(c, lisO27, BO.BAS.ConvertString2ListInt(v.o27IDs4Delete));
                if (v.Rec.pid > 0)
                {
                    Factory.o51TagBL.SaveTagging("o23", v.Rec.pid, v.TagPids);
                    v.SetJavascript_CallOnLoad(v.Rec.pid);
                    return(View(v));
                }
            }



            RefreshState(v);
            this.Notify_RecNotSaved();



            return(View(v));
        }
Exemple #2
0
        public IActionResult Record(int pid, bool isclone, string recprefix, int recpid)
        {
            if (!this.TestIfUserEditor(true, true))
            {
                return(this.StopPageCreateEdit(true));
            }
            var v = new Models.o23RecordViewModel();

            v.Guid = BO.BAS.GetGuid();
            if (pid > 0)
            {
                v.Rec = Factory.o23DocBL.Load(pid);
                if (v.Rec == null)
                {
                    return(RecNotFound(v));
                }
                if (!this.TestIfRecordEditable(v.Rec.j02ID_Owner))
                {
                    return(this.StopPageEdit(true));
                }
                var tg = Factory.o51TagBL.GetTagging("o23", pid);
                v.TagPids  = tg.TagPids;
                v.TagNames = tg.TagNames;
                v.TagHtml  = tg.TagHtml;
            }
            else
            {
                v.Rec        = new BO.o23Doc();
                v.Rec.entity = "o23";
                if (string.IsNullOrEmpty(recprefix))
                {
                    v.Rec.o23Entity = "p28Company";
                }
                else
                {
                    v.Rec.o23Entity = BL.TheEntities.ByPrefix(recprefix).TableName;
                    if (recpid > 0)
                    {
                        v.Rec.o23RecordPid   = recpid;
                        v.Rec.RecordPidAlias = Factory.CBL.GetRecordAlias(v.Rec.o23Entity, recpid);
                    }
                }

                v.Rec.o23Code = Factory.CBL.EstimateRecordCode("o23");
            }



            RefreshState(v);

            if (isclone)
            {
                v.Toolbar.MakeClone();
                v.Rec.o23Code = Factory.CBL.EstimateRecordCode("o23");
            }

            if (pid > 0 && !isclone)
            {
                v.lisO27 = Factory.o23DocBL.GetListO27(pid);
            }

            return(View(v));
        }