Esempio n. 1
0
        public Boolean addUserDetail(User user)
        {
            Boolean status = false;


            try
            {
                using (var db = new PayrollModel())
                {
                    string passencripted = EncryptionUtil.ToSHA256(user.Password);
                    Console.WriteLine(passencripted);
                    user.Password = passencripted;
                    db.Users.Add(user);
                    db.SaveChanges();
                    status = true;
                }
            }
            catch (DbEntityValidationException ex)
            {
                foreach (var entityValidationErrors in ex.EntityValidationErrors)
                {
                    foreach (var validationError in entityValidationErrors.ValidationErrors)
                    {
                        Console.Write("Property: " + validationError.PropertyName + " Error: " + validationError.ErrorMessage);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.InnerException);
            }
            return(status);
        }
Esempio n. 2
0
        public Boolean checkUserLogin(string username, string password)
        {
            Console.Write("username " + username + " password " + password);

            string encrypted = EncryptionUtil.ToSHA256(password);

            Console.Write("encrypted " + encrypted);

            User    userdetail  = null;
            Boolean user_status = false;

            try
            {
                using (var db = new PayrollModel())
                {
                    Console.Write("user detail" + db.Users.FirstOrDefault());
                    userdetail = db.Users.Where(u => u.User_Name == username && u.Password == encrypted).FirstOrDefault();
                    Console.Write("user detail " + userdetail);
                    if (userdetail != null)
                    {
                        user_status = true;
                    }
                }
            }
            catch (InvalidOperationException ex)
            {
                Console.Write(ex.StackTrace);
            }

            return(user_status);
        }
Esempio n. 3
0
        public void ShouldReturnSuccessForDelete()
        {
            PayrollModel account = new PayrollModel();

            account.ID = 6;

            bool   opeartionSucceeded = false;
            string dataAccessJsonStr  = string.Empty;
            string formattedJsonStr   = string.Empty;

            try
            {
                payrollService.Remove(account);
                opeartionSucceeded = true;
            }
            catch (DataAccessException e)
            {
                e.DataAccessStatusInfo.OperationSucceeded = opeartionSucceeded;
                dataAccessJsonStr = JsonConvert.SerializeObject(e.DataAccessStatusInfo);
                formattedJsonStr  = JToken.FromObject(dataAccessJsonStr).ToString();
            }

            try
            {
                Assert.True(opeartionSucceeded);
                testOutputHelper.WriteLine("The record has been succesfully deleted");
            }
            finally
            {
                testOutputHelper.WriteLine(formattedJsonStr);
            }
        }
Esempio n. 4
0
        public ActionResult DoCreatePayroll(string json)
        {
            PayrollModel payrollModel = JsonConvert.DeserializeObject <PayrollModel>(json);

            info.InsertPayroll(payrollModel.EmployeeID, payrollModel.EmployeeName, payrollModel.BasicSalary, payrollModel.WorkDay, payrollModel.Bonus, payrollModel.Penalty, payrollModel.Total, "VND", payrollModel.Desc, DateTime.Now);
            //TimeSheet timeSheet = info.GetTimeSheetByEmployeeID(payrollModel.EmployeeID);
            //info.InsertTimeSheetDetail(timeSheet.TimeSheetID, payrollModel.Bonus, payrollModel.Penalty, "VND", payrollModel.Desc);
            return(Json(JsonRequestBehavior.AllowGet));
        }
Esempio n. 5
0
        /// <summary>
        /// Finds the emp between Date Range of joining.
        /// </summary>
        /// <param name="firstRange">The first range.</param>
        /// <param name="lastRange">The last range.</param>
        /// <returns></returns>
        public bool FindEmpBetweenRange(string firstRange, string lastRange)
        {
            bool   isExist = false;
            int    id      = 0;
            string name    = "";

            try
            {
                using (SqlConnection sqlConnection = new SqlConnection(connection))
                {
                    //Opening Connection
                    sqlConnection.Open();
                    PayrollModel employee = new PayrollModel();

                    //Setting command object with defined stored procedure name
                    SqlCommand command = new SqlCommand("findEmployeesBetweenRange", sqlConnection);

                    //setting commmand type to stored procedure
                    command.CommandType = CommandType.StoredProcedure;

                    //Adding date range parameters to the command object
                    command.Parameters.AddWithValue("@firstRange", firstRange);
                    command.Parameters.AddWithValue("@lastRange", lastRange);

                    //excecute Sql Data Reader for DQL operation
                    SqlDataReader dataReader = command.ExecuteReader();

                    //If Query gives back result/rows
                    if (dataReader.HasRows)
                    {
                        //Read Rows through Result set one by one
                        while (dataReader.Read())
                        {
                            id   = Convert.ToInt32(dataReader["id"]);
                            name = Convert.ToString(dataReader["name"]);
                            Console.WriteLine("Employee ID:" + id + " Name:" + name + "\n");

                            //Employee exist between range
                            isExist = true;
                        }
                    }
                    else
                    {
                        Console.WriteLine("No records exist\n");
                        isExist = false;
                    }
                    dataReader.Close();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }


            return(isExist);
        }
        private void btnEdit_Click(object sender, RoutedEventArgs e)
        {
            PayrollModel pm = dgvEmployees.SelectedItem as PayrollModel;

            if (pm != null)
            {
                PayrollDetailsWindow pdw = new PayrollDetailsWindow(this, pm);
                pdw.ShowDialog();
            }
        }
        public PayrollModel GetByEmployee(int employeeID)
        {
            PayrollModel     account              = new PayrollModel();
            DataAccessStatus dataAccessStatus     = new DataAccessStatus();
            bool             matchingRecoredFound = false;
            string           selectByIdQuery      = "SELECT ID, GrossPay, NetPay " +
                                                    "FROM Payrolls WHERE EmployeeID = @EmployeeID";

            using (SqlConnection sqlConnection = new SqlConnection(this.connectionString))
            {
                try
                {
                    sqlConnection.Open();

                    using (SqlCommand cmd = new SqlCommand(selectByIdQuery, sqlConnection))
                    {
                        cmd.CommandText = selectByIdQuery;
                        cmd.Prepare();
                        cmd.Parameters.Add(new SqlParameter("@EmployeeID", employeeID));

                        using (SqlDataReader reader = cmd.ExecuteReader())
                        {
                            matchingRecoredFound = reader.HasRows;
                            while (reader.Read())
                            {
                                account.ID         = Convert.ToInt32(reader["ID"].ToString());
                                account.EmployeeID = employeeID;
                                account.GrossPay   = Convert.ToInt32(reader["GrossPay"].ToString());
                                account.NetPay     = Convert.ToInt32(reader["NetPay"].ToString());
                            }
                        }
                    }
                    sqlConnection.Close();
                }
                catch (SqlException e)
                {
                    dataAccessStatus.setValues(status: "Error", operationSucceeded: false, exceptionMessage: e.Message,
                                               customMessage: "Unable to get the Payroll record from database", helpLink: e.HelpLink, errorCode: e.ErrorCode,
                                               stackTrace: e.StackTrace);

                    throw new DataAccessException(e.Message, e.InnerException, dataAccessStatus);
                }

                if (!matchingRecoredFound)
                {
                    dataAccessStatus.setValues(status: "Error", operationSucceeded: false, exceptionMessage: "",
                                               customMessage: $"Record not found!. Unable to get Payroll record for with employee id: {employeeID}.It does not exist in the database.", helpLink: "", errorCode: 0,
                                               stackTrace: "");

                    throw new DataAccessException(dataAccessStatus);
                }

                return(account);
            }
        }
Esempio n. 8
0
 public void Post([FromBody] PayrollModel payroll)
 {
     if (Get(payroll.Oib) == null)
     {
         _payrollData.InsertPayroll(payroll);
     }
     else
     {
         _payrollData.UpdatePayroll(payroll);
     }
 }
Esempio n. 9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void DownloadTemplate_Click(object sender, DirectEventArgs e)
        {
            // init table
            var dataTable          = new DataTable();
            var salaryBoardConfigs = new List <SalaryBoardConfigModel>();
            var payroll            = new PayrollModel();
            var salaryBoardInfos   = new List <SalaryBoardInfoModel>();

            // adjust table
            dataTable.Rows.Add();
            dataTable.Columns.Add(new DataColumn(EmployeeCode));
            dataTable.Columns.Add(new DataColumn(FullName));

            // get config
            if (!string.IsNullOrEmpty(hdfConfigId.Text))
            {
                salaryBoardConfigs = SalaryBoardConfigController.GetAll(int.Parse(hdfConfigId.Text), null, null, null,
                                                                        SalaryConfigDataType.DynamicValue, null, null);
            }

            // get payroll
            if (!string.IsNullOrEmpty(hdfSalaryBoardListID.Text))
            {
                payroll = PayrollController.GetById(int.Parse(hdfSalaryBoardListID.Text));
            }


            if (salaryBoardConfigs != null)
            {
                foreach (var model in salaryBoardConfigs)
                {
                    dataTable.Columns.Add(new DataColumn(model.Display));
                }
            }

            // get record by department
            if (payroll != null)
            {
                salaryBoardInfos = SalaryBoardInfoController.GetAll(null, payroll.Id.ToString(), null, null);
            }

            // fill employee name and code
            for (var i = 0; i < salaryBoardInfos.Count; i++)
            {
                dataTable.Rows.Add();
                dataTable.Rows[i][EmployeeCode] = salaryBoardInfos[i].EmployeeCode;
                dataTable.Rows[i][FullName]     = salaryBoardInfos[i].FullName;
            }

            ExportToExcel(dataTable, "~/" + Constant.PathTemplate, ImportSalaryExcelFile);
        }
Esempio n. 10
0
        // GET: Payroll
        public ActionResult Index()
        {
            var payrollModel = new PayrollModel
            {
                FullName    = string.Empty,
                Month       = DateTime.Now,
                GrossIncome = 0,
                IncomeTax   = 0,
                NetIncome   = 0,
                SuperFund   = 0
            };

            return(View(payrollModel));
        }
Esempio n. 11
0
        public void UpdatePayroll(PayrollModel payroll)
        {
            try
            {
                _sql.StartTransaction("AccountingConnStr");

                _sql.SaveDataInTransaction("dbo.spPayroll_Update", payroll);
            }
            catch (System.Exception)
            {
                _sql.RollBackTransaction();
                throw;
            }
        }
Esempio n. 12
0
        private void OpenCalculationDialog()
        {
            var parameters = new DialogParameters();

            parameters.Add("payroll", SelectedPayroll);
            parameters.Add("employee", Employees.Where(x => x.Oib == SelectedPayroll.Oib).FirstOrDefault());
            _showDialog.ShowDialog(nameof(PayrollCalculationDialog), parameters, result =>
            {
                if (result.Result == ButtonResult.OK)
                {
                    PayrollModel payroll = result.Parameters.GetValue <PayrollModel>("payroll");
                    SaveNewCalculation(payroll);
                }
            });
        }
Esempio n. 13
0
 public async Task <bool> PostPayroll(PayrollModel payroll)
 {
     using (HttpResponseMessage response = await _apiService.ApiClient.PostAsJsonAsync("/api/Payroll", payroll))
     {
         if (response.IsSuccessStatusCode)
         {
             return(true);
         }
         else
         {
             var error = response.ReasonPhrase;
             return(false);
         }
     }
 }
Esempio n. 14
0
        public async void OnDialogOpened(IDialogParameters parameters)
        {
            Payroll  = parameters.GetValue <PayrollModel>("payroll");
            Employee = parameters.GetValue <EmployeeModel>("employee");
            if (Payroll != null)
            {
                GetPayrollFromDatabase(Payroll.Oib);
            }
            else
            {
                Payroll = new PayrollModel();
            }

            City = await _cityEndpoint.GetByName(Employee.Mjesto);
        }
        public bool UpdatePayroll(PayrollModel payroll)
        {
            var checkExistingPayroll = ctx.Payrolls.Where(c => c.WageTier == payroll.WageTier).FirstOrDefault <Payroll>();

            if (checkExistingPayroll != null)
            {
                checkExistingPayroll.Coefficient = (double)payroll.Coefficient;
                ctx.SaveChanges();
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 16
0
        /// <summary>
        /// Init setting window
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void InitWindow(object sender, DirectEventArgs e)
        {
            ResetForm();
            var param = e.ExtraParams["Id"];

            if (int.TryParse(param, out var id))
            {
                if (id > 0)
                {
                    // edit
                    EmployeeGrid.Disabled  = true;
                    cbxDepartment.Disabled = true;
                    wdSetting.Title        = @"Sửa bảng lương";
                    wdSetting.Icon         = Icon.Pencil;
                }
                else
                {
                    // insert
                    EmployeeGrid.Disabled  = false;
                    cbxDepartment.Disabled = false;
                    wdSetting.Title        = @"Thêm mới bảng lương";
                    wdSetting.Icon         = Icon.Add;
                }
                hdfSalaryBoardListId.Text = id.ToString();
                var payrollModel = new PayrollModel();

                if (id > 0)
                {
                    var result = PayrollController.GetById(Convert.ToInt32(hdfSalaryBoardListId.Text));
                    if (result != null)
                    {
                        payrollModel = result;
                    }
                    //data
                    txtName.Text       = payrollModel.Title;
                    txtCode.Text       = payrollModel.Code;
                    txtNote.Text       = payrollModel.Description;
                    hdfConfigId.Text   = payrollModel.ConfigId.ToString();
                    cbxConfigList.Text = payrollModel.ConfigName;
                }
                hdfMonth.Text = payrollModel.Month.ToString();
                cbxMonth.Text = payrollModel.Month.ToString();
                hdfYear.Text  = payrollModel.Year.ToString();
                spnYear.Text  = payrollModel.Year.ToString();
                // show window
                wdSetting.Show();
            }
        }
        public IList <Payroll> GetPayrolls(PayrollModel payroll)
        {
            IList <Payroll> listpayroll = null;

            if (payroll != null)
            {
                listpayroll = ctx.Payrolls.Where(c => (c.Coefficient == payroll.Coefficient || payroll.Coefficient == null) &&
                                                 (c.WageTier == payroll.WageTier || payroll.WageTier == null)
                                                 ).ToList <Payroll>();
            }
            else
            {
                listpayroll = ctx.Payrolls.ToList <Payroll>();
            }
            return(listpayroll);
        }
        //send month as int from DateTime.Month
        public List <Emp_Extra_Work> getExtraWorkForMonth(int employeeId, int month)
        {
            List <Emp_Extra_Work> emp_extraworks = null;

            try
            {
                using (var db = new PayrollModel())
                {
                    emp_extraworks = db.Emp_Extra_Work.Where(extra => extra.Employee_ID == employeeId && month == extra.Work_Date.Month).ToList();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("find extra work error" + ex.InnerException);
            }
            return(emp_extraworks);
        }
        public Employee_Type findEmployeeType(int employeeTypeId)
        {
            Employee_Type employeeType = null;

            try
            {
                using (var db = new PayrollModel())
                {
                    employeeType = db.Employee_Type.Find(employeeTypeId);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("find employee" + ex.InnerException);
            }
            return(employeeType);
        }
        public List <Payment_Catagory> loadAllPaymentCategories()
        {
            List <Payment_Catagory> categories = null;

            try
            {
                using (var db = new PayrollModel())
                {
                    categories = db.Set <Payment_Catagory>().ToList();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("load payement categories  error " + ex.InnerException);
            }
            return(categories);
        }
        public Payroll_Allowances_Master findByAllowanceId(int allowanceId)
        {
            Payroll_Allowances_Master allowance = null;

            try
            {
                using (var db = new PayrollModel())
                {
                    allowance = db.Payroll_Allowances_Master.Find(allowanceId);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("find allowance error" + ex.InnerException);
            }
            return(allowance);
        }
        public List <Payroll_Allowances_Master> loadallAllowances()
        {
            List <Payroll_Allowances_Master> allowances = null;

            try
            {
                using (var db = new PayrollModel())
                {
                    allowances = db.Set <Payroll_Allowances_Master>().ToList();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("findall allowances error " + ex.InnerException);
            }
            return(allowances);
        }
Esempio n. 23
0
        public Emp_Attendance findEmployeeAttendanceByDate(DateTime date)
        {
            Emp_Attendance attendance = null;

            try
            {
                using (var db = new PayrollModel())
                {
                    attendance = db.Emp_Attendance.Where(employee => employee.Atten_Date == date).First();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("find employee Type error" + ex.InnerException);
            }
            return(attendance);
        }
Esempio n. 24
0
        public Emp_Attendance findEmployeeAttendanceById(int employeeId)
        {
            Emp_Attendance attendance = null;

            try
            {
                using (var db = new PayrollModel())
                {
                    attendance = db.Emp_Attendance.Find(employeeId);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("find employee Type error" + ex.InnerException);
            }
            return(attendance);
        }
        public Emp_Extra_Work findByEmployeeExtraWorkByID(int employeeId)
        {
            Emp_Extra_Work emp_extrawork = null;

            try
            {
                using (var db = new PayrollModel())
                {
                    emp_extrawork = db.Emp_Extra_Work.Find(employeeId);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("find extra work error" + ex.InnerException);
            }
            return(emp_extrawork);
        }
Esempio n. 26
0
        public List <Employee> loadallEmployees()
        {
            List <Employee> employees = null;

            try
            {
                using (var db = new PayrollModel())
                {
                    employees = db.Set <Employee>().ToList();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("findall employee error " + ex.InnerException);
            }
            return(employees);
        }
        public List <Employee_Type> loadallEmployeeTypes()
        {
            List <Employee_Type> allEmpTypes = null;

            try
            {
                using (var db = new PayrollModel())
                {
                    allEmpTypes = db.Set <Employee_Type>().ToList();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("load all types error " + ex.InnerException);
            }
            return(allEmpTypes);
        }
Esempio n. 28
0
        public List <Emp_Attendance> loadallAttendance()
        {
            List <Emp_Attendance> attendances = null;

            try
            {
                using (var db = new PayrollModel())
                {
                    attendances = db.Set <Emp_Attendance>().ToList();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("load attendance error " + ex.InnerException);
            }
            return(attendances);
        }
Esempio n. 29
0
        protected void Page_Load(object sender, EventArgs e)
        {
            hdfPayrollId.Text = Request.QueryString["id"];
            // get payroll
            _payroll = PayrollController.GetById(int.Parse(hdfPayrollId.Text));

            if (!ExtNet.IsAjaxRequest)
            {
                if (_payroll != null)
                {
                    hdfConfigId.Text = _payroll.ConfigId.ToString();
                    ReloadGrid();
                }
            }

            InitDynamicColumn();
        }
        public List <Department_Master> loadallDepartments()
        {
            List <Department_Master> departments = null;

            try
            {
                using (var db = new PayrollModel())
                {
                    departments = db.Set <Department_Master>().ToList();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("load departments error " + ex.InnerException);
            }
            return(departments);
        }