public void disableNewRow() { WebTextEditor txtMyCoverage = (WebTextEditor)gvLimits.FooterRow.FindControl("txtMyCoverage"); WebTextEditor txtMyDescription = (WebTextEditor)gvLimits.FooterRow.FindControl("txtMyDescription"); WebNumericEditor txtMyLimit = (WebNumericEditor)gvLimits.FooterRow.FindControl("txtMyLimit"); WebNumericEditor txtMyDeductible = (WebNumericEditor)gvLimits.FooterRow.FindControl("txtMyDeductible"); WebTextEditor txtMyCATDeductible = (WebTextEditor)gvLimits.FooterRow.FindControl("txtMyCATDeductible"); WebDropDown ddlMySettlementType = (WebDropDown)gvLimits.FooterRow.FindControl("ddlMySettlementType"); WebPercentEditor txtMyCoInsuranceLimit = (WebPercentEditor)gvLimits.FooterRow.FindControl("txtMyCoInsuranceLimit"); WebPercentEditor txtMyITV = (WebPercentEditor)gvLimits.FooterRow.FindControl("txtMyITV"); WebPercentEditor txtMyReserve = (WebPercentEditor)gvLimits.FooterRow.FindControl("txtMyReserve"); WebTextEditor txtMyWHDeductible = (WebTextEditor)gvLimits.FooterRow.FindControl("txtMyWHDeductible"); WebNumericEditor txtMyLossAmountACV = (WebNumericEditor)gvLimits.FooterRow.FindControl("txtMyLossAmountACV"); WebNumericEditor txtMyLossAmountRCV = (WebNumericEditor)gvLimits.FooterRow.FindControl("txtMyLossAmountRCV"); WebNumericEditor txtMyOverage = (WebNumericEditor)gvLimits.FooterRow.FindControl("txtMyOverage"); txtMyCoverage.Enabled = false; txtMyDescription.Enabled = false; txtMyLimit.Enabled = false; txtMyDeductible.Enabled = false; txtMyCATDeductible.Enabled = false; ddlMySettlementType.Enabled = false; txtMyCoInsuranceLimit.Enabled = false; txtMyITV.Enabled = false; txtMyReserve.Enabled = false; txtMyWHDeductible.Enabled = false; txtMyLossAmountACV.Enabled = false; txtMyLossAmountRCV.Enabled = false; txtMyOverage.Enabled = false; }
// We come here each time user selected invoice service protected void cbxServiceDescription_selectedIndexChanged(object sender, EventArgs e) { DropDownList cbx = sender as DropDownList; string billable = null; string[] values = null; decimal rate = 0; string unitDescription = null; values = cbx.SelectedValue.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries); if (values.Length >= 4) { // get rate decimal.TryParse(values[1], out rate); // unit description, i.e., Hrs unitDescription = values[2]; // is billable billable = values[3]; WebNumericEditor txtRate = gvInvoiceLines.FooterRow.FindControl("txtRate") as WebNumericEditor; if (txtRate != null && !string.IsNullOrEmpty(unitDescription)) { txtRate.Text = rate.ToString("N2"); } CheckBox cbxBillable = gvInvoiceLines.FooterRow.FindControl("cbxBillable") as CheckBox; if (cbxBillable != null) { cbxBillable.Checked = billable.Equals("1"); } Label lblUnitDescription = gvInvoiceLines.FooterRow.FindControl("lblUnitDescription") as Label; if (lblUnitDescription != null) { lblUnitDescription.Text = unitDescription; } if (unitDescription.ToLower() == "sales tax") { WebNumericEditor txtQty = gvInvoiceLines.FooterRow.FindControl("txtQty") as WebNumericEditor; if (txtQty != null) { txtQty.Text = "1"; } } calculateLineTotal(); } }
public void saveLimits(int policyID) { int policyLimitID = 0; int limitID = 0; PolicyLimit limit = null; foreach (GridViewRow row in gvLimits.Rows) { if (row.RowType == DataControlRowType.DataRow) { WebNumericEditor txtLimit = row.FindControl("txtLimit") as WebNumericEditor; policyLimitID = (int)gvLimits.DataKeys[row.RowIndex].Values[0]; limitID = (int)gvLimits.DataKeys[row.RowIndex].Values[1]; if (policyLimitID == 0) { limit = new PolicyLimit(); } else { limit = PolicyLimitManager.Get(policyLimitID); } limit.PolicyLimitID = policyLimitID; limit.LimitID = limitID; limit.PolicyID = policyID; limit.LimitAmount = txtLimit.Value == null ? 0 : Convert.ToDecimal(txtLimit.Value); try { PolicyLimitManager.Save(limit); } catch (Exception ex) { Core.EmailHelper.emailError(ex); } } } }
public void saveLimits(int claimID) { int claimLimitID = 0; int limitID = 0; ClaimLimit limit = null; foreach (GridViewRow row in gvLimits.Rows) { if (row.RowType == DataControlRowType.DataRow) { try { WebNumericEditor txtLossAmount = row.FindControl("txtLossAmount") as WebNumericEditor; claimLimitID = (int)gvLimits.DataKeys[row.RowIndex].Values[0]; limitID = (int)gvLimits.DataKeys[row.RowIndex].Values[1]; if (claimLimitID == 0) { // new record limit = new ClaimLimit(); limit.ClaimID = claimID; limit.LimitID = limitID; } else { limit = ClaimLimitManager.Get(claimLimitID); } limit.LossAmountACV = txtLossAmount.Value == null ? 0 : Convert.ToDecimal(txtLossAmount.Value); ClaimLimitManager.Save(limit); } catch (Exception ex) { Core.EmailHelper.emailError(ex); } } } }
public void saveLimits(int policyID) { int policyLimitID = 0; int limitID = 0; //int claimLimitID = 0; int myClaimID = 0; int myClaimLimitID = 0; int myLimitId = 0; //anything prefaced with "my" is new; OC myClaimID = SessionHelper.getClaimID(); //Convert.ToInt32(Session["ClaimID"]); PolicyLimit limit = null; PolicyLimit myPolicyLimit = null; Limit myLimit = null; // ClaimLimit myClaimLimit = null; //added new; OC 9/11/2014: put in place to add new row to the policy limits grid. took the old 3 column one out. //crete the footer controls available for use here :OC 9/12/14 WebTextEditor txtMyCoverage = (WebTextEditor)gvLimits.FooterRow.FindControl("txtMyCoverage"); WebTextEditor txtMyDescription = (WebTextEditor)gvLimits.FooterRow.FindControl("txtMyDescription"); WebNumericEditor txtMyLimit = (WebNumericEditor)gvLimits.FooterRow.FindControl("txtMyLimit"); WebNumericEditor txtMyDeductible = (WebNumericEditor)gvLimits.FooterRow.FindControl("txtMyDeductible"); WebTextEditor txtMyCATDeductible = (WebTextEditor)gvLimits.FooterRow.FindControl("txtMyCATDeductible"); WebDropDown ddlMySettlementType = (WebDropDown)gvLimits.FooterRow.FindControl("ddlMySettlementType"); WebPercentEditor txtMyCoInsuranceLimit = (WebPercentEditor)gvLimits.FooterRow.FindControl("txtMyCoInsuranceLimit"); WebPercentEditor txtMyITV = (WebPercentEditor)gvLimits.FooterRow.FindControl("txtMyITV"); WebNumericEditor txtMyReserve = (WebNumericEditor)gvLimits.FooterRow.FindControl("txtMyReserve"); WebTextEditor txtMyWHDeductible = (WebTextEditor)gvLimits.FooterRow.FindControl("txtMyWHDeductible"); WebNumericEditor txtMyLossAmountACV = (WebNumericEditor)gvLimits.FooterRow.FindControl("txtMyLossAmountACV"); WebNumericEditor txtMyLossAmountRCV = (WebNumericEditor)gvLimits.FooterRow.FindControl("txtMyLossAmountRCV"); WebNumericEditor txtMyOverage = (WebNumericEditor)gvLimits.FooterRow.FindControl("txtMyOverage"); if (txtMyCoverage.Text != "")//TODO: change this condition to something more stable (checkbox or something) { //LIMIT TABLE STUFF myLimit = new Limit(); myLimit.LimitLetter = txtMyCoverage.Text; myLimit.LimitType = 1;//need to change to user input and create text boxes myLimit.LimitDescription = txtMyDescription.Text; myLimit.IsStatic = false; try { LimitManager.Save(myLimit); } catch (Exception ex) { Core.EmailHelper.emailError(ex); } var a = LimitManager.GetLatest(); //need to get the lastly created limit id from the insert we just did above myLimitId = Convert.ToInt32(a.LimitID); //CLAIM LIMIT STUFF //myClaimLimit = new ClaimLimit(); //myClaimLimit.LimitID = myLimitId; //myClaimLimit.ClaimID = myClaimID; //myClaimLimit.PolicyID = policyID; //myClaimLimit.LossAmountACV = txtMyLossAmountACV.Value == null ? 0 : Convert.ToDecimal(txtMyLossAmountACV.Text); //myClaimLimit.LossAmountRCV = txtMyLossAmountRCV.Value == null ? 0 : Convert.ToDecimal(txtMyLossAmountRCV.Text); //myClaimLimit.OverageAmount = txtMyOverage.Value == null ? 0 : Convert.ToDecimal(txtMyOverage.Text); //try //{ // ClaimLimitManager.Save(myClaimLimit); //} //catch (Exception ex) //{ //} //var b = ClaimLimitManager.GetLatest(); //myClaimLimitID = Convert.ToInt32(b.ClaimLimitID); //POLICY LIMIT STUFF myPolicyLimit = new PolicyLimit(); myPolicyLimit.PolicyID = policyID; myPolicyLimit.LimitID = myLimitId; myPolicyLimit.ClaimLimitID = myClaimLimitID; myPolicyLimit.LimitAmount = txtMyLimit.Value == null ? 0 : Convert.ToDecimal(txtMyLimit.Text); //= Convert.ToDecimal(txtMyLimit.Text); myPolicyLimit.LimitDeductible = txtMyDeductible.Value == null ? 0 : Convert.ToDecimal(txtMyDeductible.Text); myPolicyLimit.CATDeductible = txtMyCATDeductible.Text; if (ddlMySettlementType.SelectedItemIndex > 0) { myPolicyLimit.ApplyTo = ddlMySettlementType.SelectedItem.Text; } else { myPolicyLimit.ApplyTo = null; } myPolicyLimit.ConInsuranceLimit = Convert.ToDecimal(txtMyCoInsuranceLimit.Value); myPolicyLimit.ITV = Convert.ToDecimal(txtMyITV.Value); myPolicyLimit.Reserve = Convert.ToDecimal(txtMyReserve.Value); myPolicyLimit.WindHailDeductible = txtMyWHDeductible.Text; myPolicyLimit.LossAmountACV = txtMyLossAmountACV.Value == null ? 0 : Convert.ToDecimal(txtMyLossAmountACV.Text); myPolicyLimit.LossAmountRCV = txtMyLossAmountRCV.Value == null ? 0 : Convert.ToDecimal(txtMyLossAmountRCV.Text); myPolicyLimit.OverageAmount = txtMyOverage.Value == null ? 0 : Convert.ToDecimal(txtMyOverage.Text); try { PolicyLimitManager.Save(myPolicyLimit); } catch (Exception ex) { } } else //run the regular stuff it was doing before { //original code foreach (GridViewRow row in gvLimits.Rows) { if (row.RowType == DataControlRowType.DataRow) { //Label txtLimitLetter = row.FindControl("txtLimitLetter") as Label; //Label txtDescription = row.FindControl("txtDescription") as Label; WebNumericEditor txtLimit = row.FindControl("txtLimit") as WebNumericEditor; WebNumericEditor txtDeductible = row.FindControl("txtDeductible") as WebNumericEditor; WebTextEditor txtWHDeductible = row.FindControl("txtWHDeductible") as WebTextEditor;//new WebTextEditor txtCATDeductible = row.FindControl("txtCATDeductible") as WebTextEditor; WebTextEditor txtSettlementType = row.FindControl("txtSettlementType") as WebTextEditor; WebNumericEditor txtCoInsuranceLimit = row.FindControl("txtCoInsuranceLimit") as WebNumericEditor; WebDropDown ddlSettlementType = row.FindControl("ddlSettlementType") as WebDropDown; WebPercentEditor txtITV = row.FindControl("txtITV") as WebPercentEditor; //new WebNumericEditor txtReserve = row.FindControl("txtReserve") as WebNumericEditor; //new WebNumericEditor txtLossAmountACV = row.FindControl("txtLossAmountACV") as WebNumericEditor; //new WebNumericEditor txtLossAmountRCV = row.FindControl("txtLossAmountRCV") as WebNumericEditor; //new WebNumericEditor txtOverage = row.FindControl("txtOverage") as WebNumericEditor; //new policyLimitID = (int)gvLimits.DataKeys[row.RowIndex].Values[0]; limitID = (int)gvLimits.DataKeys[row.RowIndex].Values[1]; //claimLimitID = (int)gvLimits.DataKeys[row.RowIndex].Values[2]; //claimLimitID = (int)gvLimits.DataKeys[row.RowIndex].Values[2]; //if ((txtLossAmountACV.Text != "" || // txtLossAmountRCV.Text != "" || // txtOverage.Text != "" )&& // ( txtOverage.Text != "0.00" || // txtLossAmountRCV.Text != "0.00" || // txtLossAmountACV.Text != "0.00")) //{ //CLAIM LIMIT STUFF //myClaimLimit = new ClaimLimit(); //myClaimLimit.ClaimLimitID = claimLimitID; //myClaimLimit.LimitID = limitID; //myClaimLimit.ClaimID = myClaimID; //myClaimLimit.PolicyID = policyID; //myClaimLimit.PolicyLimitID = policyLimitID; //myClaimLimit.LossAmountACV = txtLossAmountACV.Value == null ? 0 : Convert.ToDecimal(txtLossAmountACV.Text); //myClaimLimit.LossAmountRCV = txtLossAmountRCV.Value == null ? 0 : Convert.ToDecimal(txtLossAmountRCV.Text); //myClaimLimit.OverageAmount = txtOverage.Value == null ? 0 : Convert.ToDecimal(txtOverage.Text); //try //{ // ClaimLimitManager.Save(myClaimLimit); //} //catch (Exception ex) //{ //} //// var b = ClaimLimitManager.GetLatest2(policyLimitID); //// myClaimLimitID = Convert.ToInt32(b.ClaimLimitID); ////} if (policyLimitID == 0) { limit = new PolicyLimit(); } else { limit = PolicyLimitManager.Get(policyLimitID); } limit.PolicyLimitID = policyLimitID; limit.LimitID = limitID; //limit.ClaimLimitID = claimLimitID; limit.PolicyID = policyID; limit.LimitAmount = txtLimit.Value == null ? 0 : Convert.ToDecimal(txtLimit.Value); limit.LimitDeductible = txtDeductible.Value == null ? 0 : Convert.ToDecimal(txtDeductible.Value); limit.CATDeductible = txtCATDeductible.Text; limit.WindHailDeductible = txtWHDeductible.Text; limit.ConInsuranceLimit = txtCoInsuranceLimit.Value == null ? 0 : Convert.ToDecimal(txtCoInsuranceLimit.Value); limit.ITV = Convert.ToDecimal(txtITV.Value); limit.Reserve = Convert.ToDecimal(txtReserve.Value); limit.LossAmountACV = txtLossAmountACV.Value == null ? 0 : Convert.ToDecimal(txtLossAmountACV.Text); limit.LossAmountRCV = txtLossAmountRCV.Value == null ? 0 : Convert.ToDecimal(txtLossAmountRCV.Text); limit.OverageAmount = txtOverage.Value == null ? 0 : Convert.ToDecimal(txtOverage.Text); if (ddlSettlementType.SelectedItemIndex > 0) { //limit.SettlementType = ddlSettlementType.SelectedValue; limit.ApplyTo = ddlSettlementType.SelectedValue; } else { limit.ApplyTo = null; } try { PolicyLimitManager.Save(limit); } catch (Exception ex) { Core.EmailHelper.emailError(ex); } } } } cbAddNewPolicy.Checked = false; disableNewRow(); }
// process gridview commands for detail lines protected void gvInvoiceLines_RowCommand(object sender, GridViewCommandEventArgs e) { int invoiceID = 0; int invoiceLineID = 0; Invoice invoice = null; InvoiceDetail invoiceLine = null; TextBox txtLineAmount; switch (e.CommandName) { case "DoSave": Page.Validate("invoice"); if (!Page.IsValid) { return; } Page.Validate("invoiceLine"); if (!Page.IsValid) { return; } saveInvoice(); break; case "DoEdit": invoiceLineID = Convert.ToInt32(e.CommandArgument); invoiceLine = InvoiceDetailManager.Get(invoiceLineID); if (invoiceLine != null) { ViewState["InvoiceLineID"] = invoiceLineID.ToString(); // date WebDatePicker txtDate = gvInvoiceLines.FooterRow.FindControl("txtDate") as WebDatePicker; if (txtDate != null && invoiceLine.LineDate != null) { txtDate.Text = string.Format("{0:MM/dd/yyyy}", invoiceLine.LineDate); } // service description DropDownList cbx = gvInvoiceLines.FooterRow.FindControl("cbxServiceDescription") as DropDownList; if (cbx != null && invoiceLine.ServiceTypeID != null) { ListItem item = cbx.Items.FindByText(invoiceLine.LineDescription.Trim()); if (item != null) { cbx.SelectedIndex = cbx.Items.IndexOf(item); } } else { ListItem item = new ListItem(invoiceLine.LineDescription, invoiceLine.LineDescription); cbx.Items.Add(item); cbx.Text = invoiceLine.LineDescription; } // quantity WebNumericEditor txtQty = gvInvoiceLines.FooterRow.FindControl("txtQty") as WebNumericEditor; if (txtQty != null && invoiceLine.Qty != null) { txtQty.Text = invoiceLine.Qty.ToString(); } // rate WebNumericEditor txtRate = gvInvoiceLines.FooterRow.FindControl("txtRate") as WebNumericEditor; if (txtRate != null) { txtRate.Value = invoiceLine.Rate; } //// service unit //Label lblUnitDescription = gvInvoiceLines.FooterRow.FindControl("lblUnitDescription") as Label; //if (lblUnitDescription != null && invoiceLine.InvoiceServiceType != null && invoiceLine.InvoiceServiceType.InvoiceServiceUnit != null) // lblUnitDescription.Text = invoiceLine.InvoiceServiceType.InvoiceServiceUnit.UnitDescription; // total amount txtLineAmount = gvInvoiceLines.FooterRow.FindControl("txtLineAmount") as TextBox; if (txtLineAmount != null) { txtLineAmount.Text = string.Format("{0:N2}", invoiceLine.LineAmount ?? 0); } //billable CheckBox cbxBillable = gvInvoiceLines.FooterRow.FindControl("cbxBillable") as CheckBox; if (cbxBillable != null && invoiceLine.isBillable != null) { cbxBillable.Checked = invoiceLine.isBillable ?? false; } // comments WebTextEditor txtComments = gvInvoiceLines.FooterRow.FindControl("txtComments") as WebTextEditor; if (txtComments != null && invoiceLine.Comments != null) { txtComments.Text = invoiceLine.Comments; } // show cancel icon ImageButton ibtnCancel = gvInvoiceLines.FooterRow.FindControl("ibtnCancel") as ImageButton; ibtnCancel.Visible = true; } break; case "DoDelete": invoiceLineID = Convert.ToInt32(e.CommandArgument); invoiceID = ViewState["InvoiceID"] != null?Convert.ToInt32(ViewState["InvoiceID"]) : 0; if (invoiceLineID > 0 && invoiceID > 0) { try { using (TransactionScope scope = new TransactionScope()) { deleteInvoiceComment(invoiceLineID); InvoiceDetailManager.Delete(invoiceLineID); // update invoice total after deleting detail line invoice = InvoiceManager.Get(invoiceID); if (invoice != null && invoice.InvoiceDetail != null) { invoice.TotalAmount = invoice.InvoiceDetail.Where(x => x.isBillable == true).Sum(x => x.LineAmount); InvoiceManager.Save(invoice); } // complete transaction scope.Complete(); refreshParentWindow(); } bindInvoiceDetails(invoiceID); } catch (Exception ex) { lblMessage.Text = "Error while deleting invoice detail line."; lblMessage.CssClass = "error"; Core.EmailHelper.emailError(ex); } } break; } }
/// <summary> /// Gathers information from gridview footer /// </summary> /// <returns></returns> protected InvoiceDetail getInvoiceDetailLine() { decimal qty = 0; decimal rate = 0; decimal totalAmount = 0; string[] values = null; int serviceTypeID = 0; DateTime date = DateTime.MaxValue; InvoiceDetail invoiceDetailLine = new InvoiceDetail(); // service date WebDatePicker txtDate = gvInvoiceLines.FooterRow.FindControl("txtDate") as WebDatePicker; if (txtDate != null && !string.IsNullOrEmpty(txtDate.Text)) { invoiceDetailLine.LineDate = Convert.ToDateTime(txtDate.Text); } // service description DropDownList cbx = gvInvoiceLines.FooterRow.FindControl("cbxServiceDescription") as DropDownList; if (cbx != null) { values = cbx.SelectedValue.Split(new char[] { '|' }); if (values.Length >= 3) { int.TryParse(values[0], out serviceTypeID); invoiceDetailLine.ServiceTypeID = serviceTypeID; invoiceDetailLine.LineDescription = cbx.SelectedItem.Text.Trim(); } } // quantity WebNumericEditor txtQty = gvInvoiceLines.FooterRow.FindControl("txtQty") as WebNumericEditor; if (txtQty != null) { qty = txtQty.Value == null ? 0 : Convert.ToDecimal(txtQty.Value); invoiceDetailLine.Qty = qty; } // unit description //Label lblUnitDescription = gvInvoiceLines.FooterRow.FindControl("lblUnitDescription") as Label; //if (lblUnitDescription != null) // invoiceDetailLine.UnitDescription = lblUnitDescription.Text; // rate WebNumericEditor txtRate = gvInvoiceLines.FooterRow.FindControl("txtRate") as WebNumericEditor; if (txtRate != null) { rate = txtRate.Value == null ? 0 : Convert.ToDecimal(txtRate.Value); invoiceDetailLine.Rate = rate; } // total amount // quantity TextBox txtLineAmount = gvInvoiceLines.FooterRow.FindControl("txtLineAmount") as TextBox; decimal.TryParse(txtLineAmount.Text.Trim().Replace(",", ""), out totalAmount); invoiceDetailLine.LineAmount = totalAmount; invoiceDetailLine.Total = totalAmount; //if (invoiceDetailLine.UnitDescription != null && invoiceDetailLine.UnitDescription.ToLower() == "percentage") // totalAmount = (rate / 100 ) * qty; //else // totalAmount = rate * qty; // comments WebTextEditor txtComments = gvInvoiceLines.FooterRow.FindControl("txtComments") as WebTextEditor; if (txtComments != null) { invoiceDetailLine.Comments = txtComments.Text.Trim(); } // is billable CheckBox cbxBillable = gvInvoiceLines.FooterRow.FindControl("cbxBillable") as CheckBox; if (cbxBillable != null) { invoiceDetailLine.isBillable = cbxBillable.Checked; } return(invoiceDetailLine); }
// We come here each time user selected invoice service protected void cbxServiceDescription_selectedIndexChanged(object sender, EventArgs e) { DropDownList cbx = sender as DropDownList; string billable = null; string[] values = null; decimal rate = 0; decimal percentage = 0; decimal qty = 0; decimal lineTotal = 0; string unitDescription = null; values = cbx.SelectedValue.Split(new char[] { '|' }); if (values.Length >= 4) { // get rate decimal.TryParse(values[1], out rate); // unit description, i.e., Hrs unitDescription = values[2]; // is billable billable = values[3]; // percentage decimal.TryParse(values[4], out percentage); // default qty decimal.TryParse(values[5], out qty); CheckBox cbxBillable = gvInvoiceLines.FooterRow.FindControl("cbxBillable") as CheckBox; if (cbxBillable != null) { cbxBillable.Checked = billable.Equals("1"); } Label lblUnitDescription = gvInvoiceLines.FooterRow.FindControl("lblUnitDescription") as Label; if (lblUnitDescription != null) { lblUnitDescription.Text = unitDescription; } // default quantity WebNumericEditor txtQty = gvInvoiceLines.FooterRow.FindControl("txtQty") as WebNumericEditor; txtQty.Value = qty; if (unitDescription.ToLower() == "sales tax") { if (txtQty != null) { txtQty.Text = "1"; } } // determine if percentage rate instead if rate fee if (percentage > 0) { rate = (percentage / 100); } lineTotal = qty * rate; // show rate to use WebNumericEditor txtRate = gvInvoiceLines.FooterRow.FindControl("txtRate") as WebNumericEditor; if (txtRate != null && !string.IsNullOrEmpty(unitDescription)) { txtRate.Value = rate; } TextBox txtLineAmount = gvInvoiceLines.FooterRow.FindControl("txtLineAmount") as TextBox; txtLineAmount.Text = lineTotal.ToString("N2"); calculateLineTotal(); } }
private void calculateLineTotal() { int invoiceID = 0; decimal qty = 0; decimal rate = 0; decimal totalAmount = 0; decimal taxableTotal = 0; string unitDescription = null; List <InvoiceDetail> invoiceDetails = null; // get service unit type Label lblUnitDescription = gvInvoiceLines.FooterRow.FindControl("lblUnitDescription") as Label; if (lblUnitDescription != null) { unitDescription = lblUnitDescription.Text; } // get quantity WebNumericEditor txtQty = gvInvoiceLines.FooterRow.FindControl("txtQty") as WebNumericEditor; if (txtQty != null) { qty = txtQty.Value == null ? 0 : Convert.ToDecimal(txtQty.Value); } // rate WebNumericEditor txtRate = gvInvoiceLines.FooterRow.FindControl("txtRate") as WebNumericEditor; // remove any % symbol if (txtRate != null) { rate = txtRate.Value == null ? 0 : Convert.ToDecimal(txtRate.Value); } if (!string.IsNullOrEmpty(unitDescription) && unitDescriptions.Contains(unitDescription.ToLower())) { rate /= 100; // make it a percent for "percentage, sales tax" } totalAmount = rate * qty; if (!string.IsNullOrEmpty(unitDescription) && unitDescription.ToLower().Equals("sales tax")) { int.TryParse(ViewState["InvoiceID"].ToString(), out invoiceID); invoiceDetails = InvoiceDetailManager.GetInvoiceDetails(invoiceID); taxableTotal = (decimal)invoiceDetails.Where(x => x.isBillable == true && x.InvoiceServiceType.InvoiceServiceUnit.UnitID != SALES_TAX_ID) .Sum(x => x.LineAmount); totalAmount = taxableTotal * rate; } TextBox txtLineAmount = gvInvoiceLines.FooterRow.FindControl("txtLineAmount") as TextBox; if (txtLineAmount != null) { txtLineAmount.Text = totalAmount.ToString("N2"); } }
public void saveLimits(int claimID) { int claimSubLimitID = 0; ClaimSubLimit sublimit = null; foreach (GridViewRow row in gvLimits.Rows) { if (row.RowType == DataControlRowType.DataRow) { WebTextEditor txtCoverageLetter = row.FindControl("txtCoverageLetter") as WebTextEditor; DropDownList ddlSubLimit = row.FindControl("ddlSubLimit") as DropDownList; // skip blank if (string.IsNullOrEmpty(txtCoverageLetter.Text) && ddlSubLimit.SelectedIndex == 0) { continue; } WebNumericEditor txtSubLimitLossAmount = row.FindControl("txtSubLimitLossAmount") as WebNumericEditor; WebNumericEditor txtACVAmount = row.FindControl("txtACVAmount") as WebNumericEditor; WebNumericEditor txtRCVAmount = row.FindControl("txtRCVAmount") as WebNumericEditor; WebNumericEditor txtOverage = row.FindControl("txtOverage") as WebNumericEditor; claimSubLimitID = (int)gvLimits.DataKeys[row.RowIndex].Values[0]; if (claimSubLimitID == 0) { // new record sublimit = new ClaimSubLimit(); sublimit.ClaimID = claimID; } else { sublimit = ClaimSubLimitManager.Get(claimSubLimitID); } if (ddlSubLimit.SelectedIndex > 0) { sublimit.PolicySublimitID = Convert.ToInt32(ddlSubLimit.SelectedValue); } else { sublimit.PolicySublimitID = null; } sublimit.LimitLetter = txtCoverageLetter.Text; sublimit.LossAmount = txtSubLimitLossAmount.Value == null ? 0 : Convert.ToDecimal(txtSubLimitLossAmount.Value); sublimit.ACVAmount = txtACVAmount.Value == null ? 0 : Convert.ToDecimal(txtACVAmount.Value); sublimit.RCVAmount = txtRCVAmount.Value == null ? 0 : Convert.ToDecimal(txtRCVAmount.Value); sublimit.OverageAmount = txtOverage.Value == null ? 0 : Convert.ToDecimal(txtOverage.Value); try { ClaimSubLimitManager.Save(sublimit); } catch (Exception ex) { Core.EmailHelper.emailError(ex); } } } }