Example #1
0
        public void AddToEmployeeTest()
        {
            ICRUDTestDBContextProvider cRUDTestDBContextProvider = new CRUDTestDBContextProvider(Guid.NewGuid().ToString());
            var context   = cRUDTestDBContextProvider.GetContext();
            var employee1 = new Employee {
                EmployeeId = 1, FirstName = "Test1First", LastName = "Test1Last"
            };
            var employee2 = new Employee {
                EmployeeId = 2, FirstName = "Test2First", LastName = "Test2Last"
            };

            context.Add(employee1);
            context.Add(employee2);
            context.SaveChanges();

            EmployeeBE employeeBE  = new EmployeeBE(cRUDTestDBContextProvider);
            EmployeeBE employeeBE2 = new EmployeeBE(cRUDTestDBContextProvider);

            employeeBE.Load(1);
            employeeBE2.Load(2);
            employeeBE2.AddSubordinate(employeeBE);
            employeeBE.Save();

            employeeBE.Load(1);
            var employeeBECollection = employeeBE2.GetReportsToThisEmployee();

            Assert.IsTrue(employeeBECollection.First().Id == 1);
            Assert.IsTrue(employeeBECollection.First().ReportsTo == 2);
        }
Example #2
0
        public void AddToCustomersTest()
        {
            ICRUDTestDBContextProvider cRUDTestDBContextProvider = new CRUDTestDBContextProvider(Guid.NewGuid().ToString());
            var context  = cRUDTestDBContextProvider.GetContext();
            var customer = new Customer {
                CustomerId = 1, FirstName = "TestFirst", LastName = "TestLast", Email = "Test"
            };
            var employee = new Employee {
                EmployeeId = 1, FirstName = "TesteFirst", LastName = "TesteLast", Email = "eTest"
            };

            context.Add(customer);
            context.Add(employee);
            context.SaveChanges();

            CustomerBE customerBE = new CustomerBE(cRUDTestDBContextProvider);
            EmployeeBE employeeBE = new EmployeeBE(cRUDTestDBContextProvider);

            employeeBE.Load(1);
            customerBE.Load(1);
            employeeBE.AddToCustomer(customerBE);
            customerBE.Save();

            employeeBE.Load(1);
            var customerBECollection = employeeBE.GetCustomers();

            Assert.IsTrue(customerBECollection.First().Id == 1);
            Assert.IsTrue(customerBECollection.First().SupportRepId == 1);
        }
        public void InicializarModificar()
        {
            if (gvPersona.RowCount > 0)
            {
                EmployeeBE objEmployee = new EmployeeBE();
                objEmployee.IdCompany  = int.Parse(gvPersona.GetFocusedRowCellValue("IdCompany").ToString());
                objEmployee.IdWorkArea = int.Parse(gvPersona.GetFocusedRowCellValue("IdWorkArea").ToString());
                objEmployee.IdEmployee = int.Parse(gvPersona.GetFocusedRowCellValue("IdEmployee").ToString());

                frmManPersonaEdit objManPersonaEdit = new frmManPersonaEdit();
                objManPersonaEdit.pOperacion = frmManPersonaEdit.Operacion.Modificar;


                objManPersonaEdit.IdWorkArea    = objEmployee.IdWorkArea;
                objManPersonaEdit.IdEmployee    = objEmployee.IdEmployee;
                objManPersonaEdit.pEmployeeBE   = objEmployee;
                objManPersonaEdit.StartPosition = FormStartPosition.CenterParent;
                objManPersonaEdit.ShowDialog();

                Cargar();
            }
            else
            {
                MessageBox.Show("Edist");
            }
        }
