示例#1
0
        public IActionResult CreateEmployee(RegisterEmployee obj)
        {
            APIResult result = new APIResult();

            try
            {
                if (!(string.IsNullOrEmpty(obj.FirstName)) || !(string.IsNullOrEmpty(obj.UserType)))
                {
                    result = logic.CreateEmployee(obj);
                }
                else
                {
                    result.Message      = "Invalid Input!!!";
                    result.Status       = false;
                    result.CommandType  = "INSERT";
                    result.Id           = 0;
                    result.EmployeeName = "";
                }
            }
            catch (Exception e)
            {
                result.Message      = e.Message;
                result.Status       = false;
                result.CommandType  = "INSERT";
                result.Id           = 0;
                result.EmployeeName = "";
            }
            return(new CustomResult(result));
        }
示例#2
0
        public APIResult CreateEmployee(RegisterEmployee input)
        {
            APIResult      result = new APIResult();
            DataBaseResult dbr    = new DataBaseResult();

            try
            {
                dbr                 = ops.CreateEmployee(input);
                result.Message      = dbr.Message;
                result.Status       = dbr.Status;
                result.Id           = dbr.Id;
                result.EmployeeName = dbr.EmployeeName;
                result.CommandType  = dbr.CommandType;
            }
            catch (Exception e)
            {
                result.Message      = e.Message;
                result.Status       = false;
                result.CommandType  = "INSERT";
                result.Id           = 0;
                result.EmployeeName = "";
                throw e;
            }
            return(result);
        }
        public ActionResult Register(RegisterEmployee model)
        {
            if (ModelState.IsValid)
            {
                if (manager.RegisterEmployee(model.FirstName, model.LastName, model.Administrator, model.Username, model.Password))
                {
                    TempData["Message"] = new ResponseMessage()
                    {
                        Error   = false,
                        Message = "Employee was successfully added to the ChildWatch database."
                    };
                }
                else
                {
                    TempData["Message"] = new ResponseMessage()
                    {
                        Error   = true,
                        Message = "Employee was unable to be added to the database."
                    };
                    return(View(model));
                }
            }

            return(View(model));
        }
        public HttpResponseMessage Post(RegisterEmployee re)
        {
            ClaimsPrincipal p = RequestContext.Principal as ClaimsPrincipal;

            EmployeeDA.LogEmployee(re, p.Claims);
            return(new HttpResponseMessage(HttpStatusCode.OK));
        }
        public static void UpdateRegisterEmployee(RegisterEmployee p, IEnumerable <Claim> claims)
        {
            string      sql  = "UPDATE RegisterEmployee SET UntilTime=@UntilTime WHERE ID=@ID";
            DbParameter par1 = Database.AddParameter("AdminDB", "@UntilTime", p.UntilTime.ToUnixTimestamp());
            DbParameter par2 = Database.AddParameter("AdminDB", "@ID", p.ID);

            Database.ModifyData(Database.GetConnection(CreateConnectionString(claims)), sql, par1, par2);
        }
        public static void LogEmployee(RegisterEmployee re, IEnumerable <Claim> claims)
        {
            string      sql  = "INSERT INTO Register_Employee VALUES (@registerid, @employeeid, @fromdate, @untildate)";
            DbParameter par1 = Database.AddParameter("ConnectionString", "@registerid", re.RegisterID);
            DbParameter par2 = Database.AddParameter("ConnectionString", "@employeeid", re.EmployeeID);
            DbParameter par3 = Database.AddParameter("ConnectionString", "@fromdate", re.From);
            DbParameter par4 = Database.AddParameter("ConnectionString", "@untildate", re.Until);

            Database.InsertData(Database.GetConnection(CreateConnectionString(claims)), sql, par1, par2, par3, par4);
        }
        public static int InsertRegisterEmployee(RegisterEmployee re, IEnumerable <Claim> claims)
        {
            string      sql  = "INSERT INTO RegisterEmployee VALUES(@RegisterID, @EmployeeID, @FromTime, @UntilTime)";
            DbParameter par1 = Database.AddParameter("AdminDB", "@RegisterID", re.Register.ID);
            DbParameter par2 = Database.AddParameter("AdminDB", "@EmployeeID", re.Employee.ID);
            DbParameter par3 = Database.AddParameter("AdminDB", "@FromTime", re.FromTime.ToUnixTimestamp());
            DbParameter par4 = Database.AddParameter("AdminDB", "@UntilTime", re.UntilTime.ToUnixTimestamp());

            return(Database.InsertData(Database.GetConnection(CreateConnectionString(claims)), sql, par1, par2, par3, par4));
        }
        public HttpResponseMessage Post(RegisterEmployee re)
        {
            ClaimsPrincipal p  = RequestContext.Principal as ClaimsPrincipal;
            int             id = RegisterEmployeeDA.InsertRegisterEmployee(re, p.Claims);

            HttpResponseMessage message = new HttpResponseMessage(HttpStatusCode.OK);

            message.Content = new StringContent(id.ToString());
            return(message);
        }
        public async Task <IHttpActionResult> Register([FromBody] RegisterEmployee model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var user = new ApplicationUser()
            {
                UserName = model.EmployeeId, Email = model.Email
            };

            IdentityResult result = await UserManager.CreateAsync(user, "123456789");

            if (!result.Succeeded)
            {
                return(GetErrorResult(result));
            }

            try
            {
                SaveUpdateActivities activity = new SaveUpdateActivities();
                LogicActivity        logic    = new LogicActivity();
                DataBind             da       = activity.SaveUpdateEmployee(new Employee
                {
                    EmployeeId    = model.EmployeeId,
                    EmployeeName  = model.EmployeeName,
                    DesignationId = model.DesignationId,
                    SectionId     = model.SectionId,
                    Email         = model.Email,
                    JoiningDate   = model.JoiningDate,
                    ReportTo      = model.ReportTo,
                    Location      = model.Location,
                    GroupName     = model.GroupId,
                    RoleId        = model.RoleId
                });

                UserManager.AddToRoles(user.Id, model.AccessPermission.ToArray());

                var beforData = logic.getEmployee(model.EmployeeId, model.AccessPermission.ToArray());

                var dataAfter = new { Info = beforData, AccessList = model.AccessPermission };

                string data = JsonConvert.SerializeObject(dataAfter);


                AuditTrialReport.SaveAuditReport(User.Identity.Name, "Insert", null, data);
            }
            catch (Exception ev)
            {
                return(BadRequest(ev.ToString()));
            }

            return(Ok("Successfully added Employee with default password"));
        }
