Exemplo n.º 1
0
        protected void btnShowLossTemplate_Click(object sender, EventArgs e)
        {
            //int policyId = 0;

            ClaimManager objClaimManager = new ClaimManager();
            int policyId = Convert.ToInt32(hdnPolicyIdDetuctible.Value);

               List<Claim> lstClaim  =objClaimManager.GetPolicyClaim(policyId);

            using (TransactionScope scope = new TransactionScope())
            {
                //delete all claim from claim limit
                foreach (var claim in lstClaim)
                {
                    int claimId = claim.ClaimID;
                    ClaimLimitManager.IsDeleted(claimId);
                }

                // delete limit,claimlimit,policylimit data which enter as loss details
                LimitManager.DeletePolicyLimit( policyId);

                //first get all limit
                List<Limit> objLimit = LimitManager.GetAllLimit(true);

                foreach (var limit in objLimit)
                {
                    //enter in
                    PolicyLimit objPolicyLimit = new PolicyLimit();
                    objPolicyLimit.PolicyID = policyId;
                    objPolicyLimit.LimitID = limit.LimitID;
                    PolicyLimitManager.Save(objPolicyLimit);

                }

                //code for enter in all claim in claim limit
                foreach (var claim in lstClaim)
                {
                    foreach (var limit in objLimit)
                    {
                        ClaimLimit objClaimLimit = new ClaimLimit();
                        objClaimLimit.ClaimID = claim.ClaimID;
                        objClaimLimit.LimitID = limit.LimitID;
                        ClaimLimitManager.Save(objClaimLimit);
                    }

                }

                scope.Complete();
            }

            acrossAllCoverages.Enabled = true;
            coverageSpecific.Enabled = true;
            txtDeductible.Enabled = true;

            propertyLimits.bindData(policyId);
            //casualtyLimits.bindData(policyId);
        }
        protected void gvLimits2_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            int limitID = Convert.ToInt32(e.CommandArgument);
            int policyId = Convert.ToInt32(Session["policyID"].ToString());
            ClaimManager objClaimManager = new ClaimManager();

            using (TransactionScope scope = new TransactionScope())
            {
                List<Claim> lstClaim = objClaimManager.GetPolicyClaim(policyId);
                foreach (var claim in lstClaim)
                {
                    int claimId = claim.ClaimID;
                    ClaimLimitManager.EditModeDeleteClaimLimit(limitID, claimId);
                }
                PolicyLimitManager.EditModeDeletePolicyLimit(limitID);
                LimitManager.EditModeDeleteLimit(limitID);
                scope.Complete();
            }
            Response.Redirect(Request.RawUrl);
            bindData(policyId);
        }
        public static string SaveLossDetails(int policyID, string coverage, string type, string policyLimit, string deductible, string applyTo, string itv, string reserve, int acrossall, string catDeductible, string coInsuranceLimit)
        {
            string json = "";
            int limitID = 0;

            ClaimLimit claimLimit = null;
            PolicyLimit objPolicyLimit = null;

            Limit limits = null;
            Limit limits2 = null;
            int userID = SessionHelper.getUserId();
            ClaimManager objClaimManager = new ClaimManager();

            try
            {
                using (TransactionScope scope = new TransactionScope())
                {

                    List<Claim> lstClaim = objClaimManager.GetPolicyClaim(policyID);

                    bool isTemplate = ClaimLimitManager.PolicyIsStaticTrue(policyID);

                    if (isTemplate)
                    {

                        PolicyLimitManager.IsDeleted(policyID);
                        //if coverage first time then delete all template data from all claimid
                        foreach (var claim in lstClaim)
                        {
                            int claimId = claim.ClaimID;
                            ClaimLimitManager.IsDeleted(claimId);
                        }

                    }

                    limits = new Limit();
                    limits.LimitLetter = coverage;
                    if (type == "Contacts" || type == "Personal Liability" || type == "Medical Payments")
                    {
                        limits.LimitType = 2;
                    }
                    else
                    {
                        limits.LimitType = 1;
                    }
                    limits.LimitDescription = type;
                    limits.IsStatic = false;
                    limits2 = LimitManager.Save(limits);

                    limitID = limits2.LimitID;

                    objPolicyLimit = new PolicyLimit();
                    objPolicyLimit.PolicyID = policyID;
                    objPolicyLimit.LimitID = limitID;
                    if (!string.IsNullOrEmpty(policyLimit))
                    {
                        objPolicyLimit.LimitAmount = Convert.ToDecimal(policyLimit);
                    }
                    else
                    {
                        objPolicyLimit.LimitAmount = 0;
                    }
                    if (!string.IsNullOrEmpty(deductible))
                    {
                        objPolicyLimit.LimitDeductible = Convert.ToDecimal(deductible);
                    }
                    else
                    {
                        objPolicyLimit.LimitDeductible = 0;
                    }
                    //new fields add
                    if (!string.IsNullOrEmpty(catDeductible))
                    {
                        objPolicyLimit.CATDeductible = catDeductible;
                    }
                    if (!string.IsNullOrEmpty(coInsuranceLimit))
                    {
                        objPolicyLimit.ConInsuranceLimit = Convert.ToDecimal(coInsuranceLimit);
                    }
                    else
                    {
                        objPolicyLimit.LimitDeductible = 0;
                    }

                    if (!string.IsNullOrEmpty(itv))
                    {
                        objPolicyLimit.ITV = Convert.ToDecimal(itv);
                    }
                    else
                    {
                        objPolicyLimit.ITV = 0;
                    }
                    if (!string.IsNullOrEmpty(reserve))
                    {
                        objPolicyLimit.Reserve = Convert.ToDecimal(reserve);
                    }
                    else
                    {
                        objPolicyLimit.Reserve = 0;
                    }
                    objPolicyLimit.IsDeleted = false;
                    if (acrossall == 1)
                    {
                        objPolicyLimit.ApplyAcrossAllCoverage = true;
                    }
                    else
                    {
                        objPolicyLimit.ApplyAcrossAllCoverage = false;
                    }
                    objPolicyLimit.ApplyTo = applyTo;

                    PolicyLimitManager.Save(objPolicyLimit);

                    // enter data for each claim
                    foreach (var claim in lstClaim)
                    {

                        claimLimit = new ClaimLimit();
                        claimLimit.ClaimID = claim.ClaimID;
                        claimLimit.LimitID = limitID;
                        claimLimit.LossAmountACV = 0;
                        claimLimit.LossAmountRCV = 0;
                        claimLimit.Depreciation = 0;
                        claimLimit.OverageAmount = 0;
                        claimLimit.NonRecoverableDepreciation = 0;
                        claimLimit.IsDeleted = false;
                        ClaimLimitManager.Save(claimLimit);

                    }

                    scope.Complete();
                }
                json = "Loss details successfully add";

            }
            catch (Exception ex)
            {
                Core.EmailHelper.emailError(ex);
            }

            return json;
        }