Exemplo n.º 1
0
        public bool ValidateSange(PungaSangeTraseu pungaSange)
        {
            bool ok = true;

            using (UnitOfWork unitOfWork = new UnitOfWork())
            {
                Analiza analiza = unitOfWork.AnalizaRepo.GetBy(a => a.PungaSange.Equals(pungaSange.Id));
                if (analiza.HepatitaB || analiza.HepatitaC || analiza.HIV || analiza.NivelALT > 80 || analiza.NivelALT < 4 || analiza.Sifilis || analiza.HTLV)
                {
                    ok = false;
                }
            }
            return(ok);
        }
Exemplo n.º 2
0
        public void UpdateStoc(PungaSangeTraseu pungaSange)
        {
            using (UnitOfWork unitOfWork = new UnitOfWork())
            {
                string  err     = "";
                Analiza analiza = unitOfWork.AnalizaRepo.GetBy(a => a.PungaSange.Equals(pungaSange.Id));
                Stoc    stoc    = unitOfWork.StocRepo.GetBy(s => s.RH.Equals(analiza.Rh) && s.Grupa.Equals(analiza.Grupa));
                if (pungaSange.DataPrelevarii.AddMonths(12) > DateTime.Now)
                {
                    stoc.Plasma = pungaSange.CantitatePlasma;
                }
                else
                {
                    err += "Plasma este expirata!\n ";
                }
                if (pungaSange.DataPrelevarii.AddDays(5) > DateTime.Now)
                {
                    stoc.Trombocite = pungaSange.CantitateTrombocite;
                }
                else
                {
                    err += "Trombocitele sunt expirate!\n";
                }
                if (pungaSange.DataPrelevarii.AddDays(42) > DateTime.Now)
                {
                    stoc.GlobuleRosii = pungaSange.CantitateGlobuleRosii;
                }
                else
                {
                    err += "Globulelele rosii sunt expirate!\n";
                }

                stoc.TotalSange         = pungaSange.CantitateSange;
                stoc.TermenPlasma       = 12;
                stoc.TermenGlobuleRosii = 42;
                stoc.TermenTrombocite   = 5;
                unitOfWork.StocRepo.Update(stoc);
                unitOfWork.Save();
                if (!err.Equals(""))
                {
                    throw new ValidationException(err);
                }
            }
        }
Exemplo n.º 3
0
        private void dataGridView2_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            DataGridViewCell cell = dataGridView2.SelectedCells[0];

            if (cell.ColumnIndex > 7)
            {
                bool ok = true;
                for (int i = 7; i < cell.ColumnIndex; i++)
                {
                    if (!(bool)dataGridView2.Rows[cell.RowIndex].Cells[i].Value)
                    {
                        ok = false;
                    }
                }
                if (ok)
                {
                    if (cell.ColumnIndex == 10 && !(bool)dataGridView2.Rows[cell.RowIndex].Cells[10].Value)
                    {
                        PungaSangeTraseu pungaSange = (PungaSangeTraseu)dataGridView2.Rows[cell.RowIndex].DataBoundItem;
                        {
                            try
                            {
                                if (serviceCentru.ValidateSange(pungaSange))
                                {
                                    serviceCentru.UpdateStoc(pungaSange);
                                    loadStocSange();
                                    dataGridView2.Rows[cell.RowIndex].Cells[cell.ColumnIndex].Value = true;
                                    updateTraseu();
                                    dataGridView2.Rows[cell.RowIndex].Cells[cell.ColumnIndex].ReadOnly = true;
                                    MessageBox.Show("Stocul de sange a fost updatat!");
                                }
                                else
                                {
                                    dataGridView2.Rows[cell.RowIndex].Cells[cell.ColumnIndex].Value = false;
                                    MessageBox.Show("Analizele pungii de sange nu permit adaugarea acesteia in stocul centrului");
                                }
                            }
                            catch (ValidationException err)
                            {
                                loadStocSange();
                                dataGridView2.Rows[cell.RowIndex].Cells[cell.ColumnIndex].Value = true;
                                updateTraseu();
                                dataGridView2.Rows[cell.RowIndex].Cells[cell.ColumnIndex].ReadOnly = true;
                                MessageBox.Show(err.GetMessage() + "Vor fi pastrate doar componentele valabile!");
                            }
                            catch (Exception)
                            {
                                dataGridView2.Rows[cell.RowIndex].Cells[cell.ColumnIndex].Value = false;
                                MessageBox.Show("Nu exista analize pentru punga de sange selectata! Mai intai trebuie sa completati analizele!");
                            }
                        }
                    }
                    else if (cell.ColumnIndex != 10)
                    {
                        dataGridView2.Rows[cell.RowIndex].Cells[cell.ColumnIndex].Value = true;
                        updateTraseu();
                        dataGridView2.Rows[cell.RowIndex].Cells[cell.ColumnIndex].ReadOnly = true;
                    }
                    else
                    {
                        dataGridView2.Rows[cell.RowIndex].Cells[cell.ColumnIndex].Value    = true;
                        dataGridView2.Rows[cell.RowIndex].Cells[cell.ColumnIndex].ReadOnly = true;
                    }
                }
                else
                {
                    dataGridView2.Rows[cell.RowIndex].Cells[cell.ColumnIndex].Value = false;
                    MessageBox.Show("Nu puteti selecta decat operatiuni consecutive!");
                }
            }

            // if (!dataGridView2.CurrentRow.Selected) throw new Exception("Trebuie selectat tot randul");
            Console.WriteLine("da");
            //if ((bool)row.Cells[7].Value) throw new Exception("Cererea a fost tratata deja!");
            // comboBoxGrupa.SelectedItem = row.Cells[8].Value.ToString();
        }