public int AddTADocumentScheduleTransaction(Guid txID, TADocumentSchedule taDocumentSchedule) { Spring.Validation.ValidationErrors errors = new Spring.Validation.ValidationErrors(); TADocumentDataSet taDocumentDS = (TADocumentDataSet)TransactionService.GetDS(txID); TADocumentDataSet.TADocumentScheduleRow taDocumentScheduleRow = taDocumentDS.TADocumentSchedule.NewTADocumentScheduleRow(); taDocumentScheduleRow.TADocumentID = taDocumentSchedule.TADocumentID.TADocumentID; if (taDocumentSchedule.Date == null) { errors.AddError("Provider.Error", new Spring.Validation.ErrorMessage("Travelling date is required.")); } else { taDocumentScheduleRow.Date = taDocumentSchedule.Date.Value; } if (string.IsNullOrEmpty(taDocumentSchedule.DepartureFrom)) { errors.AddError("Provider.Error", new Spring.Validation.ErrorMessage("Departure From is required.")); } else { taDocumentScheduleRow.DepartureFrom = taDocumentSchedule.DepartureFrom; } if (string.IsNullOrEmpty(taDocumentSchedule.ArrivalAt)) { errors.AddError("Provider.Error", new Spring.Validation.ErrorMessage("Arrival At is required.")); } else { taDocumentScheduleRow.ArrivalAt = taDocumentSchedule.ArrivalAt; } if (!errors.IsEmpty) { throw new ServiceValidationException(errors); } taDocumentScheduleRow.DepartureFrom = taDocumentSchedule.DepartureFrom; taDocumentScheduleRow.ArrivalAt = taDocumentSchedule.ArrivalAt; taDocumentScheduleRow.TravelBy = taDocumentSchedule.TravelBy; taDocumentScheduleRow.Time = taDocumentSchedule.Time; taDocumentScheduleRow.FlightNo = taDocumentSchedule.FlightNo; taDocumentScheduleRow.TravellingDetail = taDocumentSchedule.TravellingDetail; taDocumentScheduleRow.Active = taDocumentSchedule.Active; taDocumentScheduleRow.CreBy = UserAccount.UserID; taDocumentScheduleRow.CreDate = DateTime.Now; taDocumentScheduleRow.UpdBy = UserAccount.UserID; taDocumentScheduleRow.UpdDate = DateTime.Now; taDocumentScheduleRow.UpdPgm = UserAccount.CurrentProgramCode; taDocumentDS.TADocumentSchedule.AddTADocumentScheduleRow(taDocumentScheduleRow); return(taDocumentScheduleRow.ScheduleID); }
public DataTable DeleteTADocumentScheduleTransaction(Guid txID, int scheduleID) { TADocumentDataSet taDocumentDS = (TADocumentDataSet)TransactionService.GetDS(txID); TADocumentDataSet.TADocumentScheduleRow taDocumentScheduleRow = taDocumentDS.TADocumentSchedule.FindByScheduleID(scheduleID); taDocumentScheduleRow.Delete(); return(taDocumentDS.TADocumentSchedule); }
public void PrepareDataToDataset(TADocumentDataSet taDocumentDS, long taDocumentID) { IList <TADocumentSchedule> taDocumentScheduleList = ScgeAccountingQueryProvider.TADocumentScheduleQuery.FindTADocumentScheduleByTADocumentID(taDocumentID); foreach (TADocumentSchedule taDocumentSchedule in taDocumentScheduleList) { TADocumentDataSet.TADocumentScheduleRow taDocumentScheduleRow = taDocumentDS.TADocumentSchedule.NewTADocumentScheduleRow(); taDocumentScheduleRow.ScheduleID = taDocumentSchedule.ScheduleID; if (taDocumentSchedule.TADocumentID != null) { taDocumentScheduleRow.TADocumentID = taDocumentSchedule.TADocumentID.TADocumentID; } if (taDocumentSchedule.Date != null) { taDocumentScheduleRow.Date = taDocumentSchedule.Date.Value; } if (taDocumentSchedule.DepartureFrom != null) { taDocumentScheduleRow.DepartureFrom = taDocumentSchedule.DepartureFrom; } if (taDocumentSchedule.ArrivalAt != null) { taDocumentScheduleRow.ArrivalAt = taDocumentSchedule.ArrivalAt; } if (taDocumentSchedule.TravelBy != null) { taDocumentScheduleRow.TravelBy = taDocumentSchedule.TravelBy; } if (taDocumentSchedule.Time != null) { taDocumentScheduleRow.Time = taDocumentSchedule.Time; } if (taDocumentSchedule.FlightNo != null) { taDocumentScheduleRow.FlightNo = taDocumentSchedule.FlightNo; } if (taDocumentSchedule.TravellingDetail != null) { taDocumentScheduleRow.TravellingDetail = taDocumentSchedule.TravellingDetail; } taDocumentScheduleRow.Active = taDocumentSchedule.Active; taDocumentScheduleRow.CreBy = taDocumentSchedule.CreBy; taDocumentScheduleRow.CreDate = taDocumentSchedule.CreDate; taDocumentScheduleRow.UpdBy = taDocumentSchedule.UpdBy; taDocumentScheduleRow.UpdDate = taDocumentSchedule.UpdDate; taDocumentScheduleRow.UpdPgm = taDocumentSchedule.UpdPgm; // Add document initiator to datatable taDocumentDS. taDocumentDS.TADocumentSchedule.AddTADocumentScheduleRow(taDocumentScheduleRow); } }
public void UpdateTADocumentScheduleTransaction(Guid txID, TADocumentSchedule taDocumentSchedule) { Spring.Validation.ValidationErrors errors = new Spring.Validation.ValidationErrors(); TADocumentDataSet taDocumentDS = (TADocumentDataSet)TransactionService.GetDS(txID); TADocumentDataSet.TADocumentScheduleRow taDocumentScheduleRow = taDocumentDS.TADocumentSchedule.FindByScheduleID(taDocumentSchedule.ScheduleID); TADocumentDataSet.TADocumentRow taDocumentRow = taDocumentDS.TADocument.FindByTADocumentID(taDocumentSchedule.TADocumentID.TADocumentID); taDocumentScheduleRow.BeginEdit(); if (taDocumentSchedule.TADocumentID != null) { taDocumentScheduleRow.TADocumentID = taDocumentSchedule.TADocumentID.TADocumentID; } if (taDocumentSchedule.Date == null) { errors.AddError("Provider.Error", new Spring.Validation.ErrorMessage("TravellingDateIsRequired")); } else { if (!taDocumentRow.IsNull("FromDate") && !taDocumentRow.IsNull("ToDate")) { if (taDocumentSchedule.Date >= taDocumentRow.FromDate && taDocumentSchedule.Date <= taDocumentRow.ToDate) { taDocumentScheduleRow.Date = taDocumentSchedule.Date.Value; } else { errors.AddError("Provider.Error", new Spring.Validation.ErrorMessage("TravellingDateIsNotBetweenTravellingFromToDate")); } } } if (string.IsNullOrEmpty(taDocumentSchedule.DepartureFrom)) { errors.AddError("Provider.Error", new Spring.Validation.ErrorMessage("DepartureFromIsRequired")); } else { taDocumentScheduleRow.DepartureFrom = taDocumentSchedule.DepartureFrom; } if (string.IsNullOrEmpty(taDocumentSchedule.ArrivalAt)) { errors.AddError("Provider.Error", new Spring.Validation.ErrorMessage("ArrivalAtIsRequired")); } else { taDocumentScheduleRow.ArrivalAt = taDocumentSchedule.ArrivalAt; } if (!errors.IsEmpty) { throw new ServiceValidationException(errors); } taDocumentScheduleRow.TravelBy = taDocumentSchedule.TravelBy; taDocumentScheduleRow.Time = taDocumentSchedule.Time; taDocumentScheduleRow.FlightNo = taDocumentSchedule.FlightNo; taDocumentScheduleRow.TravellingDetail = taDocumentSchedule.TravellingDetail; taDocumentScheduleRow.Active = taDocumentSchedule.Active; taDocumentScheduleRow.CreBy = UserAccount.UserID; taDocumentScheduleRow.CreDate = DateTime.Now; taDocumentScheduleRow.UpdBy = UserAccount.UserID; taDocumentScheduleRow.UpdDate = DateTime.Now; taDocumentScheduleRow.UpdPgm = UserAccount.CurrentProgramCode; taDocumentScheduleRow.EndEdit(); }