void Details(ConfinementRecords item) { if (item == null) { return; } try { using (UnitOfWork unitOfWork = new UnitOfWork()) { this.oldValue = item; this.cboOwner.EditValue = item.OwnerId; this.txtObservation.EditValue = item.Observations; this.cboAttendingVet.EditValue = item.VetId; entityServerModeSource2.QueryableSource = new Models.ModelDb().Patients.Where(x => x.OwnerId == item.OwnerId); this.cboPetName.EditValue = item.PatientId; this.txtColor.Text = item.Patients?.Color; this.txtSpecies.Text = item.Patients?.Species; // var owner = cboOwner.GetSelectedDataRow() as Owners; txtAddress.Text = item.Patients?.Owners?.Address; txtTelNo.Text = item.Patients?.Owners?.TelNo; txtMedication.Text = item.Medication; comboBoxEdit1.EditValue = item.Status; } } catch (Exception e) { MessageBox.Show(e.Message, e.Message, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public frmAddEditConfinedRecord(ConfinementRecords oldValue, MethodType methodType) { InitializeComponent(); // This line of code is generated by Data Source Configuration Wizard OwnerBinding.QueryableSource = new Models.ModelDb().Owners; VetBinding.QueryableSource = new UnitOfWork().VeterinariesRepo.Fetch(); Details(oldValue); this.methodType = methodType; this.oldValue = oldValue; }
void Add(ConfinementRecords item) { try { using (UnitOfWork unitOfWork = new UnitOfWork()) { item.DateCreated = DateTime.Now; item.CreatedBy = User.UserId; unitOfWork.ConfinementRecordsRepo.Insert(item); unitOfWork.Save(); } } catch (Exception e) { MessageBox.Show(e.Message, e.Message, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
void Edit(ConfinementRecords item) { try { using (UnitOfWork unitOfWork = new UnitOfWork()) { item.Id = oldValue.Id; item.DateCreated = oldValue.DateCreated; item.CreatedBy = oldValue.CreatedBy; unitOfWork.ConfinementRecordsRepo.Update(item); unitOfWork.Save(); } } catch (Exception e) { MessageBox.Show(e.Message, e.Message, MessageBoxButtons.OK, MessageBoxIcon.Error); } }