protected void btnSave_Click(object sender, EventArgs e)
        {
            lblError.Text      = string.Empty;
            lblError.Visible   = false;
            lblSave.Text       = string.Empty;
            lblSave.Visible    = false;
            lblMessage.Visible = false;
            lblMessage.Text    = string.Empty;

            Page.Validate("TypeofDamage");
            if (!Page.IsValid)
            {
                return;
            }

            try {
                bool exists = TypeofDamageManager.IsExist(txtTypeofDamage.Text.Trim(), Convert.ToInt32(hdId.Value));
                if (exists)
                {
                    lblMessage.Text    = "Type Of Damage already exists.";
                    lblMessage.Visible = true;
                    txtTypeofDamage.Focus();
                    return;
                }
                TypeOfDamageMaster obj = TypeofDamageManager.GetbyTypeOfDamageId(Convert.ToInt32(hdId.Value));
                obj.TypeOfDamage = txtTypeofDamage.Text;

                if (!string.IsNullOrEmpty(txtSort.Text))
                {
                    obj.Sort = (byte)Convert.ToInt32(txtSort.Text);
                }

                obj.Status = true;

                if (clientID > 0)
                {
                    obj.ClientId = clientID;
                }

                TypeofDamageManager.Save(obj);
                saveMsg = hdId.Value == "0" ? "Record Saved Successfully." : "Record Updated Successfully.";
                btnCancel_Click(null, null);
                lblSave.Text    = saveMsg;
                lblSave.Visible = true;
            }
            catch (Exception ex) {
                lblError.Visible = true;
                lblError.Text    = "Record Not Saved !!!";
            }
        }
        protected void cbxHidden_CheckedChanged(object sender, EventArgs e)
        {
            ListViewItem lvItem         = ((CheckBox)sender).NamingContainer as ListViewItem;
            int          idx            = lvItem.DataItemIndex;
            int          TypeofDamageId = (int)lvData.DataKeys[idx].Value;

            TypeOfDamageMaster damageType = TypeofDamageManager.GetbyTypeOfDamageId(TypeofDamageId);

            if (damageType != null)
            {
                damageType.IsHidden = ((CheckBox)sender).Checked;

                TypeofDamageManager.Save(damageType);
                DoBind();
            }
        }
        protected void lvData_ItemCommand(object sender, ListViewCommandEventArgs e)
        {
            lblError.Text      = string.Empty;
            lblSave.Text       = string.Empty;
            lblMessage.Text    = string.Empty;
            lblMessage.Visible = false;
            lblError.Visible   = false;
            lblSave.Visible    = false;

            if (e.CommandName.Equals("DoEdit"))
            {
                int Id = Convert.ToInt32(e.CommandArgument);
                hdId.Value = Id.ToString();
                Label lblTypeOfDamage = (Label)e.Item.FindControl("lblTypeOfDamage");
                txtTypeofDamage.Text = lblTypeOfDamage.Text;

                Label lblSort = (Label)e.Item.FindControl("lblSort");
                txtSort.Text = lblSort.Text;
            }
            else if (e.CommandName.Equals("DoDelete"))
            {
                // In Case of delete
                try {
                    //Label lblTypeOfDamage = (Label)e.Item.FindControl("lblTypeOfDamage");
                    //var list = CheckPrimaryValue.checkTypeofDamage(lblTypeOfDamage.Text);
                    //if (list.ToList().Count > 0) {
                    //	lblMessage.Text = "Type of Damage is used so you can't delete !!!";
                    //	lblMessage.Visible = true;
                    //	return;
                    //}

                    var dt = TypeofDamageManager.GetbyTypeOfDamageId(Convert.ToInt32(e.CommandArgument));

                    dt.Status = false;

                    TypeofDamageManager.Save(dt);
                    DoBind();

                    lblSave.Text    = "Record Deleted Successfully.";
                    lblSave.Visible = true;
                }
                catch (Exception ex) {
                    lblError.Text    = "Record Not Deleted.";
                    lblError.Visible = true;
                }
            }
        }
