Beispiel #1
0
        public void LoadEvent(string eventName, string stateName)
        {
            Spring.Validation.ValidationErrors errors = new Spring.Validation.ValidationErrors();

            try
            {
                IList <SearchResultData> resultList = new List <SearchResultData>();
                long workFlowID;
                int  workFlowStateEventID;

                if (stateName.Equals(WorkFlowStateFlag.Draft))
                {
                    resultList = ctlInboxEmployeeSearchResultDraft.GetGridViewDataList();
                }
                if (stateName.Equals(WorkFlowStateFlag.WaitInitial))
                {
                    resultList = ctlInboxEmployeeSearchResultWaitInitial.GetGridViewDataList();
                }
                if (stateName.Equals(WorkFlowStateFlag.WaitApprove))
                {
                    resultList = ctlInboxEmployeeSearchResultWaitApprove.GetGridViewDataList();
                }
                if (stateName.Equals(WorkFlowStateFlag.WaitAgree))
                {
                    resultList = ctlInboxEmployeeSearchResultWaitAgree.GetGridViewDataList();
                }

                foreach (SearchResultData result in resultList)
                {
                    workFlowID           = 0;
                    workFlowStateEventID = 0;
                    WorkFlow workFlow = WorkFlowQueryProvider.WorkFlowQuery.GetWorkFlowByDocumentID(result.DocumentID);

                    if (workFlow != null)
                    {
                        workFlowID           = workFlow.WorkFlowID;
                        workFlowStateEventID = ScgeAccountingQueryProvider.SCGDocumentQuery.GetWorkStateEvent(workFlow.CurrentState.WorkFlowStateID, eventName);

                        object             eventData          = new SubmitResponse(workFlowStateEventID);
                        WorkFlowStateEvent workFlowStateEvent = WorkFlowQueryProvider.WorkFlowStateEventQuery.FindByIdentity(workFlowStateEventID);
                        if (workFlowStateEvent != null)
                        {
                            WorkFlowService.NotifyEvent(workFlowID, workFlowStateEvent.Name, eventData);
                        }
                    }
                }
            }
            catch (ServiceValidationException ex)
            {
                errors.MergeErrors(ex.ValidationErrors);
            }
            ctlUpdatePanelValidation.Update();
        }
