コード例 #1
0
        public void Edit(Medicine medicine)
        {
            var currentMedicine = this.GetById(medicine.Id);

            currentMedicine.Name = medicine.Name;

            Uow.Medicines.Edit(currentMedicine);
            Uow.Commit();
        }
コード例 #2
0
 public void Create(Medicine medicine)
 {
     Uow.Medicines.Add(medicine);
     Uow.Commit();
 }
コード例 #3
0
        private void FrmCreateEditBatchMedicine_Load(object sender, EventArgs e)
        {
            var formTitle = "";

            using (var batchService = _serviceFactory.Create<IBatchService>())
            {
                _batch = batchService.GetById(_stateController.CurrentSelectedBatch.Id);

                dtpStartDate.Value = _batch.DateOfBirth;
                dtpEndDate.Value = _batch.DateOfBirth.AddDays(_batch.GeneticLine.ProductionWeeks * 7);
                txtObservation.Text = "";
                formTitle = string.Format("Lote {0} - Crear Medicamento", _batch.Number.ToString());
            }

            using (var medicineService = _serviceFactory.Create<IMedicineService>())
            {
                var vaccines = medicineService.GetAllActive().OrderBy(x => x.Name).ToList();
                ddlMedicines.ValueMember = "Id";
                ddlMedicines.DisplayMember = "Name";
                Medicine item = new Medicine();
                item.Name = "Selecciona un medicamento..";
                item.Id = Guid.Empty;
                vaccines.Insert(0,item);
                ddlMedicines.DataSource = vaccines;
            }

            if (_batchMedicineId != Guid.Empty)
            {
                //Editar
                using (var batchMedicineService = _serviceFactory.Create<IBatchMedicineService>())
                {
                    _batchMedicine = batchMedicineService.GetById(_batchMedicineId);
                    txtObservation.Text = _batchMedicine.Observation;
                    dtpStartDate.Value = _batchMedicine.StartDate;
                    if (_batchMedicine.EndDate != null) dtpEndDate.Value = _batchMedicine.EndDate.Value;
                    ddlMedicines.SelectedValue = _batchMedicine.MedicineId;
                    formTitle = string.Format("Lote {0} - Editar Medicamento", _batch.Number.ToString());
                }
            }

            this.Text = formTitle;
        }