コード例 #1
0
        public void UpdateDocumentInitiatorWhenOverRole(IList <DocumentInitiator> documentInitiators)
        {
            Spring.Validation.ValidationErrors errors = new Spring.Validation.ValidationErrors();

            if (documentInitiators.Count == 0)
            {
                errors.AddError("WorkFlow.Error", new Spring.Validation.ErrorMessage("WorkFlow_ValidateOverrole_Skip"));
            }
            else
            {
                foreach (DocumentInitiator initiator in documentInitiators)
                {
                    if (initiator.IsSkip && string.IsNullOrEmpty(initiator.SkipReason))
                    {
                        errors.AddError("WorkFlow.Error", new Spring.Validation.ErrorMessage("WorkFlow_ValidateOverrole_SkipReasonIsRequired", new object[] { initiator.Seq }));
                    }
                }
            }

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

            foreach (DocumentInitiator initiator in documentInitiators)
            {
                ScgeAccountingDaoProvider.DocumentInitiatorDao.SaveOrUpdate(initiator);
            }
        }
コード例 #2
0
 protected void ctlDeleteGroup_Click(object sender, ImageClickEventArgs e)
 {
     foreach (GridViewRow row in ctlGroupGrid.Rows)
     {
         if ((row.RowType == DataControlRowType.DataRow) && (((CheckBox)row.FindControl("ctlSelect")).Checked))
         {
             try
             {
                 long       userId = UIHelper.ParseLong(ctlGroupGrid.DataKeys[row.RowIndex].Value.ToString());
                 SuUserRole group  = QueryProvider.SuUserRoleQuery.FindUserRoleByUserRoleId(userId);
                 SuUserRoleService.DeleteGroup(group);
             }
             catch (ServiceValidationException ex)
             {
                 ValidationErrors.MergeErrors(ex.ValidationErrors);
             }
             catch (Exception ex)
             {
                 string exMessage = ex.Message;
                 Spring.Validation.ValidationErrors errors = new Spring.Validation.ValidationErrors();
                 errors.AddError("DeleteGroup.Error", new Spring.Validation.ErrorMessage("CannotDelete"));
                 ValidationErrors.MergeErrors(errors);
             }
         }
     }
     ctlGroupGrid.DataCountAndBind();
     ctlUpdatePanelGroup.Update();
 }
コード例 #3
0
        public void AddParameterGroup(DbParameterGroup parameterGroup)
        {
            #region Validate DbParameterGroup
            Spring.Validation.ValidationErrors errors = new Spring.Validation.ValidationErrors();

            if (string.IsNullOrEmpty(parameterGroup.GroupName))
            {
                errors.AddError("ParameterGroup.Error", new Spring.Validation.ErrorMessage("RequiredSymbol"));
            }
            else
            {
                DbParameterGroup       DbParameterGroup   = new DbParameterGroup();
                IList <ParameterGroup> parameterGroupList = SsDbDaoProvider.DbParameterGroupDao.FindByDbParameterGroupCriteria(parameterGroup);
                if (parameterGroupList.Count != 0)
                {
                    errors.AddError("ParameterGroup.Error", new Spring.Validation.ErrorMessage("GroupNameIsAlready"));
                }
            }
            if (!errors.IsEmpty)
            {
                throw new ServiceValidationException(errors);
            }
            #endregion

            SsDbDaoProvider.DbParameterGroupDao.Save(parameterGroup);
        }
コード例 #4
0
        public void AddRolepb(SuRolepb suRolepb)
        {
            suRolepb.CreDate = DateTime.Now.Date;
            suRolepb.UpdDate = DateTime.Now.Date;
            Spring.Validation.ValidationErrors errors = new Spring.Validation.ValidationErrors();
            if (suRolepb.PBID.Pbid == null)
            {
                errors.AddError("SuRolepb.Error", new Spring.Validation.ErrorMessage("RequiredPBID"));
            }
            if (suRolepb.RoleID.RoleID == null)
            {
                errors.AddError("SuRolepb.Error", new Spring.Validation.ErrorMessage("RequiredRoleID"));
            }
            if (DaoProvider.SuRolepbDao.IsExist(suRolepb.RoleID.RoleID, suRolepb.PBID.Pbid))
            {
                errors.AddError("SuRolepb.Error", new Spring.Validation.ErrorMessage("Already exist"));
            }

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

            DaoProvider.SuRolepbDao.Save(suRolepb);
            RefreshWorkflowPermission();
        }
