//chetu com public void CopyProfile(int profileID) { //int profileID = 0; CarrierInvoiceProfile profile = null; CarrierInvoiceProfile profileold = null; profileold = CarrierInvoiceProfileManager.Get(profileID); profile = new CarrierInvoiceProfile(); profile.CarrierID = carrierID; profile.IsActive = true; if (profile != null) { profile.ProfileName = profileold.ProfileName; profile.CarrierInvoiceProfileTypeID = profileold.CarrierInvoiceProfileTypeID; profile.EffiectiveDate = profileold.EffiectiveDate; profile.ExpirationDate = profileold.ExpirationDate; profile.InvoiceType = profileold.InvoiceType; profile.AccountingContact = profileold.AccountingContact; profile.AccountingContactEmail = profileold.AccountingContactEmail; profile.FirmDiscountPercentage = profileold.FirmDiscountPercentage; profile.FlatCatFee = profileold.FlatCatFee; profile.FlatCatPercent = profileold.FlatCatPercent; try { CarrierInvoiceProfileManager.Save(profile); showInvoiceProfiles(); bindInvoiceProfiles(); } catch (Exception ex) { Core.EmailHelper.emailError(ex); } } }
protected void gvInvoiceProfile_RowCommand(object sender, GridViewCommandEventArgs e) { int profileID = Convert.ToInt32(e.CommandArgument); CarrierInvoiceProfile profile = null; if (e.CommandName == "DoEdit") { ViewState["CarrierInvoiceProfileID"] = profileID.ToString(); profile = CarrierInvoiceProfileManager.Get(profileID); if (profile != null) { // enable edit panel showInvoiceProfilePanel(); bindInvoiceType(); txtProgramName.Text = profile.ProfileName; effetiveDate.Text = profile.EffiectiveDate == null ? "" : profile.EffiectiveDate.ToString(); expirationDate.Text = profile.ExpirationDate == null ? "" : profile.ExpirationDate.ToString(); ddlInvoiceType.SelectedValue = string.Format("{0}", profile.InvoiceType ?? 1); // 2014-04-21 //CollectionManager.SetSelectedItems(cbxCoverageArea, profile.CoverageArea); txtAccoutingContact.Text = profile.AccountingContact; txtAccoutingContactEmail.Text = profile.AccountingContactEmail; txtFirmDiscountPercentage.Value = profile.FirmDiscountPercentage; //txtFlatCatPercent.Value = profile.FlatCatPercent;//new oc // txtFlatCatFee.Value = profile.FlatCatFee;//new oc tabContainerFee.Visible = true; if (profile.CarrierInvoiceProfileTypeID != null) { ucProfileType.SelectedValue = profile.CarrierInvoiceProfileTypeID.ToString(); } ucFeeSchedule.bindFeeSchedule(profileID); // 2014-04-21 //ucFeeProvision.bindProvisions(profileID); ucFeeItemized.bindItems(profileID); } } if (e.CommandName == "DoDelete") { try { profile = CarrierInvoiceProfileManager.Get(profileID); if (profile != null) { profile.IsActive = false; CarrierInvoiceProfileManager.Save(profile); showInvoiceProfiles(); bindInvoiceProfiles(); } } catch (Exception ex) { Core.EmailHelper.emailError(ex); } } if (e.CommandName == "DoCopy") { CopyProfile(profileID); } }
protected void btnProfileSave_Click(object sender, EventArgs e) { int profileID = 0; CarrierInvoiceProfile profile = null; Page.Validate("Profile"); if (!Page.IsValid) { return; } int.TryParse(ViewState["CarrierInvoiceProfileID"].ToString(), out profileID); try { if (profileID == 0) { // new profile profile = new CarrierInvoiceProfile(); profile.CarrierID = carrierID; profile.IsActive = true; } else { profile = CarrierInvoiceProfileManager.Get(profileID); } } catch (Exception ex) { Core.EmailHelper.emailError(ex); } if (profile != null) { profile.CarrierID = carrierID; profile.ProfileName = txtProgramName.Text; if (ucProfileType.SelectedIndex > 0) { profile.CarrierInvoiceProfileTypeID = Convert.ToInt32(ucProfileType.SelectedValue); } if (!string.IsNullOrEmpty(effetiveDate.Text)) { profile.EffiectiveDate = effetiveDate.Date; } else { profile.EffiectiveDate = null; } if (!string.IsNullOrEmpty(expirationDate.Text)) { profile.ExpirationDate = expirationDate.Date; } else { profile.ExpirationDate = null; } //profile.CoverageArea = CollectionManager.GetSelectedItemsID(cbxCoverageArea); profile.InvoiceType = Convert.ToInt32(ddlInvoiceType.SelectedValue); profile.AccountingContact = txtAccoutingContact.Text; profile.AccountingContactEmail = txtAccoutingContactEmail.Text; profile.FirmDiscountPercentage = txtFirmDiscountPercentage.ValueDecimal; // profile.FlatCatPercent = txtFlatCatPercent.ValueDecimal;//NEW OC // profile.FlatCatFee = txtFlatCatFee.ValueDecimal; // NEW OC try { CarrierInvoiceProfileManager.Save(profile); showInvoiceProfiles(); bindInvoiceProfiles(); } catch (Exception ex) { Core.EmailHelper.emailError(ex); } } }
protected void btnSaveClaimService_Click(object sender, EventArgs e) { ClaimService claimService = null; ClaimComment diary = null; AdjusterMaster adjuster = null; Claim myClaim = null; CarrierInvoiceProfile CarrierInvoice = null; int userID = SessionHelper.getUserId(); int claimID = SessionHelper.getClaimID(); int id = 0; int myAdjusterID = 0; int profileID = 0; Page.Validate("service"); if (!Page.IsValid) { return; } id = Convert.ToInt32(ViewState["ClaimServiceID"]); //Get current claim info to pass through to emails ClaimManager cm = new ClaimManager(); myClaim = cm.Get(claimID); //AdjusterManager try { using (TransactionScope scope = new TransactionScope()) { using (ClaimServiceManager repository = new ClaimServiceManager()) { if (id == 0) { claimService = new ClaimService(); claimService.ClaimID = claimID; } else { claimService = repository.Get(id); } claimService.ServiceQty = this.txtServiceQty.Value == null ? 0 : Convert.ToDecimal(txtServiceQty.Value); claimService.ServiceDate = txtServiceDate.Date; claimService.ServiceDescription = txtServiceDescription.Text.Trim(); claimService.ServiceTypeID = Convert.ToInt32(this.ddlInvoiceServiceType.SelectedValue); claimService.UserID = userID; claimService.AdjusterID = Convert.ToInt32(hf_serviceAdjusterID.Value); claimService.Activity = ddlActivity.SelectedItem.Text; claimService.InternalComments = txtMyComments.Text.Trim(); claimService.IsBillable = cbIsBillable.Checked; claimService.Billed = false; //save to db claimService = repository.Save(claimService); //string EmailService = ddlInvoiceServiceType.SelectedItem.Text; //string EmailActivity = ddlActivity.SelectedItem.Text; //string EmailDescription = txtServiceDescription.Text; //string EmailInternal = txtMyComments.Text; //string EmailQuantity = txtServiceQty.Text; //string EmailDate = txtServiceDate.Text; } // diary diary = new ClaimComment(); diary.ClaimID = claimID; diary.CommentDate = DateTime.Now; diary.UserId = userID; diary.ActivityType = ddlActivity.SelectedItem.Text; diary.InternalComments = txtMyComments.Text.Trim(); diary.CommentText = string.Format("Service: {0}, Description: {1}, Date {2:MM/dd/yyyy}, Qty: {3:N2}, Adjuster: {4}", ddlInvoiceServiceType.SelectedItem.Text, claimService.ServiceDescription, claimService.ServiceDate, claimService.ServiceQty, txtServiceAdjuster.Text ); ClaimCommentManager.Save(diary); myAdjusterID = Convert.ToInt32(claimService.AdjusterID); //Convert.ToInt32(myClaim.AdjusterID); //EMAIL ADJUSTER OC 10/21/2014 if (myAdjusterID != 0 || myAdjusterID != null) { adjuster = AdjusterManager.GetAdjusterId(myAdjusterID); } if (cbEmailAdjuster.Checked == true) { try { notifyAdjuster(adjuster, claimService, myClaim); } catch (Exception ex) { lblMessage.Text = "Unable to send email to adjuster"; lblMessage.CssClass = "error"; } } //EMAIL CLIENT CONTACT OC 10/22/2014 if (cbEmailClient.Checked == true) //Dont need to check if invoice Pro ID is empty becuase to get to this point, one has to exist already { if (Session["ComingFromAllClaims"] != null) //if the user got here straight from the all claims screen { profileID = Convert.ToInt32(Session["CarrierInvoiceID"]); } else//coming from claim detail page { profileID = Convert.ToInt32(Session["InvoiceProfileID"]); } CarrierInvoice = CarrierInvoiceProfileManager.Get(profileID); try { notifyClientContact(CarrierInvoice, claimService, myClaim, adjuster); } catch (Exception ex) { lblMessage.Text = "Unable to send email to client contact"; lblMessage.CssClass = "error"; } } //EMAIL TO WHOMEVER if (txtEmailTo.Text != "") { try { notifySpecifiedUser(adjuster, claimService, myClaim); } catch (Exception ex) { lblMessage.Text = "Unable to send email to adjuster"; lblMessage.CssClass = "error"; } } scope.Complete(); } lblMessage.Text = "Service was saved successfully."; lblMessage.CssClass = "ok"; // keep edit form active lbtnNewClaimService_Click(null, null); // refresh grid gvClaimService.DataSource = loadClaimServices(claimID); gvClaimService.DataBind(); } catch (Exception ex) { Core.EmailHelper.emailError(ex); lblMessage.Text = "Unable to save claim service."; lblMessage.CssClass = "error"; } //send email to adjuster }
// generate invoices protected void btnGenerate_Click(object sender, EventArgs e) { Carrier carrier = null; CarrierInvoiceProfile profile = null; Invoice invoice = null; int carrierID = Convert.ToInt32(ddlCarrier.SelectedValue); decimal invoiceAmount = 0; int policyID = 0; int profileID = Convert.ToInt32(this.ddlInvoiceProfile.SelectedValue); if (carrierID == 0 || profileID == 0) { return; } try { profile = CarrierInvoiceProfileManager.Get(profileID); carrier = CarrierManager.Get(carrierID); } catch (Exception ex) { Core.EmailHelper.emailError(ex); showErrorMessage(); return; } try { using (TransactionScope scope = new TransactionScope()) { foreach (GridViewRow row in gvCarrierPolicy.Rows) { if (row.RowType == DataControlRowType.DataRow) { CheckBox cbxSelect = row.FindControl("cbxSelect") as CheckBox; if (cbxSelect.Checked) { invoice = new Invoice(); //invoice.ClientID = clientID; //invoice.CarrierID = carrierID; invoice.InvoiceDate = DateTime.Now; invoice.InvoiceTypeID = profile.InvoiceType; invoice.CarrierInvoiceProfileID = profileID; invoice.IsVoid = false; invoice.BillToAddress1 = carrier.AddressLine1; invoice.BillToAddress2 = carrier.AddressLine2; invoice.BillToAddress3 = string.Empty; invoice.BillToName = carrier.CarrierName; policyID = (int)gvCarrierPolicy.DataKeys[row.RowIndex].Values[0]; //invoice.PolicyID = policyID; //invoice.LeadId = (int)gvCarrierPolicy.DataKeys[row.RowIndex].Values[1]; //invoice.PolicyTypeID = (int)gvCarrierPolicy.DataKeys[row.RowIndex].Values[2]; Label lblInvoiceAmount = row.FindControl("lblInvoiceAmount") as Label; decimal.TryParse(lblInvoiceAmount.Text, out invoiceAmount); invoice.TotalAmount = invoiceAmount; invoice.InvoiceNumber = InvoiceManager.GetNextInvoiceNumber(clientID); int invoiceID = InvoiceManager.Save(invoice); InvoiceDetail invoiceDetail = new InvoiceDetail(); invoiceDetail.InvoiceID = invoiceID; invoiceDetail.isBillable = true; invoiceDetail.Qty = 1; invoiceDetail.Rate = invoiceAmount; invoiceDetail.LineAmount = invoiceAmount; invoiceDetail.LineDate = DateTime.Now; invoiceDetail.LineDescription = "As per contract"; InvoiceDetailManager.Save(invoiceDetail); // flag policy as invoiced CRM.Data.Entities.LeadPolicy policy = LeadPolicyManager.Get(policyID); if (policy != null) { policy.IsInvoiced = true; LeadPolicyManager.Save(policy); } } } } // foreach // complete transaction scope.Complete(); lblMessage.Text = "Invoice(s) have been generated."; lblMessage.CssClass = "ok"; } } catch (Exception ex) { Core.EmailHelper.emailError(ex); showErrorMessage(); } finally { // refresh those policies to be invoiced bindPoliciesReadyForInvoice(); } }
protected void btnSaveExpense_Click(object sender, EventArgs e) { Claim claim = null; Claim myClaim = null; ClaimExpense claimExpense = null; AdjusterMaster adjuster = null; CarrierInvoiceProfile CarrierInvoice = null; int clientID = SessionHelper.getClientId(); int userID = SessionHelper.getUserId(); int claimID = SessionHelper.getClaimID(); int myAdjusterID = 0; int profileID = 0; int expenseTypeID = 0; int id = 0; Page.Validate("expense"); if (!Page.IsValid) { return; } id = Convert.ToInt32(ViewState["ClaimExpenseID"]); ClaimManager cm = new ClaimManager(); myClaim = cm.Get(claimID); try { expenseTypeID = Convert.ToInt32(ddlExpenseType.SelectedValue); using (TransactionScope scope = new TransactionScope()) { using (ClaimExpenseManager repository = new ClaimExpenseManager()) { if (id == 0) { claimExpense = new ClaimExpense(); claimExpense.ClaimID = claimID; } else { claimExpense = repository.Get(id); } // populate fields if (txtExpenseAmount.Visible == false) { var x = Session["multiplier"].ToString(); double expenseAmount = Convert.ToDouble(x) * Convert.ToDouble(txtExpenseQty.ValueDecimal); //newOC 10/7/14 claimExpense.ExpenseAmount = Convert.ToDecimal(expenseAmount); decimal d = Convert.ToDecimal(expenseAmount); //Session["EmailAmount"] = "$" + Math.Round(d, 2); Session["EmailAmount"] = String.Format("{0:0.00}", expenseAmount); // Session["EmailAmount"] = expenseAmount; } else { claimExpense.ExpenseAmount = txtExpenseAmount.ValueDecimal; } claimExpense.ExpenseDate = txtExpenseDate.Date; claimExpense.ExpenseDescription = txtExpenseDescription.Text.Trim(); claimExpense.ExpenseTypeID = expenseTypeID; claimExpense.IsReimbursable = cbxExpenseReimburse.Checked; claimExpense.UserID = userID; claimExpense.AdjusterID = Convert.ToInt32(hf_expenseAdjusterID.Value); claimExpense.ExpenseQty = txtExpenseQty.ValueDecimal; claimExpense.InternalComments = txtMyComments.Text.Trim(); claimExpense.Billed = false; // claimExpense.IsBillable = cbIsBillable.Checked; // save expense claimExpense = repository.Save(claimExpense); } // update diary entry ClaimComment diary = new ClaimComment(); diary.ClaimID = claimID; diary.CommentDate = DateTime.Now; diary.UserId = userID; diary.CommentText = string.Format("Expense: {0}, Description: {1}, Date: {2:MM/dd/yyyy}, Amount: {3:N2}, Adjuster: {4} Qty: {5:N2}", ddlExpenseType.SelectedItem.Text, claimExpense.ExpenseDescription, claimExpense.ExpenseDate, claimExpense.ExpenseAmount, txtExpenseAdjuster.Text, claimExpense.ExpenseQty ); ClaimCommentManager.Save(diary); // 2014-05-02 apply rule using (SpecificExpenseTypePerCarrier ruleEngine = new SpecificExpenseTypePerCarrier()) { claim = new Claim(); claim.ClaimID = claimID; RuleException ruleException = ruleEngine.TestRule(clientID, claim, expenseTypeID); if (ruleException != null) { ruleException.UserID = Core.SessionHelper.getUserId(); ruleEngine.AddException(ruleException); CheckSendMail(ruleException); } } myAdjusterID = Convert.ToInt32(claimExpense.AdjusterID); //Convert.ToInt32(myClaim.AdjusterID); //EMAIL ADJUSTER OC 10/22/2014 if (myAdjusterID != 0 || myAdjusterID != null) { adjuster = AdjusterManager.GetAdjusterId(myAdjusterID); } if (cbEmailAdjuster.Checked == true) { try { notifyAdjuster(adjuster, claimExpense, myClaim); } catch (Exception ex) { lblMessage.Text = "Unable to send email to adjuster"; lblMessage.CssClass = "error"; } } //EMAIL CLIENT CONTACT OC 10/22/2014 if (cbEmailClient.Checked == true) //Dont need to check if invoice Pro ID is empty becuase to get to this point, one has to exist already { if (Session["ComingFromAllClaims"] != null) //if the user got here straight from the all claims screen { profileID = Convert.ToInt32(Session["CarrierInvoiceID"]); } else//coming from claim detail page { profileID = Convert.ToInt32(Session["InvoiceProfileID"]); } CarrierInvoice = CarrierInvoiceProfileManager.Get(profileID); try { notifyClientContact(CarrierInvoice, claimExpense, myClaim, adjuster); } catch (Exception ex) { lblMessage.Text = "Unable to send email to client contact"; lblMessage.CssClass = "error"; } } //EMAIL TO WHOMEVER OC 10/22/2014 if (txtEmailTo.Text != "") { try { notifySpecifiedUser(adjuster, claimExpense, myClaim); } catch (Exception ex) { lblMessage.Text = "Unable to send email to adjuster"; lblMessage.CssClass = "error"; } } // complete transaction scope.Complete(); } lblMessage.Text = "Expense saved successfully."; lblMessage.CssClass = "ok"; // refresh grid gvExpense.DataSource = loadExpenses(claimID); gvExpense.DataBind(); // keep edit form active lbtnNewExpense_Click(null, null); lblAmount.Text = ""; lblAmount.Visible = false; txtExpenseAmount.Visible = true; } catch (Exception ex) { Core.EmailHelper.emailError(ex); lblMessage.Text = "Unable to save claim expense."; lblMessage.CssClass = "error"; } }