コード例 #1
0
        public void datePacient(string lastname, string firstname, ref string cnp)
        {
            PacientDetail pacient = new PacientDetail();

            using (MedicDBEntities3 md = new MedicDBEntities3())
            {
                pacient = md.PacientDetails.Where(x => x.firstname == firstname && x.lastname == lastname).FirstOrDefault();
                cnp     = pacient.pacient_cnp;
            }
        }
コード例 #2
0
        public void listPacienti(string pCnp, ref string pFName, ref string pLName)
        {
            PacientDetail pacient = new PacientDetail();

            using (MedicDBEntities3 md = new MedicDBEntities3())
            {
                pacient = md.PacientDetails.Where(x => x.pacient_cnp == pCnp).FirstOrDefault();

                pFName = pacient.firstname;
                pLName = pacient.lastname;
            }
        }
コード例 #3
0
        public int registerPacient(string pUser, string pPass, string pCNP, string pEmail, string pLName, string pFName, string pBirth, string pAddress)
        {
            Pacienti p  = new Pacienti();
            Pacienti p1 = new Pacienti();  //variabila temporara de cautare

            PacientDetail detail = new PacientDetail();

            detail.address     = pAddress;
            detail.dateofbirth = pBirth;
            detail.firstname   = pFName;
            detail.lastname    = pLName;
            detail.pacient_cnp = pCNP;


            using (MedicDBEntities3 md = new MedicDBEntities3())
            {
                p1 = md.Pacientis.Where(x => x.pacient_cnp == pCNP).FirstOrDefault();

                if (p1 != null)  //cnp exista deja
                {
                    return(0);
                }
                else
                {
                    p.username    = pUser;
                    p.password    = pPass;
                    p.email       = pEmail;
                    p.pacient_cnp = pCNP;
                    try
                    {
                        md.Pacientis.Add(p);
                        md.SaveChanges();
                    }
                    catch
                    {
                        return(-1);
                    }
                    try
                    {
                        md.PacientDetails.Add(detail);
                        md.SaveChanges();
                    }
                    catch
                    {
                        return(-2);
                    }
                }
                return(1);
            }
        }
コード例 #4
0
        public int programari(string pCNP, string pLName, string pFName, string descriere, string date, string mFName, string mLName)
        {
            Programare    programare = new Programare();
            PacientDetail p_detail   = new PacientDetail();
            MedicDetail   m_detail   = new MedicDetail();
            Programare    p1         = new Programare();


            using (MedicDBEntities3 md = new MedicDBEntities3())
            {
                try
                {
                    p_detail = md.PacientDetails.Where(x => x.pacient_cnp == pCNP).FirstOrDefault();
                    m_detail = md.MedicDetails.Where(x => x.lastname == mLName && x.firstname == mFName).FirstOrDefault();

                    programare = md.Programares.Where(x => x.data == date && x.m_lastname == m_detail.lastname && x.m_firstname == m_detail.firstname).FirstOrDefault();

                    if (programare != null)
                    {
                        return(0); //exista o programare
                    }
                    else
                    {
                        p1.pacient_cnp = pCNP;
                        p1.p_lastname  = pLName;
                        p1.p_firstname = pFName;
                        p1.descriere   = descriere;
                        p1.data        = date;
                        p1.m_firstname = mFName;
                        p1.m_lastname  = mLName;

                        md.Programares.Add(p1);
                        md.SaveChanges();
                    }
                }
                catch
                {
                    return(-1);
                }
                return(1);
            }
        }
コード例 #5
0
        public int deletePacient(string pUser, string pCNP)
        {
            Pacienti      pacient = new Pacienti();
            PacientDetail detail  = new PacientDetail();

            using (MedicDBEntities3 md = new MedicDBEntities3())
            {
                try
                {
                    pacient = md.Pacientis.Where(x => x.username == pUser).FirstOrDefault();

                    if (pacient.pacient_cnp != pCNP)
                    {
                        return(-1);
                    }
                    detail = md.PacientDetails.Where(x => x.pacient_cnp == pacient.pacient_cnp).FirstOrDefault();
                    var entry = md.Entry(detail);
                    if (entry.State == System.Data.Entity.EntityState.Detached)
                    {
                        md.PacientDetails.Attach(detail);
                    }
                    md.PacientDetails.Remove(detail);
                    md.SaveChanges();

                    var entry1 = md.Entry(pacient);
                    if (entry1.State == System.Data.Entity.EntityState.Detached)
                    {
                        md.Pacientis.Attach(pacient);
                    }
                    md.Pacientis.Remove(pacient);
                    md.SaveChanges();
                }
                catch
                {
                    return(-2);
                }
                return(1);
            }
        }
コード例 #6
0
        public int updatePacientData(string pUser, string pPass, string pCNP, string pEmail, string pLName, string pFName, string pBirth, string pAddress)
        {
            Pacienti      pacient = new Pacienti();
            PacientDetail detail  = new PacientDetail();

            using (MedicDBEntities3 md = new MedicDBEntities3())
            {
                try
                {
                    pacient = md.Pacientis.Where(x => x.pacient_cnp == pCNP).FirstOrDefault();

                    pacient.username = pUser;
                    pacient.password = pPass;
                    pacient.email    = pEmail;

                    //nu vom schimba cnp-ul pentru ca este o informatia esentiala pt cautare

                    md.Entry(pacient).State = System.Data.Entity.EntityState.Modified;
                    md.SaveChanges();

                    detail             = md.PacientDetails.Where(x => x.pacient_cnp == pacient.pacient_cnp).FirstOrDefault();
                    detail.lastname    = pLName;
                    detail.firstname   = pFName;
                    detail.address     = pAddress;
                    detail.dateofbirth = pBirth;

                    md.Entry(detail).State = System.Data.Entity.EntityState.Modified;
                    md.SaveChanges();
                }
                catch
                {
                    return(-1);
                }
                return(1);
            }
        }
コード例 #7
0
        public void getPacientDetails(ref string pUser, ref string pPass, string pCNP, ref string pEmail, ref string pLName, ref string pFName, ref string pBirth, ref string pAddress)
        {
            PacientDetail detail  = new PacientDetail();
            Pacienti      pacient = new Pacienti();

            using (MedicDBEntities3 md = new MedicDBEntities3())
            {
                //cautare date de login in tabelul pacienti
                pacient = md.Pacientis.Where(x => x.pacient_cnp == pCNP).FirstOrDefault();

                pUser  = pacient.username;
                pPass  = pacient.password;
                pCNP   = pacient.pacient_cnp;
                pEmail = pacient.email;

                //cautare date personale in tabelul pacientDetail

                detail   = md.PacientDetails.Where(x => x.pacient_cnp == pacient.pacient_cnp).FirstOrDefault();
                pAddress = detail.address;
                pLName   = detail.lastname;
                pFName   = detail.firstname;
                pBirth   = detail.dateofbirth;
            }
        }