private void ViewTHRDetail(THR thr) { txtID.Text = thr.ID.ToString(); txtEmployeeId.Text = thr.EmployeeId.ToString(); txtCode.Text = thr.Employee.EmployeeCode;; txtName.Text = thr.Employee.EmployeeName; txtBranch.Text = thr.Branch; txtDepartment.Text = thr.Department; txtGrade.Text = thr.Grade; txtGradeLevel.Text = thr.GradeLevel.ToString(); txtOccupation.Text = thr.Occupation; txtStatus.Text = thr.Status; txtPaymentType.Text = thr.PaymentType; chkTransfer.Checked = thr.IsTransfer; txtBank.Text = thr.BankName; txtAccount.Text = thr.AccountNumber; lblCode.Text = thr.HolidayType; dtpDate.Text = thr.StartDate.ToShortDateString(); dtpEfective.Text = thr.EffectiveDate.ToShortDateString(); chkIsPaid.Checked = thr.IsPaid; txtYearOfWork.Text = thr.YearOfWork.ToString(); txtMonthOfWork.Text = thr.MonthOfWork.ToString(); txtDaysOfWork.Text = thr.DayOfWork.ToString(); txtMainSalary.Text = thr.MainSalary.ToString("N0").Replace(",", "."); txtAmount.Text = thr.Amount.ToString("N0").Replace(",", "."); txtOtherAmount.Text = thr.OtherAmount.ToString("N0").Replace(",", "."); txtTotalAmount.Text = thr.TotalAmount.ToString("N0").Replace(",", "."); }
public dynamic GetDefaultInfo() { THR model = new THR(); try { model = _thrService.GetQueryable().FirstOrDefault(); } catch (Exception ex) { LOG.Error("GetInfo", ex); Dictionary <string, string> Errors = new Dictionary <string, string>(); Errors.Add("Generic", "Error " + ex); return(Json(new { Errors }, JsonRequestBehavior.AllowGet)); } return(Json(new { model.Id, model.SalaryItemId, model.Code, model.Name, model.Description, model.EffectiveDate, model.Errors }, JsonRequestBehavior.AllowGet)); }
public void UpdateValue(THR thr) { try { using (var em = EntityManagerFactory.CreateInstance(ds)) { string[] fields = { "OtherAmount", "TotalAmount", "AmountInWords", "ModifiedDate", "ModifiedBy" }; object[] values = { thr.OtherAmount, thr.TotalAmount, thr.AmountInWords, DateTime.Now.ToShortDateString(), Store.ActiveUser }; Query q = new Query().Select(fields).From(tableName).Update(values) .Where("ID").Equal("{" + thr.ID + "}"); em.ExecuteNonQuery(q.ToSql()); } } catch (Exception ex) { throw ex; } }
public dynamic Insert(THR model) { try { if (!AuthenticationModel.IsAllowed("Create", Core.Constants.Constant.MenuName.THR, Core.Constants.Constant.MenuGroupName.Setting)) { Dictionary <string, string> Errors = new Dictionary <string, string>(); Errors.Add("Generic", "You are Not Allowed to Add record"); return(Json(new { Errors }, JsonRequestBehavior.AllowGet)); } model = _thrService.CreateObject(model, _salaryItemService); } catch (Exception ex) { LOG.Error("Insert Failed", ex); Dictionary <string, string> Errors = new Dictionary <string, string>(); Errors.Add("Generic", "Error " + ex); return(Json(new { Errors }, JsonRequestBehavior.AllowGet)); } return(Json(new { model.Errors })); }
public THR UpdateObject(THR thr, ISalaryItemService _salaryItemService) { if (_validator.ValidUpdateObject(thr, this)) { SalaryItem salaryItem = _salaryItemService.GetObjectById(thr.SalaryItemId.GetValueOrDefault()); if (salaryItem == null) { salaryItem = _salaryItemService.CreateObject(thr.Code, thr.Name, (int)Constant.SalarySign.Income, (int)Constant.SalaryItemType.SalarySlip, (int)Constant.SalaryItemStatus.Monthly, thr.IsMainSalary, thr.IsDetailSalary, false); thr.SalaryItemId = salaryItem.Id; } else { salaryItem.Code = thr.Code; salaryItem.Name = thr.Name; _salaryItemService.UpdateObject(salaryItem); if (salaryItem.Errors.Any()) { thr.Errors.Clear(); thr.Errors.Add("Code", "Tidak dapat mengubah SalaryItem dengan Code ini"); } } _repository.UpdateObject(thr); } return(thr); }
public THR VHasEffectiveDate(THR thr) { if (thr.EffectiveDate == null || thr.EffectiveDate.Equals(DateTime.FromBinary(0))) { thr.Errors.Add("EffectiveDate", "Tidak valid"); } return(thr); }
private void GetTHRById(Guid id) { THR thr = thrRepository.GetById(id); if (thr != null) { ViewTHRDetail(thr); } }
private void GetLastTHR() { THR thr = thrRepository.GetLast(Store.ActiveYear); if (thr != null) { ViewTHRDetail(thr); } }
public THRDetail VHasTHR(THRDetail thrDetail, ITHRService _thrService) { THR thr = _thrService.GetObjectById(thrDetail.THRId); if (thr == null) { thrDetail.Errors.Add("THR", "Tidak ada"); } return(thrDetail); }
public THR VHasSalaryItem(THR thr, ISalaryItemService _salaryItemService) { SalaryItem salaryItem = _salaryItemService.GetObjectById(thr.SalaryItemId.GetValueOrDefault()); if (salaryItem == null) { thr.Errors.Add("SalaryItem", "Tidak valid"); } return(thr); }
public bool ValidCreateObject(THR thr, ITHRService _thrService) { VHasUniqueCode(thr, _thrService); if (!isValid(thr)) { return(false); } VHasEffectiveDate(thr); return(isValid(thr)); }
public THR VHasUniqueCode(THR thr, ITHRService _thrService) { if (String.IsNullOrEmpty(thr.Code) || thr.Code.Trim() == "") { thr.Errors.Add("Code", "Tidak boleh kosong"); } else if (_thrService.IsCodeDuplicated(thr)) { thr.Errors.Add("Code", "Tidak boleh ada duplikasi"); } return(thr); }
public string PrintError(THR obj) { string erroroutput = ""; KeyValuePair <string, string> first = obj.Errors.ElementAt(0); erroroutput += first.Key + "," + first.Value; foreach (KeyValuePair <string, string> pair in obj.Errors.Skip(1)) { erroroutput += Environment.NewLine; erroroutput += pair.Key + "," + pair.Value; } return(erroroutput); }
public THR SoftDeleteObject(THR thr, ISalaryItemService _salaryItemService) { if (_validator.ValidDeleteObject(thr)) { SalaryItem salaryItem = _salaryItemService.GetObjectById(thr.SalaryItemId.GetValueOrDefault()); _repository.SoftDeleteObject(thr); if (salaryItem != null) { _salaryItemService.SoftDeleteObject(salaryItem); } } return(thr); }
public THR GetLast() { THR thr = null; using (var em = EntityManagerFactory.CreateInstance(ds)) { var sql = "SELECT TOP 1 t.*, " + "e.* " + "FROM THR t INNER JOIN Employee e ON t.EmployeeId = e.ID " + "ORDER BY e.EmployeeCode ASC"; thr = em.ExecuteObject <THR>(sql, new THRMapper()); } return(thr); }
private void PopulateTHR(THR thr) { var item = new ListViewItem(thr.ID.ToString()); item.SubItems.Add(thr.EmployeeId.ToString()); item.SubItems.Add(thr.Employee.EmployeeCode); item.SubItems.Add(thr.Employee.EmployeeName); item.SubItems.Add(thr.Branch); item.SubItems.Add(thr.Department); item.SubItems.Add(thr.CreatedDate.ToString("dd/MM/yyyy")); item.SubItems.Add(thr.CreatedBy); item.SubItems.Add(thr.ModifiedDate.ToString("dd/MM/yyyy")); item.SubItems.Add(thr.ModifiedBy); lvwData.Items.Add(item); }
public THR GetLast(int year) { THR thr = null; using (var em = EntityManagerFactory.CreateInstance(ds)) { var sql = "SELECT t.*, " + "e.* " + "FROM THR t INNER JOIN Employee e ON t.EmployeeId = e.ID " + "WHERE t.YearPeriod=" + year + " " + "ORDER BY t.HolidayType ASC, e.EmployeeCode ASC"; thr = em.ExecuteObject <THR>(sql, new THRMapper()); } return(thr); }
public THR GetById(Guid id) { THR thr = null; using (var em = EntityManagerFactory.CreateInstance(ds)) { var sql = "SELECT t.*, " + "e.* " + "FROM THR t INNER JOIN Employee e ON t.EmployeeId = e.ID " + "WHERE " + "t.ID='{" + id + "}'"; thr = em.ExecuteObject <THR>(sql, new THRMapper()); } return(thr); }
public ITHR Create( ImmutableList <ITHRParameterElement> value) { ITHR parameter = null; try { parameter = new THR( value); } catch (Exception exception) { this.Log.Error( exception.Message, exception); } return(parameter); }
public dynamic Update(THR model) { try { if (!AuthenticationModel.IsAllowed("Edit", Core.Constants.Constant.MenuName.THR, Core.Constants.Constant.MenuGroupName.Setting)) { Dictionary <string, string> Errors = new Dictionary <string, string>(); Errors.Add("Generic", "You are Not Allowed to Edit record"); return(Json(new { Errors }, JsonRequestBehavior.AllowGet)); } var data = _thrService.GetObjectById(model.Id); //data.SalaryItemId = model.SalaryItemId; data.Code = model.Code; data.Name = model.Name; data.Description = model.Description; data.EffectiveDate = model.EffectiveDate; model = _thrService.UpdateObject(data, _salaryItemService); } catch (Exception ex) { LOG.Error("Update Failed", ex); Dictionary <string, string> Errors = new Dictionary <string, string>(); Errors.Add("Generic", "Error " + ex); return(Json(new { Errors }, JsonRequestBehavior.AllowGet)); } return(Json(new { model.Errors })); }
public void Update(THR thr) { try { using (var em = EntityManagerFactory.CreateInstance(ds)) { string[] fields = { "YearPeriod", "EmployeeId", "Branch", "Department", "Grade", "GradeLevel", "Occupation", "Status", "PaymentType", "IsTransfer", "BankName", "AccountNumber", "HolidayType", "StartDate", "EffectiveDate", "YearOfWork", "MonthOfWork","DayOfWork", "MainSalary", "Amount", "OtherAmount", "TotalAmount", "AmountInWords", "IsPaid", "CreatedDate", "CreatedBy", "ModifiedDate", "ModifiedBy" }; object[] values = { thr.YearPeriod, thr.EmployeeId, thr.Branch, thr.Department, thr.Grade, thr.GradeLevel, thr.Occupation, thr.Status, thr.PaymentType, thr.IsTransfer == true?1:0, thr.BankName, thr.AccountNumber, thr.HolidayType, thr.StartDate.ToShortDateString(),thr.EffectiveDate.ToShortDateString(), thr.YearOfWork, thr.MonthOfWork, thr.DayOfWork, thr.MainSalary, thr.Amount, thr.OtherAmount, thr.TotalAmount, thr.AmountInWords, thr.IsPaid == true?1:0, DateTime.Now.ToShortDateString(), Store.ActiveUser, DateTime.Now.ToShortDateString(), Store.ActiveUser }; Query q = new Query().Select(fields).From(tableName).Update(values) .Where("ID").Equal("{" + thr.ID + "}"); em.ExecuteNonQuery(q.ToSql()); } } catch (Exception ex) { throw ex; } }
public dynamic Delete(THR model) { try { if (!AuthenticationModel.IsAllowed("Delete", Core.Constants.Constant.MenuName.THR, Core.Constants.Constant.MenuGroupName.Setting)) { Dictionary <string, string> Errors = new Dictionary <string, string>(); Errors.Add("Generic", "You are Not Allowed to Delete Record"); return(Json(new { Errors }, JsonRequestBehavior.AllowGet)); } var data = _thrService.GetObjectById(model.Id); model = _thrService.SoftDeleteObject(data, _salaryItemService); } catch (Exception ex) { LOG.Error("Delete Failed", ex); Dictionary <string, string> Errors = new Dictionary <string, string>(); Errors.Add("Generic", "Error " + ex); return(Json(new { Errors }, JsonRequestBehavior.AllowGet)); } return(Json(new { model.Errors })); }
private void SaveTHR() { THR thr = new THR(); thr.OtherAmount = decimal.Parse(txtOtherAmount.Text == "" ? "0" : txtOtherAmount.Text.Replace(".", "")); thr.TotalAmount = decimal.Parse(txtTotalAmount.Text == "" ? "0" : txtTotalAmount.Text.Replace(".", "")); if (thr.TotalAmount > 0) { string amountInWords = Store.GetAmounInWords(Convert.ToInt32(thr.TotalAmount)); string firstLetter = amountInWords.Substring(0, 2).Trim().ToUpper(); string theRest = amountInWords.Substring(2, amountInWords.Length - 2); thr.AmountInWords = firstLetter + theRest + " rupiah"; } else { thr.AmountInWords = "Nol rupiah"; } if (formMode == FormMode.Add) { thrRepository.Save(thr); GetLastTHR(); } else if (formMode == FormMode.Edit) { thr.ID = new Guid(txtID.Text); thrRepository.UpdateValue(thr); } GetLastTHR(); DisableForm(); formMode = FormMode.View; this.Text = "THR"; }
public THR CreateObject(THR thr, ISalaryItemService _salaryItemService) { thr.Errors = new Dictionary <String, String>(); if (_validator.ValidCreateObject(thr, this)) { SalaryItem salaryItem = _salaryItemService.GetObjectByCode(thr.Code); if (salaryItem != null) { thr.Errors = new Dictionary <string, string>(); thr.Errors.Add("Code", "SalaryItem dengan Code ini sudah ada"); return(thr); } salaryItem = _salaryItemService.CreateObject(thr.Code, thr.Name, (int)Constant.SalarySign.Income, (int)Constant.SalaryItemType.THR, (int)Constant.SalaryItemStatus.Monthly, thr.IsMainSalary, thr.IsDetailSalary, false); if (salaryItem == null) { thr.Errors = new Dictionary <string, string>(); thr.Errors.Add("Code", "Tidak dapat membuat SalaryItem dengan Code ini"); return(thr); } thr.SalaryItemId = salaryItem.Id; _repository.CreateObject(thr); } return(thr); }
public bool IsCodeDuplicated(THR thr) { IQueryable <THR> thrs = _repository.FindAll(x => x.Code == thr.Code && !x.IsDeleted && x.Id != thr.Id); return(thrs.Count() > 0 ? true : false); }
public bool ValidUpdateObject(THR thr, ITHRService _thrService) { thr.Errors.Clear(); ValidCreateObject(thr, _thrService); return(isValid(thr)); }
public bool ValidDeleteObject(THR thr) { thr.Errors.Clear(); return(isValid(thr)); }
public void CalculateTHR(DateTime effectiveDate, string holidays) { using (var em = EntityManagerFactory.CreateInstance(ds)) { int mainSalaryDivider = 0; //employee DateTime startDate; string religion; int monthPeriod = 0; int yearPeriod = 0; string branch = ""; string department = ""; string grade = ""; int gradeLevel = 0; string occupation = ""; string status = ""; string paymentType = ""; bool isTransfer = false; string bankName = ""; string accountNumber = ""; string holidayType = ""; decimal mainSalary = 0; decimal amount = 0; decimal otherAmount = 0; decimal totalAmount = 0; string amountInWord = ""; bool isPaid = false; //EMPLOYEE List <Employee> employees = new List <Employee>(); if (holidays == "LEBARAN") { employees = employeeRepository.GetMoslemEmployee(); } else { employees = employeeRepository.GetNonMoslemEmployee(); } foreach (var e in employees) { mainSalary = 0; amount = 0; otherAmount = 0; totalAmount = 0; startDate = e.StartDate; isTransfer = e.IsTransfer; bankName = e.BankName; accountNumber = e.AccountNumber; monthPeriod = effectiveDate.Month; yearPeriod = effectiveDate.Year; //LAMA KERJA CalculateYearAndMonth(startDate, effectiveDate); if (monthOfWork >= 3 || yearOfWork >= 1) { //HARI RAYA religion = e.Religion; if (religion == "Islam") { holidayType = "LEBARAN"; } else { holidayType = "NATAL"; } //AMBIL BRANCH & DEPT var dept = employeeDepartmentRepository.GetCurrentDepartment(e.ID, monthPeriod, yearPeriod); if (dept != null) { department = dept.DepartmentName; branch = dept.BranchName; } else { var previousDept = employeeDepartmentRepository.GetPreviousDepartment(e.ID, monthPeriod, yearPeriod); if (previousDept != null) { department = previousDept.DepartmentName; branch = previousDept.BranchName; } } //AMBIL GRADE var grades = employeeGradeRepository.GetCurrentGrade(e.ID, monthPeriod, yearPeriod); if (grades != null) { grade = grades.GradeName; gradeLevel = grades.GradeLevel; } else { var previousGrade = employeeGradeRepository.GetPreviousGrade(e.ID, monthPeriod, yearPeriod); if (previousGrade != null) { department = previousGrade.GradeName; gradeLevel = previousGrade.GradeLevel; } } //AMBIL OCCUPATION var occupations = employeeOccupationRepository.GetCurrentOccupation(e.ID, monthPeriod, yearPeriod); if (occupations != null) { occupation = occupations.OccupationName; } else { var previousOccupation = employeeOccupationRepository.GetPreviousOccupation(e.ID, monthPeriod, yearPeriod); if (previousOccupation != null) { occupation = previousOccupation.OccupationName; } } //AMBIL STATUS var statusEmployee = employeeStatusRepository.GetCurrentStatus(e.ID, monthPeriod, yearPeriod); if (statusEmployee != null) { status = statusEmployee.Status; paymentType = statusEmployee.PaymentType; } else { var previousStatus = employeeStatusRepository.GetPreviousStatus(e.ID, monthPeriod, yearPeriod); if (previousStatus != null) { status = previousStatus.Status; paymentType = previousStatus.PaymentType; } } //AMBIL NILAI-NILAI GAJI var salary = employeeSalaryRepository.GetCurrentSalary(e.ID, monthPeriod, yearPeriod); if (salary != null) { mainSalary = salary.MainSalary; } else { var previousSalary = employeeSalaryRepository.GetPreviousSalary(e.ID, monthPeriod, yearPeriod); if (previousSalary != null) { mainSalary = previousSalary.MainSalary; } } //HITUNG THR if (yearOfWork >= 1) { amount = mainSalary; } else if (monthOfWork >= 3 && monthOfWork <= 12) { amount = ((Convert.ToDecimal(monthOfWork)) / 12) * mainSalary; } else if (monthOfWork < 3) { amount = 0; } totalAmount = Math.Round(amount) + otherAmount; if (totalAmount > 0) { string amountInWords = Store.GetAmounInWords(Convert.ToInt32(totalAmount)); string firstLetter = amountInWords.Substring(0, 2).Trim().ToUpper(); string theRest = amountInWords.Substring(2, amountInWords.Length - 2); amountInWord = firstLetter + theRest + " rupiah"; } else { amountInWord = "Nol rupiah"; } THR oldTHR = GetByEmployeeId(e.ID, Store.ActiveYear); THR thr = new THR(); thr.YearPeriod = yearPeriod; thr.EffectiveDate = effectiveDate; thr.EmployeeId = e.ID; thr.StartDate = startDate; thr.Branch = branch; thr.Department = department; thr.Grade = grade; thr.GradeLevel = gradeLevel; thr.Occupation = occupation; thr.Status = status; thr.PaymentType = paymentType; thr.IsTransfer = isTransfer; thr.BankName = bankName; thr.AccountNumber = accountNumber; thr.HolidayType = holidayType; thr.YearOfWork = yearOfWork; thr.MonthOfWork = Convert.ToInt32(monthOfWork); thr.DayOfWork = daysOfWork; thr.MainSalary = mainSalary; thr.Amount = amount; thr.OtherAmount = otherAmount; thr.TotalAmount = totalAmount; thr.AmountInWords = amountInWord; thr.IsPaid = false; if (oldTHR == null) { Save(thr); } else { thr.ID = oldTHR.ID; thr.Branch = branch; thr.Department = department; thr.Grade = grade; thr.GradeLevel = gradeLevel; thr.Occupation = occupation; thr.Status = status; thr.PaymentType = paymentType; thr.IsTransfer = isTransfer; thr.BankName = bankName; thr.AccountNumber = accountNumber; thr.MainSalary = mainSalary; thr.Amount = amount; thr.OtherAmount = oldTHR.OtherAmount; thr.TotalAmount = amount + thr.OtherAmount; if (thr.TotalAmount > 0) { string amountInWords = Store.GetAmounInWords(Convert.ToInt32(thr.TotalAmount)); string firstLetter = amountInWords.Substring(0, 2).Trim().ToUpper(); string theRest = amountInWords.Substring(2, amountInWords.Length - 2); thr.AmountInWords = firstLetter + theRest + " rupiah"; } else { thr.AmountInWords = "Nol rupiah"; } Update(thr); } } } } }
public bool isValid(THR obj) { bool isValid = !obj.Errors.Any(); return(isValid); }