protected void salaryCalculator_Click(object sender, EventArgs e)
        {
            DateTime date            = DateTime.Now;
            var      firstDayOfMonth = new DateTime(date.Year, date.Month, 1);
            var      lastDayOfMonth  = firstDayOfMonth.AddMonths(1).AddDays(-1);

            int fridays = CountDays(DayOfWeek.Friday, firstDayOfMonth, lastDayOfMonth);


            var employee = _employeeUserManager.GetEmployeeById(EmployeeId);
            int month    = int.Parse(DateTime.Now.ToString("MM"));
            int year     = int.Parse(DateTime.Now.Year.ToString());

            int    days         = DateTime.DaysInMonth(year, month) - fridays;
            double salaryPerDay = employee.BasicSalary / days;

            if (days != Count)
            {
                int absentday = days - Count;
                employee.BasicSalary -= (absentday * salaryPerDay);
            }



            var empSalary = new EmpSalary()
            {
                EmployeeName    = employee.FullName,
                EmployeeCode    = employee.EmployeeId,
                TotalPresentDay = Count,
                Salary          = employee.BasicSalary
            };

            Session["empSalalry"] = empSalary;
            Response.Redirect("EmployeeSalary.aspx");
        }
Exemplo n.º 2
0
        protected void employeeDropdownList_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (employeeDropdownList.SelectedIndex == 0)
            {
            }
            else
            {
                firstNameTextBox.Enabled = true;
                lastNameTextBox.Enabled  = true;
                emailTextBox.Enabled     = true;
                Employee emp = _employeeUserManager.
                               GetEmployeeById(int.Parse(employeeDropdownList
                                                         .SelectedItem.Value.ToString()));

                firstNameTextBox.Text = emp.FirstName;
                lastNameTextBox.Text  = emp.LastName;
                emailTextBox.Text     = emp.Email;
            }
        }
Exemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var role = (string)Session["role"];

            if (Session["username"] == null || role != "Admin")
            {
                Response.Redirect("Login.aspx");
            }

            if (string.IsNullOrEmpty(Request.QueryString["Id"]))
            {
                Response.Redirect("EmployeeEntry.aspx?Id=" + 0);
            }

            if (!IsPostBack)
            {
                ListItem listItem = new ListItem("---------Select One---------", "-1");
                roleDropDownBox.DataSource = _roleManager.GetAllRoles().ToList();
                roleDropDownBox.DataBind();

                sectionDropDownBox.DataSource = _sectionManager.GetAllSections();
                sectionDropDownBox.DataBind();

                designationDropDownBox.DataSource = _designationManager.GetAllDesignations();
                designationDropDownBox.DataBind();

                branchDropDownBox.DataSource = _branchManager.GetAllBranch();
                branchDropDownBox.DataBind();

                roleDropDownBox.Items.Insert(0, listItem);
                sectionDropDownBox.Items.Insert(0, listItem);
                designationDropDownBox.Items.Insert(0, listItem);
                branchDropDownBox.Items.Insert(0, listItem);

                int id = int.Parse(Request.QueryString["Id"].ToString());
                if (id > 0)
                {
                    passwordTextBox.Visible        = false;
                    confirmPasswordTextBox.Visible = false;
                    emailTextBox.Visible           = false;
                    passwordLabel.Visible          = false;
                    confirmPasswordLabel.Visible   = false;
                    emailLabel.Visible             = false;


                    Employee employee = _employeeUserManager.GetEmployeeById(id);
                    employeeIdHiddenField.Value = employee.Id.ToString();
                    fullNameTextBox.Text        = employee.FullName;
                    firstNameTextBox.Text       = employee.FirstName;
                    lastNameTextBox.Text        = employee.LastName;
                    roleDropDownBox.DataSource  = _roleManager.GetAllRoles().ToList();
                    roleDropDownBox.DataBind();
                    roleDropDownBox.Items.FindByValue(employee.RoleId.ToString()).Selected = true;
                    mobileTextBox.Text = employee.MobileNo;
                    sectionDropDownBox.Items.FindByValue(employee.SectionId.ToString()).Selected         = true;
                    designationDropDownBox.Items.FindByValue(employee.DesignationId.ToString()).Selected = true;
                    salaryTextBox.Text = employee.BasicSalary.ToString();
                    if (employee.Gander == "Male")
                    {
                        maleRadioButton.Checked = true;
                    }
                    else
                    {
                        femaleRadioButton.Checked = true;
                    }
                    dateOfBirthTextBox.Text = employee.DateOfBirth.ToString();
                    joinDateTextBox.Text    = employee.JoinDate.ToString();
                    branchDropDownBox.Items.FindByValue(employee.BranchId.ToString()).Selected = true;
                    addressTextBox.Text = employee.Address;
                }
            }
        }