예제 #1
0
        public override void AfterApplyChanges(EntityDbHelper dbHelper, Entity entity)
        {
            base.AfterApplyChanges(dbHelper, entity);

            if (entity.ChangeStatus != EntityChangeTypes.Delete)
            {
                UpdateChildPersonsStoredDisplayText(entity);
            }
        }
예제 #2
0
        public override void AfterApplyChanges(EntityDbHelper dbHelper, Entity entity)
        {
            base.AfterApplyChanges(dbHelper, entity);

            if (entity.ChangeStatus != EntityChangeTypes.Delete)
            {
                new SalesCaseBL().UpdateSalesCaseLastActionTime(entity.GetFieldValue <Guid>("SalesCase"));
            }
        }
예제 #3
0
파일: rp.cs 프로젝트: Taraznegar/Common
        public void BeforeApplyPaidChequeChanges(EntityDbHelper dbHelper, Entity entity)
        {
            if (entity.ChangeStatus == EntityChangeTypes.Delete)
            {
                DeletingChequeID = entity.GetFieldValue <Guid>("ID");
            }

            new PaidChequeBL().BeforeApplyChanges(dbHelper, entity);
        }
예제 #4
0
        public override void BeforeApplyChanges(EntityDbHelper dbHelper, Entity entity)
        {
            base.BeforeApplyChanges(dbHelper, entity);

            var id = entity.GetFieldValue <Guid>("ID");

            if (entity.ChangeStatus == EntityChangeTypes.Modify)
            {
                _OldConnectedPersonID = dbHelper.FetchSingleByID("cmn.PersonConnectedPerson", id, null).GetFieldValue <Guid>("ConnectedPerson");
            }
        }
예제 #5
0
        public override void AfterApplyChanges(EntityDbHelper dbHelper, Entity entity)
        {
            base.AfterApplyChanges(dbHelper, entity);

            if (wm.Instance.IsRunningUnvaluation)
            {
                return;
            }

            var ghabzOrHavale           = dbHelper.FetchSingleByID("wm.GhabzOrHavale", entity.GetFieldValue <Guid>("GhabzOrHavale"), null);
            var ghabzOrHavaleTypeEntity = wm.Instance.GetGhabzOrHavaleTypeEntity(ghabzOrHavale.GetFieldValue <Guid>("GhabzOrHavaleType"));
            var warehouseDocName        = OptionSetHelper.GetOptionSetItemName(ghabzOrHavaleTypeEntity.GetFieldValue <Guid>("WarehouseDocType"));
            var stuffLocationID         = ghabzOrHavale.GetFieldValue <Guid>("StuffLocation");

            if (entity.ChangeStatus == EntityChangeTypes.Delete)
            {
                if (entity.GetFieldValue <Guid>("GhabzOrHavale") != wm.Instance.DeletingGhabzOrHavaleID)
                {
                    wm.Instance.CompareRefDocItemsWithGhabzOrHavaleItems(ghabzOrHavale);
                }
            }
            else
            {
                if (warehouseDocName == "Havale" &&
                    ghabzOrHavaleTypeEntity.GetFieldValue <bool>("Havale_CheckStuffStock"))
                {
                    CheckStuffStock(entity, stuffLocationID,
                                    ghabzOrHavale.GetFieldValue <DateTime>("IssueDate"),
                                    null, null);
                }

                //bool? isValuationActivity = null;
                //if (entity.ChangeStatus == EntityChangeTypes.Modify)
                //{
                //    if (wm.Instance.IsRunningValuation || wm.Instance.IsRunningUnvaluation || wm.Instance.IsEvaluatingDocsForValuation)
                //        isValuationActivity = true;
                //    else
                //    {
                //        var changedFieldNames = cmn.Instance.GetChangedFieldsName(_OldEntity, entity, null);
                //        if (changedFieldNames.Any(o => !o.IsIn("LastModifyTime", "LastModifierUser", "RialiAmount")))
                //            isValuationActivity = true;
                //        else
                //            isValuationActivity = false;
                //    }
                //}
                //else
                //    isValuationActivity = false;

                if (!wm.Instance.InventoryValuationBL.IsInValuationOperation)
                {
                    ApplyItemSerialNumbersChanges(ghabzOrHavale, entity);
                }
            }
        }
