Exemplo n.º 1
0
        public EmployeeList GetAll()
        {
            Database database = new Database("Employer");

            database.Command.Parameters.Clear();
            database.Command.CommandType = System.Data.CommandType.StoredProcedure;
            database.Command.CommandText = "tblEmployeeGetAll";
            DataTable dt = database.ExecuteQuery();

            foreach (DataRow dr in dt.Rows)
            {
                Employee e = new Employee();
                e.Initialize(dr);
                e.InitializeBusinessData(dr);
                e.IsNew                 = false;
                e.IsDirty               = false;
                e.Savable              += Employee_Savable;
                e.Phones.Savable       += Phones_Savable;
                e.Emails.Savable       += Emails_Savable;
                e.Subordinates.Savable += Subordinates_Savable;
                e.Family.Savable       += Family_Savable;
                _List.Add(e);
            }

            return(this);
        }
Exemplo n.º 2
0
        public EmployeeList GetByDepartmentId(Guid departmentId)
        {
            Database database = new Database("Employer");

            database.Command.Parameters.Clear();
            database.Command.CommandType = System.Data.CommandType.StoredProcedure;
            database.Command.CommandText = "tblEmployeeGetByDepartmentId";
            database.Command.Parameters.Add("@DepartmentId", SqlDbType.UniqueIdentifier).Value = departmentId;
            DataTable dt = database.ExecuteQuery();

            foreach (DataRow dr in dt.Rows)
            {
                Employee e = new Employee();
                e.Initialize(dr);
                e.InitializeBusinessData(dr);
                e.IsNew                 = false;
                e.IsDirty               = false;
                e.Savable              += Employee_Savable;
                e.Phones.Savable       += Phones_Savable;
                e.Emails.Savable       += Emails_Savable;
                e.Subordinates.Savable += Subordinates_Savable;
                _List.Add(e);
            }

            return(this);
        }