示例#10
0
        private async void createRegisterEmployee()
        {
            RegisterEmployee registerEmployee = new RegisterEmployee();

            registerEmployee.Register  = ApplicationVM.register;
            registerEmployee.Employee  = SelectedEmployee;
            registerEmployee.FromTime  = DateTime.Now;
            registerEmployee.UntilTime = DateTime.Now;

            registerEmployee.ID = await addRegisterEmployee(registerEmployee);

            ApplicationVM.registerEmployee = registerEmployee;
        }
示例#11
0
        private void metroButton10_Click(object sender, EventArgs e)
        {
            if (ActiveMdiChild != null)
            {
                ActiveMdiChild.Close();
            }
            RegisterEmployee newMDIChild = new RegisterEmployee();

            // Set the Parent Form of the Child window.
            newMDIChild.MdiParent = this;
            // Display the new form.
            newMDIChild.Show();
            newMDIChild.Dock = DockStyle.Fill;
        }
示例#12
0
        private async void MedewerkerLoggen()
        {
            RegisterEmployee re = new RegisterEmployee()
            {
                RegisterID = int.Parse(Properties.Settings.Default.RegisterID), EmployeeID = ApplicationVM.ActiveEmployee.ID, From = ApplicationVM.From, Until = DateTime.Now
            };
            string input = JsonConvert.SerializeObject(re);

            using (HttpClient client = new HttpClient())
            {
                client.SetBearerToken(ApplicationVM.Token.AccessToken);
                HttpResponseMessage response = await client.PostAsync("http://localhost:3655/api/register/", new StringContent(input, Encoding.UTF8, "application/json"));

                if (response.IsSuccessStatusCode)
                {
                    ApplicationVM appvm = App.Current.MainWindow.DataContext as ApplicationVM;
                    appvm.ChangePage(new LoginVM());
                }
            }
        }