예제 #6
0
        public void BeforeApplyChanges(EntityDbHelper dbHelper, Entity entity)
        {
            base.BeforeApplyChanges(dbHelper, entity);

            //DebugHelper.Break();

            var salesCaseStatus_OpenID = OptionSetHelper.GetOptionSetItemID("crm.SalesCaseStatuses", "Open");
            var salesCaseStatus_WonID  = OptionSetHelper.GetOptionSetItemID("crm.SalesCaseStatuses", "Won");

            if (entity.ChangeStatus == "Delete" ||
                entity.FieldValues["Status"].ToString() == salesCaseStatus_OpenID.ToString() ||
                entity.FieldValues["Status"].ToString() == salesCaseStatus_WonID.ToString())
            {
                var salesCaseLoseInfoEntity = dbHelper.FetchSingle("crm.SalesCaseLoseInfo",
                                                                   string.Format(@"SalesCase = '{0}'", entity.GetFieldValue <Guid>("ID")), null);
                if (salesCaseLoseInfoEntity != null)
                {
                    dbHelper.DeleteEntity(salesCaseLoseInfoEntity);
                }
            }

            if (entity.ChangeStatus == "Delete")
            {
                var salesCaseStageChangeHistoryEntityList = dbHelper.FetchMultiple("crm.SalesCaseStageChangeHistory",
                                                                                   string.Format(@"SalesCase = '{0}'", entity.GetFieldValue <Guid>("ID")), null, null, null, null);
                if (salesCaseStageChangeHistoryEntityList.Entities.Count != 0)
                {
                    foreach (Entity salesCaseStageChangeHistoryEntity in salesCaseStageChangeHistoryEntityList.Entities)
                    {
                        dbHelper.DeleteEntity(salesCaseStageChangeHistoryEntity);
                    }
                }

                var salesCaseOwnerUserChangeHistoryEntityList = dbHelper.FetchMultiple("crm.SalesCaseOwnerUserChangeHistory",
                                                                                       string.Format(@"SalesCase = '{0}'", entity.GetFieldValue <Guid>("ID")), null, null, null, null);
                if (salesCaseOwnerUserChangeHistoryEntityList.Entities.Count != 0)
                {
                    foreach (Entity salesCaseOwnerUserChangeHistoryEntity in salesCaseOwnerUserChangeHistoryEntityList.Entities)
                    {
                        dbHelper.DeleteEntity(salesCaseOwnerUserChangeHistoryEntity);
                    }
                }

                var salesCaseStatusChangeHistoryEntityList = dbHelper.FetchMultiple("crm.SalesCaseStatusChangeHistory",
                                                                                    string.Format(@"SalesCase = '{0}'", entity.GetFieldValue <Guid>("ID")), null, null, null, null);
                if (salesCaseStatusChangeHistoryEntityList.Entities.Count != 0)
                {
                    foreach (Entity salesCaseStatusChangeHistoryEntity in salesCaseStatusChangeHistoryEntityList.Entities)
                    {
                        dbHelper.DeleteEntity(salesCaseStatusChangeHistoryEntity);
                    }
                }
            }
        }
예제 #7
0
        public override void AfterApplyChanges(EntityDbHelper dbHelper, Entity entity)
        {
            base.AfterApplyChanges(dbHelper, entity);

            //var cmn = CoreComponent.Instance.GetSubsystemObject("cmn") as cmn;

            //if (!cmn.ReminderBL.IsInSnoozeReminderItems && entity.GetFieldValue<Guid?>("SalesCase") != null)
            //{
            //    new SalesCaseBL().UpdateSalesCaseLastActionTime(entity.GetFieldValue<Guid>("SalesCase"));
            //}
        }
예제 #8
0
        public override void AfterApplyChanges(EntityDbHelper dbHelper, Entity entity)
        {
            base.AfterApplyChanges(dbHelper, entity);

            if (entity.ChangeStatus == EntityChangeTypes.Delete)
            {
                acc.Instance.DeleteAccDocMaster(
                    entity.GetFieldValue <Guid?>("AccDoc"),
                    "rp.ReceiveReceipt",
                    entity.GetFieldValue <Guid>("ID"));
            }
        }
        public override void BeforeApplyChanges(EntityDbHelper dbHelper, Entity entity)
        {
            base.BeforeApplyChanges(dbHelper, entity);

            var id = entity.GetFieldValue <Guid>("ID");

            if (entity.ChangeStatus == EntityChangeTypes.Delete)
            {
                ValidateDelete(entity);
                acc.Instance.DeleteAccDocItems(entity.GetFieldValue <Guid?>("AccDoc"), "RefOp_ReceivedChequeStatusChange", id);
            }
        }