コード例 #5
0
        public void UpdateGlobalTranslate(SuGlobalTranslate globalTranslate)
        {
            Spring.Validation.ValidationErrors errors = new Spring.Validation.ValidationErrors();

            if (string.IsNullOrEmpty(globalTranslate.TranslateSymbol) && string.IsNullOrEmpty(globalTranslate.TranslateControl))
            {
                errors.AddError("GlobalTranslate.Error", new Spring.Validation.ErrorMessage("RequiredSymbolOrControl"));
            }

            //Check ProgramCode and symbol is unique.
            if (DaoProvider.SuGlobalTranslateDao.IsDuplicateProgramCodeSymbol(globalTranslate))
            {
                errors.AddError("GlobalTranslate.Error", new Spring.Validation.ErrorMessage("UniqueProgramCodeSymbol"));
            }

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

            SuGlobalTranslate translate = DaoProvider.SuGlobalTranslateDao.FindByIdentity(globalTranslate.TranslateId);

            translate.ProgramCode      = globalTranslate.ProgramCode;
            translate.TranslateControl = globalTranslate.TranslateControl;
            translate.TranslateSymbol  = globalTranslate.TranslateSymbol;
            translate.Comment          = globalTranslate.Comment;
            translate.Active           = globalTranslate.Active;
            translate.UpdBy            = globalTranslate.UpdBy;
            translate.UpdDate          = DateTime.Now.Date;
            translate.UpdPgm           = globalTranslate.UpdPgm;

            DaoProvider.SuGlobalTranslateDao.SaveOrUpdate(translate);
        }
コード例 #6
0
        public void UpdateUserRole(IList <SuUserRole> userRoleList)
        {
            #region Validate Input
            Spring.Validation.ValidationErrors errors = new Spring.Validation.ValidationErrors();
            foreach (SuUserRole userRole in userRoleList)
            {
                if (userRole.Role == null)
                {
                    errors.AddError("UserRole.Error", new Spring.Validation.ErrorMessage("RoleRequired"));
                }
                if (userRole.User == null)
                {
                    errors.AddError("UserRole.Error", new Spring.Validation.ErrorMessage("UserRequired"));
                }
            }
            #endregion

            // Delete existing Role in UserRole table.
            foreach (SuUserRole userRole in userRoleList)
            {
                DaoProvider.SuUserRoleDao.DeleteByRoleIdAndUserId(userRole.Role.RoleID, userRole.User.Userid);
            }

            // Save new Role to UserRole table.
            foreach (SuUserRole userRole in userRoleList)
            {
                this.Save(userRole);
            }
        }
コード例 #7
0
        public void SaveAnnouncementLang(SuAnnouncementLang announcementLang)
        {
            Spring.Validation.ValidationErrors errors = new Spring.Validation.ValidationErrors();
            if (announcementLang.Announcement == null)
            {
                errors.AddError("AnnouncementLang.Error", new Spring.Validation.ErrorMessage("AnnouncementRequired"));
            }
            if (announcementLang.Language == null)
            {
                errors.AddError("AnnouncementLang.Error", new Spring.Validation.ErrorMessage("LanguageRequired"));
            }
            if (string.IsNullOrEmpty(announcementLang.AnnouncementHeader))
            {
                errors.AddError("AnnouncementLang.Error", new Spring.Validation.ErrorMessage("RequiredSymbol"));
            }
            if (string.IsNullOrEmpty(announcementLang.AnnouncementBody))
            {
                errors.AddError("AnnouncementLang.Error", new Spring.Validation.ErrorMessage("RequiredSymbol"));
            }
            if (!errors.IsEmpty)
            {
                throw new ServiceValidationException(errors);
            }

            DaoProvider.SuAnnouncementLangDao.DeleteByCriteria(announcementLang.Announcement.Announcementid, announcementLang.Language.Languageid);
            DaoProvider.SuAnnouncementLangDao.Save(announcementLang);
        }
コード例 #8
0
        protected void UpdateMrrButton_Click(object sender, ImageClickEventArgs e)
        {
            DbMileageRateRevision MiRvs = new DbMileageRateRevision();

            MiRvs.Id = new Guid(MiRvsId.Value);
            MiRvs.EffectiveFromDate = UIHelper.ParseDate(ctlEffectiveFrom.DateValue);
            MiRvs.EffectiveToDate   = UIHelper.ParseDate(ctlctlEffectiveTo.DateValue);
            #region Validate MileageRate
            Spring.Validation.ValidationErrors errors = new Spring.Validation.ValidationErrors();

            if (MiRvs.EffectiveFromDate > MiRvs.EffectiveToDate)
            {
                errors.AddError("MileageRateRivision.Error", new Spring.Validation.ErrorMessage("Effective From  more than Effective To "));
            }
            #endregion
            if (!errors.IsEmpty)
            {
                this.ValidationErrors.MergeErrors(errors);
                return;
            }

            DbMileageRateRevisionService.UpdateMileageRateRevision(MiRvs, UserAccount.UserID);
            DivManageMileageRate.Style.Add("display", "none");
            ctlAddItem.Visible = true;
            ctlMiRvsGrid.DataCountAndBind();
            ctlUpdatePanelGridview.Update();
        }
