public void DeleteExpensePerdiemDetailTransaction(long perdiemDetailId, Guid txId) { ExpenseDataSet expDs = (ExpenseDataSet)TransactionService.GetDS(txId); ExpenseDataSet.FnExpensePerdiemDetailRow row = expDs.FnExpensePerdiemDetail.FindByExpensePerdiemDetailID(perdiemDetailId); long expensePerdiemId = row.ExpensePerdiemID; row.Delete(); FnExpensePerdiemService.UpdateExpensePerdiemCalculateTransaction(expensePerdiemId, txId); }
public void DeleteExpensePerdiemItemTransaction(long itemId, Guid txId) { ExpenseDataSet expDs = (ExpenseDataSet)TransactionService.GetDS(txId); ExpenseDataSet.FnExpensePerdiemItemRow row = expDs.FnExpensePerdiemItem.FindByPerdiemItemID(itemId); long expensePerdiemID = row.ExpensePerdiemID; row.Delete(); FnExpensePerdiemService.UpdateExpensePerdiemCalculateTransaction(expensePerdiemID, txId); }
public void AddExpensePerdiemDetailTransaction(FnExpensePerdiemDetail perdiemDetail, Guid txId) { Spring.Validation.ValidationErrors errors = new Spring.Validation.ValidationErrors(); if (perdiemDetail.Description.Length.Equals(0)) { errors.AddError("PerdiemDetail.Error", new Spring.Validation.ErrorMessage("RequiredDescription")); } if (perdiemDetail.ExchangeRate.Equals((double)0)) { errors.AddError("PerdiemDetail.Error", new Spring.Validation.ErrorMessage("RequiredExchangeRate")); } if (perdiemDetail.Amount.Equals((double)0)) { errors.AddError("PerdiemDetail.Error", new Spring.Validation.ErrorMessage("RequiredAmount")); } if (!errors.IsEmpty) { throw new ServiceValidationException(errors); } ExpenseDataSet ds = (ExpenseDataSet)TransactionService.GetDS(txId); ExpenseDataSet.FnExpensePerdiemDetailRow row = ds.FnExpensePerdiemDetail.NewFnExpensePerdiemDetailRow(); row.BeginEdit(); row.ExpensePerdiemID = perdiemDetail.ExpensePerdiem.ExpensePerdiemID; row.Description = perdiemDetail.Description; row.CurrencyID = perdiemDetail.CurrencyID; row.ExchangeRate = perdiemDetail.ExchangeRate; row.Amount = perdiemDetail.Amount; row.EndEdit(); ds.FnExpensePerdiemDetail.AddFnExpensePerdiemDetailRow(row); FnExpensePerdiemService.UpdateExpensePerdiemCalculateTransaction(perdiemDetail.ExpensePerdiem.ExpensePerdiemID, txId); }
public void AddExpensePerdiemItemTransaction(FnExpensePerdiemItem item, Guid txId) { Spring.Validation.ValidationErrors errors = new Spring.Validation.ValidationErrors(); string PerdiemType = GetPerdiemType(item, txId); if (!item.FromDate.HasValue) { errors.AddError("PerdiemItem.Error", new Spring.Validation.ErrorMessage("RequiredFromDate")); } if (!item.FromTime.HasValue) { errors.AddError("PerdiemItem.Error", new Spring.Validation.ErrorMessage("RequiredFromTime")); } if (!item.ToDate.HasValue) { errors.AddError("PerdiemItem.Error", new Spring.Validation.ErrorMessage("RequiredToDate")); } if (!item.ToTime.HasValue) { errors.AddError("PerdiemItem.Error", new Spring.Validation.ErrorMessage("RequiredToTime")); } if (item.FromDate.HasValue && item.FromTime.HasValue && item.ToDate.HasValue && item.ToTime.HasValue) { DateTime FromDateTime = ConvertDateTime(item.FromDate, item.FromTime); DateTime ToDateTime = ConvertDateTime(item.ToDate, item.ToTime); if (DateTime.Compare(ToDateTime, DateTime.Now.Date) > 0) { errors.AddError("PerdiemItem.Error", new Spring.Validation.ErrorMessage("PleaseSelectDateIsNotToday")); } if (ToDateTime < FromDateTime) { errors.AddError("PerdiemItem.Error", new Spring.Validation.ErrorMessage("RequiredToDateIncorrect")); } else { if (CalculateNetDay(CalculateTotalDay(FromDateTime, ToDateTime, PerdiemType), item.AdjustedDay) < 0) { errors.AddError("PerdiemItem.Error", new Spring.Validation.ErrorMessage("Invalid Date Information")); } if (PerdiemType == ZoneType.Foreign) { if (item.HalfDay < 0) { errors.AddError("PerdiemItem.Error", new Spring.Validation.ErrorMessage("Invalid Date Information")); } else { if (CalculateFullDay(CalculateNetDay(CalculateTotalDay(FromDateTime, ToDateTime, PerdiemType), item.AdjustedDay), item.HalfDay) < 0) { errors.AddError("PerdiemItem.Error", new Spring.Validation.ErrorMessage("Invalid Date Information")); } } } } } if (PerdiemType == ZoneType.Foreign) { if (!item.CountryID.HasValue && string.IsNullOrEmpty(item.Remark)) { errors.AddError("PerdiemItem.Error", new Spring.Validation.ErrorMessage("Remark is required")); } } if (!errors.IsEmpty) { throw new ServiceValidationException(errors); } ExpenseDataSet ds = (ExpenseDataSet)TransactionService.GetDS(txId); ExpenseDataSet.FnExpensePerdiemItemRow row = ds.FnExpensePerdiemItem.NewFnExpensePerdiemItemRow(); row.ExpensePerdiemID = item.ExpensePerdiem.ExpensePerdiemID; row.FromDate = item.FromDate.Value; row.FromTime = ConvertDateTime(item.FromDate.Value, item.FromTime.Value); row.ToDate = item.ToDate.Value; row.ToTime = ConvertDateTime(item.ToDate, item.ToTime); row.AdjustedDay = (decimal)item.AdjustedDay; row.NetDay = (decimal)CalculateNetDay(CalculateTotalDay(row.FromTime, row.ToTime, PerdiemType), item.AdjustedDay); //** for Domestic and Foreign row.Remark = item.Remark; if (PerdiemType == ZoneType.Foreign) { row.HalfDay = (decimal)item.HalfDay; row.FullDay = (decimal)CalculateFullDay((double)row.NetDay, (double)row.HalfDay); if (item.CountryID.HasValue) { row.CountryID = item.CountryID.Value; } if (item.CountryZoneID.HasValue) { row.CountryZoneID = item.CountryZoneID.Value; } } row.CreBy = row.UpdBy = UserAccount.UserID; row.CreDate = row.UpdDate = DateTime.Now.Date; row.UpdPgm = item.UpdPgm; row.Active = true; ds.FnExpensePerdiemItem.AddFnExpensePerdiemItemRow(row); FnExpensePerdiemService.UpdateExpensePerdiemCalculateTransaction(item.ExpensePerdiem.ExpensePerdiemID, txId); }