Example #1
0
        public Employee Get(int id)
        {
            SearchEmployee employee = new SearchEmployee();

            using (SqlConnection connection = new SqlConnection(_configuration.GetConnectionString("testTailorItDB")))
            {
                connection.Open();

                employee = connection.QuerySingle <SearchEmployee>("GetEmployeesById", param: new { Id = id }, commandType: CommandType.StoredProcedure);
            }
            return(new Employee()
            {
                Id = employee.Id,
                FirstName = employee.FirstName,
                LastName = employee.LastName,
                BirthDate = employee.BirthDate,
                Age = employee.Age,
                Email = employee.Email,
                Gender = employee.Gender,
                Habilities = new Hability()
                {
                    Id = employee.IdHability,
                    Name = employee.NameHability
                }
            });
        }
Example #2
0
        static void Main(string[] args)
        {
            DefaultClientPacket packet = new DefaultClientPacket();

            packet.Register(typeof(Employee).Assembly);
            TcpClient client = SocketFactory.CreateClient <TcpClient>(packet, "127.0.0.1", 9090);

            //TcpClient client = SocketFactory.CreateClient<TcpClient>(packet, "127.0.0.1", 9090,"localhost");
            while (true)
            {
                Console.Write("enter get employee quantity:");
                string line = Console.ReadLine();
                int    quantity;
                if (int.TryParse(line, out quantity))
                {
                    SearchEmployee search = new SearchEmployee();
                    search.Quantity = quantity;
                    client.SendMessage(search);
                    var result = client.ReadMessage <IList <Employee> >();
                    foreach (Employee item in result)
                    {
                        Console.WriteLine("\t{0} {1}", item.FirstName, item.LastName);
                    }
                }
                else
                {
                    Console.WriteLine("input not a number!");
                }
            }
        }
Example #3
0
        public async Task <IEnumerable <Profile> > SearchEmployee(SearchEmployee employee, string clientKey = null, string apiKey = null)
        {
            List <Profile> candidateList = new List <Profile>();

            try
            {
                configuration.ClientURL = @ServerApi.URL_AuthGateway;


                if ((!string.IsNullOrEmpty(clientKey) && !string.IsNullOrEmpty(apiKey)))
                {
                    configuration.Client.Authenticator = new HttpBasicAuthenticator(clientKey, apiKey);
                }

                configuration.RequestURL = $"SearchEmployee";
                configuration.Client     = new RestClient($"{configuration.ClientURL}");
                configuration.Request    = new RestRequest($"{configuration.RequestURL}", Method.POST, DataFormat.Json);
                configuration.Request.AddJsonBody(employee);

                var response = configuration.Client.Execute <List <Profile> >(configuration.Request);

                return(response.Data);
            }
            catch (Exception ex)
            {
                Debug.WriteLine($"An error occured when request to API: {ex.Message}");
            }

            return(await Task.FromResult(candidateList));
        }
Example #4
0
        public ActionResult SearchEmployee()
        {
            SearchEmployee searchEmployee = new SearchEmployee();

            searchEmployee.Departments = FillDepartmentsFromDepartmentList(null);
            return(View(searchEmployee));
        }
        public ActionResult Employee(SearchEmployee filter)
        {
            IEnumerable <Employee> employee = Enumerable.Empty <Employee>();

            ViewData["Employeefilter"] = filter;

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(BaseUri);
                //HTTP GET
                var responseTask = client.GetAsync("EmployeeApi/Get");
                responseTask.Wait();

                var result = responseTask.Result;
                if (result.IsSuccessStatusCode)
                {
                    var readTask = result.Content.ReadAsAsync <IList <Employee> >();
                    readTask.Wait();

                    employee = readTask.Result;
                    if (filter.Name != null)
                    {
                        employee = employee.Where(q => q.FName.ToLower().Contains(filter.Name.ToLower()) || q.LName.ToLower().Contains(filter.Name.ToLower()));
                    }
                    if (filter.StartDate != null && filter.EndDate != null)
                    {
                        employee = employee.Where(q => q.DOJ >= filter.StartDate && q.DOJ <= filter.EndDate);
                    }

                    return(View("Employee", employee));
                }
                ModelState.AddModelError(string.Empty, "Server error. Please contact administrator.");
            }
            return(View("Employee", employee));
        }
