Exemple #1
0
        public long SaveAvAdvance(Guid txid, long advanceId)
        {
            AdvanceDataSet advanceDataset = (AdvanceDataSet)TransactionService.GetDS(txid);

            AdvanceDataSet.AvAdvanceDocumentRow row = advanceDataset.AvAdvanceDocument.FindByAdvanceID(advanceId);
            long documentID = row.DocumentID;

            documentID = SCGDocumentService.SaveSCGDocument(txid, documentID);
            //insert update or delete AvAdvanveDocument
            advanceId = ScgeAccountingDaoProvider.AvAdvanceDocumentDao.Persist(advanceDataset.AvAdvanceDocument);

            //inset update or delete AvAdvanceItem
            AvAdvanceItemService.saveAdvanceItem(txid, advanceId);

            return(advanceId);
        }
Exemple #2
0
        public AdvanceDataSet PrepareDataToDs(long documentId)
        {
            AdvanceDataSet advanceDs = new AdvanceDataSet();
            //ดึงจาก base มาใส่ใน DataSet
            AvAdvanceDocument avDb = ScgeAccountingQueryProvider.AvAdvanceDocumentQuery.GetAvAdvanceByDocumentID(documentId);

            Spring.Validation.ValidationErrors errors = new Spring.Validation.ValidationErrors();

            if (avDb == null)
            {
                errors.AddError("Provider.Error", new Spring.Validation.ErrorMessage("NoAvAdvanceFound"));
            }
            if (!errors.IsEmpty)
            {
                throw new ServiceValidationException(errors);
            }
            // Prepare Data to Document datatable.
            SCGDocumentService.PrepareDataToDataset(advanceDs, documentId);

            // Set data to Advance Document row in advanceDs.
            AdvanceDataSet.AvAdvanceDocumentRow avRow = advanceDs.AvAdvanceDocument.NewAvAdvanceDocumentRow();
            avRow.AdvanceID  = avDb.AdvanceID;
            avRow.DocumentID = avDb.DocumentID.DocumentID;
            if (avDb.TADocumentID.HasValue)
            {
                avRow.TADocumentID = avDb.TADocumentID.Value;
            }
            else
            {
                avRow.SetTADocumentIDNull();
            }
            avRow.AdvanceType = avDb.AdvanceType;
            if (avDb.PBID != null && avDb.PBID.Pbid > 0)
            {
                avRow.PBID = avDb.PBID.Pbid;
            }
            else
            {
                avRow.SetPBIDNull();
            }
            if (avDb.ServiceTeamID != null && avDb.ServiceTeamID.ServiceTeamID > 0)
            {
                avRow.ServiceTeamID = avDb.ServiceTeamID.ServiceTeamID;
            }
            else
            {
                avRow.SetServiceTeamIDNull();
            }
            avRow.RequestDateOfAdvance    = avDb.RequestDateOfAdvance;
            avRow.DueDateOfRemittance     = avDb.DueDateOfRemittance;
            avRow.RequestDateOfRemittance = avDb.RequestDateOfRemittance;
            if (avDb.AdvanceType == ZoneType.Foreign)
            {
                avRow.ArrivalDate = avDb.ArrivalDate.Value;
            }
            avRow.Reason           = avDb.Reason;
            avRow.PerDiemExRateUSD = (decimal)avDb.PerDiemExRateUSD;
            avRow.Amount           = (decimal)avDb.Amount;
            avRow.RemittanceAmount = (decimal)avDb.RemittanceAmount;
            avRow.ExpenseAmount    = (decimal)avDb.ExpenseAmount;
            avRow.Active           = avDb.Active;
            avRow.CreBy            = UserAccount.UserID;
            avRow.CreDate          = DateTime.Now;
            avRow.UpdBy            = UserAccount.UserID;
            avRow.UpdDate          = DateTime.Now;
            avRow.UpdPgm           = UserAccount.CurrentProgramCode;

            if (avDb.MainCurrencyID.HasValue && avDb.MainCurrencyID.Value > 0)
            {
                avRow.MainCurrencyID = avDb.MainCurrencyID.Value;
            }
            else
            {
                avRow.SetMainCurrencyIDNull();
            }

            if (avDb.MainCurrencyAmount.HasValue)
            {
                avRow.MainCurrencyAmount = (decimal)avDb.MainCurrencyAmount.Value;
            }
            else
            {
                avRow.SetMainCurrencyAmountNull();
            }

            if (avDb.ExchangeRateForLocalCurrency.HasValue)
            {
                avRow.ExchangeRateForLocalCurrency = (decimal)avDb.ExchangeRateForLocalCurrency.Value;
            }
            else
            {
                avRow.SetExchangeRateForLocalCurrencyNull();
            }

            if (avDb.ExchangeRateMainToTHBCurrency.HasValue)
            {
                avRow.ExchangeRateMainToTHBCurrency = (decimal)avDb.ExchangeRateMainToTHBCurrency.Value;
            }
            else
            {
                avRow.SetExchangeRateMainToTHBCurrencyNull();
            }

            if (avDb.LocalCurrencyAmount.HasValue)
            {
                avRow.LocalCurrencyAmount = (decimal)avDb.LocalCurrencyAmount.Value;
            }
            else
            {
                avRow.SetLocalCurrencyAmountNull();
            }

            if (avDb.IsRepOffice.HasValue)
            {
                avRow.IsRepOffice = avDb.IsRepOffice.Value;
            }
            else
            {
                avRow.SetIsRepOfficeNull();
            }


            if (avDb.RequestDateOfAdvanceApproved.HasValue)
            {
                avRow.RequestDateOfAdvanceApproved = avDb.RequestDateOfAdvanceApproved.Value;
            }
            else
            {
                avRow.SetRequestDateOfAdvanceApprovedNull();
            }

            advanceDs.AvAdvanceDocument.AddAvAdvanceDocumentRow(avRow);

            // Prepare Data to AvAdvanceItem Datatable.
            AvAdvanceItemService.PrepareDataToDataset(advanceDs, avRow.AdvanceID, false);

            advanceDs.AcceptChanges();
            return(advanceDs);
        }
