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 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); } }