protected void gvExpenseType_RowCommand(object sender, GridViewCommandEventArgs e) { int expenseID = 0; ExpenseType expense = null; if (e.CommandName == "DoEdit") { expenseID = Convert.ToInt32(e.CommandArgument); using (ExpenseTypeManager repository = new ExpenseTypeManager()) { expense = repository.Get(expenseID); } if (expense != null) { showEditPanel(); txtExpenseDescription.Text = expense.ExpenseDescription; txtExpenseName.Text = expense.ExpenseName; txtRateAmount.Value = expense.ExpenseRate; ViewState["ExpenseTypeID"] = expenseID.ToString(); } } else if (e.CommandName == "DoDelete") { try { expenseID = Convert.ToInt32(e.CommandArgument); using (ExpenseTypeManager repository = new ExpenseTypeManager()) { expense = repository.Get(expenseID); if (expense != null) { expense.IsActive = false; expense = repository.Save(expense); // refresh grid bindData(); } } } catch (Exception ex) { Core.EmailHelper.emailError(ex); showErrorMessage(); } } }
protected void btnSave_Click(object sender, EventArgs e) { ExpenseType expense = null; int expenseID = 0; lblMessage.Text = string.Empty; lblMessage.CssClass = string.Empty; expenseID = Convert.ToInt32(ViewState["ExpenseTypeID"]); if (expenseID == 0) { expense = new ExpenseType(); expense.ClientID = this.clientID; expense.IsActive = true; } else { using (ExpenseTypeManager repository = new ExpenseTypeManager()) { expense = repository.Get(expenseID); } } if (expense != null) { expense.ExpenseName = txtExpenseName.Text.Trim(); expense.ExpenseDescription = txtExpenseDescription.Text.Trim(); try { using (ExpenseTypeManager repository = new ExpenseTypeManager()) { expense = repository.Save(expense); } showGridPanel(); // refresh grid bindData(); } catch (Exception ex) { Core.EmailHelper.emailError(ex); showErrorMessage(); } } }
protected void ddlExpenseType_SelectedIndexChanged(object sender, EventArgs e) { ExpenseType expense = null; int expenseID = 0; if (ddlExpenseType.SelectedIndex > 0) { expenseID = Convert.ToInt32(ddlExpenseType.SelectedValue); using (ExpenseTypeManager repository = new ExpenseTypeManager()){ expense = repository.Get(expenseID); if (expense != null) { Session["multiplier"] = expense.ExpenseRate; if (Convert.ToDouble(expense.ExpenseRate) == 0.00) { txtExpenseQty.Text = ""; txtExpenseQty.Enabled = false; txtExpenseAmount.Visible = true; lblMyAmount.Text = "Amount"; lblAmount.Text = ""; lblAmount.Visible = false; } else { txtExpenseQty.Enabled = true; lblAmount.Visible = true; lblAmount.Text = "$" + expense.ExpenseRate.ToString(); txtExpenseAmount.Visible = false; lblMyAmount.Text = "Rate"; } // txtExpenseAmount.Value = "";//expense.ExpenseRate; } } } }
protected void gvExpense_RowCommand(object sender, GridViewCommandEventArgs e) { ClaimExpense claimExpense = null; int claimID = SessionHelper.getClaimID(); int id = 0; if (e.CommandName == "DoEdit") { id = Convert.ToInt32(e.CommandArgument); using (ClaimExpenseManager repository = new ClaimExpenseManager()) { claimExpense = repository.Get(id); } if (claimExpense != null) { txtExpenseAmount.Value = claimExpense.ExpenseAmount; txtExpenseQty.Value = claimExpense.ExpenseQty; if (claimExpense.ExpenseDate != null) { txtExpenseDate.Value = claimExpense.ExpenseDate; } txtExpenseDescription.Text = claimExpense.ExpenseDescription; cbxExpenseReimburse.Checked = claimExpense.IsReimbursable; ddlExpenseType.SelectedValue = claimExpense.ExpenseTypeID.ToString(); txtMyComments.Text = claimExpense.InternalComments; //cbIsBillable.Checked = claimExpense.IsBillable.Value; //NEW OC 10/7/2014 // PUT IN PLACE TO GRAB THE NEW RATE IF USER HITS EDIT ExpenseType expense = null; int expenseID = 0; if (ddlExpenseType.SelectedIndex > 0) { expenseID = Convert.ToInt32(ddlExpenseType.SelectedValue); using (ExpenseTypeManager repository = new ExpenseTypeManager()) { expense = repository.Get(expenseID); if (expense != null) { txtExpenseAmount.Value = expense.ExpenseRate; Session["multiplier"] = expense.ExpenseRate; } } } // END NEW OC 10/7/2014 if (claimExpense.AdjusterID != null) { txtExpenseAdjuster.Text = claimExpense.AdjusterMaster.adjusterName; hf_expenseAdjusterID.Value = claimExpense.AdjusterMaster.AdjusterId.ToString(); } showExpenseEditPanel(); ViewState["ClaimExpenseID"] = e.CommandArgument.ToString(); } } else if (e.CommandName == "DoDelete") { id = Convert.ToInt32(e.CommandArgument); try { using (ClaimExpenseManager repository = new ClaimExpenseManager()) { repository.Delete(id); } // refresh grid gvExpense.DataSource = loadExpenses(claimID); gvExpense.DataBind(); } catch (Exception ex) { Core.EmailHelper.emailError(ex); lblMessage.Text = "Unable to delete claim expense."; lblMessage.CssClass = "error"; } } }
protected void btnAddExpense_save_Click(object sender, EventArgs e) { CarrierInvoiceProfileFeeItemized item = null; ExpenseType expense = null; //NEW to account for rate pointing to correct place Page.Validate("expense"); if (!Page.IsValid) { return; } int profileID = Convert.ToInt32(ViewState["profileID"]); int id = Convert.ToInt32(ViewState["ID"]); if (id == 0) { item = new CarrierInvoiceProfileFeeItemized(); item.CarrierInvoiceProfileID = profileID; item.IsActive = true; } else { item = CarrierInvoiceProfileFeeItemizedManager.Get(id); } if (item != null) { item.ExpenseTypeID = Convert.ToInt32(ddlExpenses.SelectedValue); item.ItemDescription = txtExpenseDescription.Text; item.ItemPercentage = txtExpensePercentage.ValueDecimal; item.ItemRate = txtExpenseRate.ValueDecimal; item.AdjusterPayroll = txtExpPayroll.Text == null ? 0 : txtExpPayroll.ValueDecimal; item.AdjusterPayrollFlatFee = txtExpPayrollFee.Text == null ? 0 : txtExpPayrollFee.ValueDecimal; if (ddlConditionalOperator.SelectedIndex > 0) { item.LogicalOperator = Convert.ToInt32(ddlConditionalOperator.SelectedValue); item.LogicalOperatorOperand = txtOperand.ValueDecimal; } else { item.LogicalOperator = null; item.LogicalOperatorOperand = 0; } try { CarrierInvoiceProfileFeeItemizedManager.Save(item); } catch (Exception ex) { Core.EmailHelper.emailError(ex); } //new OC to save the expense rate into the expense type table 10/8/14 try { using (ExpenseTypeManager repository = new ExpenseTypeManager()) { int expenseID = Convert.ToInt32(ddlExpenses.SelectedValue); if (expenseID == 0) { expense = new ExpenseType(); expense.ClientID = Core.SessionHelper.getClientId(); expense.IsActive = true; } else { expense = repository.Get(expenseID); } if (expense != null) { expense.ExpenseRate = txtExpenseRate.ValueDecimal; //txtRateAmount.ValueDecimal; expense = repository.Save(expense); } } } catch (Exception ex) { Core.EmailHelper.emailError(ex); } pnlAddExpense.Visible = false; pnlGrid.Visible = true; bindItems(profileID); } }