Beispiel #2
0
        public long Save()
        {
            Spring.Validation.ValidationErrors errors = new Spring.Validation.ValidationErrors();

            CADocumentDataSet caDocumentDS = (CADocumentDataSet)TransactionService.GetDS(this.TransactionID);

            if (caDocumentDS == null)
            {
                OnDsNull();
            }
            CADocumentDataSet.CADocumentRow caDocumentRow = caDocumentDS.CADocument.FindByCADocumentID(this.CADocumentID);
            long tempDocumentID = caDocumentRow.DocumentID;

            #region SCGDocument
            SCGDocument scgDocument = new SCGDocument(tempDocumentID);
            if (!string.IsNullOrEmpty(ctlCompanyField.CompanyID))
            {
                scgDocument.CompanyID = new DbCompany(UIHelper.ParseLong(ctlCompanyField.CompanyID));
            }
            scgDocument.CreatorID = new SuUser(UIHelper.ParseLong(ctlCreatorData.UserID));
            if (!string.IsNullOrEmpty(ctlRequesterData.UserID))
            {
                scgDocument.RequesterID = new SuUser(UIHelper.ParseLong(ctlRequesterData.UserID));
            }
            scgDocument.Subject = ctlSubject.Text;
            if (!string.IsNullOrEmpty(ctlApproverData.UserID))
            {
                scgDocument.ApproverID = new SuUser(UIHelper.ParseLong(ctlApproverData.UserID));
            }

            scgDocument.DocumentType = new SS.Standard.WorkFlow.DTO.DocumentType(DocumentTypeID.CADocument);


            scgDocument.Memo   = ctlMemo.Text;
            scgDocument.Active = true;

            try
            {
                // Save SCG Document to Transaction.
                SCGDocumentService.UpdateTransactionDocument(this.TransactionID, scgDocument, false, true);
            }
            catch (ServiceValidationException ex)
            {
                errors.MergeErrors(ex.ValidationErrors);
            }
            #endregion SCGDocument

            #region CADocument
            CADocument caDocument = new CADocument(this.CADocumentID);

            caDocument.DocumentID = scgDocument;

            if (ctlSomeTime.Checked)
            {
                caDocument.IsTemporary = true;
                try
                {
                    if (ctlStartDateSumtime.Value != null)
                    {
                        caDocument.StartDate = ctlStartDateSumtime.Value.Value;
                    }

                    if (ctlEndDateSumtime.Value != null)
                    {
                        caDocument.EndDate = ctlEndDateSumtime.Value.Value;
                    }
                }
                catch (FormatException fex)
                {
                    errors.AddError("Provider.Error", new Spring.Validation.ErrorMessage("Invalid_Date_Format"));
                    throw new ServiceValidationException(errors);
                }
            }
            else if (ctlRegular.Checked)
            {
                caDocument.IsTemporary = false;
                try
                {
                    if (ctlStartDate.Value != null)
                    {
                        caDocument.StartDate = ctlStartDate.Value.Value;
                    }

                    if (ctlEndDate.Value != null)
                    {
                        caDocument.EndDate = ctlEndDate.Value.Value;
                    }
                }
                catch (FormatException fex)
                {
                    errors.AddError("Provider.Error", new Spring.Validation.ErrorMessage("Invalid_Date_Format"));
                    throw new ServiceValidationException(errors);
                }
            }

            caDocument.CarLicenseNo = ctlCarLicenseNo.Text;
            caDocument.Brand        = ctlBrand.Text;
            caDocument.Model        = ctlModel.Text;

            switch (ctlDropDownListCategory.SelectedValue)
            {
            case "1":
                caDocument.OwnerType = OwnerMileage.Employee;
                break;

            case "2":
                caDocument.OwnerType = OwnerMileage.Company;
                break;

            default:
                break;
            }

            switch (ctlDropDownListType.SelectedValue)
            {
            case "1":
                caDocument.CarType = TypeOfCar.PrivateCar;
                break;

            case "2":
                caDocument.CarType = TypeOfCar.MotorCycle;
                break;

            case "3":
                caDocument.CarType = TypeOfCar.Pickup;
                break;

            default:
                break;
            }

            if (caDocument.IsTemporary)
            {
                if (ctlWorkInArea.Checked || ctlWorkOutOfArea.Checked)
                {
                    if (ctlWorkInArea.Checked)
                    {
                        caDocument.IsWorkArea = true;
                    }
                    else if (ctlWorkOutOfArea.Checked)
                    {
                        caDocument.IsWorkArea = false;
                        caDocument.Remark     = ctlWorkOutOfAreatxt.Text;
                    }
                }
                else
                {
                    errors.AddError("Provider.Error", new Spring.Validation.ErrorMessage("Please Select Work Area."));
                }
            }
            else
            {
                if (ctlWorkInArea.Checked)
                {
                    caDocument.IsWorkArea = true;
                }
                else if (ctlWorkOutOfArea.Checked)
                {
                    caDocument.IsWorkArea = false;
                    caDocument.Remark     = ctlWorkOutOfAreatxt.Text;
                }
            }

            caDocument.Active = true;

            try
            {
                // Get ta document information and save to transaction.
                CADocumentService.UpdateCADocumentTransaction(this.TransactionID, caDocument);
            }
            catch (ServiceValidationException ex)
            {
                errors.MergeErrors(ex.ValidationErrors);
            }

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

            #endregion CADocument

            try
            {
                ctlInitiator.Save();
                DocumentInitiatorService.ValidateDocumentInitiator(this.TransactionID, this.CADocumentID);
            }
            catch (ServiceValidationException ex)
            {
                errors.MergeErrors(ex.ValidationErrors);
            }

            if (!errors.IsEmpty)
            {
                // If have some validation error then return error.
                throw new ServiceValidationException(errors);
            }
            else
            {
                return(this.SaveToDatabase());
            }
        }
        public void UpdateTransactionDocument(Guid TxID, SCGDocument document, bool haveReceiver, bool haveApprover)
        {
            Spring.Validation.ValidationErrors errors = new Spring.Validation.ValidationErrors();
            try
            {
                this.ValidateSCGDocument(document, haveReceiver, haveApprover);
            }
            catch (ServiceValidationException ex)
            {
                errors.MergeErrors(ex.ValidationErrors);
            }

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

            DataSet   ds            = TransactionService.GetDS(TxID);
            DataTable documentTable = ds.Tables["Document"];

            if (documentTable.Rows.Count > 0)
            {
                DataRow documentRow = documentTable.Rows[0];
                documentRow.BeginEdit();

                if (document.CompanyID != null)
                {
                    documentRow["CompanyID"] = document.CompanyID.CompanyID;
                }
                if (document.CreatorID != null)
                {
                    documentRow["CreatorID"] = document.CreatorID.Userid;
                }
                if (document.RequesterID != null)
                {
                    documentRow["RequesterID"] = document.RequesterID.Userid;
                }
                if (document.ApproverID != null)
                {
                    documentRow["ApproverID"] = document.ApproverID.Userid;
                }
                if (document.ReceiverID != null)
                {
                    documentRow["ReceiverID"] = document.ReceiverID.Userid;
                }
                //documentRow["DocumentNo"] = document.DocumentNo;
                if (document.DocumentType != null)
                {
                    documentRow["DocumentTypeID"] = document.DocumentType.DocumentTypeID;
                }
                IList <object> advanceEditableField      = AvAdvanceDocumentService.GetEditableFields(document.DocumentID, null);
                IList <object> expenseEditableField      = FnExpenseDocumentService.GetEditableFields(document.DocumentID);
                IList <object> remittanceEditableField   = FnRemittanceService.GetEditableFields(document.DocumentID);
                IList <object> fixedAdvanceEditableField = FixedAdvanceDocumentService.GetEditableFields(document.DocumentID);
                if (advanceEditableField.Contains(AdvanceFieldGroup.VerifyDetail) || expenseEditableField.Contains(ExpenseFieldGroup.VerifyDetail) || remittanceEditableField.Contains(RemittanceFieldGroup.VerifyDetail) || fixedAdvanceEditableField.Contains(FixedAdvanceFieldGroup.VerifyDetail))
                {
                    //add new field
                    if (!string.IsNullOrEmpty(document.BranchCode))
                    {
                        documentRow["BranchCode"] = document.BranchCode;
                    }
                    if (!string.IsNullOrEmpty(document.BusinessArea))
                    {
                        documentRow["BusinessArea"] = document.BusinessArea;
                    }
                    else
                    {
                        documentRow["BusinessArea"] = string.Empty;
                    }

                    if (!string.IsNullOrEmpty(document.Supplementary))
                    {
                        documentRow["Supplementary"] = document.Supplementary;
                    }
                    else
                    {
                        documentRow["Supplementary"] = string.Empty;
                    }

                    if (document.PaymentMethodID.HasValue && document.PaymentMethodID > 0)
                    {
                        documentRow["PaymentMethodID"] = document.PaymentMethodID.Value;
                    }
                    if (document.PostingDate.HasValue && document.PostingDate.Value != DateTime.MinValue)
                    {
                        documentRow["PostingDate"] = document.PostingDate;
                    }
                    if (document.BaseLineDate.HasValue && document.BaseLineDate.Value != DateTime.MinValue)
                    {
                        documentRow["BaseLineDate"] = document.BaseLineDate;
                    }
                    if (!string.IsNullOrEmpty(document.BankAccount))
                    {
                        documentRow["BankAccount"] = document.BankAccount;
                    }
                }
                if (!string.IsNullOrEmpty(document.ReferenceNo))
                {
                    documentRow["ReferenceNo"] = document.ReferenceNo;
                }
                else
                {
                    if (!documentRow["DocumentNo"].ToString().StartsWith("EHR"))
                    {
                        documentRow["ReferenceNo"] = document.ReferenceNo;
                    }
                }

                documentRow["IsVerifyImage"] = document.IsVerifyImage;
                documentRow["Subject"]       = document.Subject;
                documentRow["Memo"]          = document.Memo;
                documentRow["Active"]        = document.Active;
                documentRow["CreBy"]         = UserAccount.UserID;
                documentRow["CreDate"]       = DateTime.Now;
                documentRow["UpdBy"]         = UserAccount.UserID;
                documentRow["UpdDate"]       = DateTime.Now;
                documentRow["UpdPgm"]        = UserAccount.CurrentProgramCode;

                documentRow.EndEdit();
            }
        }