Esempio n. 1
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (dataGridView1.Columns[e.ColumnIndex].HeaderText == "Delete")
            {
                if (MessageBox.Show("Do you want to delete this " + type + " ?", "Confirm", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    int dni      = Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells[2].Value);
                    int personId = servPerson.GetPersonByDni(dni).ID;
                    if (type == "Nurse")
                    {
                        nurse objNurse = new nurse();
                        objNurse = nurseService.GetNurseByPersonId(personId);
                        nurseService.DeleteNurse(objNurse.id);
                    }
                    else if (type == "Doctor")
                    {
                        doctor objDoctor = new doctor();
                        objDoctor = doctorService.GetDoctorByPersonId(personId);
                        doctorService.DeleteDoctor(objDoctor.id);
                    }
                    else if (type == "Patient")
                    {
                        patient objPatient = new patient();
                        objPatient = patientService.GetPatientByPersonId(personId);
                        patientService.DeletePatient(objPatient.id);
                    }

                    dataGridView1.DataBindings.Clear();
                    loadPersons();
                }
            }
        }
Esempio n. 2
0
        public void remove(nurse n)
        {
            user user = hms.users.Where(x => x.uid == n.employee.user.uid).FirstOrDefault();

            hms.users.Remove(user);
            hms.SaveChanges();
        }
Esempio n. 3
0
 public void CreateNurse(nurse objNurse)
 {
     using (var dataContext = new FinalAppWebEntities())
     {
         //LINQ
         //return dataContext.Customers.ToList();
         dataContext.nurses.Add(objNurse);
         dataContext.SaveChanges();
     }
 }
Esempio n. 4
0
        public void updateNurse(nurse nur)
        {
            nurse    currentNurse = hms.nurses.Where(x => x.nid == nur.nid).FirstOrDefault();
            employee currentEmp   = hms.employees.Where(x => x.eid == nur.eid).FirstOrDefault();
            user     currentUser  = hms.users.Where(x => x.uid == nur.employee.uid).FirstOrDefault();

            hms.Entry(currentNurse).CurrentValues.SetValues(nur);
            hms.Entry(currentEmp).CurrentValues.SetValues(nur.employee);
            hms.Entry(currentUser).CurrentValues.SetValues(nur.employee.user);

            hms.SaveChanges();
        }
Esempio n. 5
0
 public nurse GetNurseByUserId(int userid)
 {
     using (var dataContext = new FinalAppWebEntities())
     {
         //LINQ
         //return dataContext.Customers.ToList();
         var custs = from c in dataContext.nurses
                     where c.userid == userid
                     select c;
         nurse objNurse = custs.FirstOrDefault();
         return(objNurse);
     }
 }
Esempio n. 6
0
 public void DeleteNurse(int id)
 {
     using (var dataContext =
                new FinalAppWebEntities())
     {
         var cust = from c in dataContext.nurses
                    where c.id == id
                    select c;
         nurse objNurse = cust.FirstOrDefault();
         dataContext.nurses.Remove(objNurse);
         dataContext.SaveChanges();
     }
 }
Esempio n. 7
0
        public List <indoor> getMyPatients(nurse n)
        {
            List <indoor> patients = hms.indoors.ToList();
            List <indoor> indoors  = new List <indoor>();

            foreach (indoor indo in patients)
            {
                if (indo.room != null && indo.room.nid == n.nid)
                {
                    indoors.Add(indo);
                }
            }

            return(indoors);
        }
Esempio n. 8
0
    public static nurse Login_nurse(string username, string password)
    {
        string query = String.Format("select count(*)  from employee_ru inner join user_control on user_control.emp_ru_id = employee_ru.emp_ru_id inner join position on position.pos_id = employee_ru.pos_id where user_control.uct_user ='******'", username);

        command.CommandText = query;
        try
        {
            conn.Open();
            int countuser = (int)command.ExecuteScalar();
            if (countuser == 1)
            {
                query = String.Format("select user_control.uct_password from employee_ru inner join user_control on user_control.emp_ru_id = employee_ru.emp_ru_id inner join position on position.pos_id = employee_ru.pos_id where user_control.uct_user ='******'", username);
                command.CommandText = query;
                string dbpassword = command.ExecuteScalar().ToString();
                if (dbpassword == password)
                {
                    query = String.Format("select employee_ru.emp_ru_name , position.pos_name  from employee_ru inner join user_control on user_control.emp_ru_id = employee_ru.emp_ru_id inner join position on position.pos_id = employee_ru.pos_id where user_control.uct_user = '******' ", username);
                    command.CommandText = query;
                    SqlDataReader reader = command.ExecuteReader();
                    while (reader.Read())
                    {
                        string emp_name = reader.GetString(0);

                        string position_name = reader.GetString(1);


                        nurse ru = new nurse(emp_name, username, password, position_name);
                        return(ru);
                    }
                    return(null);
                }
                return(null);
            }
            else
            {
                return(null);
            }
        }
        finally
        {
            conn.Close();
        }

        return(null);
    }