Example #6
0
 public EmployeeViewModel()
 {
     this.EmployeeBag                     = new Employee();
     this.PhoneBag                        = new Phone();
     this.AddressBag                      = new Address();
     this.Employees                       = new List <Employee>();
     this.PaginationBag                   = new Pagination();
     this.PaginationBag.TotalLinks        = 5;
     this.PaginationBag.TotalShownRecords = 5;
     this.SearchEmployeeBag               = new SearchEmployee();
 }
Example #7
0
        private void OnSearchEmployee(SearchEmployee e, IServer server, ISession session)
        {
            if (e.Quantity > mEmployees.Count)
            {
                e.Quantity = mEmployees.Count;
            }
            List <Employee> result = new List <Employee>();

            for (int i = 0; i < e.Quantity; i++)
            {
                result.Add(mEmployees[i]);
            }
            server.Send(result, session);
        }
Example #8
0
        public override void SessionPacketDecodeCompleted(IServer server, PacketDecodeCompletedEventArgs e)
        {
            base.SessionPacketDecodeCompleted(server, e);
            List <Employee> items  = new List <Employee>();
            SearchEmployee  search = (SearchEmployee)e.Message;

            if (search.Quantity > mEmployees.Count)
            {
                search.Quantity = mEmployees.Count;
            }
            for (int i = 0; i < search.Quantity; i++)
            {
                items.Add(mEmployees[i]);
            }
            server.Send(items, e.Session);
        }
Example #9
0
        public ActionResult SearchEmployee(SearchEmployee searchEmployee)
        {
            ActionResult retVal = null;

            if (ModelState.IsValid)
            {
                ISearchEmployeeDTO searchEmployeeDTO = (ISearchEmployeeDTO)DTOFactory.Instance.Create(DTOType.SearchEmployeeDTO);
                DTOConverter.FillDTOFromViewModel(searchEmployeeDTO, searchEmployee);

                IUserFacade userFacade = (IUserFacade)FacadeFactory.Instance.Create(FacadeType.UserManagerFacade);
                OperationResult <IList <IEmployeeDTO> > result = userFacade.SearchEmployeeByRawQuery(searchEmployeeDTO, (User.IsInRole("NonAdmin"))?true:false);

                if (result.IsValid())
                {
                    IList <Employee> employeeList = new List <Employee>();
                    Employee         employee     = null;

                    IDepartmentFacade departmentFacade = (IDepartmentFacade)FacadeFactory.Instance.Create(FacadeType.DepartmentManagerFacade);
                    //OperationResult<IList<IEmployeeDTO>> result = userFacade.SearchEmployeeByRawQuery(searchEmployeeDTO, true);

                    foreach (var employeeDTO in result.Data)
                    {
                        employee = new Employee();
                        DTOConverter.FillViewModelFromDTO(employee, employeeDTO);

                        OperationResult <IDepartmentDTO> department = departmentFacade.GetADepartment(employeeDTO.DepartmentId);
                        if (department.IsValid())
                        {
                            employee.Department = new Department();
                            DTOConverter.FillViewModelFromDTO(employee.Department, department.Data);
                        }

                        employeeList.Add(employee);
                    }

                    retVal = PartialView("~/Views/User/_SearchEmployeeList.cshtml", employeeList);
                }
                else if (result.HasFailed())
                {
                }
                else
                {
                    retVal = View("~/Views/Shared/Error.cshtml");
                }
            }
            return(retVal);
        }