コード例 #9
0
        protected void ctlAddNew_Click(object sender, ImageClickEventArgs e)
        {
            DbMileageRateRevision MiRvs = new DbMileageRateRevision();

            MiRvs.EffectiveFromDate = UIHelper.ParseDate(ctlEffectiveFrom.DateValue);
            MiRvs.EffectiveToDate   = UIHelper.ParseDate(ctlctlEffectiveTo.DateValue);


            #region Validate MileageRate
            Spring.Validation.ValidationErrors errors = new Spring.Validation.ValidationErrors();

            if (MiRvs.EffectiveFromDate > MiRvs.EffectiveToDate)
            {
                errors.AddError("MileageRateRivision.Error", new Spring.Validation.ErrorMessage("Effective From  more than Effective To "));
            }
            #endregion
            if (!errors.IsEmpty)
            {
                this.ValidationErrors.MergeErrors(errors);
                return;
            }

            DbMileageRateRevisionService.AddMileageRateRevision(MiRvs, UserAccount.UserID);
            ctlEffectiveFrom.DateValue  = string.Empty;
            ctlctlEffectiveTo.DateValue = string.Empty;

            ctlMiRvsGrid.DataCountAndBind();
            ctlUpdatePanelGridview.Update();
        }
コード例 #10
0
        public void UpdateRole(SuRole role)
        {
            role.UpdDate = DateTime.Now.Date;
            Spring.Validation.ValidationErrors errors = new Spring.Validation.ValidationErrors();

            #region validation
            if (string.IsNullOrEmpty(role.RoleName))
            {
                errors.AddError("Role.Error", new Spring.Validation.ErrorMessage("RequiredRoleName"));
            }
            if (string.IsNullOrEmpty(role.RoleCode))
            {
                errors.AddError("Role.Error", new Spring.Validation.ErrorMessage("RoleCodeIsRequired"));
            }
            if (DaoProvider.SuRoleDao.IsDuplicateRoleCode(role))
            {
                errors.AddError("Role.Error", new Spring.Validation.ErrorMessage("RoleCodeIsDuplicated"));
            }
            if (role.ApproveVerifyMinLimit > role.ApproveVerifyMaxLimit)
            {
                errors.AddError("Role.Error", new Spring.Validation.ErrorMessage("Approve Verify min limit must be less then the Max limit."));
            }
            if (role.VerifyMaxLimit < role.VerifyMinLimit)
            {
                errors.AddError("Role.Error", new Spring.Validation.ErrorMessage("Verify min limit must be less then the Max limit."));
            }
            #endregion
            //throw error to UI for handle.
            if (!errors.IsEmpty)
            {
                throw new ServiceValidationException(errors);
            }
            DaoProvider.SuRoleDao.Update(role);
            RefreshWorkflowPermission();
        }
コード例 #11
0
 protected void ctlDeleteApproverEditor_Click(object sender, ImageClickEventArgs e)
 {
     foreach (GridViewRow row in ctlApproverEditorGrid.Rows)
     {
         if ((row.RowType == DataControlRowType.DataRow) && (((CheckBox)row.FindControl("ctlSelect")).Checked))
         {
             try
             {
                 long userId = UIHelper.ParseLong(ctlApproverEditorGrid.DataKeys[row.RowIndex].Value.ToString());
                 SuUserFavoriteActor ApproverEditor = QueryProvider.SuUserFavoriteActorQuery.FindUserFavoriteByFavoriteId(userId);
                 SuUserFavoriteActorService.DeleteFavorite(ApproverEditor);
                 //SuUserFavoriteActor user = SuUserFavoriteActor.FindProxyByIdentity(organizationId);
                 //SuOrganizationService.Delete(organization);
             }
             catch (Exception ex)
             {
                 string exMessage = ex.Message;
                 Spring.Validation.ValidationErrors errors = new Spring.Validation.ValidationErrors();
                 errors.AddError("DeleteApproverEditor.Error", new Spring.Validation.ErrorMessage("CannotDelete"));
                 ValidationErrors.MergeErrors(errors);
             }
         }
     }
     ctlApproverEditorGrid.DataCountAndBind();
     ctlApprroverUpdatePanel.Update();
 }
コード例 #12
0
        public void UpdatePB(Dbpb pb, DBPbDataSet pbDataSet)
        {
            #region Validate SuAnnouncementGroup
            Spring.Validation.ValidationErrors errors = new Spring.Validation.ValidationErrors();
            if (string.IsNullOrEmpty(pb.PBCode))
            {
                errors.AddError("PB.Error", new Spring.Validation.ErrorMessage("PBCode Required"));
            }
            if (ScgDbDaoProvider.DbPBDao.IsDuplicatePBCode(pb))
            {
                errors.AddError("PB.Error", new Spring.Validation.ErrorMessage("PBCode is duplicate"));
            }
            if (string.IsNullOrEmpty(pb.CompanyCode))
            {
                errors.AddError("PB.Error", new Spring.Validation.ErrorMessage("Company_CodeRequired"));
            }
            if (pb.PettyCashLimit <= 0)
            {
                errors.AddError("PB.Error", new Spring.Validation.ErrorMessage("PettyCashLimitMustMoreThanZero"));
            }
            if (pb.RepOffice && !pb.MainCurrencyID.HasValue)
            {
                errors.AddError("PB.Error", new Spring.Validation.ErrorMessage("MainCurrencyIsRequire"));
            }
            if (!errors.IsEmpty)
            {
                throw new ServiceValidationException(errors);
            }
            #endregion

            ScgDbDaoProvider.DbPBDao.SaveOrUpdate(pb);
            ScgDbDaoProvider.DbPBCurrencyDao.Persist(pbDataSet.DbPBCurrency);
        }
