Пример #1
0
        public void Edit(Vaccine vaccine)
        {
            var currentVaccine = this.GetById(vaccine.Id);

            currentVaccine.Name = vaccine.Name;
            currentVaccine.RecommendedDay = vaccine.RecommendedDay;

            Uow.Vaccines.Edit(currentVaccine);
            Uow.Commit();
        }
Пример #2
0
 public void Create(Vaccine vaccine)
 {
     Uow.Vaccines.Add(vaccine);
     Uow.Commit();
 }
        private void FrmCreateEditBatchVaccine_Load(object sender, EventArgs e)
        {
            var formTitle = "";
            txtRecommendedDate.Visible = false;
            lblRecommendedDate.Visible = false;

            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);
                txtRecommendedDate.Text = "";
                formTitle = string.Format("Lote {0} - Crear Vacunación", _batch.Number.ToString());
            }

            using (var vaccineService = _serviceFactory.Create<IVaccineService>())
            {
                var vaccines = vaccineService.GetAllActive().OrderBy(x => x.Name).ToList();
                ddlVaccines.ValueMember = "Id";
                ddlVaccines.DisplayMember = "Name";
                Vaccine item = new Vaccine();
                item.Name = "Seleccione una vacuna..";
                item.Id = Guid.Empty;
                vaccines.Insert(0,item);
                ddlVaccines.DataSource = vaccines;
                //ddlVaccines.Items.Add(item);
            }

            if (_batchVaccineId != Guid.Empty)
            {
                //Editar
                using (var batchVaccineService = _serviceFactory.Create<IBatchVaccineService>())
                {
                    _batchVaccine = batchVaccineService.GetById(_batchVaccineId);
                    if (_batchVaccine.Vaccine.RecommendedDay.HasValue)
                    {
                        txtRecommendedDate.Text = _batch.DateOfBirth.AddDays(_batchVaccine.Vaccine.RecommendedDay.Value).ToString();
                        txtRecommendedDate.ReadOnly = true;
                    }
                    else
                    {
                        txtRecommendedDate.Visible = false;
                        lblRecommendedDate.Visible = false;
                    }

                    dtpStartDate.Value = _batchVaccine.StartDate;
                    if (_batchVaccine.EndDate != null) dtpEndDate.Value = _batchVaccine.EndDate.Value;
                    ddlVaccines.SelectedValue = _batchVaccine.VaccineId;
                    formTitle = string.Format("Lote {0} - Editar Vacunación", _batch.Number.ToString());
                }
            }

            this.Text = formTitle;
        }