Exemple #3
0
        public AdvanceDataSet PrepareDataToDsTA(long taDocumentID)
        {
            AdvanceDataSet advanceDs = new AdvanceDataSet();
            //ดึงจาก base มาใส่ใน DataSet
            TADocument taDoc = ScgeAccountingQueryProvider.TADocumentQuery.FindProxyByIdentity(taDocumentID);

            Spring.Validation.ValidationErrors errors = new Spring.Validation.ValidationErrors();

            if (taDoc == null)
            {
                errors.AddError("Provider.Error", new Spring.Validation.ErrorMessage("NoTADocumentFound"));
            }
            if (!errors.IsEmpty)
            {
                throw new ServiceValidationException(errors);
            }
            // Prepare Data to Document datatable.

            AdvanceDataSet.DocumentRow docRow = advanceDs.Document.NewDocumentRow();
            docRow.ApproverID  = taDoc.DocumentID.ApproverID.Userid;
            docRow.RequesterID = taDoc.DocumentID.RequesterID.Userid;
            docRow.RequesterID = taDoc.DocumentID.RequesterID.Userid;
            docRow.CreatorID   = taDoc.DocumentID.CreatorID.Userid;
            docRow.CompanyID   = taDoc.DocumentID.CompanyID.CompanyID;
            advanceDs.Document.AddDocumentRow(docRow);


            IList <DocumentInitiator> documentInitiatorList = new List <DocumentInitiator>();

            documentInitiatorList = ScgeAccountingQueryProvider.DocumentInitiatorQuery.GetDocumentInitiatorByDocumentID(taDoc.DocumentID.DocumentID);
            foreach (DocumentInitiator initiator in documentInitiatorList)
            {
                // Set data to document initiator datatable.
                AdvanceDataSet.DocumentInitiatorRow docInitial = advanceDs.DocumentInitiator.NewDocumentInitiatorRow();
                //docInitial.ini = initiator.InitiatorID;
                //if (initiator.DocumentID != null)
                //{
                //    initiatorRow["DocumentID"] = initiator.DocumentID.DocumentID;
                //}
                docInitial.InitiatorType = initiator.InitiatorType;
                docInitial.Seq           = initiator.Seq;
                if (initiator.UserID != null)
                {
                    docInitial.UserID = initiator.UserID.Userid;
                }
                docInitial.DoApprove = initiator.DoApprove;
                docInitial.Active    = initiator.Active;
                docInitial.CreBy     = initiator.CreBy;
                docInitial.CreDate   = initiator.CreDate;
                docInitial.UpdBy     = initiator.UpdBy;
                docInitial.UpdDate   = initiator.UpdDate;
                docInitial.UpdPgm    = initiator.UpdPgm;

                // Add document initiator to datatable budgetDocumentDS.
                advanceDs.DocumentInitiator.AddDocumentInitiatorRow(docInitial);
            }
            advanceDs.DocumentAttachment.NewDocumentAttachmentRow();

            // Set data to Advance Document row in advanceDs.
            AdvanceDataSet.AvAdvanceDocumentRow avRow = advanceDs.AvAdvanceDocument.NewAvAdvanceDocumentRow();
            //avRow.AdvanceID = -1;
            avRow.DocumentID   = Convert.ToInt64(advanceDs.Document.Rows[0]["DocumentID"].ToString());
            avRow.TADocumentID = taDoc.TADocumentID;
            //avRow.AdvanceType = taDoc.;
            //if (avDb.PBID != null && avDb.PBID.Pbid > 0)
            //    avRow.PBID = avDb.PBID.Pbid;
            //else
            //    avRow.SetPBIDNull();
            //avRow.ServiceTeamID = avDb.ServiceTeamID.ServiceTeamID;
            if (taDoc.TravelBy.Equals(TravellBy.Foreign))
            {
                avRow.ArrivalDate = taDoc.ToDate;
                avRow.AdvanceType = ZoneType.Foreign;
            }
            else
            {
                avRow.AdvanceType = ZoneType.Domestic;
            }
            //avRow.RequestDateOfAdvance = avDb.RequestDateOfAdvance;
            //avRow.DueDateOfRemittance = avDb.DueDateOfRemittance;
            //avRow.RequestDateOfRemittance = avDb.RequestDateOfRemittance;
            //if (avDb.AdvanceType == ZoneType.Foreign)
            //    avRow.ArrivalDate = avDb.ArrivalDate.Value;
            //avRow.Reason = avDb.Reason;
            //avRow.PerDiemExRateUSD = (decimal)avDb.PerDiemExRateUSD;
            //avRow.Amount = (decimal)avDb.Amount;
            //avRow.RemittanceAmount = (decimal)avDb.RemittanceAmount;
            //avRow.ExpenseAmount = (decimal)avDb.ExpenseAmount;
            avRow.Active  = true;
            avRow.CreBy   = UserAccount.UserID;
            avRow.CreDate = DateTime.Now;
            avRow.UpdBy   = UserAccount.UserID;
            avRow.UpdDate = DateTime.Now;
            avRow.UpdPgm  = UserAccount.CurrentProgramCode;
            advanceDs.AvAdvanceDocument.AddAvAdvanceDocumentRow(avRow);

            // Prepare Data to AvAdvanceItem Datatable.
            AvAdvanceItemService.PrepareDataToDataset(advanceDs, avRow.AdvanceID, false);

            //advanceDs.AcceptChanges();
            return(advanceDs);
        }