コード例 #13
0
        private void CheckDataValueUpdate(DbWithHoldingTax WHTTax)
        {
            Literal ctlLblWhtCodeInGrid = ctlGridWithholdingTax.Rows[ctlGridWithholdingTax.EditIndex].FindControl("ctlLblWhtCode") as Literal;
            TextBox txtWHTCode          = ctlFormViewWHT.FindControl("ctlTxtWHTCode") as TextBox;

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

            if (string.IsNullOrEmpty(WHTTax.WhtCode))
            {
                errors.AddError("WHT.Error", new Spring.Validation.ErrorMessage("WhtCode"));
            }
            if (string.IsNullOrEmpty(WHTTax.WhtName))
            {
                errors.AddError("WHT.Error", new Spring.Validation.ErrorMessage("WhtName"));
            }
            if (WHTTax.Rate == 0)
            {
                errors.AddError("WHT.Error", new Spring.Validation.ErrorMessage("Rate>0"));
            }

            if (
                (ctlLblWhtCodeInGrid.Text != txtWHTCode.Text) &&
                (ScgDbQueryProvider.DbWithHoldingTaxQuery.isDuplicationWHTCode(WHTTax.WhtCode)))
            {
                errors.AddError("WHT.Error", new Spring.Validation.ErrorMessage("DuplicationWhtCode"));
            }

            if (!errors.IsEmpty)
            {
                throw new ServiceValidationException(errors);
            }
        }
コード例 #14
0
        private void CheckDataValueInsert(DbWithHoldingTax WHTTax)
        {
            Spring.Validation.ValidationErrors errors = new Spring.Validation.ValidationErrors();

            if (string.IsNullOrEmpty(WHTTax.WhtCode))
            {
                errors.AddError("WHT.Error", new Spring.Validation.ErrorMessage("WhtCode"));
            }
            if (string.IsNullOrEmpty(WHTTax.WhtName))
            {
                errors.AddError("WHT.Error", new Spring.Validation.ErrorMessage("WhtName"));
            }
            if (WHTTax.Rate == 0)
            {
                errors.AddError("WHT.Error", new Spring.Validation.ErrorMessage("Rate>0"));
            }
            if (ScgDbQueryProvider.DbWithHoldingTaxQuery.isDuplicationWHTCode(WHTTax.WhtCode))
            {
                errors.AddError("WHT.Error", new Spring.Validation.ErrorMessage("DuplicationWhtCode"));
            }

            if (!errors.IsEmpty)
            {
                throw new ServiceValidationException(errors);
            }
        }
コード例 #15
0
        public override string OnApproveWaitInitial(long workFlowID, object eventData)
        {
            WorkFlow    workFlow    = WorkFlowQueryProvider.WorkFlowQuery.FindByIdentity(workFlowID);
            SCGDocument scgDocument = ScgeAccountingQueryProvider.SCGDocumentQuery.GetSCGDocumentByDocumentID(workFlow.Document.DocumentID);

            Spring.Validation.ValidationErrors errors = new Spring.Validation.ValidationErrors();
            MPADocument  mpaDocument        = ScgeAccountingQueryProvider.MPADocumentQuery.GetMPADocumentByDocumentID(workFlow.Document.DocumentID);
            IList <long> advanceWorkflowIDs = new List <long>();

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

            string signal = base.OnApproveWaitInitial(workFlowID, eventData);

            // ====================== For Approve all advance that link to TA ======================
            // Use state WaitInitial to add into table WorkflowResponse
            string             eventName  = "Approve";
            WorkFlowStateEvent stateEvent = WorkFlowQueryProvider.WorkFlowStateEventQuery.GetByWorkFlowStateID_EventName(AdvanceStateID.WaitInitial, eventName);

            //SubmitResponse submitResponse = eventData as SubmitResponse;

            return(signal);
        }