Example #10
0
        public ContractFrm()
        {
            InitializeComponent();
            // remove context menu
            //   this.ContextMenuStrip.Items.Clear();
            // load data
            Sender         = new SendStatus(GetStatus);
            updateEmployee = new SearchEmployee(UpdateEmployee);

            this.headerControl1.btnNewSubcontractor.Click               += new System.EventHandler(this.btnNewSubcontractor_click);
            this.headerControl1.dgvSubcontract.CellValidated            += new System.Windows.Forms.DataGridViewCellEventHandler(this.dgvSubcontract_CellValidated);
            this.headerControl1.txtContractStatus.TextChanged           += new System.EventHandler(this.updat_satatus);
            this.headerControl1.cbxResponsibleSite.SelectedIndexChanged += new System.EventHandler(this.cbxResponsibleSite_SelectedIndexChanged);
            this.headerControl1.cbxCostcenter.SelectedIndexChanged      += new System.EventHandler(this.cbxCostcenter_SelectedIndexChanged);
            this.headerControl1.cbxValidWorkshop.SelectedIndexChanged   += new System.EventHandler(this.cbxValidWorkshop_SelectedIndexChanged);
            //this.headerControl1.cbxContractType.SelectedIndexChanged += new System.EventHandler(this.cbxContractType_SelectedIndexChanged);
            this.headerControl1.cbxContractType.DropDownClosed += new System.EventHandler(this.cbxContractType_DropDownClosed);
            this.headerControl1.cbxContractType.KeyUp          += new KeyEventHandler(this.cbxContractType_DropDownClosed);
            this.headerControl1.cbxContractType.MouseWheel     += new System.Windows.Forms.MouseEventHandler(this.cbxContractType_DropDownClosed);


            //Load data
            reloadAll();
        }
Example #11
0
        public async Task <ActionResult> searchEmployee([Bind] SearchEmployee searchEmployee, string sortOrder, string currentFilter, string searchString, int?page)
        {
            ViewBag.IsAlertResponse        = false;
            ViewBag.ActivityResponsMessage = null;

            // Info.
            var    identity = (ClaimsPrincipal)Thread.CurrentPrincipal;
            string userName = identity.Claims.Where(c => c.Type == ClaimTypes.Name)
                              .Select(c => c.Value).SingleOrDefault();
            var role = "";

            if (userName != null)
            {
                var fetchingProfileList = await reader.SearchProfileIndex(userName);

                //side menu validasi
                role           = fetchingProfileList.Data.FirstOrDefault(x => x.RoleID == x.RoleID)?.RoleID;
                ViewBag.roleID = role;
            }
            else
            {
                ViewBag.roleID = "";
            }

            //CreateActionInvoker pagination
            ViewBag.CurrentSort  = sortOrder;
            ViewBag.NameSortParm = String.IsNullOrEmpty(sortOrder) ? "name_desc" : "";
            ViewBag.DateSortParm = sortOrder == "Date" ? "date_desc" : "Date";

            if (searchString != null)
            {
                page = 1;
            }
            else
            {
                searchString = currentFilter;
            }

            ViewBag.CurrentFilter = searchString;


            var item = new SearchEmployee()
            {
                Username   = searchEmployee.Username,
                Experience = searchEmployee.Experience,
                Gender     = searchEmployee.Gender,
                CreateDate = searchEmployee.CreateDate,
                Skills     = searchEmployee.Skills,
                FullName   = searchEmployee.FullName,
                AddID      = searchEmployee.AddID,
                Type       = searchEmployee.Type
            };

            if (role == "4" || role == "5" || role == "")
            {
                var candidateResult = await reader.SearchEmployeePublic(item);

                var count = candidateResult.Count();
                ViewBag.CountCandidateList = count;

                int pageSize     = 5;
                int pageGridSize = 6;

                int pageNumber = (page ?? 1);

                var PagelistCandidate = candidateResult.ToPagedList(pageNumber, pageSize);
                ViewBag.CandidateList = PagelistCandidate;

                ViewBag.CandidateGridList = candidateResult.ToPagedList(pageNumber, pageGridSize);


                return(View());
            }

            else
            {
                var candidateResult = await reader.SearchEmployee(item);

                var count = candidateResult.Count();
                ViewBag.CountCandidateList = count;

                int pageSize     = 5;
                int pageGridSize = 6;

                int pageNumber = (page ?? 1);

                var PagelistCandidate = candidateResult.ToPagedList(pageNumber, pageSize);
                ViewBag.CandidateList = PagelistCandidate;

                ViewBag.CandidateGridList = candidateResult.ToPagedList(pageNumber, pageGridSize);


                return(View());
            }
            //End pagination
        }