예제 #10
0
        public override void BeforeApplyChanges(EntityDbHelper dbHelper, Entity entity)
        {
            if (wm.Instance.IsRunningUnvaluation)
            {
                LoadOldEntityOnBeforeApplyChanges = false;
            }

            base.BeforeApplyChanges(dbHelper, entity);

            if (wm.Instance.IsRunningUnvaluation)
            {
                return;
            }

            if (entity.ChangeStatus.IsIn(EntityChangeTypes.Add, EntityChangeTypes.Modify))
            {
                var ghabzOrHavale           = dbHelper.FetchSingleByID("wm.GhabzOrHavale", entity.GetFieldValue <Guid>("GhabzOrHavale"), null);
                var ghabzOrHavaleTypeEntity = wm.Instance.GetGhabzOrHavaleTypeEntity(ghabzOrHavale.GetFieldValue <Guid>("GhabzOrHavaleType"));
                var warehouseDocName        = OptionSetHelper.GetOptionSetItemName(ghabzOrHavaleTypeEntity.GetFieldValue <Guid>("WarehouseDocType"));
                var stuffLocationID         = ghabzOrHavale.GetFieldValue <Guid?>("StuffLocation");
                var stuffLocation           = dbHelper.FetchSingleByID("cmn.StuffLocation", (Guid)stuffLocationID, null);
                var stuff = dbHelper.FetchSingleByID("cmn.Stuff", entity.GetFieldValue <Guid>("Stuff"), null);

                if (entity.FieldExists("Stuff_Entity"))
                {
                    entity.RemoveField("Stuff_Entity");
                }

                if (entity.GetFieldValue <int>("Quantity") < 0)
                {
                    throw new AfwException("تعداد کالای وارد شده در سطر {0} مجاز نمی باشد.",
                                           entity.GetFieldValue <int>("RowNumber"));
                }
                else if (entity.GetFieldValue <int>("Quantity") == 0)
                {
                    //تنها در رسید و حواله تغییر ارزش تعداد 0 مجاز است و در این حالت هم نباید شماره بچ و وضعیت وارد شود
                    if (!string.IsNullOrEmpty(entity.GetFieldValue <string>("BatchNumber")) || entity.GetFieldValue <Guid?>("StuffStatus") != null)
                    {
                        throw new AfwException("تعداد کالای وارد شده در سطر {0} مجاز نمی باشد.",
                                               entity.GetFieldValue <int>("RowNumber"));
                    }
                }

                if (!dbHelper.EntityExists("cmn.StuffPossibleLocation", string.Format("StuffDef = '{0}' and StuffLocation = '{1}'",
                                                                                      stuff.GetFieldValue <Guid>("StuffDef"), stuffLocationID)))
                {
                    throw new AfwException("در تعریف کالای سطر {0}، {1} بعنوان انبار مجاز انتخاب نشده است.",
                                           entity.GetFieldValue <int>("RowNumber"), stuffLocation.GetFieldValue <string>("Name"));
                }

                new GhabzOrHavaleItemBL().ValidateBatchNumbers(entity);
            }
        }
예제 #11
0
        public override void AfterApplyChanges(EntityDbHelper dbHelper, Entity entity)
        {
            base.AfterApplyChanges(dbHelper, entity);

            if (entity.ChangeStatus != EntityChangeTypes.Delete)
            {
                if (dbHelper.EntityExists("rp.FinancialOpKindAccSetting", string.Format("ID <> '{0}' and FinancialYear = '{1}' and FinancialOpKind = '{2}'",
                                                                                        entity.GetFieldValue <Guid>("ID"), entity.GetFieldValue <Guid>("FinancialYear"), entity.GetFieldValue <Guid>("FinancialOpKind"))))
                {
                    throw new AfwException("برای این سال مالی قبلا تنظیمات حسابداری ثبت شده است");
                }
            }
        }
예제 #12
0
        public override void BeforeApplyChanges(EntityDbHelper dbHelper, Entity entity)
        {
            base.BeforeApplyChanges(dbHelper, entity);

            if (entity.ChangeStatus.IsIn(EntityChangeTypes.Add, EntityChangeTypes.Modify))
            {
                if (entity.GetFieldValue <DateTime?>("ReminderTime") == null && entity.GetFieldValue <DateTime?>("ScheduledTime") != null)
                {
                    var reminderTime = GetDefaultReminderTime(entity);
                    entity.SetFieldValue("ReminderTime", reminderTime);
                }
            }
        }