コード例 #16
0
        public DataTable DeleteRemittanceItemFromTransaction(Guid txID, long fnremittrnceItemID, bool isFromAdvanceGrid)
        {
            Spring.Validation.ValidationErrors errors = new Spring.Validation.ValidationErrors();
            long remittanceId = 0;
            FnRemittanceDataset remittanceDS = (FnRemittanceDataset)TransactionService.GetDS(txID);

            FnRemittanceDataset.FnRemittanceItemRow remittanceItemRow = remittanceDS.FnRemittanceItem.FindByRemittanceItemID(fnremittrnceItemID);
            if (remittanceItemRow != null && !remittanceItemRow.IsNull("RemittanceID"))
            {
                remittanceId = remittanceItemRow.RemittanceID;
            }

            if (!isFromAdvanceGrid)
            {
                if (remittanceItemRow.IsImportFromAdvance)
                {
                    errors.AddError("Provider.Error", new Spring.Validation.ErrorMessage("CanNotDeleteItemInsertFromAdvance"));
                }

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

            FnRemittanceService.UpdateTotalRemittanceAmount(txID, remittanceId);

            return(remittanceDS.FnRemittanceItem);
        }
コード例 #17
0
        public void AddParameter(DbParameter parameter)
        {
            #region Validate DbParameter
            Spring.Validation.ValidationErrors errors = new Spring.Validation.ValidationErrors();

            if (parameter.SeqNo == null)
            {
                errors.AddError("Parameter.Error", new Spring.Validation.ErrorMessage("RequiredSeqNo"));
            }

            if (string.IsNullOrEmpty(parameter.ParameterValue))
            {
                errors.AddError("Parameter.Error", new Spring.Validation.ErrorMessage("RequiredSymbol"));
            }
            else
            {
                DbParameter       dbparameter   = new DbParameter();
                IList <Parameter> parameterList = SsDbDaoProvider.DbParameterDao.FindByDbParameterCriteria(parameter);
                if (parameterList.Count != 0)
                {
                    //errors.AddError("Parameter.Error", new Spring.Validation.ErrorMessage("ParameterValueIsAlready"));
                    errors.AddError("Parameter.Error", new Spring.Validation.ErrorMessage("SeqNoNotAllow"));
                }
            }
            if (!errors.IsEmpty)
            {
                throw new ServiceValidationException(errors);
            }
            #endregion

            SsDbDaoProvider.DbParameterDao.Save(parameter);
        }
コード例 #18
0
        public void ValidateRemittanceItem(FnRemittanceItem remittanceItem, bool isFromAddItemInGrid)
        {
            Spring.Validation.ValidationErrors errors = new Spring.Validation.ValidationErrors();

            if (string.IsNullOrEmpty(remittanceItem.PaymentType))
            {
                errors.AddError("Provider.Error", new Spring.Validation.ErrorMessage("RemittanceItem_Payment_IsRequired"));
            }
            if (remittanceItem.Currency == null)
            {
                errors.AddError("Provider.Error", new Spring.Validation.ErrorMessage("RemittanceItem_Currency_IsRequired"));
            }
            //if (remittanceItem.ExchangeRate == 0)
            //{
            //    errors.AddError("Provider.Error", new Spring.Validation.ErrorMessage("RemittanceItem_ExchangeRate_IsRequired"));
            //}
            if (isFromAddItemInGrid)
            {
                if (remittanceItem.ForeignCurrencyRemitted <= 0)
                {
                    //errors.AddError("Provider.Error", new Spring.Validation.ErrorMessage("RemittanceItem_ForrignCurrencyRemitted_IsRequired"));
                }
            }
            if (!errors.IsEmpty)
            {
                throw new ServiceValidationException(errors);
            }
        }
コード例 #19
0
        public short AddNode(SuRTENode node, HttpPostedFile imageFile)
        {
            Spring.Validation.ValidationErrors errors = new Spring.Validation.ValidationErrors();

            if (node.NodeHeaderid == null)
            {
                errors.AddError("Node.Error", new Spring.Validation.ErrorMessage("RequeiredNodeHeaderId"));
            }
            // Check file Type of imageFile.
            if ((!imageFile.ContentType.Equals("image/gif")) && (!imageFile.ContentType.Equals("image/jpeg")) && (!imageFile.ContentType.Equals("image/jpg")) && (!imageFile.ContentType.Equals("image/x-png")))
            {
                errors.AddError("Node.Error", new Spring.Validation.ErrorMessage("FileTypeError"));
            }
            // Check file Size of imageFile.
            if (imageFile.ContentLength > maxFileSize)
            {
                // File size exceed 50KB.
                errors.AddError("Node.Error", new Spring.Validation.ErrorMessage("FileSizeError"));
            }
            //// Check file Dimension of imageFile
            //Image uploadImage = Image.FromStream(imageFile.InputStream);
            //if ((uploadImage.Width > maxImageWidth) || (uploadImage.Height > maxImageHeight))
            //{
            //    errors.AddError("Node.Error", new Spring.Validation.ErrorMessage("DimensionError"));
            //}
            if (!errors.IsEmpty)
            {
                throw new ServiceValidationException(errors);
            }

            return(DaoProvider.SuRTENodeDao.Save(node));
        }
コード例 #20
0
        public short AddAnnouncementGroup(SuAnnouncementGroup announcementGroup, SuAnnouncementGroupLang announcementGroupLang)
        {
            #region Validate SuAnnouncementGroup
            Spring.Validation.ValidationErrors errors = new Spring.Validation.ValidationErrors();
            if (announcementGroup.DisplayOrder == null)
            {
                errors.AddError("AnnouncementGroup.Error", new Spring.Validation.ErrorMessage("DisplayOrderTypeMissMatch"));
            }
            else if (announcementGroup.DisplayOrder.GetValueOrDefault(0) == 0)
            {
                errors.AddError("AnnouncementGroup.Error", new Spring.Validation.ErrorMessage("DisplayOrderRequired"));
            }
            if (string.IsNullOrEmpty(announcementGroupLang.AnnouncementGroupName))
            {
                errors.AddError("AnnouncementGroup.Error", new Spring.Validation.ErrorMessage("AnnouncementGroupNameRequired"));
            }
            if (!errors.IsEmpty)
            {
                throw new ServiceValidationException(errors);
            }
            #endregion

            short announcementGroupId = DaoProvider.SuAnnouncementGroupDao.Save(announcementGroup);
            DaoProvider.SuAnnouncementGroupLangDao.Save(announcementGroupLang);

            return(announcementGroupId);
        }
コード例 #21
0
        public void InsertAnnouncementLang(SuAnnouncementLang announcementLang)
        {
            #region Validate AnnouncementLang
            Spring.Validation.ValidationErrors errors = new Spring.Validation.ValidationErrors();
            if (announcementLang.Announcement == null)
            {
                errors.AddError("AnnouncementLang.Error", new Spring.Validation.ErrorMessage("AnnouncementRequired"));
            }
            if (announcementLang.Language == null)
            {
                errors.AddError("AnnouncementLang.Error", new Spring.Validation.ErrorMessage("LanguageRequired"));
            }
            if (string.IsNullOrEmpty(announcementLang.AnnouncementHeader))
            {
                errors.AddError("AnnouncementLang.Error", new Spring.Validation.ErrorMessage("AnnouncementHeaderRequired"));
            }
            if (string.IsNullOrEmpty(announcementLang.AnnouncementBody))
            {
                errors.AddError("AnnouncementLang.Error", new Spring.Validation.ErrorMessage("AnnouncementBodyRequired"));
            }
            if (!errors.IsEmpty)
            {
                throw new ServiceValidationException(errors);
            }
            #endregion

            DaoProvider.SuAnnouncementLangDao.Save(announcementLang);
        }
コード例 #22
0
        public void UpdateDivision(SuDivision div)
        {
            Spring.Validation.ValidationErrors errors = new Spring.Validation.ValidationErrors();

            if (div.Organization == null)
            {
                errors.AddError("Division.Error", new Spring.Validation.ErrorMessage("RequiredOrganization"));
            }

            //Check ProgramCode and symbol is unique.
            //if (DaoProvider.SuGlobalTranslateDao.IsDuplicateProgramCodeSymbol(globalTranslate))
            //{
            //    errors.AddError("GlobalTranslate.Error", new Spring.Validation.ErrorMessage("UniqueProgramCodeSymbol"));
            //}
            if (!errors.IsEmpty)
            {
                throw new ServiceValidationException(errors);
            }

            //SuDivision division = new SuDivision();
            //division.Comment = div.Comment;
            //division.Active = div.Active;
            //division.UpdBy = div.UpdBy;
            //division.UpdDate = DateTime.Now.Date;
            //division.UpdPgm = div.UpdPgm;

            //if (!errors.IsEmpty) throw new ServiceValidationException(errors);

            DaoProvider.SuDivisionDao.SaveOrUpdate(div);
        }
コード例 #23
0
        public void UpdateTax(DbTax tax)
        {
            //#region Validate SuAnnouncementGroup
            Spring.Validation.ValidationErrors errors = new Spring.Validation.ValidationErrors();

            if (string.IsNullOrEmpty(tax.TaxCode))
            {
                errors.AddError("Tax.Error", new Spring.Validation.ErrorMessage("TaxCodeRequired"));
            }
            if (string.IsNullOrEmpty(tax.GL))
            {
                errors.AddError("Tax.Error", new Spring.Validation.ErrorMessage("GLRequired"));
            }
            if (tax.Rate < 0)
            {
                errors.AddError("Tax.Error", new Spring.Validation.ErrorMessage("RateRequired"));
            }
            if (ScgDbDaoProvider.DbTaxDao.IsDuplicateTaxCode(tax))
            {
                errors.AddError("Tax.Error", new Spring.Validation.ErrorMessage("UniqueTaxCode"));
            }

            if (!errors.IsEmpty)
            {
                throw new ServiceValidationException(errors);
            }
            ScgDbDaoProvider.DbTaxDao.SaveOrUpdate(tax);
        }
コード例 #24
0
        public int AddReason(DbRejectReason reason)
        {
            Spring.Validation.ValidationErrors errors = new Spring.Validation.ValidationErrors();

            if (string.IsNullOrEmpty(reason.ReasonCode))
            {
                errors.AddError("ReasonReject.Error", new Spring.Validation.ErrorMessage("ReasonCodeRequired"));
            }
            if (RejectReasonDao.IsDuplicateReasonCode(reason))
            {
                errors.AddError("ReasonReject.Error", new Spring.Validation.ErrorMessage("ReasonCodeIsDuplicate"));
            }
            //if (reason.DocumentTypeID.Equals(0))
            //{
            //    errors.AddError("ReasonReject.Error", new Spring.Validation.ErrorMessage("RequestTypeIsRequired"));
            //}
            //if (reason.WorkFlowStateEventID.Equals(0))
            //{
            //    errors.AddError("ReasonReject.Error", new Spring.Validation.ErrorMessage("WorkFlowStateEventIsRequired"));
            //}

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

            reason.CreBy   = UserAccount.UserID;
            reason.CreDate = DateTime.Now.Date;
            reason.UpdBy   = UserAccount.UserID;
            reason.UpdDate = DateTime.Now.Date;
            reason.UpdPgm  = UserAccount.CurrentProgramCode;

            return(ScgDbDaoProvider.RejectReasonDao.Save(reason));
        }
コード例 #25
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string TokenCode = Request.QueryString["TokenCode"] == null ? string.Empty : Request.QueryString["TokenCode"].Trim();
            string From      = Request.QueryString["From"] == null ? string.Empty : Request.QueryString["From"].Trim();
            string Type      = Request.QueryString["Type"] == null ? string.Empty : Request.QueryString["Type"].Trim();
            int    eventID   = Request.QueryString["EventID"] == null ? -1 : Int32.Parse(Request.QueryString["EventID"].Trim());

            //1. SignIn by UserName (From)
            string userName = SS.SU.Query.QueryProvider.SuUserQuery.FindByIdentity(UIHelper.ParseLong(From)).UserName;

            UserEngine.SignIn(userName);

            this.Title       = "Approval via Email By :" + userName;
            this.ProgramCode = "ApprovalViaEmail";
            UserAccount.CurrentProgramCode = this.ProgramCode;

            //1.1 If cannot SignIn , we not need to call workflow
            if (UserAccount.Authentication)
            {
                try
                {
                    WorkFlowResponseToken token = WorkFlowResponseTokenQuery.GetByTokenCode_WorkFlowStateEventID(TokenCode, eventID);


                    if (token == null)
                    {
                        Spring.Validation.ValidationErrors errors = new Spring.Validation.ValidationErrors();
                        errors.AddError("General.Error", new Spring.Validation.ErrorMessage(
                                            GetMessage("InvalidTokenID")
                                            ));
                        throw new ServiceValidationException(errors);
                    }
                    else
                    {
                        string successText = GetMessage("ApproveRejectResultMessage",
                                                        token.WorkFlow.Document.DocumentNo,
                                                        WorkFlowStateEventQuery.GetTranslatedEventName(
                                                            token.WorkFlowStateEvent.WorkFlowStateEventID,
                                                            UserAccount.CurrentLanguageID));

                        WorkFlowService.NotifyEventFromToken(TokenCode, UserAccount.UserID, eventID, TokenType.Email);

                        ctlResult.Text = successText;
                    }
                }
                catch (ServiceValidationException ex)
                {
                    this.ValidationErrors.MergeErrors(ex.ValidationErrors);
                }
                finally
                {
                    UserEngine.SignOut(UserAccount.UserID);
                }
            }
            else
            {
                this.ValidationErrors.AddError("General.Error",
                                               new Spring.Validation.ErrorMessage("ApproveRejectResultLoginFail"));
            }
        }