Example #12
0
        static void Main(string[] args)
        {
            Messages.ClientPacket packet = new Messages.ClientPacket();
            packet.Register(typeof(Employee).Assembly);
            TcpClient client = SocketFactory.CreateClient <TcpClient>(packet, "127.0.0.1", 9090);

            //TcpClient client = SocketFactory.CreateClient<TcpClient>(packet, "127.0.0.1", 9090, "localhost");
            while (true)
            {
                Console.Write("select search category 1.customer  2.employee :");
                string line = Console.ReadLine();
                int    category;
                if (int.TryParse(line, out category))
                {
                    if (category == 1)
                    {
                        Console.Write("enter get customer quantity:");
                        line = Console.ReadLine();
                        int quantity;
                        if (int.TryParse(line, out quantity))
                        {
                            SearchCustomer search = new SearchCustomer();
                            search.Quantity = quantity;
                            client.SendMessage(search);
                            var result = client.ReceiveMessage <IList <Customer> >();
                            foreach (Customer item in result)
                            {
                                Console.WriteLine("\t{0}", item.CompanyName);
                            }
                        }
                        else
                        {
                            Console.WriteLine("input not a number!");
                        }
                    }
                    else if (category == 2)
                    {
                        Console.Write("enter get employee quantity:");
                        line = Console.ReadLine();
                        int quantity;
                        if (int.TryParse(line, out quantity))
                        {
                            SearchEmployee search = new SearchEmployee();
                            search.Quantity = quantity;
                            client.SendMessage(search);
                            var result = client.ReceiveMessage <IList <Employee> >();
                            foreach (Employee item in result)
                            {
                                Console.WriteLine("\t{0} {1}", item.FirstName, item.LastName);
                            }
                        }
                        else
                        {
                            Console.WriteLine("input not a number!");
                        }
                    }
                    else
                    {
                        Console.WriteLine("input category error!");
                    }
                }
                else
                {
                    Console.WriteLine("input not a number!");
                }
            }
        }
Example #13
0
 public Employees(SearchEmployee employeeId)
 {
     InitializeComponent();
     Messenger.Default.Send <SearchEmployee>(employeeId);
     Messenger.Reset();
 }
Example #14
0
        public void AdminCall(ref List <Employee> EmployeeList, ref SortedDictionary <string, List <string> > managerEmployee)
        {
            while (true)
            {
                Console.WriteLine("**************************************");
                Console.WriteLine("---------------Admin Menu----------------");
                Console.WriteLine("**************************************");
                Console.WriteLine("OPTION #1: ADD EMPLOYEE DETAILS");
                Console.WriteLine("OPTION #2: VIEW EMPLOYEE DETAILS");
                Console.WriteLine("OPTION #3: CHANGE SCREEN SETTINGS");
                Console.WriteLine("OPTION #4: RETURN TO MAIN MENU");
                Console.WriteLine("OPTION #5: EXIT");
                try
                {
                    switch (Convert.ToInt32(Console.ReadLine()))
                    {
                    case 1:
                        Console.WriteLine("How many Employee details you want to add");
                        int numberOfEmployee = Convert.ToInt32(Console.ReadLine());
                        for (int i = 1; i <= numberOfEmployee; i++)
                        {
                            AddEmployee AddEmp = new AddEmployee();
                            AddEmp.NewEmployee(ref EmployeeList, ref managerEmployee);
                        }
                        break;

                    case 2:
                        Console.WriteLine("List of Employee ID");
                        if (EmployeeList.Capacity >= 1)
                        {
                            foreach (var employee in EmployeeList)
                            {
                                Console.WriteLine(employee.MatchEmployee());
                            }
                            SearchEmployee seachEmp = new SearchEmployee();
                            seachEmp.SearchEmp(ref EmployeeList);
                        }
                        else
                        {
                            Console.WriteLine("No employee exist");
                        }
                        break;

                    case 3:
                        Employee.ColorSet();
                        break;

                    case 4:
                        return;

                    case 5:
                        Environment.Exit(0);
                        break;

                    default:
                        Console.WriteLine("Option not available");
                        break;
                    }
                }
                catch (Exception)
                {
                    Console.WriteLine("Invalid input");
                }
            }
        }