Example #4
0
        public void ReportsToCountTest()
        {
            ICRUDTestDBContextProvider cRUDTestDBContextProvider = new CRUDTestDBContextProvider(Guid.NewGuid().ToString());
            var context  = cRUDTestDBContextProvider.GetContext();
            var employee = new Employee {
                EmployeeId = 1, ReportsTo = 3, FirstName = "TestFirst", LastName = "TestLast", Email = "Test"
            };
            var employee2 = new Employee {
                EmployeeId = 2, FirstName = "Test2First", LastName = "Test2Last", Email = "2Test"
            };
            var employeeReportedTo = new Employee {
                EmployeeId = 3, FirstName = "Test3First", LastName = "Test3Last", Email = "3Test"
            };

            context.Add(employee);
            context.Add(employee2);
            context.Add(employeeReportedTo);
            context.SaveChanges();

            EmployeeBE employeeBE = new EmployeeBE(cRUDTestDBContextProvider);

            employeeBE.Load(3);
            Assert.IsTrue(employeeBE.ReportsToCount == 1);

            EmployeeBE employeeBE2 = new EmployeeBE(cRUDTestDBContextProvider);

            employeeBE2.Load(2);
            employeeBE.AddSubordinate(employeeBE2);
            employeeBE2.Save();

            EmployeeBE employeeBE3 = new EmployeeBE(cRUDTestDBContextProvider);

            employeeBE3.Load(3);
            Assert.IsTrue(employeeBE3.ReportsToCount == 2);
        }