コード例 #26
0
        public long CheckExistAndAddNew(SS.Standard.WorkFlow.DTO.WorkFlow domain)
        {
            Spring.Validation.ValidationErrors errors = new Spring.Validation.ValidationErrors();
            if (domain.Document == null)
            {
                errors.AddError("WorkFlow.Error", new Spring.Validation.ErrorMessage("DocumentRequired"));
            }
            if (domain.WorkFlowType == null)
            {
                errors.AddError("WorkFlow.Error", new Spring.Validation.ErrorMessage("WorkFlowTypeRequired"));
            }
            if (!errors.IsEmpty)
            {
                throw new ServiceValidationException(errors);
            }

            WorkFlow.DTO.WorkFlow workFlow = WorkFlowQueryProvider.WorkFlowQuery.GetWorkFlowByDocumentID(domain.Document.DocumentID);
            if (workFlow == null)
            {
                domain.Active  = true;
                domain.CreBy   = UserAccount.UserID;
                domain.CreDate = DateTime.Now;
                domain.UpdBy   = UserAccount.UserID;
                domain.UpdDate = DateTime.Now;
                domain.UpdPgm  = UserAccount.CurrentProgramCode;
                long workFlowID = WorkFlowDaoProvider.WorkFlowDao.Save(domain);

                return(workFlowID);
            }
            else
            {
                return(workFlow.WorkFlowID);
            }
        }