Example #15
0
        public void RegisterEmployee(ref List <Employee> employeeList, ref SortedDictionary <string, List <string> > managerEmployee)
        {
            while (true)
            {
                Console.WriteLine("**************************************");
                Console.WriteLine("----------Admin Manager Menu----------");
                Console.WriteLine("**************************************");
                Console.WriteLine("OPTION #1: ADD EMPLOYEE DETAILS");
                Console.WriteLine("OPTION #2: VIEW EMPLOYEE DETAILS");
                Console.WriteLine("OPTION #3: UPDATE EMPLOYEE DETAILS");
                Console.WriteLine("OPTION #4: RETURN TO MAIN MENU");
                Console.WriteLine("OPTION #5: EXIT");
                try
                {
                    switch (Convert.ToInt32(Console.ReadLine()))
                    {
                    case 1:
                        Console.WriteLine("How many Employee details you want to add");
                        int numberOfEmployee = Convert.ToInt32(Console.ReadLine());
                        for (int i = 1; i <= numberOfEmployee; i++)
                        {
                            AddEmployee AddEmp = new AddEmployee();
                            AddEmp.NewEmployee(ref employeeList, ref managerEmployee);
                        }
                        break;

                    case 2:
                        Console.WriteLine("List of Employee ID");
                        if (employeeList.Capacity >= 1)
                        {
                            foreach (var employee in employeeList)
                            {
                                Console.WriteLine(employee.MatchEmployee());
                            }
                            SearchEmployee seachEmp = new SearchEmployee();
                            seachEmp.SearchEmp(ref employeeList);
                        }
                        else
                        {
                            Console.WriteLine("No employee exist");
                        }
                        break;

                    case 3:
                        if (employeeList.Capacity >= 1)
                        {
                            int Flag = 1;
                            Console.WriteLine("Enter Employee ID whose details you want to update");
                            string employeeID = (new Employee()).SearchEmployee(Console.ReadLine());
                            foreach (var employee in employeeList)
                            {
                                if (employeeID == employee.MatchEmployee())
                                {
                                    employee.UpdateDetails(ref employeeList, ref managerEmployee);
                                    Flag = 2;
                                    break;
                                }
                            }
                            if (Flag == 1)
                            {
                                Console.WriteLine("No employee found");
                            }
                        }
                        else
                        {
                            Console.WriteLine("No employee exist");
                        }
                        break;

                    case 4:
                        return;

                    case 5:
                        Environment.Exit(0);
                        break;

                    default:
                        Console.WriteLine("Option not available");
                        break;
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Source + e.Message);
                }
            }
        }
Example #16
0
 private void txtEmployeeSearch(object sender, KeyEventArgs e)
 {
     DataContext = new SearchEmployee(grdEmployee, btnShowAdd, btnShowEdit, txtSearchEmployeee);
 }
Example #17
0
        private void SearchEmployee()
        {
            SearchEmployee frmSearchEmployee = new SearchEmployee();

            frmSearchEmployee.Show();
        }