コード例 #1
0
        protected void btnRegister_Click(object sender, EventArgs e)
        {
            Doctor     doctor     = _dc.Doctors.FirstOrDefault(dc => dc.FirstName + " " + dc.LastName == ddlDoctors.SelectedValue.Trim().ToString());
            Speciality speciality = _dc.Specialities.FirstOrDefault(s => s.SpecialityName == ddlSpecialities.SelectedValue.Trim().ToString());

            DoctorsAndSpeciality CheckDoc = _dc.DoctorsAndSpecialities.FirstOrDefault(ds => ds.DoctorsID == doctor.ID && ds.SpecialityID == speciality.ID);

            if (CheckDoc == null)
            {
                DoctorsAndSpeciality docAndSpec = new DoctorsAndSpeciality();
                docAndSpec.DoctorsID    = doctor.ID;
                docAndSpec.SpecialityID = speciality.ID;
                _dc.DoctorsAndSpecialities.InsertOnSubmit(docAndSpec);
                _dc.SubmitChanges();

                Session["Message"] = "Success !";
                Response.Redirect("SetDoctorSpeciality.aspx");
            }
            else
            {
                Session["Message"] = "The Doctor already has that speciality added";
                Response.Redirect("SetDoctorSpeciality.aspx");
            }
        }
コード例 #2
0
 partial void DeleteSpeciality(Speciality instance);
コード例 #3
0
 partial void UpdateSpeciality(Speciality instance);
コード例 #4
0
 partial void InsertSpeciality(Speciality instance);
コード例 #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["LoggedUserID"] != null)
            {
                User user = _dc.Users.FirstOrDefault(u => u.ID == Convert.ToInt32(Session["LoggedUserID"].ToString()));

                if (Session["Message"] != null)
                {
                    lblMessage.Text    = Session["Message"].ToString();
                    Session["Message"] = null;
                }

                if (user.Type != 1)
                {
                    //Normal User

                    btnCreateAppointment.Visible = true;

                    List <Appointment> userAppointmentsList = _dc.Appointments.Where(a => a.UserID == Convert.ToInt32(Session["LoggedUserID"].ToString()) && a.IsDeleted == false).ToList();

                    int count = 1;

                    foreach (Appointment userAppointment in userAppointmentsList)
                    {
                        Button btnDelete = new Button()
                        {
                            ID = userAppointment.ID.ToString() + "D", Text = "Delete", CssClass = "btn btn-danger"
                        };
                        btnDelete.Click += buttonDelete_Click;

                        Button btnEdit = new Button()
                        {
                            ID = userAppointment.ID.ToString() + "E", Text = "Edit", CssClass = "btn btn-warning"
                        };
                        btnEdit.Click += buttonEdit_Click;

                        TableRow row = new TableRow();

                        TableCell countNumber         = new TableCell();
                        TableCell doctorCell          = new TableCell();
                        TableCell specialityCell      = new TableCell();
                        TableCell appointmentDateCell = new TableCell();
                        TableCell actionsCell         = new TableCell();



                        //appointment date/time

                        DateTime appointmentDate = userAppointment.AppointmentDate;

                        DoctorsAndSpeciality docAndSpecs = _dc.DoctorsAndSpecialities.FirstOrDefault(d => d.ID == userAppointment.DoctorAndSpecialityID);

                        // Doctor name

                        Doctor doctorsName = _dc.Doctors.FirstOrDefault(d => d.ID == docAndSpecs.DoctorsID);

                        //Speciality

                        Speciality specialityName = _dc.Specialities.FirstOrDefault(d => d.ID == docAndSpecs.SpecialityID);

                        countNumber.Text         = count.ToString();
                        doctorCell.Text          = doctorsName.FirstName.ToString() + " " + doctorsName.LastName.ToString();
                        specialityCell.Text      = specialityName.SpecialityName.ToString();
                        appointmentDateCell.Text = appointmentDate.ToString();

                        actionsCell.Controls.Add(btnEdit);

                        DateTime now      = DateTime.Now;
                        DateTime tomorrow = now.AddDays(1);
                        if (appointmentDate > tomorrow)
                        {
                            actionsCell.Controls.Add(btnDelete);
                        }

                        row.Cells.Add(countNumber);
                        row.Cells.Add(doctorCell);
                        row.Cells.Add(specialityCell);
                        row.Cells.Add(appointmentDateCell);
                        row.Cells.Add(actionsCell);

                        AppointmentsTable.Rows.Add(row);
                        count++;
                    }
                }
                else
                {
                    //Admin
                    List <Appointment> userAppointmentsList = _dc.Appointments.Where(a => a.IsDeleted == false).ToList();

                    int count = 1;

                    foreach (Appointment userAppointment in userAppointmentsList)
                    {
                        Button btnDelete = new Button()
                        {
                            ID = userAppointment.ID.ToString() + "D", Text = "Delete", CssClass = "btn btn-danger"
                        };
                        btnDelete.Click += buttonDelete_Click;

                        Button btnEdit = new Button()
                        {
                            ID = userAppointment.ID.ToString() + "E", Text = "Edit", CssClass = "btn btn-warning"
                        };
                        btnEdit.Click += buttonEdit_Click;

                        TableRow row = new TableRow();

                        TableCell countNumber         = new TableCell();
                        TableCell doctorCell          = new TableCell();
                        TableCell specialityCell      = new TableCell();
                        TableCell appointmentDateCell = new TableCell();
                        TableCell actionsCell         = new TableCell();



                        //appointment date/time

                        DateTime appointmentDate = userAppointment.AppointmentDate;

                        DoctorsAndSpeciality docAndSpecs = _dc.DoctorsAndSpecialities.FirstOrDefault(d => d.ID == userAppointment.DoctorAndSpecialityID);

                        // Doctor name

                        Doctor doctorsName = _dc.Doctors.FirstOrDefault(d => d.ID == docAndSpecs.DoctorsID);

                        //Speciality

                        Speciality specialityName = _dc.Specialities.FirstOrDefault(d => d.ID == docAndSpecs.SpecialityID);

                        countNumber.Text         = count.ToString();
                        doctorCell.Text          = doctorsName.FirstName.ToString() + " " + doctorsName.LastName.ToString();
                        specialityCell.Text      = specialityName.SpecialityName.ToString();
                        appointmentDateCell.Text = appointmentDate.ToString();

                        actionsCell.Controls.Add(btnEdit);

                        DateTime now = DateTime.Now;
                        if (appointmentDate > now)
                        {
                            actionsCell.Controls.Add(btnDelete);
                        }

                        row.Cells.Add(countNumber);
                        row.Cells.Add(doctorCell);
                        row.Cells.Add(specialityCell);
                        row.Cells.Add(appointmentDateCell);
                        row.Cells.Add(actionsCell);

                        AppointmentsTable.Rows.Add(row);
                        count++;
                    }
                }
            }
            else
            {
                Response.Redirect("Index.aspx");
            }
        }