コード例 #27
0
        public string GenerateSellingLetter(List <SellingRequestLetterParameter> allList)
        {
            Spring.Validation.ValidationErrors errors = new Spring.Validation.ValidationErrors();
            string letterNoList    = string.Empty;
            string prevCompanyCode = string.Empty;
            string letterNo        = string.Empty;
            long   letterID        = 0;

            string resultMsg = CheckDuplicateDocumentID(allList);

            if (!string.IsNullOrEmpty(resultMsg))
            {
                errors.AddError("Generate.Error", new Spring.Validation.ErrorMessage("CannotGenerateSellingLetter", resultMsg));
            }

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

            for (int i = 0; i < allList.Count; i++)
            {
                if (allList[i].CompanyCode != prevCompanyCode)
                {
                    prevCompanyCode = allList[i].CompanyCode;
                    letterNo        = DbSellingRunningService.RetrieveNextSellingRunningNo(allList[i].CompanyCode, allList[i].Year);
                    letterID        = DbSellingLetterDetailService.AddLetterDetail(allList[i], letterNo);

                    letterNoList += letterNo + ",";
                }
                AddLetterAndDocument(allList[i].DocumentID, letterID);
            }
            return(string.IsNullOrEmpty(letterNoList) ? letterNoList : letterNoList.Substring(0, letterNoList.Length - 1));;
        }