예제 #13
0
        public override void BeforeApplyChanges(EntityDbHelper dbHelper, Entity entity)
        {
            base.BeforeApplyChanges(dbHelper, entity);

            if (entity.ChangeStatus.IsIn(EntityChangeTypes.Modify, EntityChangeTypes.Delete))
            {
                var tankhah = dbHelper.FetchSingleByID("rp.Tankhah", entity.GetFieldValue <Guid>("Tankhah"), null);

                if (tankhah.GetFieldValue <Guid?>("AccDoc") != null)
                {
                    throw new AfwException("امکان تغییر یا حذف این آیتم بدلیل صدور سند حسابداری وجود ندارد.");
                }
            }
        }
예제 #14
0
        public override void BeforeApplyChanges(EntityDbHelper dbHelper, Entity entity)
        {
            base.BeforeApplyChanges(dbHelper, entity);

            var onTheWayStuffInfoID = entity.GetFieldValue <Guid>("OnTheWayStuffInfo");

            Entity onTheWayStuffInfoEntity = dbHelper.FetchSingleByID("wm.OnTheWayStuffInfo", onTheWayStuffInfoID, null);
            int    notReceivedNumber       = new OnTheWayStuffInfoBL().GetNotReceivedStuffNumber(onTheWayStuffInfoEntity);

            if (notReceivedNumber < entity.GetFieldValue <int>("CurrentPartyReceivedQuantity"))
            {
                throw new AfwException("تعداد رسیده در این دریافت بیشتر از تعداد دریافت نشده در اطلاعات کالا در راه است ");
            }
        }
예제 #15
0
        public override void BeforeApplyChanges(EntityDbHelper dbHelper, Entity entity)
        {
            base.BeforeApplyChanges(dbHelper, entity);

            //DebugHelper.Break();
            if (entity.ChangeStatus == EntityChangeTypes.Add)
            {
                if (entity.GetFieldValue <Guid?>("ParentOrganizationUnit") == null &&
                    dbHelper.EntityExists("cmn.OrganizationInformation", "ParentOrganizationUnit is null"))
                {
                    throw new AfwException("اطلاعات سازمان قبلا ثبت شده است.");
                }
            }
        }
예제 #16
0
        public override void BeforeApplyChanges(EntityDbHelper dbHelper, Entity entity)
        {
            base.BeforeApplyChanges(dbHelper, entity);

            if (entity.ChangeStatus == EntityChangeTypes.Add)
            {
                //چک شود برای هرکالا تنها بتوان یکBOM ثبت کرد
                var stuffBomExists = dbHelper.EntityExists("cmn.StuffBOM",
                                                           string.Format("Stuff = '{0}'", entity.GetFieldValue <Guid>("Stuff")));

                if (stuffBomExists)
                {
                    throw new AfwException(" برای هر کالا تنها می توان یک BOM تعریف کرد. برای این کالا BOM تعریف شده است.");
                }
            }

            if (entity.ChangeStatus.IsIn(EntityChangeTypes.Add, EntityChangeTypes.Modify))
            {
                var stuffComponents = entity.GetFieldValue <EntityList>("StuffBOM_StuffComponents").Entities;

                foreach (var stuffComponent in stuffComponents)
                {
                    if (stuffComponent.FieldExists("Stuff_Entity"))
                    {
                        stuffComponent.RemoveField("Stuff_Entity");
                    }
                }

                if (stuffComponents.Any(o => o.GetFieldValue <decimal?>("ValuePercent") != null))
                {
                    int valuePercentSum = 0;

                    foreach (var stuffComponent in stuffComponents)
                    {
                        if (stuffComponent.GetFieldValue <decimal?>("ValuePercent") == null)
                        {
                            throw new AfwException("درصد ریالی برای سطر {0} وارد نشده است.\r\nدرصد ریالی باید یا برای همه سطر ها وارد شود و یا برای هیچ سطری وارد نشود.", stuffComponent.GetFieldValue <int>("RowNumber"));
                        }

                        valuePercentSum += stuffComponent.GetFieldValue <int>("ValuePercent");
                    }

                    if (valuePercentSum != 100)
                    {
                        throw new AfwException("مجموع درصد ریالی اجزاء باید برابر با 100 باشد.");
                    }
                }
            }
        }