Example #5
0
 private void SeleccionarRegistro()
 {
     if (gvPersona.RowCount > 0)
     {
         EmployeeBE objEmployee = new EmployeeBE();
         if (pFlagMultiSelect)
         {
             List <EmployeeBE> lista = new List <EmployeeBE>();
             foreach (int i in gvPersona.GetSelectedRows())
             {
                 objEmployee = (EmployeeBE)gvPersona.GetRow(i);
                 lista.Add(objEmployee);
             }
             pListaEmployee = lista;
         }
         else
         {
             int index = gvPersona.FocusedRowHandle;
             objEmployee = (EmployeeBE)gvPersona.GetRow(index);
             pEmployeeBE = objEmployee;
         }
         this.Close();
     }
     else
     {
         MessageBox.Show("No existen registros.", "Busqueda Employee");
     }
 }
        public void testAddEmployee_Add3EmployeesValidValues_EmployeeCountIncreasedBy3()
        {
            EmployeeViewmodel employeeViewmodel = new EmployeeViewmodel();

            employeeViewmodel.EmployeeList = new ObservableCollection <EmployeeBE>();
            EmployeeBE employee1 = new EmployeeBE();

            employee1.Id   = "1001";
            employee1.Name = "Nirmal";
            employee1.Age  = "28";
            employeeViewmodel.AddEmployee(employee1);
            EmployeeBE employee2 = new EmployeeBE();

            employee2.Id   = "1002";
            employee2.Name = "John";
            employee2.Age  = "35";
            employeeViewmodel.AddEmployee(employee2);
            EmployeeBE employee3 = new EmployeeBE();

            employee3.Id   = "1003";
            employee3.Name = "Sarah";
            employee3.Age  = "25";
            employeeViewmodel.AddEmployee(employee3);
            Assert.AreEqual(3, employeeViewmodel.EmployeeList.Count);
        }
        private void tlbMenu_DeleteClick()
        {
            try
            {
                Cursor = Cursors.WaitCursor;
                if (XtraMessageBox.Show("Be sure to delete the record?", this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    if (!ValidarIngreso())
                    {
                        EmployeeBE objE_Persona = new EmployeeBE();
                        objE_Persona.IdEmployee = int.Parse(gvPersona.GetFocusedRowCellValue("IdEmployee").ToString());
                        objE_Persona.Login      = Parametros.strUsuarioLogin;
                        objE_Persona.Machine    = WindowsIdentity.GetCurrent().Name.ToString();
                        objE_Persona.IdCompany  = Parametros.intEmpresaId;

                        EmployeeBL objBL_Area = new EmployeeBL();
                        objBL_Area.Elimina(objE_Persona);
                        XtraMessageBox.Show("The record was successfully deleted.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                        Cargar();
                    }
                }
                Cursor = Cursors.Default;
            }
            catch (Exception ex)
            {
                Cursor = Cursors.Default;
                XtraMessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #8
0
        public void CustomerCountTest()
        {
            ICRUDTestDBContextProvider cRUDTestDBContextProvider = new CRUDTestDBContextProvider(Guid.NewGuid().ToString());
            var context  = cRUDTestDBContextProvider.GetContext();
            var customer = new Customer {
                CustomerId = 1, SupportRepId = 1, FirstName = "TestFirst", LastName = "TestLast", Email = "Test"
            };
            var customer2 = new Customer {
                CustomerId = 2, FirstName = "Test2First", LastName = "Test2Last", Email = "2Test"
            };
            var employee = new Employee {
                EmployeeId = 1, FirstName = "TesteFirst", LastName = "TesteLast", Email = "eTest"
            };

            context.Add(customer);
            context.Add(customer2);
            context.Add(employee);
            context.SaveChanges();

            EmployeeBE employeeBE = new EmployeeBE(cRUDTestDBContextProvider);

            employeeBE.Load(1);
            Assert.IsTrue(employeeBE.CustomerCount == 1);

            CustomerBE customerBE = new CustomerBE(cRUDTestDBContextProvider);

            customerBE.Load(2);
            employeeBE.AddToCustomer(customerBE);
            customerBE.Save();

            EmployeeBE employeeBE2 = new EmployeeBE(cRUDTestDBContextProvider);

            employeeBE2.Load(1);
            Assert.IsTrue(employeeBE2.CustomerCount == 2);
        }
Example #9
0
        public void Actualiza(EmployeeBE pItem)
        {
            Database  db        = DatabaseFactory.CreateDatabase("cnERPBD");
            DbCommand dbCommand = db.GetStoredProcCommand("usp_Employee_Actualiza");

            db.AddInParameter(dbCommand, "pIdEmployee", DbType.Int32, pItem.IdEmployee);
            db.AddInParameter(dbCommand, "pIdCompany", DbType.Int32, pItem.IdCompany);
            db.AddInParameter(dbCommand, "pIdWorkArea", DbType.Int32, pItem.IdWorkArea);
            db.AddInParameter(dbCommand, "pDocumentNumber", DbType.String, pItem.DocumentNumber);
            db.AddInParameter(dbCommand, "pName", DbType.String, pItem.Name);
            db.AddInParameter(dbCommand, "pLastName", DbType.String, pItem.LastName);
            db.AddInParameter(dbCommand, "pFullName", DbType.String, pItem.FullName);
            db.AddInParameter(dbCommand, "pIdGender", DbType.Int32, pItem.IdGender);
            db.AddInParameter(dbCommand, "pIdCivilStatus", DbType.Int32, pItem.IdCivilStatus);
            db.AddInParameter(dbCommand, "pIdOccupation", DbType.Int32, pItem.IdOccupation);
            db.AddInParameter(dbCommand, "pEssalud", DbType.String, pItem.Essalud);
            db.AddInParameter(dbCommand, "pFlagEps", DbType.Boolean, pItem.FlagEps);
            db.AddInParameter(dbCommand, "pFlagSctr", DbType.Boolean, pItem.FlagSctr);
            db.AddInParameter(dbCommand, "pLicense", DbType.String, pItem.License);
            db.AddInParameter(dbCommand, "pBithDate", DbType.DateTime, pItem.BithDate);
            db.AddInParameter(dbCommand, "pIdUbigeo", DbType.String, pItem.IdUbigeo);
            db.AddInParameter(dbCommand, "pAddress", DbType.String, pItem.Address);
            db.AddInParameter(dbCommand, "pPhone", DbType.String, pItem.Phone);
            db.AddInParameter(dbCommand, "pCelPhone1", DbType.String, pItem.CelPhone1);
            db.AddInParameter(dbCommand, "pCelPhone2", DbType.String, pItem.CelPhone2);
            db.AddInParameter(dbCommand, "pEmail", DbType.String, pItem.Email);
            db.AddInParameter(dbCommand, "pPhoto", DbType.Binary, pItem.Photo);
            db.AddInParameter(dbCommand, "pComment", DbType.String, pItem.Comment);
            db.AddInParameter(dbCommand, "pIdSituation", DbType.Int32, pItem.IdSituation);
            db.AddInParameter(dbCommand, "pFlagState", DbType.Boolean, pItem.FlagState);
            db.AddInParameter(dbCommand, "pLogin", DbType.String, pItem.Login);
            db.AddInParameter(dbCommand, "pMachine", DbType.String, pItem.Machine);

            db.ExecuteNonQuery(dbCommand);
        }
Example #10
0
        public bool Insert(EmployeeBE emp)
        {
            Mapper.Initialize(cf => cf.CreateMap <EmployeeBE, Employee>());
            EmployeeDAC dac = new EmployeeDAC();

            dac.Insert(Mapper.Map <EmployeeBE, Employee>(emp));
            return(true);
        }
Example #11
0
 public void Actualiza(EmployeeBE pItem)
 {
     try
     {
         EmployeeDL Employee = new EmployeeDL();
         Employee.Actualiza(pItem);
     }
     catch (Exception ex)
     { throw ex; }
 }
Example #12
0
 public void Elimina(EmployeeBE pItem)
 {
     try
     {
         EmployeeDL Employee = new EmployeeDL();
         Employee.Elimina(pItem);
     }
     catch (Exception ex)
     { throw ex; }
 }
Example #13
0
 public void Inserta(EmployeeBE pItem)
 {
     try
     {
         EmployeeDL Employee = new EmployeeDL();
         Employee.Inserta(pItem);
     }
     catch (Exception ex)
     { throw ex; }
 }
Example #14
0
 public EmployeeBE SeleccionaNumeroDocumento(string Dni)
 {
     try
     {
         EmployeeDL Employee = new EmployeeDL();
         EmployeeBE objEmp   = Employee.SeleccionaNumeroDocumento(Dni);
         return(objEmp);
     }
     catch (Exception ex)
     { throw ex; }
 }
        public HttpResponseMessage Post([FromBody] EmployeeBE emp)
        {
            EmployeeBLO blo = new EmployeeBLO();

            if (blo.Insert(emp))
            {
                var response = Request.CreateResponse(HttpStatusCode.Created);
                return(response);
            }
            return(Request.CreateResponse(HttpStatusCode.BadRequest));
        }
Example #16
0
 private Employee Map(EmployeeBE e)
 {
     return(new Employee
     {
         Salary = e.Salary,
         Workdays = e.Workdays,
         Name = e.Name,
         Surname = e.Surname,
         Id = e.Id
     });
 }
Example #17
0
        public List <EmployeeBE> ListaTodosActivo(int IdCompany, int IdWorkArea)
        {
            Database  db        = DatabaseFactory.CreateDatabase("cnERPBD");
            DbCommand dbCommand = db.GetStoredProcCommand("usp_Employee_ListaTodosActivo");

            db.AddInParameter(dbCommand, "pIdCompany", DbType.Int32, IdCompany);
            db.AddInParameter(dbCommand, "pIdWorkArea", DbType.Int32, IdWorkArea);

            IDataReader       reader       = db.ExecuteReader(dbCommand);
            List <EmployeeBE> Employeelist = new List <EmployeeBE>();
            EmployeeBE        Employee;

            while (reader.Read())
            {
                Employee                = new EmployeeBE();
                Employee.IdEmployee     = Int32.Parse(reader["idEmployee"].ToString());
                Employee.IdCompany      = Int32.Parse(reader["IdCompany"].ToString());
                Employee.IdWorkArea     = Int32.Parse(reader["IdWorkArea"].ToString());
                Employee.NameWorkArea   = reader["NameWorkArea"].ToString();
                Employee.DocumentNumber = reader["DocumentNumber"].ToString();
                Employee.Name           = reader["Name"].ToString();
                Employee.LastName       = reader["LastName"].ToString();
                Employee.FullName       = reader["FullName"].ToString();
                Employee.IdGender       = Int32.Parse(reader["IdGender"].ToString());
                Employee.NameGender     = reader["NameGender"].ToString();
                Employee.IdOccupation   = Int32.Parse(reader["IdOccupation"].ToString());
                Employee.NameOccupation = reader["NameOccupation"].ToString();
                Employee.Essalud        = reader["Essalud"].ToString();
                Employee.FlagEps        = Boolean.Parse(reader["FlagEps"].ToString());
                Employee.FlagSctr       = Boolean.Parse(reader["FlagSctr"].ToString());
                Employee.License        = reader["License"].ToString();
                Employee.IdCivilStatus  = Int32.Parse(reader["IdCivilStatus"].ToString());
                Employee.NameStateCivil = reader["NameStateCivil"].ToString();
                Employee.BithDate       = DateTime.Parse(reader["BithDate"].ToString());
                Employee.IdUbigeo       = reader["IdUbigeo"].ToString();
                Employee.NomDpto        = reader["NomDpto"].ToString();
                Employee.NomProv        = reader["NomProv"].ToString();
                Employee.NomDist        = reader["NomDist"].ToString();
                Employee.Address        = reader["Address"].ToString();
                Employee.Phone          = reader["Phone"].ToString();
                Employee.CelPhone1      = reader["CelPhone1"].ToString();
                Employee.CelPhone2      = reader["CelPhone2"].ToString();
                Employee.Email          = reader["Email"].ToString();
                //Employee.Photo = (byte[])reader["Photo"];
                Employee.Comment       = reader["Comment"].ToString();
                Employee.IdSituation   = Int32.Parse(reader["IdSituation"].ToString());
                Employee.NameSituation = reader["NameSituation"].ToString();
                Employee.FlagState     = Boolean.Parse(reader["FlagState"].ToString());
                Employeelist.Add(Employee);
            }
            reader.Close();
            reader.Dispose();
            return(Employeelist);
        }
Example #18
0
 public EmployeeBE SeleccionaDescripcion(int IdEmpresa, int IdArea, string DescEmployee)
 {
     try
     {
         EmployeeDL Employee = new EmployeeDL();
         EmployeeBE objEmp   = Employee.SeleccionaDescripcion(IdEmpresa, IdArea, DescEmployee);
         return(objEmp);
     }
     catch (Exception ex)
     { throw ex; }
 }
Example #19
0
        public void SaveWithoutIdTest()
        {
            ICRUDTestDBContextProvider cRUDTestDBContextProvider = new CRUDTestDBContextProvider(Guid.NewGuid().ToString());
            EmployeeBE employeeBE = new EmployeeBE(cRUDTestDBContextProvider);

            employeeBE.New();
            employeeBE.FirstName = "TestFirstName";
            employeeBE.LastName  = "TestLastName";
            employeeBE.Save();

            Assert.IsTrue(employeeBE.Id != default);
        }
Example #20
0
        public void Elimina(EmployeeBE pItem)
        {
            Database  db        = DatabaseFactory.CreateDatabase("cnERPBD");
            DbCommand dbCommand = db.GetStoredProcCommand("usp_Employee_Elimina");

            db.AddInParameter(dbCommand, "pIdEmployee", DbType.Int32, pItem.IdEmployee);
            db.AddInParameter(dbCommand, "pIdCompany", DbType.Int32, pItem.IdCompany);
            db.AddInParameter(dbCommand, "pLogin", DbType.String, pItem.Login);
            db.AddInParameter(dbCommand, "pMachine", DbType.String, pItem.Machine);

            db.ExecuteNonQuery(dbCommand);
        }
        public void testAddEmployee_NameIdAgeCorrectValues_EmployeeCountIncreased()
        {
            EmployeeViewmodel employeeViewmodel = new EmployeeViewmodel();

            employeeViewmodel.EmployeeList = new ObservableCollection <EmployeeBE>();
            EmployeeBE employee = new EmployeeBE();

            employee.Id   = "1001";
            employee.Name = "Nirmal";
            employee.Age  = "28";
            employeeViewmodel.AddEmployee(employee);
            Assert.AreEqual(1, employeeViewmodel.EmployeeList.Count);
        }
        public void testAddEmployee_NameAgeIdBlank_EmployeeCountConstant()
        {
            EmployeeViewmodel employeeViewmodel = new EmployeeViewmodel();

            employeeViewmodel.EmployeeList = new ObservableCollection <EmployeeBE>();
            EmployeeBE employee = new EmployeeBE();

            employee.Id   = "";
            employee.Name = "";
            employee.Id   = "";
            employeeViewmodel.AddEmployee(employee);
            Assert.AreEqual(0, employeeViewmodel.EmployeeList.Count);
        }
        public void testAddEmployee_NegativeAgeValue_EmployeeCountConstant()
        {
            EmployeeViewmodel employeeViewmodel = new EmployeeViewmodel();

            employeeViewmodel.EmployeeList = new ObservableCollection <EmployeeBE>();
            EmployeeBE employee = new EmployeeBE();

            employee.Id   = "1001";
            employee.Name = "Nirmal";
            employee.Age  = "-28";
            employeeViewmodel.AddEmployee(employee);
            Assert.AreEqual(0, employeeViewmodel.EmployeeList.Count);
        }
        public void testAddEmployee_NameContainingUnderscore_EmployeeCountConstant()
        {
            EmployeeViewmodel employeeViewmodel = new EmployeeViewmodel();

            employeeViewmodel.EmployeeList = new ObservableCollection <EmployeeBE>();
            EmployeeBE employee = new EmployeeBE();

            employee.Id   = "1001";
            employee.Name = "Nirmal_P";
            employee.Age  = "28";
            employeeViewmodel.AddEmployee(employee);
            Assert.AreEqual(0, employeeViewmodel.EmployeeList.Count);
        }
Example #25
0
        public void ToStringTest()
        {
            ICRUDTestDBContextProvider cRUDTestDBContextProvider = new CRUDTestDBContextProvider(Guid.NewGuid().ToString());
            var context  = cRUDTestDBContextProvider.GetContext();
            var employee = new Employee {
                EmployeeId = 1, Title = "TestTitle", FirstName = "TestFirst", LastName = "TestLast", Email = "Test"
            };

            context.Add(employee);
            context.SaveChanges();

            EmployeeBE employeeBE = new EmployeeBE(cRUDTestDBContextProvider);

            employeeBE.Load(1);
            Assert.IsTrue(employeeBE.ToString().Equals("Employee Name:TestFirst TestLast Title:TestTitle"));
        }
Example #26
0
        public void SaveValidIdTest()
        {
            ICRUDTestDBContextProvider cRUDTestDBContextProvider = new CRUDTestDBContextProvider(Guid.NewGuid().ToString());
            var context  = cRUDTestDBContextProvider.GetContext();
            var employee = new Employee {
                EmployeeId = 1
            };

            context.Add(employee);
            context.SaveChanges();

            EmployeeBE employeeBE = new EmployeeBE(cRUDTestDBContextProvider);

            employeeBE.Load(1);
            employeeBE.FirstName  = "TestFirstName";
            employeeBE.LastName   = "TestLastName";
            employeeBE.Title      = "TestTitle";
            employeeBE.BirthDate  = new DateTime(2000, 1, 1);
            employeeBE.HireDate   = new DateTime(2020, 1, 1);
            employeeBE.Address    = "123 Test Address";
            employeeBE.City       = "TestCity";
            employeeBE.State      = "TestState";
            employeeBE.Country    = "TestCountry";
            employeeBE.PostalCode = "TestPC";
            employeeBE.Phone      = "TestPhone";
            employeeBE.Fax        = "TestFax";
            employeeBE.Email      = "*****@*****.**";
            employeeBE.Save();

            EmployeeBE employeeBE2 = new EmployeeBE(cRUDTestDBContextProvider);

            employeeBE2.Load(1);
            Assert.IsTrue(employeeBE2.Id == 1);
            Assert.IsTrue(employeeBE2.FirstName == "TestFirstName");
            Assert.IsTrue(employeeBE2.LastName == "TestLastName");
            Assert.IsTrue(employeeBE2.Title == "TestTitle");
            Assert.IsTrue(employeeBE2.BirthDate.Equals(new DateTime(2000, 1, 1)));
            Assert.IsTrue(employeeBE2.HireDate.Equals(new DateTime(2020, 1, 1)));
            Assert.IsTrue(employeeBE2.Address == "123 Test Address");
            Assert.IsTrue(employeeBE2.City == "TestCity");
            Assert.IsTrue(employeeBE2.State == "TestState");
            Assert.IsTrue(employeeBE2.Country == "TestCountry");
            Assert.IsTrue(employeeBE2.PostalCode == "TestPC");
            Assert.IsTrue(employeeBE2.Phone == "TestPhone");
            Assert.IsTrue(employeeBE2.Fax == "TestFax");
            Assert.IsTrue(employeeBE2.Email == "*****@*****.**");
        }
Example #27
0
        public List <EmployeeBE> ListaCombo(int IdCompany)
        {
            Database  db        = DatabaseFactory.CreateDatabase("cnERPBD");
            DbCommand dbCommand = db.GetStoredProcCommand("usp_Employee_ListaCombo");

            db.AddInParameter(dbCommand, "pIdCompany", DbType.Int32, IdCompany);

            IDataReader       reader       = db.ExecuteReader(dbCommand);
            List <EmployeeBE> Employeelist = new List <EmployeeBE>();
            EmployeeBE        Employee;

            while (reader.Read())
            {
                Employee            = new EmployeeBE();
                Employee.IdEmployee = Int32.Parse(reader["idEmployee"].ToString());
                Employee.FullName   = reader["FullName"].ToString();
                Employeelist.Add(Employee);
            }
            reader.Close();
            reader.Dispose();
            return(Employeelist);
        }
Example #28
0
        public List <EmployeeBE> SeleccionaBusqueda(int IdCompany, int IdSituation, string pFiltro, int Pagina, int CantidadRegistro)
        {
            Database  db        = DatabaseFactory.CreateDatabase("cnERPBD");
            DbCommand dbCommand = db.GetStoredProcCommand("usp_Employee_SeleccionaBus");

            db.AddInParameter(dbCommand, "pIdCompany", DbType.Int32, IdCompany);
            db.AddInParameter(dbCommand, "pIdSituation", DbType.Int32, IdSituation);
            db.AddInParameter(dbCommand, "pPagina", DbType.Int32, Pagina);
            db.AddInParameter(dbCommand, "pCantidadRegistro", DbType.Int32, CantidadRegistro);
            db.AddInParameter(dbCommand, "pFiltro", DbType.String, pFiltro);

            IDataReader       reader       = db.ExecuteReader(dbCommand);
            List <EmployeeBE> Employeelist = new List <EmployeeBE>();
            EmployeeBE        Employee;

            while (reader.Read())
            {
                Employee                = new EmployeeBE();
                Employee.IdEmployee     = Int32.Parse(reader["idEmployee"].ToString());
                Employee.IdCompany      = Int32.Parse(reader["IdCompany"].ToString());
                Employee.NameCompany    = reader["NameCompany"].ToString();
                Employee.IdWorkArea     = Int32.Parse(reader["IdWorkArea"].ToString());
                Employee.NameWorkArea   = reader["NameWorkArea"].ToString();
                Employee.DocumentNumber = reader["DocumentNumber"].ToString();
                Employee.FullName       = reader["FullName"].ToString();
                Employee.NameOccupation = reader["NameOccupation"].ToString();
                Employee.IdUbigeo       = reader["IdUbigeo"].ToString();
                Employee.NomDpto        = reader["NomDpto"].ToString();
                Employee.NomProv        = reader["NomProv"].ToString();
                Employee.NomDist        = reader["NomDist"].ToString();
                Employee.Email          = reader["Email"].ToString();
                Employee.NameSituation  = reader["NameSituation"].ToString();
                Employeelist.Add(Employee);
            }
            reader.Close();
            reader.Dispose();
            return(Employeelist);
        }
Example #29
0
        public void GetCustomersTest()
        {
            ICRUDTestDBContextProvider cRUDTestDBContextProvider = new CRUDTestDBContextProvider(Guid.NewGuid().ToString());
            var context = cRUDTestDBContextProvider.GetContext();
            var customerGetCustomersTest = new Customer
            {
                CustomerId   = 1,
                SupportRepId = 1,
                FirstName    = "Test",
                LastName     = "Test",
                Email        = "Test"
            };

            var employeeGetCustomersTest = new Employee {
                EmployeeId = 1, FirstName = "TestFirst", LastName = "TestLast"
            };
            var employeeGetCustomersTest2 = new Employee {
                EmployeeId = 2, FirstName = "TestFirst", LastName = "TestLast"
            };

            context.Add(customerGetCustomersTest);
            context.Add(employeeGetCustomersTest);
            context.Add(employeeGetCustomersTest2);
            context.SaveChanges();

            EmployeeBE employeeBE  = new EmployeeBE(cRUDTestDBContextProvider);
            EmployeeBE employeeBE2 = new EmployeeBE(cRUDTestDBContextProvider);

            employeeBE.Load(1);
            employeeBE2.Load(2);
            var customerBECollection = employeeBE.GetCustomers();

            Assert.IsTrue(customerBECollection.First().GetType() == typeof(CustomerBE));
            Assert.IsTrue(customerBECollection.First().FirstName == "Test");
            Assert.IsTrue(customerBECollection.First().Id == 1);
            Assert.IsTrue(employeeBE2.GetCustomers().IsNullOrEmpty());
        }
Example #30
0
        public void LoadValidIdTest()
        {
            ICRUDTestDBContextProvider cRUDTestDBContextProvider = new CRUDTestDBContextProvider(Guid.NewGuid().ToString());
            var context  = cRUDTestDBContextProvider.GetContext();
            var employee = new Employee
            {
                EmployeeId = 1,
                FirstName  = "TestFirstName",
                LastName   = "TestLastName",
                Title      = "TestTitle",
                ReportsTo  = 2,
                BirthDate  = new DateTime(2000, 1, 1),
                HireDate   = new DateTime(2020, 1, 1),
                Email      = "*****@*****.**",
                Address    = "123 Test Address",
                City       = "TestCity",
                State      = "TestState",
                Country    = "TestCountry",
                PostalCode = "TestPC",
                Phone      = "TestPhone",
                Fax        = "TestFax",
            };
            var employee2 = new Employee
            {
                EmployeeId = 2,
                FirstName  = "TestFirstName2",
                LastName   = "TestLastName2",
                Title      = "TestTitle2",
                BirthDate  = new DateTime(1990, 1, 1),
                HireDate   = new DateTime(2020, 1, 1),
                Email      = "*****@*****.**",
                Address    = "123 Test Address",
                City       = "TestCity",
                State      = "TestState",
                Country    = "TestCountry",
                PostalCode = "TestPC",
                Phone      = "TestPhone",
                Fax        = "TestFax",
            };

            context.Add(employee);
            context.Add(employee2);
            context.SaveChanges();

            EmployeeBE employeeBE = new EmployeeBE(cRUDTestDBContextProvider);

            employeeBE.Load(1);
            Assert.IsTrue(employeeBE.Id == 1);
            Assert.IsTrue(employeeBE.FirstName == "TestFirstName");
            Assert.IsTrue(employeeBE.LastName == "TestLastName");
            Assert.IsTrue(employeeBE.Title == "TestTitle");
            Assert.IsTrue(employeeBE.BirthDate.Equals(new DateTime(2000, 1, 1)));
            Assert.IsTrue(employeeBE.HireDate.Equals(new DateTime(2020, 1, 1)));
            Assert.IsTrue(employeeBE.Address == "123 Test Address");
            Assert.IsTrue(employeeBE.City == "TestCity");
            Assert.IsTrue(employeeBE.State == "TestState");
            Assert.IsTrue(employeeBE.Country == "TestCountry");
            Assert.IsTrue(employeeBE.PostalCode == "TestPC");
            Assert.IsTrue(employeeBE.Phone == "TestPhone");
            Assert.IsTrue(employeeBE.Fax == "TestFax");
            Assert.IsTrue(employeeBE.Email == "*****@*****.**");
            Assert.IsTrue(employeeBE.ReportsTo == 2);
        }