コード例 #1
0
    private void BindEmployeeData(string empName)
    {
        DataTable dtEmployee = employee.GetEmployeeData(empName);

        if (dtEmployee != null && dtEmployee.Rows.Count > 0)
        {
            ViewState["EmpID"] = dtEmployee.Rows[0]["pEmployeeMasterID"].ToString();
            lblUserName.Text   = dtEmployee.Rows[0]["EmployeeName"].ToString();
            SelectItem(ddlSalutation, dtEmployee.Rows[0]["Salutation"].ToString());
            SelectItem(ddlHireLocation, dtEmployee.Rows[0]["Location"].ToString());
            //hidLocation.Value = ddlHireLocation.SelectedItem.Text;
            EmpLocation = (ddlHireLocation.SelectedItem.Value.ToString() != "")?((ddlHireLocation.SelectedItem.Value.ToString()) + "-" + (ddlHireLocation.SelectedItem.Text.ToString())):"";
            employee.BindListControls(ddlSupervisior, "Supervisior", "pEmployeeMasterID", employee.GetSupervisior(ddlHireLocation.SelectedItem.Value.ToString()), "--Select--");
            //dtEmployee.Rows[0]["Location"].ToString();
            txtEmpNo.Text = dtEmployee.Rows[0]["EmployeeNo"].ToString();
            SelectItem(ddlStatus, dtEmployee.Rows[0]["EmploymentStatus"].ToString());
            dtpHireDate.SelectedDate = ((dtEmployee.Rows[0]["HireDt"].ToString() != "01/01/1900") ? dtEmployee.Rows[0]["HireDt"].ToString() : "");
            SelectItem(ddlDepartment, dtEmployee.Rows[0]["DepartmentNo"].ToString());
            SelectItem(ddlPosition, dtEmployee.Rows[0]["DefaultJobCd"].ToString());
            SelectItem(ddlShift, dtEmployee.Rows[0]["Shift"].ToString());
            SelectItem(ddlSupervisior, dtEmployee.Rows[0]["SupervisorEmpID"].ToString());
            txtFirstName.Text  = dtEmployee.Rows[0]["FirstName"].ToString();
            txtMiddleName.Text = dtEmployee.Rows[0]["MiddleInitial"].ToString().Trim();
            txtLastName.Text   = dtEmployee.Rows[0]["LastName"].ToString();
            txtEmail.Text      = dtEmployee.Rows[0]["EmailAddress"].ToString().Replace("@porteousfastener.com", "");
            txtPhone.Text      = FormatPhoneBasedOnLocation(dtEmployee.Rows[0]["PhoneNo"].ToString(), ddlHireLocation.SelectedItem.Value.ToString());
            txtFax.Text        = FormatPhoneBasedOnLocation(dtEmployee.Rows[0]["FaxNo"].ToString(), ddlHireLocation.SelectedItem.Value.ToString());
            SelectItem(ddlPayCode, dtEmployee.Rows[0]["PayCd"].ToString());
            txtPayrollEmpNo.Text = dtEmployee.Rows[0]["PayrollEmployeeNo"].ToString();
            SelectItem(ddlPayrollLoc, dtEmployee.Rows[0]["PayRollLocation"].ToString());
            txtHoliday.Text    = dtEmployee.Rows[0]["HolidayHours"].ToString();
            txtSick.Text       = dtEmployee.Rows[0]["SickHours"].ToString();
            txtVacation.Text   = dtEmployee.Rows[0]["VacationHours"].ToString();
            txtBegin.Text      = ((dtEmployee.Rows[0]["LeaveBeginDt"].ToString() != "01/01/1900")? dtEmployee.Rows[0]["LeaveBeginDt"].ToString():"");
            txtEnd.Text        = ((dtEmployee.Rows[0]["LeaveEndDt"].ToString() != "01/01/1900")?dtEmployee.Rows[0]["LeaveEndDt"].ToString():"");
            txtAbsenceBal.Text = ((dtEmployee.Rows[0]["LeaveBalanceDt"].ToString() != "01/01/1900")?dtEmployee.Rows[0]["LeaveBalanceDt"].ToString():"");
            txtBalance.Text    = ((dtEmployee.Rows[0]["BenefitBalance"].ToString() != "") ? (String.Format("{0:###0.00}", Convert.ToDecimal(dtEmployee.Rows[0]["BenefitBalance"].ToString()))) : "");

            ViewState["UserID"] = employee.GetUserIDByEmployeeID(ViewState["EmpID"].ToString());
        }
        // hidUserName.Value = "";
        ViewState["Mode"] = "Save";
    }