示例#13
0
        public void CreateNewEmp()
        {
            TestData Data = DataManager.GetTestData("EmpData", DataRandomToken, TestRunNum);

            Login login = new Login(this.DriverManager);
            login.OpenApp().LogIn(Data.Get("Login"));

            Dashboard dashboard = new Dashboard(this.DriverManager);
            dashboard.OpenSideMenu("Employee Central").OpenMenu("Employees");
            
            RegisterEmployee registerEmployee = new RegisterEmployee(this.DriverManager);
            string actualMessage = registerEmployee.Register(Data.Get("Employee"));
            string expectedMessage = registerEmployee.GetExpectedMessage(Data);
            Assert.AreEqual(actualMessage, expectedMessage);

            dashboard.OpenSideMenu("Company").OpenMenu("Settings").OpenTab("Others");
            ActivateEmployee activation = new ActivateEmployee(this.DriverManager);
            activation.ActivateEmployeeViaUrl(Data.Get("Employee"));
            Assert.IsTrue(activation.IsPersonalTabPresent());

            registerEmployee.AddBasicDetails(Data.Get("Employee"));
        }
示例#14
0
        private async Task <int> addRegisterEmployee(RegisterEmployee registerEmployee)
        {
            string input = JsonConvert.SerializeObject(registerEmployee);

            using (HttpClient client = new HttpClient())
            {
                client.SetBearerToken(ApplicationVM.token.AccessToken);
                HttpResponseMessage response = await client.PostAsync("http://localhost:55853/api/registeremployee", new StringContent(input, Encoding.UTF8, "application/json"));

                if (response.IsSuccessStatusCode)
                {
                    string output = await response.Content.ReadAsStringAsync();

                    return(Int32.Parse(output));
                }
                else
                {
                    Console.WriteLine("error");
                    return(0);
                }
            }
        }
示例#15
0
        private void button1_Click(object sender, EventArgs e)
        {
            RegisterEmployee registerEmployee = new RegisterEmployee();

            registerEmployee.Show();
        }
        //Projeto Larissa Iurk
        //github.com/larissaiurk/ProjetoFolhaPagamento

        static void Main(string[] args)
        {
            Console.BackgroundColor = ConsoleColor.DarkRed;
            Console.ForegroundColor = ConsoleColor.White;
            SeedsDAO.Add();

            int opcao = 0;

            do
            {
                Console.Clear();

                Console.WriteLine("  -- MENU FOLHA DE PAGAMENTO -- \n");
                Console.WriteLine("1 - Cadastrar cargo \n");
                Console.WriteLine("2 - Cadastrar funcionário \n");
                Console.WriteLine("3 - Cadastrar folha de pagamento \n");
                Console.WriteLine("4 - Consultar folha de pagamento \n ");
                Console.WriteLine("5 - Consultar histórico de folhas de pagamento do funcionário \n ");
                Console.WriteLine("6 - Consultar histórico de folhas de pagamento do mês \n ");
                Console.WriteLine("0 - Sair\n");

                Console.WriteLine("Digite a opção desejada:");
                opcao = Convert.ToInt32(Console.ReadLine());
                Console.Clear();
                switch (opcao)
                {
                case 1:
                    ListPositions.Render();
                    RegisterPosition.Render();
                    break;

                case 2:
                    ListEmployees.Render();
                    RegisterEmployee.Render();
                    break;

                case 3:
                    ListPositions.Render();
                    ListEmployees.Render();
                    RegisterPayroll.Render();
                    ListPayrolls.Render();
                    break;

                case 4:
                    ListPayrolls.Render();
                    ListPayrolls.ListByEmployee();
                    break;

                case 5:
                    ListPayrolls.ListByEmployeeHistoricByCpf();
                    break;

                case 6:
                    ListPayrolls.ListByEmployeeHistoricByDate();
                    break;

                case 0:
                    Console.WriteLine("Saindo...");
                    break;

                default:
                    Console.WriteLine("Opção inválida!");
                    break;
                }
                Console.WriteLine("\n Aperte uma tecla para continuar...");
                Console.ReadKey();
            } while (opcao != 0);
        }
