示例#1
0
        protected void btnSave_Command(object sender, CommandEventArgs e)
        {
            // Save the new employee
            Employee employee = GetEmployeeDetailsFromForm();

            employee.EmployeeID = EmployeeManager.Save(employee);

            //Save the home address
            Address myHomeAddress = null;

            myHomeAddress           = GetHomeAddressDetailsFromForm();
            myHomeAddress.AddressID = AddressManager.Save(myHomeAddress);

            //Save the Home address and the new employee on the EmployeeAddress table
            EmployeeAddress newEmployeeAddress = new EmployeeAddress();

            newEmployeeAddress.EmployeeID  = employee.EmployeeID;
            newEmployeeAddress.AddressID   = myHomeAddress.AddressID;
            newEmployeeAddress.AddressType = Convert.ToInt32(AddressType.Home);
            EmployeeAddressManager.AddEmployeeAddress(newEmployeeAddress);

            Session["employeeID"] = null;
            Session["employeeID"] = employee.EmployeeID;
            Response.Redirect("~/Admin/EmployeeManagement/ViewEmployee.aspx");
        }
示例#2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if ((Session["employeeID"] == null))
                {
                    // go back to the seach employee page
                    Response.Redirect("~/Admin/EmployeeManagement/SearchEmployee.aspx");
                }
                else
                {
                    employeeID       = Convert.ToInt32(Session["employeeID"]);
                    employeeSearched = EmployeeManager.GetEmployeeByID(employeeID);

                    // dislay the employee details
                    DisplayEmployee(employeeSearched);

                    // Get job description
                    position = JobPositionManager.GetPositionByID(employeeSearched.JobPositionID);
                    DisplayJobPosition(position);

                    // With the employee id, get the address id for the Home Address
                    // from the EmployeeAddress table
                    homeAddress.AddressID = EmployeeAddressManager.GetAddressID(Convert.ToInt32(AddressType.Home), employeeSearched.EmployeeID);
                    homeAddress           = AddressManager.GetAddressById(homeAddress.AddressID);
                    DisplayHomeAddress(homeAddress);
                }
            }
        }