Example #4
0
        private Claim createClaim(int policyID, DataRow dataRow)
        {
            decimal            amount                 = 0;
            AdjusterMaster     adjuster               = null;
            string             adjusterName           = null;
            string             causeofLoss            = null;
            Claim              claim                  = null;
            string             claimstatus            = null;
            int                clientID               = SessionHelper.getClientId();
            Contact            contact                = null;
            DateTime           dateTime               = DateTime.MinValue;
            LeadContactType    contactType            = null;
            string             ownerManagerName       = null;
            string             ownerManagerEntityName = null;
            int                severity               = 0;
            string             supervisorName         = null;
            string             teamLead               = null;
            TypeOfDamageMaster damageType             = null;
            int                userID                 = SessionHelper.getUserId();
            string             userFieldName          = null;

            claim          = new Claim();
            claim.PolicyID = policyID;
            claim.IsActive = true;

            // Insurer Claim ID
            userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Insurer Claim ID");
            if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null)
            {
                claim.InsurerClaimNumber  = dataRow[userFieldName].ToString().Trim();
                claim.AdjusterClaimNumber = claim.InsurerClaimNumber;
            }

            // Adjuster Claim Number
            userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Adjuster Claim Number");
            if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null)
            {
                claim.AdjusterClaimNumber = dataRow[userFieldName].ToString().Trim();
            }

            // Claim Status
            userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Claim Status");
            if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null)
            {
                claimstatus = dataRow[userFieldName].ToString().Trim();
                if (!string.IsNullOrEmpty(claimstatus))
                {
                    StatusMaster statusMaster = StatusManager.GetByStatusName(clientID, claimstatus);
                    if (statusMaster.StatusId == 0)
                    {
                        statusMaster.StatusName = claimstatus;
                        statusMaster.clientID   = clientID;
                        statusMaster.Status     = true;
                        statusMaster            = StatusManager.Save(statusMaster);
                    }
                    claim.StatusID = statusMaster.StatusId;
                }
            }

            #region Dates
            // Date of Loss
            userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Date of Loss");
            if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null)
            {
                if (DateTime.TryParse(dataRow[userFieldName].ToString(), out dateTime))
                {
                    claim.LossDate = dateTime;
                }
            }

            // Date Reported
            userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Date Reported");
            if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null)
            {
                if (DateTime.TryParse(dataRow[userFieldName].ToString(), out dateTime))
                {
                    claim.DateOpenedReported = dateTime;
                }
            }

            // Date First Closed
            userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Date First Closed");
            if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null)
            {
                if (DateTime.TryParse(dataRow[userFieldName].ToString(), out dateTime))
                {
                    claim.DateFirstClosed = dateTime;
                }
            }

            // Date First Reopen
            userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Date First Reopen");
            if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null)
            {
                if (DateTime.TryParse(dataRow[userFieldName].ToString(), out dateTime))
                {
                    claim.DateFirstReOpened = dateTime;
                }
            }
            // Date Assigned
            userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Date Assigned");
            if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null)
            {
                if (DateTime.TryParse(dataRow[userFieldName].ToString(), out dateTime))
                {
                    claim.DateAssigned = dateTime;
                }
            }
            // Date Acknowledged
            userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Date Acknowledged");
            if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null)
            {
                if (DateTime.TryParse(dataRow[userFieldName].ToString(), out dateTime))
                {
                    claim.DateAcknowledged = dateTime;
                }
            }
            // Date First Contact Attempted
            userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Date First Contact Attempted");
            if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null)
            {
                if (DateTime.TryParse(dataRow[userFieldName].ToString(), out dateTime))
                {
                    claim.DateFirstContactAttempt = dateTime;
                }
            }
            //Date Contacted
            userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Date Contacted");
            if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null)
            {
                if (DateTime.TryParse(dataRow[userFieldName].ToString(), out dateTime))
                {
                    claim.DateContacted = dateTime;
                }
            }
            //Date Inspection Scheduled
            userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Date Inspection Scheduled");
            if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null)
            {
                if (DateTime.TryParse(dataRow[userFieldName].ToString(), out dateTime))
                {
                    claim.DateInspectionScheduled = dateTime;
                }
            }
            // Date Inspection Completed
            userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Date Inspection Completed");
            if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null)
            {
                if (DateTime.TryParse(dataRow[userFieldName].ToString(), out dateTime))
                {
                    claim.DateInspectionCompleted = dateTime;
                }
            }
            // Date Estimate Uploaded
            userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Date Estimate Uploaded");
            if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null)
            {
                if (DateTime.TryParse(dataRow[userFieldName].ToString(), out dateTime))
                {
                    claim.DateEstimateUploaded = dateTime;
                }
            }
            // Date of Initial Reserve Change
            userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Date of Initial Reserve Change");
            if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null)
            {
                if (DateTime.TryParse(dataRow[userFieldName].ToString(), out dateTime))
                {
                    claim.DateInitialReserveChange = dateTime;
                }
            }
            // Date Indemnity Payment Requested
            userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Date Indemnity Payment Requested");
            if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null)
            {
                if (DateTime.TryParse(dataRow[userFieldName].ToString(), out dateTime))
                {
                    claim.DateIndemnityPaymentRequested = dateTime;
                }
            }
            // Date Indemnity Payment Approved
            userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Date Indemnity Payment Approved");
            if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null)
            {
                if (DateTime.TryParse(dataRow[userFieldName].ToString(), out dateTime))
                {
                    claim.DateIndemnityPaymentApproved = dateTime;
                }
            }
            // Date Indemnity Payment Issued
            userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Date Indemnity Payment Issued");
            if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null)
            {
                if (DateTime.TryParse(dataRow[userFieldName].ToString(), out dateTime))
                {
                    claim.DateIndemnityPaymentIssued = dateTime;
                }
            }
            // Date Completed
            userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Date Completed");
            if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null)
            {
                if (DateTime.TryParse(dataRow[userFieldName].ToString(), out dateTime))
                {
                    claim.DateCompleted = dateTime;
                }
            }
            // Date Closed
            userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Date Closed");
            if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null)
            {
                if (DateTime.TryParse(dataRow[userFieldName].ToString(), out dateTime))
                {
                    claim.DateClosed = dateTime;
                }
            }
            // Date Closed
            userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Date Closed");
            if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null)
            {
                if (DateTime.TryParse(dataRow[userFieldName].ToString(), out dateTime))
                {
                    claim.DateClosed = dateTime;
                }
            }

            #endregion

            userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Cycle Time");
            if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null)
            {
                if (decimal.TryParse(dataRow[userFieldName].ToString(), out amount))
                {
                    claim.CycleTime = amount;
                }
            }
            userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "ReOpenCycle Time");
            if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null)
            {
                if (decimal.TryParse(dataRow[userFieldName].ToString(), out amount))
                {
                    claim.ReopenCycleTime = amount;
                }
            }

            #region adjuster
            userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Adjuster Name");
            if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null)
            {
                adjusterName = dataRow[userFieldName].ToString().Trim();
                adjuster     = AdjusterManager.GetByAdjusterName(clientID, adjusterName);
                if (adjuster.AdjusterId == 0)
                {
                    // add adjuster
                    adjuster                     = new AdjusterMaster();
                    adjuster.Status              = true;
                    adjuster.AdjusterName        = adjusterName.Trim();
                    adjuster.ClientId            = clientID;
                    adjuster.InsertBy            = userID;
                    adjuster.InsertDate          = DateTime.Now;
                    adjuster.isEmailNotification = true;
                    adjuster                     = AdjusterManager.Save(adjuster);
                }

                claim.AdjusterID = adjuster.AdjusterId;
            }
            #endregion

            #region supervisor
            userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Supervisor Name");
            if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null)
            {
                supervisorName = dataRow[userFieldName].ToString().Trim();
                if (!string.IsNullOrEmpty(supervisorName))
                {
                    contactType = LeadContactTypeManager.Get(clientID, "Supervisor");
                    if (contactType == null)
                    {
                        contactType = addNewContactType(clientID, "Supervisor");
                    }

                    contact = ContactManager.Get(clientID, supervisorName);
                    if (contact == null)
                    {
                        contact = addNewContact(clientID, supervisorName, contactType.ID);
                    }

                    claim.SupervisorID = contact.ContactID;
                }
            }
            #endregion

            #region Team Lead
            userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Team Lead Name");
            if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null)
            {
                teamLead = dataRow[userFieldName].ToString().Trim();
                if (!string.IsNullOrEmpty(teamLead))
                {
                    contactType = LeadContactTypeManager.Get(clientID, "Team Lead");
                    if (contactType == null)
                    {
                        contactType = addNewContactType(clientID, "Team Lead");
                    }

                    contact = ContactManager.Get(clientID, teamLead);
                    if (contact == null)
                    {
                        contact = addNewContact(clientID, teamLead, contactType.ID);
                    }

                    claim.TeamLeadID = contact.ContactID;
                }
            }
            #endregion

            #region Owner Manager Name
            userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Owner Manager Name");
            if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null)
            {
                ownerManagerName = dataRow[userFieldName].ToString().Trim();
                if (!string.IsNullOrEmpty(ownerManagerName))
                {
                    contactType = LeadContactTypeManager.Get(clientID, "Owner Manager");
                    if (contactType == null)
                    {
                        contactType = addNewContactType(clientID, "Owner Manager");
                    }

                    contact = ContactManager.Get(clientID, ownerManagerName);
                    if (contact == null)
                    {
                        contact = addNewContact(clientID, ownerManagerName, contactType.ID);
                    }

                    claim.ManagerID = contact.ContactID;
                }
            }
            #endregion

            #region Owner Manager Entity Name
            userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Owner Manager Entity Name");
            if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null)
            {
                ownerManagerEntityName = dataRow[userFieldName].ToString().Trim();
                if (!string.IsNullOrEmpty(ownerManagerEntityName))
                {
                    contactType = LeadContactTypeManager.Get(clientID, "Owner Manager Entity Name");
                    if (contactType == null)
                    {
                        contactType = addNewContactType(clientID, "Owner Manager Entity Name");
                    }

                    contact = ContactManager.Get(clientID, ownerManagerEntityName);
                    if (contact == null)
                    {
                        contact = addNewContact(clientID, ownerManagerEntityName, contactType.ID);
                    }
                    claim.ManagerEntityID = contact.ContactID;
                }
            }
            #endregion

            // severity
            userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Severity");
            if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null)
            {
                if (int.TryParse(dataRow[userFieldName].ToString().Trim(), out severity))
                {
                    claim.SeverityNumber = severity;
                }
            }

            // event
            userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Event Type");
            if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null)
            {
                claim.EventType = dataRow[userFieldName].ToString().Trim();
            }

            // event name
            userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Event Name");
            if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null)
            {
                claim.EventName = dataRow[userFieldName].ToString().Trim();
            }

            // Cause of Loss Description
            userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Cause of Loss Description");
            if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null)
            {
                causeofLoss = dataRow[userFieldName].ToString().Trim();

                damageType = TypeofDamageManager.GetTypeOfDamage(clientID, causeofLoss);
                if (damageType.TypeOfDamageId == 0)
                {
                    damageType.ClientId     = clientID;
                    damageType.Status       = true;
                    damageType.TypeOfDamage = causeofLoss;

                    damageType = TypeofDamageManager.Save(damageType);
                }

                claim.CauseOfLoss = damageType.TypeOfDamageId.ToString();
            }

            #region Amounts
            // Claim Workflow Type
            userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Claim Workflow Type");
            if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null)
            {
                claim.ClaimWorkflowType = dataRow[userFieldName].ToString().Trim();
            }

            // Outstanding Indemnity Reserve
            userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Outstanding Indemnity Reserve");
            if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null)
            {
                decimal.TryParse(dataRow[userFieldName].ToString().Trim(), out amount);
                claim.OutstandingIndemnityReserve = amount;
            }

            // Outstanding LAE Reserves
            userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Outstanding LAE Reserves");
            if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null)
            {
                decimal.TryParse(dataRow[userFieldName].ToString().Trim(), out amount);
                claim.OutstandingLAEReserves = amount;
            }

            // Total Indemnity Paid
            userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Total Indemnity Paid");
            if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null)
            {
                decimal.TryParse(dataRow[userFieldName].ToString().Trim(), out amount);
                claim.TotalIndemnityPaid = amount;
            }

            // Coverage A Paid
            userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Coverage A Paid");
            if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null)
            {
                decimal.TryParse(dataRow[userFieldName].ToString().Trim(), out amount);
                claim.CoverageAPaid = amount;
            }

            // Coverage B Paid
            userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Coverage B Paid");
            if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null)
            {
                decimal.TryParse(dataRow[userFieldName].ToString().Trim(), out amount);
                claim.CoverageBPaid = amount;
            }

            // Coverage C Paid
            userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Coverage C Paid");
            if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null)
            {
                decimal.TryParse(dataRow[userFieldName].ToString().Trim(), out amount);
                claim.CoverageCPaid = amount;
            }

            // Coverage D Paid
            userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Coverage D Paid");
            if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null)
            {
                decimal.TryParse(dataRow[userFieldName].ToString().Trim(), out amount);
                claim.CoverageDPaid = amount;
            }

            // Total Expenses Paid
            userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Total Expenses Paid");
            if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null)
            {
                decimal.TryParse(dataRow[userFieldName].ToString().Trim(), out amount);
                claim.TotalExpensesPaid = amount;
            }
            #endregion

            claim = ClaimsManager.Save(claim);

            return(claim);
        }