Esempio n. 9
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            String type = txtType.SelectedItem.ToString();

            if (isANewPerson)
            {
                objPerson             = new person();
                objPerson.name        = txtName.Text.ToString();
                objPerson.lastName    = txtLastName.Text.ToString();
                objPerson.age         = Decimal.ToInt32(numericAge.Value);
                objPerson.email       = txtEmail.Text.ToString();
                objPerson.address     = txtAddress.Text.ToString();
                objPerson.phone       = Decimal.ToInt32(numericPhoneNumber.Value);
                objPerson.nationality = txtNationality.Text.ToString();
                objPerson.DNI         = Decimal.Parse(txtDNI2.Text.ToString());
                objPerson.gender      = cmbGender.SelectedItem.ToString();
                objPerson.dateOfBith  = dateOfBirth.Value.Date;
                personServ.CreatePerson(objPerson);
            }
            String name        = objPerson.name;
            char   firstletter = name[0];
            int    dniValue    = Decimal.ToInt32(objPerson.DNI);

            username = firstletter + dniValue.ToString();
            //Verifico si tiene usuario y si no es estoy creando paciente
            if (userService.GetUserByUsername(username) == null && type != "Patient")
            {
                objUser          = new user();
                objUser.username = username;
                objUser.email    = txtEmail.Text.ToString();
                objUser.password = "******";
                userService.CreateUser(objUser);
            }
            //VERIFICAR TIPO DE USUARIO
            if (type.Equals("Admin"))
            {
                admin objAdmin = new admin();
                //Buscamos el usuario
                objUser = userService.GetUserByUsername(username);
                //Buscamos la persona
                objPerson = personServ.GetPersonByDni(dniValue);
                //Lo asignamos al admin
                objAdmin          = new admin();
                objAdmin.userId   = objUser.id;
                objAdmin.personId = objPerson.ID;
                //lo creamos
                if (adminService.GetAdminByUserId(objAdmin.userId) != null)
                {
                    MessageBox.Show("This user is already an Admin");
                }
                else
                {
                    adminService.CreateAdmin(objAdmin);
                    MessageBox.Show("New Admin Saved");
                    enableTextbox(false);
                    initialize();
                }
            }

            else if (type.Equals("Doctor"))
            {
                doctor objDoctor = new doctor();
                //Buscamos el usuario
                objUser = userService.GetUserByUsername(username);
                //Buscamos la persona
                objPerson = personServ.GetPersonByDni(dniValue);
                //Lo asignamos al admin
                objDoctor                  = new doctor();
                objDoctor.userId           = objUser.id;
                objDoctor.personId         = objPerson.ID;
                objDoctor.dateOfEnrollment = DateTime.Today;
                objDoctor.status           = true;
                //lo creamos
                if (docService.GetDoctorByUserId(objDoctor.userId) != null)
                {
                    MessageBox.Show("This user is already a Doctor");
                }
                else
                {
                    docService.CreateDoctor(objDoctor);
                    MessageBox.Show("New Doctor Saved");
                    enableTextbox(false);
                    initialize();
                }
            }

            else if (type.Equals("Nurse"))
            {
                nurse objNurse = new nurse();
                //Buscamos el usuario
                objUser = userService.GetUserByUsername(username);
                //Buscamos la persona
                objPerson = personServ.GetPersonByDni(dniValue);
                //Lo asignamos al admin
                objNurse          = new nurse();
                objNurse.userid   = objUser.id;
                objNurse.personId = objPerson.ID;
                //lo creamos
                if (nurService.GetNurseByUserId(objNurse.userid) != null)
                {
                    MessageBox.Show("This user is already a Nurse");
                }
                else
                {
                    nurService.CreateNurse(objNurse);
                    MessageBox.Show("New Nurse Saved");
                    enableTextbox(false);
                    initialize();
                }
            }
            else if (type.Equals("Patient"))
            {
                patient objPatient = new patient();
                //Buscamos el usuario
                objUser = userService.GetUserByUsername(username);
                //Buscamos la persona
                objPerson = personServ.GetPersonByDni(dniValue);
                //Lo asignamos al admin
                objPatient          = new patient();
                objPatient.personId = objPerson.ID;
                //lo creamos
                if (patientServ.GetPatientByPersonId(objPatient.personId) != null)
                {
                    MessageBox.Show("This user is already a Patient");
                }
                else
                {
                    patientServ.CreatePatient(objPatient);
                    MessageBox.Show("New Patient Saved");
                    enableTextbox(false);
                    initialize();
                }
            }
        }
