protected override void OnSaving()
 {
     base.OnSaving();
     if (!(Session is NestedUnitOfWork) &&
         (Session.DataLayer != null) &&
         (Session.ObjectLayer is SimpleObjectLayer)
         )
     {
         if (Session.IsNewObject(this))
         {
             PurchaseQuotationDocStatus ds = new PurchaseQuotationDocStatus(Session);
             ds.DocStatus        = DocStatus.Draft;
             ds.DocStatusRemarks = "";
             if (!GeneralValues.IsNetCore)
             {
                 ds.CreateUser = Session.GetObjectByKey <SystemUsers>(SecuritySystem.CurrentUserId);
             }
             else
             {
                 ds.CreateUser = Session.FindObject <SystemUsers>(CriteriaOperator.Parse("UserName=?", GeneralValues.NetCoreUserName));
             }
             ds.CreateDate = DateTime.Now;
             this.DocumentStatus.Add(ds);
         }
         else
         {
         }
     }
 }
        //public void assignCurrDocStatus()
        //{
        //    if (DocumentStatus.Count > 0)
        //        CurrDocStatus = DocumentStatus.OrderByDescending<PurchaseQuotationDocStatus, DateTime?>(pp => pp.CreateDate).First<PurchaseQuotationDocStatus>().DocStatus;

        //}
        public void AddDocStatus(DocStatus newstatus, string remarks)
        {
            PurchaseQuotationDocStatus ds = new PurchaseQuotationDocStatus(Session);

            ds.DocStatus        = newstatus;
            ds.DocStatusRemarks = remarks;
            if (!GeneralValues.IsNetCore)
            {
                ds.CreateUser = Session.GetObjectByKey <SystemUsers>(SecuritySystem.CurrentUserId);
            }
            else
            {
                ds.CreateUser = Session.FindObject <SystemUsers>(CriteriaOperator.Parse("UserName=?", GeneralValues.NetCoreUserName));
            }
            ds.CreateDate = DateTime.Now;
            this.DocumentStatus.Add(ds);
        }