コード例 #28
0
        public void NotifyEventFromToken(string tokenCode, long userID, int workFlowStateEventID, TokenType tokenType)
        {
            Spring.Validation.ValidationErrors errors = new Spring.Validation.ValidationErrors();

            WorkFlowResponseToken responseToken = WorkFlowQueryProvider.WorkFlowResponseTokenQuery.GetByTokenCode_WorkFlowStateEventID(tokenCode, workFlowStateEventID);

            if (responseToken == null)
            {
                errors.AddError("NotifyEventFromToken", new Spring.Validation.ErrorMessage("NotifyEventFromToken_Mismatch_ResponseToken"));
            }
            else if (userID != responseToken.UserID)
            {
                errors.AddError("NotifyEventFromToken", new Spring.Validation.ErrorMessage("NotifyEventFromToken_Mismatch_UserID"));
            }

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

            SubmitResponse eventData = new SubmitResponse(workFlowStateEventID);

            if (tokenType == TokenType.Email)
            {
                eventData.ResponseMethod = ResponseMethod.Email;
            }
            else if (tokenType == TokenType.SMS)
            {
                eventData.ResponseMethod = ResponseMethod.SMS;
            }
            NotifyEvent(responseToken.WorkFlow.WorkFlowID, responseToken.WorkFlowStateEvent.Name, eventData);

            WorkFlowResponseTokenService.ClearResponseToken(tokenCode);
        }
コード例 #29
0
        public long AddMenu(SuMenu menu)
        {
            Spring.Validation.ValidationErrors errors = new Spring.Validation.ValidationErrors();

            //Check MenuCode is unique.
            if (DaoProvider.SuMenuDao.IsDuplicateMenuCode(menu))
            {
                errors.AddError("Menu.Error", new Spring.Validation.ErrorMessage("UniqueMenuCode"));
            }

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

            SuMenu suMenu = new SuMenu();

            suMenu.Menuid     = menu.Menuid;
            suMenu.MenuCode   = menu.MenuCode;
            suMenu.Program    = menu.Program;
            suMenu.MenuMainid = menu.MenuMainid;
            suMenu.MenuLevel  = menu.MenuLevel;
            suMenu.MenuSeq    = menu.MenuSeq;
            suMenu.Comment    = menu.Comment;
            suMenu.CreBy      = menu.CreBy;
            suMenu.CreDate    = DateTime.Now.Date;
            suMenu.UpdBy      = menu.UpdBy;
            suMenu.UpdDate    = DateTime.Now.Date;
            suMenu.UpdPgm     = menu.UpdPgm;
            suMenu.Active     = menu.Active;

            return(DaoProvider.SuMenuDao.Save(menu));
        }
コード例 #30
0
        private void CheckDataValueUpdate(DbCompanyTax ct)
        {
            Spring.Validation.ValidationErrors errors = new Spring.Validation.ValidationErrors();
            if (ct.CompanyID <= 0)
            {
                errors.AddError("CompanyTax.Error", new Spring.Validation.ErrorMessage("RequiredCompany"));
            }
            if (!ctlUseParentRate.Checked)
            {
                if (ct.Rate == 0)
                {
                    errors.AddError("CompanyTax.Error", new Spring.Validation.ErrorMessage("RequiredRate"));
                }
            }
            if (CompanyTaxID == 0)
            {
                if (ScgDbDaoProvider.DbCompanyTaxDao.IsDuplicateCompanyCode(ct))
                {
                    errors.AddError("CompanyTax.Error", new Spring.Validation.ErrorMessage("Duplicate Company Code"));
                }
            }

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