public void SaveMPAItem(Guid txID, long documentID)
        {
            MPADocumentDataSet mpaItemDS = (MPADocumentDataSet)TransactionService.GetDS(txID);

            // Insert, Delete TADocumentTraveller.
            ScgeAccountingDaoProvider.MPAItemDao.Persist(mpaItemDS.MPAItem);
        }
        public System.Data.DataSet PrepareDS(long documentID)
        {
            MPADocumentDataSet documentDS = (MPADocumentDataSet)this.PrepareDataToDataset(documentID, false);

            documentDS.AcceptChanges();

            return(documentDS);
        }
        public DataTable DeleteMPAItemTransaction(Guid txID, long MPAItemID)
        {
            MPADocumentDataSet MPAItemDS = (MPADocumentDataSet)TransactionService.GetDS(txID);

            MPADocumentDataSet.MPAItemRow mpaItemRow = MPAItemDS.MPAItem.FindByMPAItemID(MPAItemID);
            mpaItemRow.Delete();

            return(MPAItemDS.MPAItem);
        }
        public void UpdateMPADocumentTransaction(Guid txID, MPADocument mpaDocument)
        {
            Spring.Validation.ValidationErrors errors = new Spring.Validation.ValidationErrors();

            MPADocumentDataSet mpaDocumentDS = (MPADocumentDataSet)TransactionService.GetDS(txID);

            MPADocumentDataSet.MPADocumentRow mpaDocumentRow = mpaDocumentDS.MPADocument.FindByMPADocumentID(mpaDocument.MPADocumentID);

            mpaDocumentRow.BeginEdit();

            mpaDocumentRow.DocumentID = mpaDocument.DocumentID.DocumentID;

            //if (mpaDocument.StartDate < DateTime.Today)
            //{
            //    errors.AddError("Provider.Error", new Spring.Validation.ErrorMessage("StartDateMoreOrEqualToDay"));
            //}

            if (mpaDocument.StartDate > mpaDocument.EndDate)
            {
                errors.AddError("Provider.Error", new Spring.Validation.ErrorMessage("StartDateLessOrEqualEndDate"));
            }

            if (mpaDocument.StartDate.Equals(DateTime.MinValue))
            {
                errors.AddError("Provider.Error", new Spring.Validation.ErrorMessage("StartDateIsRequired"));
            }
            else
            {
                mpaDocumentRow.StartDate = mpaDocument.StartDate;
            }

            if (mpaDocument.EndDate.Equals(DateTime.MinValue))
            {
                errors.AddError("Provider.Error", new Spring.Validation.ErrorMessage("EndDateIsRequired"));
            }
            else
            {
                mpaDocumentRow.EndDate = mpaDocument.EndDate;
            }

            if (!errors.IsEmpty)
            {
                throw new ServiceValidationException(errors);
            }

            mpaDocumentRow.Active  = mpaDocument.Active;
            mpaDocumentRow.CreBy   = UserAccount.UserID;
            mpaDocumentRow.CreDate = DateTime.Now;
            mpaDocumentRow.UpdBy   = UserAccount.UserID;
            mpaDocumentRow.UpdDate = DateTime.Now;
            mpaDocumentRow.UpdPgm  = UserAccount.CurrentProgramCode;

            mpaDocumentRow.EndEdit();
        }
        public long AddMPADocumentTransaction(Guid txID)
        {
            //Initial Data for another table.
            MPADocumentDataSet mpaDocumentDS = (MPADocumentDataSet)TransactionService.GetDS(txID);

            MPADocumentDataSet.DocumentRow documentRow = mpaDocumentDS.Document.NewDocumentRow(); //create new row to dataset.
            mpaDocumentDS.Document.AddDocumentRow(documentRow);                                   //add new row to dataset.

            MPADocumentDataSet.MPADocumentRow mpaDocumentRow = mpaDocumentDS.MPADocument.NewMPADocumentRow();
            mpaDocumentRow.DocumentID = documentRow.DocumentID;
            mpaDocumentDS.MPADocument.AddMPADocumentRow(mpaDocumentRow);

            return(mpaDocumentRow.MPADocumentID);
        }
        public long AddMPAItemTransaction(Guid txID, MPAItem mpaItem)
        {
            MPADocumentDataSet mpaItemDS = (MPADocumentDataSet)TransactionService.GetDS(txID);

            MPADocumentDataSet.MPAItemRow mpaItemRow = mpaItemDS.MPAItem.NewMPAItemRow();

            //mpaItemRow.MPAItemID = mpaItem.MPAItemID;
            mpaItemRow.MPADocumentID = mpaItem.MPADocumentID.MPADocumentID;
            mpaItemRow.UserID        = mpaItem.UserID.Userid;
            mpaItemRow.UpdBy         = UserAccount.UserID;
            mpaItemRow.UpdDate       = DateTime.Now;
            mpaItemRow.UpdPgm        = UserAccount.CurrentProgramCode;

            mpaItemDS.MPAItem.AddMPAItemRow(mpaItemRow);
            return(mpaItemRow.MPAItemID);
        }
        public void PrepareDataToDataset(MPADocumentDataSet MPAItemDS, long mpaDocumentID)
        {
            IList <MPAItem> mpaItemList = ScgeAccountingQueryProvider.MPAItemQuery.FindMPAItemByMPADocumentID(mpaDocumentID);

            //MPADocumentDataSet.MPAItemRow mpaItemRow = MPAItemDS.MPAItem.NewMPAItemRow(); ;

            foreach (MPAItem mpaItem in mpaItemList)
            {
                MPADocumentDataSet.MPAItemRow mpaItemDataRow = MPAItemDS.MPAItem.NewMPAItemRow();

                mpaItemDataRow.MPAItemID     = mpaItem.MPAItemID;
                mpaItemDataRow.MPADocumentID = mpaItem.MPADocumentID.MPADocumentID;
                mpaItemDataRow.UserID        = mpaItem.UserID.Userid;
                if (mpaItem.ActualAmount != null)
                {
                    mpaItemDataRow.ActualAmount = mpaItem.ActualAmount;
                }
                if (mpaItem.ActualAmountNotExceed != null)
                {
                    mpaItemDataRow.ActualAmountNotExceed = mpaItem.ActualAmountNotExceed;
                }
                if (mpaItem.AmountCompanyPackage != null)
                {
                    mpaItemDataRow.AmountCompanyPackage = mpaItem.AmountCompanyPackage;
                }
                if (mpaItem.TotalAmount != null)
                {
                    mpaItemDataRow.TotalAmount = mpaItem.TotalAmount;
                }
                mpaItemDataRow.MobilePhoneNo = mpaItem.MobilePhoneNo;
                mpaItemDataRow.MobileBrand   = mpaItem.MobileBrand;
                mpaItemDataRow.MobileModel   = mpaItem.MobileModel;
                mpaItemDataRow.CreBy         = UserAccount.UserID;
                mpaItemDataRow.CreDate       = DateTime.Now;
                mpaItemDataRow.UpdBy         = UserAccount.UserID;
                mpaItemDataRow.UpdDate       = DateTime.Now;
                mpaItemDataRow.UpdPgm        = UserAccount.CurrentProgramCode;

                // Add document initiator to datatable taDocumentDS.
                MPAItemDS.MPAItem.AddMPAItemRow(mpaItemDataRow);
            }
        }
        public long SaveMPADocument(Guid txID, long mpaDocumentID)
        {
            MPADocumentDataSet mpaDocumentDS = (MPADocumentDataSet)TransactionService.GetDS(txID);

            MPADocumentDataSet.MPADocumentRow mpaDocumentRow = mpaDocumentDS.MPADocument.FindByMPADocumentID(mpaDocumentID);
            long documentID = mpaDocumentRow.DocumentID;

            // Insert, Update SCGDocument.
            // Insert, Update, Delete DocumentInitiator.
            // Insert, Delete DocumentAttachment.
            documentID = SCGDocumentService.SaveSCGDocument(txID, documentID);

            // Insert, Update, Delete MPADocument.
            mpaDocumentID = ScgeAccountingDaoProvider.MPADocumentDao.Persist(mpaDocumentDS.MPADocument);

            // Insert, Update, Delete MPAItem.
            MPAItemService.SaveMPAItem(txID, documentID);

            return(mpaDocumentID);
        }
        public void UpdateMPAItemTransaction(Guid txID, MPAItem mpaItem)
        {
            Spring.Validation.ValidationErrors errors = new Spring.Validation.ValidationErrors();

            MPADocumentDataSet MPAItemDS = (MPADocumentDataSet)TransactionService.GetDS(txID);

            MPADocumentDataSet.MPAItemRow mpaItemRow = MPAItemDS.MPAItem.FindByMPAItemID(mpaItem.MPAItemID);


            mpaItemRow.BeginEdit();


            mpaItemRow.UserID = mpaItem.UserID.Userid;
            if (mpaItem.ActualAmount != null)
            {
                mpaItemRow.ActualAmount = mpaItem.ActualAmount;
            }
            if (mpaItem.ActualAmountNotExceed != null)
            {
                mpaItemRow.ActualAmountNotExceed = mpaItem.ActualAmountNotExceed;
            }
            if (mpaItem.AmountCompanyPackage != null)
            {
                mpaItemRow.AmountCompanyPackage = mpaItem.AmountCompanyPackage;
            }
            if (mpaItem.TotalAmount != null)
            {
                mpaItemRow.TotalAmount = mpaItem.TotalAmount;
            }
            mpaItemRow.MobilePhoneNo = mpaItem.MobilePhoneNo;
            mpaItemRow.MobileBrand   = mpaItem.MobileBrand;
            mpaItemRow.MobileModel   = mpaItem.MobileModel;
            mpaItemRow.CreBy         = UserAccount.UserID;
            mpaItemRow.CreDate       = DateTime.Now;
            mpaItemRow.UpdBy         = UserAccount.UserID;
            mpaItemRow.UpdDate       = DateTime.Now;
            mpaItemRow.UpdPgm        = UserAccount.CurrentProgramCode;

            mpaItemRow.EndEdit();
        }
        public void ChangeRequesterMAPItem(Guid txID, MPAItem mpaItem)
        {
            MPADocumentDataSet mpaItemDS = (MPADocumentDataSet)TransactionService.GetDS(txID);

            MPADocumentDataSet.MPAItemRow mpaItemRow = mpaItemDS.MPAItem.FindByMPAItemID(mpaItem.MPAItemID);

            mpaItemRow.BeginEdit();

            //mpaItemRow.MPAItemID = mpaItem.MPAItemID;
            mpaItemRow.UserID                = mpaItem.UserID.Userid;
            mpaItemRow.ActualAmount          = mpaItem.ActualAmount;
            mpaItemRow.ActualAmountNotExceed = mpaItem.ActualAmountNotExceed;
            mpaItemRow.AmountCompanyPackage  = mpaItem.AmountCompanyPackage;
            mpaItemRow.TotalAmount           = mpaItem.TotalAmount;
            mpaItemRow.MobilePhoneNo         = mpaItem.MobilePhoneNo;
            mpaItemRow.MobileBrand           = mpaItem.MobileBrand;
            mpaItemRow.MobileModel           = mpaItem.MobileModel;
            mpaItemRow.UpdBy   = UserAccount.UserID;
            mpaItemRow.UpdDate = DateTime.Now;
            mpaItemRow.UpdPgm  = UserAccount.CurrentProgramCode;

            mpaItemRow.EndEdit();
        }
        public System.Data.DataSet PrepareDS()
        {
            MPADocumentDataSet documentDS = new MPADocumentDataSet();

            return(documentDS);
        }
        public System.Data.DataSet PrepareDataToDataset(long documentID, bool isCopy)
        {
            MPADocumentDataSet mpaDocumentDS = new MPADocumentDataSet();

            MPADocument mpaDocument = ScgeAccountingQueryProvider.MPADocumentQuery.GetMPADocumentByDocumentID(documentID);

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

            if (mpaDocument == null)
            {
                errors.AddError("Provider.Error", new Spring.Validation.ErrorMessage("MPADocumentNotFound"));
            }
            if (!errors.IsEmpty)
            {
                throw new ServiceValidationException(errors);
            }

            // Prepare Data to Document datatable.
            if (!isCopy)
            {
                SCGDocumentService.PrepareDataToDataset(mpaDocumentDS, documentID);
            }
            else
            {
                SCGDocumentService.PrepareDataInternalToDataset(mpaDocumentDS, documentID, isCopy);
            }

            // Set data to Document row
            MPADocumentDataSet.MPADocumentRow mpaDocumentRow = mpaDocumentDS.MPADocument.NewMPADocumentRow();

            mpaDocumentRow.MPADocumentID = mpaDocument.MPADocumentID;

            if (!isCopy)
            {
                if (mpaDocument.DocumentID != null)
                {
                    mpaDocumentRow.DocumentID = mpaDocument.DocumentID.DocumentID;
                }
            }
            else
            {
                if (mpaDocumentDS.Document.Rows.Count > 0)
                {
                    MPADocumentDataSet.DocumentRow docRow = (MPADocumentDataSet.DocumentRow)mpaDocumentDS.Document.Rows[0];
                    mpaDocumentRow.DocumentID = docRow.DocumentID;
                }
            }

            mpaDocumentRow.StartDate = mpaDocument.StartDate;
            mpaDocumentRow.EndDate   = mpaDocument.EndDate;

            mpaDocumentRow.Active  = mpaDocument.Active;
            mpaDocumentRow.CreBy   = mpaDocument.CreBy;
            mpaDocumentRow.CreDate = mpaDocument.CreDate;
            mpaDocumentRow.UpdBy   = mpaDocument.UpdBy;
            mpaDocumentRow.UpdDate = mpaDocument.UpdDate;
            mpaDocumentRow.UpdPgm  = mpaDocument.UpdPgm;

            // Add ta document row to MPADocument.
            mpaDocumentDS.MPADocument.AddMPADocumentRow(mpaDocumentRow);

            // Prepare Data to MPAItemService Datatable.
            MPAItemService.PrepareDataToDataset(mpaDocumentDS, mpaDocument.MPADocumentID);


            return(mpaDocumentDS);
        }