예제 #17
0
        public override void BeforeApplyChanges(EntityDbHelper dbHelper, Entity entity)
        {
            base.BeforeApplyChanges(dbHelper, entity);

            if (entity.ChangeStatus.IsIn(EntityChangeTypes.Add, EntityChangeTypes.Modify))
            {
                if (dbHelper.EntityExists("ps.TaxAndTollPercent",
                                          string.Format("ID <> '{0}' and (FromDate between '{1}' and '{2}' or ToDate between '{1}' and '{2}')",
                                                        entity.GetFieldValue <Guid>("ID"), entity.GetFieldValue <DateTime>("FromDate"), entity.GetFieldValue <DateTime>("ToDate"))
                                          ))
                {
                    throw new AfwException("رکورد دیگری با این رکورد همپوشانی زمانی دارد.");
                }
            }
        }
예제 #18
0
        public override void BeforeApplyChanges(EntityDbHelper dbHelper, Entity entity)
        {
            base.BeforeApplyChanges(dbHelper, entity);

            //DebugHelper.Break();

            if (entity.ChangeStatus == "Add")
            {
                var configs = dbHelper.GetCount("ps.Config", "");
                if (configs > 0)
                {
                    throw new AfwException("امکان ثبت بیش از یک رکورد نیست.");
                }
            }
        }
예제 #19
0
        public override void AfterApplyChanges(EntityDbHelper dbHelper, Entity entity)
        {
            base.AfterApplyChanges(dbHelper, entity);

            new PayReceiptBL().UpdateTotalAmount(entity.GetFieldValue <Guid>("PayReceipt"));

            if (entity.ChangeStatus == EntityChangeTypes.Delete)
            {
                DeleteFinancialItem(dbHelper, entity);
            }
            else
            {
                CheckPayeeInPersonsGroup(entity);
            }
        }
예제 #20
0
        public override void BeforeApplyChanges(EntityDbHelper dbHelper, Entity entity)
        {
            base.BeforeApplyChanges(dbHelper, entity);

            //DebugHelper.Break();

            if (entity.ChangeStatus.IsIn(EntityChangeTypes.Add, EntityChangeTypes.Modify))
            {
                var redundantExists = dbHelper.EntityExists("cmn.FinancialGroup",
                                                            string.Format("Title = '{0}' and ID <> '{1}'",
                                                                          entity.GetFieldValue <string>("Title"),
                                                                          entity.GetFieldValue <Guid>("ID")));

                if (redundantExists)
                {
                    throw new AfwException("این گروه مالی قبلا ثبت شده است.");
                }

                var isDefaultFinancialGroupExists = dbHelper.EntityExists("cmn.FinancialGroup",
                                                                          string.Format("IsDefault = 1 and ID <> '{0}'",
                                                                                        entity.GetFieldValue <Guid>("ID")));

                if (isDefaultFinancialGroupExists && entity.GetFieldValue <bool>("IsDefault"))
                {
                    throw new AfwException("قبلا گروه مالی پیش فرض تعیین شده است.");
                }

                if (entity.GetFieldValue <bool>("IsDefault") == true)
                {
                    var isCurrentYearExists = dbHelper.EntityExists("cmn.FinancialGroup",
                                                                    string.Format("IsDefault = '{0}' and ID <> '{1}'",
                                                                                  entity.GetFieldValue <bool>("IsDefault"),
                                                                                  entity.GetFieldValue <Guid>("ID")));

                    if (isCurrentYearExists)
                    {
                        var financialYearEntity = dbHelper.FetchSingle("cmn.FinancialGroup",
                                                                       string.Format("IsDefault = '{0}' and ID <> '{1}'",
                                                                                     entity.GetFieldValue <bool>("IsDefault"),
                                                                                     entity.GetFieldValue <Guid>("ID")), null);

                        financialYearEntity.ChangeStatus = "Modify";
                        financialYearEntity.SetFieldValue("IsDefault", false);
                        dbHelper.ApplyChanges(financialYearEntity);
                    }
                }
            }
        }
