private void BindEmployeeExpenseTypeLink() { try { EmployeeExpenseType employeeExpenseType = EmployeeExpenseType.GetEmployeeExpenseTypeLinkByEmployeeExpenseTypeLinkId(this.employeeExpenseTypeLinkId); DropDownListEmployeeExpenseType.Items.FindByValue(employeeExpenseType.EmployeeExpenseTypeId.ToString()).Selected = true; TextBoxExpenseDate.Text = employeeExpenseType.ExpenseDate.ToString("yyyy/MM/dd"); TextBoxDetail.Text = employeeExpenseType.Detail.ToString(); TextBoxComment.Text = employeeExpenseType.Comment.ToString(); var a = employeeExpenseType.Amount; var b = employeeExpenseType.Budget; TextBoxAmount.Text = employeeExpenseType.Amount.ToString(); TextBoxBudget.Text = employeeExpenseType.Budget.ToString(); BindGridviewResult(); } catch (System.Data.SqlClient.SqlException sqlEx) { for (int i = 0; i < sqlEx.Errors.Count; i++) { LabelError.Text += (sqlEx.Errors[i].Message + "<br />"); } PanelError.Visible = true; } catch (Exception exception) { LabelError.Text += (exception.Message + "<br />"); PanelError.Visible = true; } }
private void BindEmployeeExpenseType() { DropDownListEmployeeExpenseType.DataSource = EmployeeExpenseType.GetEmployeeExpenseTypeListByCompanyId(this.companyId); DropDownListEmployeeExpenseType.DataTextField = "FormattedDescriptionGlCode"; DropDownListEmployeeExpenseType.DataValueField = "EmployeeExpenseTypeId"; DropDownListEmployeeExpenseType.DataBind(); DropDownListEmployeeExpenseType.Items.Insert(0, new ListItem("Please select", "0")); }
protected void GridViewResult_RowCommand(object sender, GridViewCommandEventArgs e) { try { switch (e.CommandName.ToLower()) { case "removeemployeeexpensetypelink": { EmployeeExpenseType.DeleteEmployeeExpenseTypeLinkByEmployeeExpenseTypeLinkId(Convert.ToInt32(e.CommandArgument)); BindGridviewResult(); break; } } } catch (System.Data.SqlClient.SqlException sqlEx) { LabelError.Text = ""; for (int i = 0; i < sqlEx.Errors.Count; i++) { LabelError.Text += (sqlEx.Errors[i].Message + "<br />"); } PanelError.Visible = true; } }
protected void ButtonSave_Click(object sender, EventArgs e) { if (Page.IsValid) { LabelError.Text = ""; PanelError.Visible = false; DateTime expenseDateValidation; bool isDate = DateTime.TryParse(TextBoxExpenseDate.Text, out expenseDateValidation); if (!isDate) { LabelError.Text += "Valid Date is required.<br />"; PanelError.Visible = true; return; } decimal amountValidation; bool isDecimal = Decimal.TryParse(TextBoxAmount.Text, out amountValidation); if (!isDecimal) { LabelError.Text += "Valid Amount is required.<br />"; PanelError.Visible = true; return; } decimal budgetValidation; isDecimal = Decimal.TryParse(TextBoxBudget.Text, out budgetValidation); if (!isDecimal) { LabelError.Text += "Valid Budget is required.<br />"; PanelError.Visible = true; return; } EmployeeExpenseType employeeExpenseType = new EmployeeExpenseType(); employeeExpenseType.EmployeeExpenseTypeLinkId = this.employeeExpenseTypeLinkId; employeeExpenseType.EmployeeExpenseTypeId = Convert.ToInt32(DropDownListEmployeeExpenseType.SelectedValue); employeeExpenseType.EmployeeId = this.employeeId; employeeExpenseType.ExpenseDate = Convert.ToDateTime(TextBoxExpenseDate.Text); employeeExpenseType.Detail = TextBoxDetail.Text; employeeExpenseType.Comment = TextBoxComment.Text; employeeExpenseType.Amount = Convert.ToDecimal(TextBoxAmount.Text); employeeExpenseType.Budget = Convert.ToDecimal(TextBoxBudget.Text); employeeExpenseType.ModifiedUser = this.Master.LoggedOnAccount; try { employeeExpenseType.Save(); this.employeeExpenseTypeLinkId = employeeExpenseType.EmployeeExpenseTypeLinkId; Button clickedButton = (Button)sender; switch (clickedButton.ID) { case "ButtonSaveNew": Response.Redirect(String.Format("EmployeeExpenseEdit.aspx?employeeId={0}", this.employeeId)); break; } } catch (System.Data.SqlClient.SqlException sqlEx) { LabelError.Text = ""; for (int i = 0; i < sqlEx.Errors.Count; i++) { LabelError.Text += (sqlEx.Errors[i].Message + "<br />"); } PanelError.Visible = true; } } }
private void BindGridviewResult() { GridViewResult.DataSource = EmployeeExpenseType.GetEmployeeExpenseTypeListByEmployeeId(this.employeeId); GridViewResult.DataBind(); }