Esempio n. 10
0
 public void addNurse(nurse n)
 {
     hms.nurses.Add(n);
     hms.SaveChanges();
 }
Esempio n. 11
0
 public List <room> getMyRooms(nurse n)
 {
     return(hms.rooms.Where(x => x.nid == n.nid).ToList());
 }
Esempio n. 12
0
    protected void btnlogin_Click(object sender, EventArgs e)
    {
        String Username = txtusername.Text;

        String Password = txtpassword.Text;

        employee_ru ru = employee_ru.Login_employee_ru(Username, Password);

        doctor doc = doctor.Login_doctor(Username, Password);

        nurse nu = nurse.Login_nurse(Username, Password);

        if (ru != null)
        {
            string      user      = ru.username;
            employee_ru show_name = employee_ru.show_employees(user);

            if (show_name != null)
            {
                if (show_name.status == "ได้รับสิทธิการรักษา")
                {
                    Session["staff_name"] = show_name.emp_ru_name;
                    if (show_name.pos_name == "เจ้าหน้าที่")
                    {
                        Response.Redirect("../Page/index_opd.aspx");
                    }
                    else if (show_name.pos_name == "เวชระเบียน")
                    {
                        Response.Redirect("../Page/index_opd.aspx");
                    }
                    else if (show_name.pos_name == "พยาบาล")
                    {
                        Response.Redirect("../Page/nurse_index_opd.aspx");
                    }
                    else if (show_name.pos_name == "เภสัชกรณ์")
                    {
                        Response.Redirect("../Page/index_opd.aspx");
                    }
                    else if (show_name.pos_name == "หัวหน้า")
                    {
                        Response.Redirect("../Page/index_opd.aspx");
                    }
                    else
                    {
                        Response.Redirect("../Page/index_student.aspx");
                    }
                }
                else
                {
                    //  ClientScript.RegisterStartupScript(GetType(), "hwa", "alert('ไม่ถูกยืนยันสิทธิการรักษา');", true);

                    Session["staff_name"] = show_name.emp_ru_name;
                    if (show_name.pos_name == "พยาบาล")
                    {
                        Response.Redirect("../Page/appointment_management_index.aspx");
                        //       ClientScript.RegisterStartupScript(GetType(), "hwa", "alert('เป็นพยาบาล');", true);
                    }
                    else
                    {
                        ClientScript.RegisterStartupScript(GetType(), "hwa", "alert('ไม่ถูกยืนยันสิทธิการรักษา');", true);
                    }
                }
            }
        }
        else if (doc != null)
        {
            Session["doc_name"]   = doc.emp_doc_name;
            Session["doc_id"]     = doc.emp_doc_id;
            Session["specialist"] = doc.emp_doc_specialist;
            Response.Redirect("../Page/index_doctor.aspx");
            // ClientScript.RegisterStartupScript(GetType(), "hwa", "alert('gfdtdryhththdyhn');", true);
        }
        else if (nu != null)
        {
            Session["nurse_name"] = nu.emp_ru_name;

            if (nu.pos_name == "พยาบาล")
            {
                Response.Redirect("../Page/appointment_management_index.aspx");
                //   ClientScript.RegisterStartupScript(GetType(), "hwa", "alert('"+ nu.emp_ru_name + "');", true);
            }
            else
            {
                ClientScript.RegisterStartupScript(GetType(), "hwa", "alert('ไม่ถูกยืนยันสิทธิการรักษา');", true);
            }
            //      Response.Redirect("../Page/index_doctor.aspx");
        }

        else
        {
            ClientScript.RegisterStartupScript(GetType(), "hwa", "alert('ไม่พบข้อมูลในระบบ');", true);
        }
    }
Esempio n. 13
0
        public void CreateNurse(nurse objNurse)
        {
            INurseRepository repo = new NurseRepository();

            repo.CreateNurse(objNurse);
        }