예제 #21
0
        private void DeleteFinancialItem(EntityDbHelper dbHelper, Entity itemEntity)
        {
            try
            {
                var receiveTypeName = new ReceiveTypeBL().GetReceiveTypeName(itemEntity.GetFieldValue <Guid>("ReceiveType"));
                var fieldName       = "";
                var entityFullName  = "";
                switch (receiveTypeName)
                {
                case "Cheque":
                    entityFullName = "rp.ReceivedCheque";
                    fieldName      = "FinancialItem_Cheque";
                    break;

                case "Safte":
                    entityFullName = "rp.SafteDaryafti";
                    fieldName      = "FinancialItem_Safte";
                    break;

                case "Havale":
                    entityFullName = "rp.HavaleDaryafti";
                    fieldName      = "FinancialItem_Havale";
                    break;

                case "Naghd":
                    entityFullName = "rp.NaghdeDaryafti";
                    fieldName      = "FinancialItem_Naghd";
                    break;

                case "ChekeZemanat":
                    entityFullName = "rp.ChekeZemanateDaryafti";
                    fieldName      = "FinancialItem_ChekeZemanat";
                    break;

                case "Pos":
                    entityFullName = "rp.ReceivedPos";
                    fieldName      = "FinancialItem_Pos";
                    break;
                }

                var financialItemEntity = dbHelper.FetchSingleByID(entityFullName, itemEntity.GetFieldValue <Guid>(fieldName), null);
                dbHelper.DeleteEntity(financialItemEntity);
            }
            catch (Exception ex)
            {
                throw new Exception("Error in Delete ReceiveReceiptFinancialItem.", ex);
            }
        }
예제 #22
0
        public override void BeforeApplyChanges(EntityDbHelper dbHelper, Entity entity)
        {
            base.BeforeApplyChanges(dbHelper, entity);

            if (entity.ChangeStatus != EntityChangeTypes.Delete)
            {
                if (dbHelper.EntityExists("cmn.DiscountAccSetting",
                                          string.Format("Discount = '{0}' and FinancialYear = '{1}' and ID <> '{2}'",
                                                        entity.GetFieldValue <Guid>("Discount"),
                                                        entity.GetFieldValue <Guid>("FinancialYear"),
                                                        entity.GetFieldValue <Guid>("ID"))))
                {
                    throw new AfwException("این رکورد قبلا ثبت شده است");
                }
            }
        }
예제 #23
0
        //public bool StuffDefHasTaxAndToll(Guid stuffDefId)
        //{
        //    var dbHelper = CoreComponent.Instance.MainDbHelper;

        //    var stuffDef = dbHelper.FetchSingleByID("cmn.StuffDef", stuffDefId, new string[] { "SubCategory.MainCategory" });

        //    if (stuffDef.GetFieldValue<bool>("DarayeMaliatBarArzesheAfzudeh")
        //        || )
        //}

        public override void BeforeApplyChanges(EntityDbHelper dbHelper, Entity entity)
        {
            base.AfterApplyChanges(dbHelper, entity);

            if (entity.ChangeStatus == EntityChangeTypes.Delete)
            {
                //فعلا با ایجاد هر تعریف کالا، یک کالا هم ایجاد می کنیم.
                //با حذف تعریف کالا، ابتدا کالا باید حذف شود
                var stuff = dbHelper.FetchSingle("cmn.Stuff", string.Format("StuffDef = '{0}'", entity.GetFieldValue <Guid>("ID")), null);

                if (stuff != null)
                {
                    dbHelper.DeleteEntity(stuff);
                }
            }
        }
예제 #24
0
        public override void BeforeApplyChanges(EntityDbHelper dbHelper, Entity entity)
        {
            base.BeforeApplyChanges(dbHelper, entity);

            if (entity.ChangeStatus.IsIn(EntityChangeTypes.Add, EntityChangeTypes.Modify))
            {
                var redundantExists = dbHelper.EntityExists("wm.AuthorizedSystemUser",
                    string.Format("GhabzOrHavaleType = '{0}' and SystemUser = '******' and ID <> '{2}'",
                        entity.GetFieldValue<Guid>("GhabzOrHavaleType"),
                        entity.GetFieldValue<Guid>("SystemUser"),
                        entity.GetFieldValue<Guid>("ID")));

                if (redundantExists)
                    throw new AfwException("این شخص قبلا ثبت شده است.");
            }
        }