示例#17
0
        public DataBaseResult CreateEmployee(RegisterEmployee input)
        {
            string         insertQuery = "";
            DataBaseResult dbr         = new DataBaseResult();
            SqlCommand     cmd         = new SqlCommand();
            SqlParameter   param;

            try
            {
                dbr.CommandType = "Insert";
                insertQuery     = DBConnection.GetInsertQuery();

                if (string.IsNullOrEmpty(insertQuery) || string.IsNullOrEmpty(connectionString))
                {
                    dbr.Id           = 0;
                    dbr.Message      = "Something Wrong with getting DB Commands!!";
                    dbr.EmployeeName = "";
                    dbr.Status       = false;
                }
                else
                {
                    using (SqlConnection conn = new SqlConnection(connectionString))
                    {
                        cmd.CommandText = insertQuery;
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Connection  = conn;

                        param           = new SqlParameter("@FirstName", input.FirstName);
                        param.Direction = ParameterDirection.Input;
                        param.SqlDbType = SqlDbType.VarChar;
                        param.Size      = 50;
                        cmd.Parameters.Add(param);

                        param           = new SqlParameter("@LastName", input.LastName);
                        param.Direction = ParameterDirection.Input;
                        param.SqlDbType = SqlDbType.VarChar;
                        param.Size      = 50;
                        cmd.Parameters.Add(param);

                        param           = new SqlParameter("@DOB", input.DOB);
                        param.Direction = ParameterDirection.Input;
                        param.SqlDbType = SqlDbType.VarChar;
                        param.Size      = 30;
                        cmd.Parameters.Add(param);

                        param           = new SqlParameter("@Age", input.Age);
                        param.Direction = ParameterDirection.Input;
                        param.SqlDbType = SqlDbType.Int;
                        cmd.Parameters.Add(param);

                        param           = new SqlParameter("@BloodGroup", input.BloodGroup);
                        param.Direction = ParameterDirection.Input;
                        param.SqlDbType = SqlDbType.VarChar;
                        param.Size      = 5;
                        cmd.Parameters.Add(param);

                        param           = new SqlParameter("@Gender", input.Gender);
                        param.Direction = ParameterDirection.Input;
                        param.SqlDbType = SqlDbType.VarChar;
                        param.Size      = 5;
                        cmd.Parameters.Add(param);

                        param           = new SqlParameter("@MaritalStatus", input.MaritalStatus);
                        param.Direction = ParameterDirection.Input;
                        param.SqlDbType = SqlDbType.Bit;
                        cmd.Parameters.Add(param);

                        param           = new SqlParameter("@Phone", input.Phone);
                        param.Direction = ParameterDirection.Input;
                        param.SqlDbType = SqlDbType.VarChar;
                        param.Size      = 12;
                        cmd.Parameters.Add(param);

                        param           = new SqlParameter("@Address1", input.Address1);
                        param.Direction = ParameterDirection.Input;
                        param.SqlDbType = SqlDbType.NVarChar;
                        param.Size      = -1;
                        cmd.Parameters.Add(param);

                        param           = new SqlParameter("@Address2", input.Address2);
                        param.Direction = ParameterDirection.Input;
                        param.SqlDbType = SqlDbType.NVarChar;
                        param.Size      = -1;
                        cmd.Parameters.Add(param);


                        param           = new SqlParameter("@Place", input.Place);
                        param.Direction = ParameterDirection.Input;
                        param.SqlDbType = SqlDbType.VarChar;
                        param.Size      = 50;
                        cmd.Parameters.Add(param);

                        param           = new SqlParameter("@StateName", input.State);
                        param.Direction = ParameterDirection.Input;
                        param.SqlDbType = SqlDbType.VarChar;
                        param.Size      = 100;
                        cmd.Parameters.Add(param);

                        param           = new SqlParameter("@PostalCode", input.PostalCode);
                        param.Direction = ParameterDirection.Input;
                        param.SqlDbType = SqlDbType.VarChar;
                        param.Size      = 10;
                        cmd.Parameters.Add(param);

                        param           = new SqlParameter("@AadharNumber", input.AadharNumber);
                        param.Direction = ParameterDirection.Input;
                        param.SqlDbType = SqlDbType.VarChar;
                        param.Size      = 20;
                        cmd.Parameters.Add(param);


                        param           = new SqlParameter("@PAN", input.PANNumber);
                        param.Direction = ParameterDirection.Input;
                        param.SqlDbType = SqlDbType.VarChar;
                        param.Size      = 20;
                        cmd.Parameters.Add(param);

                        param           = new SqlParameter("@IsPermanent", input.IsPermanent);
                        param.Direction = ParameterDirection.Input;
                        param.SqlDbType = SqlDbType.Bit;
                        cmd.Parameters.Add(param);

                        param           = new SqlParameter("@EmployeeType", input.EmployeeType);
                        param.Direction = ParameterDirection.Input;
                        param.SqlDbType = SqlDbType.VarChar;
                        param.Size      = 50;
                        cmd.Parameters.Add(param);


                        param           = new SqlParameter("@Gaurd_firstname", input.Gaurd_firstname);
                        param.Direction = ParameterDirection.Input;
                        param.SqlDbType = SqlDbType.VarChar;
                        param.Size      = 50;
                        cmd.Parameters.Add(param);


                        param           = new SqlParameter("@Gaurd_lastname", input.Gaurd_lastname);
                        param.Direction = ParameterDirection.Input;
                        param.SqlDbType = SqlDbType.VarChar;
                        param.Size      = 50;
                        cmd.Parameters.Add(param);


                        param           = new SqlParameter("@Gaurd_middlename", input.Gaurd_middlename);
                        param.Direction = ParameterDirection.Input;
                        param.SqlDbType = SqlDbType.VarChar;
                        param.Size      = 50;
                        cmd.Parameters.Add(param);

                        param           = new SqlParameter("@Gaurd_Phone", input.Gaurd_PhoneNumber);
                        param.Direction = ParameterDirection.Input;
                        param.SqlDbType = SqlDbType.VarChar;
                        param.Size      = 12;
                        cmd.Parameters.Add(param);

                        param           = new SqlParameter("@DOJ", input.DOJ);
                        param.Direction = ParameterDirection.Input;
                        param.SqlDbType = SqlDbType.VarChar;
                        param.Size      = 30;
                        cmd.Parameters.Add(param);

                        param           = new SqlParameter("@LoginType", input.LoginType);
                        param.Direction = ParameterDirection.Input;
                        param.SqlDbType = SqlDbType.VarChar;
                        param.Size      = 50;
                        cmd.Parameters.Add(param);

                        param           = new SqlParameter("@Designation", input.Designation);
                        param.Direction = ParameterDirection.Input;
                        param.SqlDbType = SqlDbType.VarChar;
                        param.Size      = 50;
                        cmd.Parameters.Add(param);

                        param           = new SqlParameter("@StateCode", input.StationCode);
                        param.Direction = ParameterDirection.Input;
                        param.SqlDbType = SqlDbType.VarChar;
                        param.Size      = 30;
                        cmd.Parameters.Add(param);

                        param           = new SqlParameter("@LocationName", input.LocationName);
                        param.Direction = ParameterDirection.Input;
                        param.SqlDbType = SqlDbType.VarChar;
                        param.Size      = 50;
                        cmd.Parameters.Add(param);

                        param           = new SqlParameter("@IsActive", false);
                        param.Direction = ParameterDirection.Input;
                        param.SqlDbType = SqlDbType.Bit;
                        cmd.Parameters.Add(param);

                        param           = new SqlParameter("@UserTypeId", input.UserTypeId);
                        param.Direction = ParameterDirection.Input;
                        param.SqlDbType = SqlDbType.Int;
                        cmd.Parameters.Add(param);

                        SqlParameter output = new SqlParameter();
                        output.ParameterName = "@EmpId";
                        output.SqlDbType     = SqlDbType.Int;
                        output.Direction     = ParameterDirection.Output;
                        cmd.Parameters.Add(output);

                        SqlParameter output2 = new SqlParameter();
                        output2.ParameterName = "@EmpName";
                        output2.SqlDbType     = SqlDbType.VarChar;
                        output2.Size          = 50;
                        output2.Direction     = ParameterDirection.Output;
                        cmd.Parameters.Add(output2);

                        conn.Open();
                        cmd.ExecuteNonQuery();

                        string empId = output.Value.ToString();

                        string empName = output2.Value.ToString();
                        conn.Close();
                        dbr.Id = string.IsNullOrEmpty(empId) ? 0 : Convert.ToInt32(empId);

                        dbr.EmployeeName = empName;
                        dbr.Status       = true;
                        dbr.Message      = "Employee Registered Successfully!!!";
                    }
                }
            }
            catch (SqlException e)
            {
                dbr.Id           = 0;
                dbr.EmployeeName = "";
                dbr.Status       = false;
                dbr.Message      = "Something wrong with database : " + e.Message;
                throw e;
            }
            catch (Exception e)
            {
                dbr.Id           = 0;
                dbr.Message      = e.Message;
                dbr.EmployeeName = "";
                dbr.Status       = false;
                throw e;
            }
            finally
            {
                cmd.Dispose();
            }
            return(dbr);
        }