private void BindFinancialPeriod() { DropDownListFinancialPeriod.ClearSelection(); DropDownListFinancialPeriod.DataSource = FinancialPeriod.GetFinancialPeriodList(Account.GetAccountByUserName(Page.User.Identity.Name.ToString()).CompanyId); DropDownListFinancialPeriod.DataTextField = "Description"; DropDownListFinancialPeriod.DataValueField = "FinancialPeriodId"; DropDownListFinancialPeriod.DataBind(); //if (DropDownListFinancialPeriod.Items.Count > 1) //{ // DropDownListFinancialPeriod.Items.Insert(0, new ListItem("Please select", "0")); //} //else //{ if (this.financialPeriodId == 0) { this.financialPeriodId = Convert.ToInt32(DropDownListFinancialPeriod.SelectedValue); } BindEmployeeLeave(); //} }
protected void Page_Load(object sender, EventArgs e) { this.employeeId = Common.GetEncryptedQueryStringValue("employeeId", 0); this.financialPeriodId = Common.GetEncryptedQueryStringValue("financialPeriodId", 0); this.employeeLeaveDaysId = Common.GetEncryptedQueryStringValue("employeeLeaveDaysId", 0); ViewState["formLoggedInId"] = Account.GetAccountByUserName(Page.User.Identity.Name.ToString()).EmployeeId; ViewState["formReportsToId"] = EmployeeReportsTo.GetEmployeeReportsToByEmployeeId(this.employeeId, Convert.ToInt32(ViewState["formLoggedInId"])).ReportsToId; LabelPageTitle.Text = String.Format("{0} {1}", "Employee Leave", Employee.GetEmployeeByEmployeeId(this.employeeId).FormattedNameNumber); PanelError.Visible = false; Page.Form.DefaultFocus = DropDownListFinancialPeriod.ClientID; Page.Form.DefaultButton = ButtonSave.UniqueID; if (!IsPostBack) { //PanelLeaveHeader.Enabled = Roles.IsUserInRole("Administrator") || Roles.IsUserInRole("Supplier"); ButtonSave.Enabled = Roles.IsUserInRole("Administrator") || Roles.IsUserInRole("Supplier"); DropDownListFinancialPeriod.Focus(); //CalendarExtenderStartDate.SelectedDate = DateTime.Now; //CalendarExtenderEndDate.SelectedDate = DateTime.Now; BindFinancialPeriod(); if (ViewState["employeeId"] != null) { this.employeeId = Convert.ToInt32(ViewState["employeeId"].ToString()); } if (this.financialPeriodId > 0) { DropDownListFinancialPeriod.ClearSelection(); DropDownListFinancialPeriod.Items.FindByValue(this.financialPeriodId.ToString()).Selected = true; } if (this.employeeId != 0 && Convert.ToInt32(DropDownListFinancialPeriod.SelectedValue) != 0) { BindEmployeeLeave(); PanelEmployeeLeaveDays.Visible = true; PanelEmployeeProjectedLeave.Visible = true; } else { PanelEmployeeLeaveDays.Visible = false; PanelEmployeeProjectedLeave.Visible = false; } if (this.financialPeriodId > 0) { ButtonSaveNew.Visible = false; PanelEmployeeLeaveDays.Visible = true; BindLeaveType(); BindGridviewResult(); } else { ButtonSaveNew.Visible = true; PanelEmployeeLeaveDays.Visible = false; } if (this.employeeLeaveDaysId != 0) { BindEmployeeLeaveDays(); ButtonSaveEmployeeLeaveDays.Visible = false; ButtonUpdateEmployeeLeaveDays.Visible = true; } else { ButtonSaveEmployeeLeaveDays.Visible = true; ButtonUpdateEmployeeLeaveDays.Visible = false; } BindEmployeeLeave(); } }