예제 #25
0
        public virtual void BeforeApplyChanges(EntityDbHelper dbHelper, Entity entity)
        {
            _OldEntity = null;

            if (entity.EntityDefID == null)
                throw new AfwException("entity.EntityDefID is not set.");

            if (entity.ChangeStatus.IsIn(EntityChangeTypes.Modify, EntityChangeTypes.Delete))
            {
                if (LoadOldEntityOnBeforeApplyChanges)
                    _OldEntity = dbHelper.FetchSingleByID((Guid)entity.EntityDefID, entity.GetFieldValue<Guid>("ID"), null);
            }

            if (entity.FieldExists("IssueDate") && entity.FieldExists("FinancialYear"))
                CheckIssueDateAndFinancialYearConsistency(entity);
        }
예제 #26
0
        public override void BeforeApplyChanges(EntityDbHelper dbHelper, Entity entity)
        {
            base.BeforeApplyChanges(dbHelper, entity);

            var id = entity.GetFieldValue <Guid>("ID");

            if (entity.ChangeStatus != EntityChangeTypes.Delete)
            {
                if (dbHelper.EntityExists("cmn.StuffLabel",
                                          string.Format("Name = N'{0}' and ID <> '{1}'",
                                                        entity.GetFieldValue <string>("Name"), id)))
                {
                    throw new AfwException("این برچسب قبلا ثبت شده است");
                }
            }
        }
예제 #27
0
        public override void AfterApplyChanges(EntityDbHelper dbHelper, Entity entity)
        {
            base.AfterApplyChanges(dbHelper, entity);

            var salesCase = dbHelper.FetchSingleByID("crm.SalesCase", entity.GetFieldValue <Guid>("SalesCase"), null);

            if (entity.ChangeStatus.IsIn(EntityChangeTypes.Add))
            {
                var salesCaseStatus_LostID = OptionSetHelper.GetOptionSetItemID("crm.SalesCaseStatuses", "Lost");
                salesCase.FieldValues["Status"] = salesCaseStatus_LostID;
            }

            salesCase.FieldValues["LastActionTime"] = CoreComponent.Instance.GetServerDateTime();
            salesCase.ChangeStatus = EntityChangeTypes.Modify;

            dbHelper.ApplyChanges(salesCase);
        }
예제 #28
0
        public override void AfterApplyChanges(EntityDbHelper dbHelper, Entity entity)
        {
            base.AfterApplyChanges(dbHelper, entity);

            if (entity.ChangeStatus.IsIn(EntityChangeTypes.Add, EntityChangeTypes.Modify))
            {
                //فعلا با ایجاد هر تعریف کالا، یک کالا هم ایجاد می کنیم.
                //بعدا وقتی امکان تعیین مشخصه ها مشخصه ها به تعریف کالا اضافه شد، باید به ازای ترکیب مشخصه ها کالا ایجاد شود

                if (!dbHelper.EntityExists("cmn.Stuff", string.Format("StuffDef = '{0}'", entity.GetFieldValue <Guid>("ID"))))
                {
                    var stuff = dbHelper.CreateNewEntity("cmn.Stuff");
                    stuff.SetFieldValue("StuffDef", entity.GetFieldValue <Guid>("ID"));
                    dbHelper.InsertEntity(stuff);
                }
            }
        }
예제 #29
0
        public override void BeforeApplyChanges(EntityDbHelper dbHelper, Entity entity)
        {
            base.BeforeApplyChanges(dbHelper, entity);

            //DebugHelper.Break();

            if (entity.ChangeStatus.IsIn(EntityChangeTypes.Add, EntityChangeTypes.Modify))
            {
                if (dbHelper.EntityExists("rp.HavaleDaryafti",
                                          string.Format("ShomareHavale = '{0}' and ID <> '{1}'",
                                                        entity.GetFieldValue <string>("ShomareHavale"),
                                                        entity.GetFieldValue <Guid>("ID"))))
                {
                    throw new AfwException("ShomareHavaleVojoodDarad");
                }
            }
        }
예제 #30
0
        public override void BeforeApplyChanges(EntityDbHelper dbHelper, Entity entity)
        {
            base.BeforeApplyChanges(dbHelper, entity);

            if (entity.ChangeStatus.IsIn(EntityChangeTypes.Add, EntityChangeTypes.Modify))
            {
                var redundantExists = dbHelper.EntityExists("rp.AllowedPosDevice",
                                                            string.Format("PosDevice = '{0}' and ID <> '{1}'",
                                                                          entity.GetFieldValue <Guid>("PosDevice"),
                                                                          entity.GetFieldValue <Guid>("ID")));

                if (redundantExists)
                {
                    throw new AfwException("این دستگاه پوز قبلا ثبت شده است.");
                }
            }
        }