void Init() { try { if (methodType == MethodType.Edit) { Details(itenaryofTravels); return; } UnitOfWork unitOfWork = new UnitOfWork(); this.itenaryofTravels = new ItenaryofTravels() { DateCreated = DateTime.Now, OBRId = itenaryofTravels.OBRId, CreatedBy = User.UserId, }; unitOfWork.ItenaryofTravelsRepo.Insert(this.itenaryofTravels); unitOfWork.Save(); Details(itenaryofTravels); return; } catch (Exception ex) { MessageBox.Show(ex.Message, ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public frmAddEditIOT(MethodType methodType, ItenaryofTravels itenaryofTravels) { InitializeComponent(); this.methodType = methodType; this.itenaryofTravels = itenaryofTravels; this.Init(); }
void Details(ItenaryofTravels item) { try { UnitOfWork unitOfWork = new UnitOfWork(); this.employeesBindingSource.DataSource = unitOfWork.EmployeesRepo.Get(); item = unitOfWork.ItenaryofTravelsRepo.Find(x => x.Id == item.Id); this.cboEmployeeName.EditValue = item.EmployeeId; this.dtDate.EditValue = item.DateCreated; this.txtPosition.EditValue = item.Position; this.txtStation.EditValue = item.OfficialAddress; this.txtPurpose.EditValue = item.Purpose; this.cboApprovedBy.EditValue = item.ApprovedBy; itenaryDetailsBindingSource.DataSource = new BindingList <ItenaryDetails>(unitOfWork.ItenaryDetailsRepo.Get(x => x.IOTId == item.Id)); } catch (Exception ex) { MessageBox.Show(ex.Message, ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Error); } }