//send a message
        protected void Button1_Click(object sender, EventArgs e)
        {
            dbcon.MessagesTables.Load();
            dbcon.DoctorsTables.Load();
            dbcon.PatientsTables.Load();

            MessagesTable mess = new MessagesTable();

            mess.MessageTO = (from x in dbcon.PatientsTables.Local
                              where x.PatientID == Convert.ToInt32(DropDownListPatients.SelectedValue)
                              select x).First().UserLoginName;
            mess.MessageFROM = (from x in dbcon.DoctorsTables.Local
                                where x.DoctorID == DocPK
                                select x).First().UserLoginName;
            mess.Date    = DateTime.Now;
            mess.Message = TextBox1.Text;

            dbcon.MessagesTables.Add(mess);
            dbcon.SaveChanges();
            GridViewInbox.DataBind();

            TextBox1.Text = "";

            GridViewSent.DataBind();
        }
Exemple #2
0
 public CustomMessage(MessagesTable m)
 {
     if (UtilitiesClass.getPatient(m.MessageTO) != null)
     {
         PatientsTable messageTo   = UtilitiesClass.getPatient(m.MessageTO);
         DoctorsTable  messageFrom = UtilitiesClass.getDoctor(m.MessageFROM);
         this.From = $"{messageFrom.FirstName.Trim()} {messageFrom.LastName.Trim()}";
         this.To   = $"{messageTo.FirstName.Trim()} {messageTo.LastName.Trim()}";
     }
     else
     {
         DoctorsTable  messageTo   = UtilitiesClass.getDoctor(m.MessageTO);
         PatientsTable messageFrom = UtilitiesClass.getPatient(m.MessageFROM);
         this.From = $"{messageFrom.FirstName.Trim()} {messageFrom.LastName.Trim()}";
         this.To   = $"{messageTo.FirstName.Trim()} {messageTo.LastName.Trim()}";
     }
     this.Date           = m.Date;
     this.MessagePreview = Regex.Replace(m.Message.Remove(40), @"\s+", " ");
     //CHECK
     if (m.Message.Length > 40)
     {
         this.MessagePreview += "...";
     }
     this.Read      = Convert.ToInt32(m.IsRead) == 0 ? "Unread" : "";
     this.MessageID = m.MessageID;
 }
Exemple #3
0
        void ReleaseDesignerOutlets()
        {
            if (MessagesTable != null)
            {
                MessagesTable.Dispose();
                MessagesTable = null;
            }

            if (MessageText != null)
            {
                MessageText.Dispose();
                MessageText = null;
            }

            if (SendButton != null)
            {
                SendButton.Dispose();
                SendButton = null;
            }

            if (ReconnectButton != null)
            {
                ReconnectButton.Dispose();
                ReconnectButton = null;
            }
        }
Exemple #4
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            if (DropDownList1.SelectedValue == null)
            {
                MessageBox.Show("Need to select a doctor.");
            }
            else
            {
                MessagesTable myMessage = new MessagesTable();
                string        ourUser   = User.Identity.Name;
                myDbcon1.PatientsTables.Load();
                myDbcon2.DoctorsTables.Load();

                PatientsTable myPatient = (from x in myDbcon1.PatientsTables.Local
                                           where x.UserLoginName.Trim().Equals(ourUser)
                                           select x).First();

                myMessage.MessageFROM = myPatient.UserLoginName.Trim();
                myMessage.MessageTO   = DropDownList1.SelectedValue.Trim();
                myMessage.Date        = DateTime.Now;
                myMessage.Message     = TextBox1.Text.Trim();

                //Add data to the table
                myDbcon1.MessagesTables.Add(myMessage);
                myDbcon1.SaveChanges();
            }
        }
 void Messages_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
 {
     UIApplication.SharedApplication.InvokeOnMainThread(
         () =>
     {
         MessagesTable.ReloadData();
     });
 }
        protected void SendMsgBtn_Click(object sender, EventArgs e)
        {
            NewBDcon();
            dbcon.StudentTables.Load();
            dbcon.UserTables.Load();
            dbcon.AdvisorTables.Load();
            dbcon.AppointmentTables.Load();
            dbcon.MessagesTables.Load();
            string userName = User.Identity.Name;
            string role = check_role();
            string advisorEmail, studentEmail;

            if ("advisor" == role)
            {
                advisorEmail = (from advisor in dbcon.AdvisorTables.Local
                                where advisor.AdvisorUserName == userName
                                join user in dbcon.UserTables.Local on advisor.AdvisorUserName equals user.UserName
                                select user.UserEmail).First();
                studentEmail = StudentsView.SelectedRow.Cells[3].Text;
            }
            else
            {
                studentEmail = (from students in dbcon.StudentTables.Local
                                where students.StudentUserName == userName
                                join user in dbcon.UserTables.Local on students.StudentUserName equals user.UserName
                                select user.UserEmail).First();

                advisorEmail = (from students in dbcon.StudentTables.Local
                                where students.StudentUserName == userName
                                join advisors in dbcon.AdvisorTables.Local on students.StudentAdvisorID equals advisors.AdvisorID
                                join user in dbcon.UserTables.Local on advisors.AdvisorUserName equals user.UserName
                                select user.UserEmail).First();
            }

            MessagesTable message;

            if (TextBox1.Text != "")
            {
                string emailMessage = TextBox1.Text;
                message = new MessagesTable
                {
                    EmailTime = DateTime.Now.TimeOfDay,
                    EmailDate = DateTime.Today,
                    EmailTo   = advisorEmail,
                    EmailFrom = studentEmail,
                    EmailText = emailMessage
                };

                dbcon.MessagesTables.Add(message);
                dbcon.SaveChanges();
            }



            TextBox1.Text = "";
        }
        protected void deleteBtn_Click(object sender, EventArgs e)
        {
            int appointmentIdentifier;

            try
            {
                appointmentIdentifier = Convert.ToInt32(appointmentsView.SelectedRow.Cells[1].Text);
            }
            catch (Exception)
            {
                return;
            }
            NewBDcon();
            dbcon.AppointmentTables.Load();
            dbcon.MessagesTables.Load();
            AppointmentTable entry        = dbcon.AppointmentTables.Find(appointmentIdentifier);
            string           advisorEmail = appointmentsView.SelectedRow.Cells[5].Text;
            string           studentEmail = appointmentsView.SelectedRow.Cells[7].Text;
            string           message      = "Appointment Cancel: " + appointmentsView.SelectedRow.Cells[2].Text + " " +
                                            appointmentsView.SelectedRow.Cells[3].Text;
            string        role = check_role();
            MessagesTable messageEntry;

            if (role == "advisor")
            {
                messageEntry = new MessagesTable
                {
                    EmailDate = DateTime.Today,
                    EmailFrom = advisorEmail,
                    EmailText = message,
                    EmailTime = DateTime.Today.TimeOfDay,
                    EmailTo   = studentEmail
                };
            }
            else
            {
                messageEntry = new MessagesTable
                {
                    EmailDate = DateTime.Today,
                    EmailFrom = studentEmail,
                    EmailText = message,
                    EmailTime = DateTime.Now.TimeOfDay,
                    EmailTo   = advisorEmail
                };
            }
            dbcon.MessagesTables.Add(messageEntry);
            dbcon.AppointmentTables.Remove(entry);
            dbcon.SaveChanges();

            View_Own_Appointments();
        }
        //delete for sent messages
        protected void Button3_Click(object sender, EventArgs e)
        {
            if (GridViewSent.SelectedIndex >= 0)
            {
                dbcon.MessagesTables.Load(); // load up the database

                // find the appointment based on the MessageID
                MessagesTable mess2 = dbcon.MessagesTables.Find(Convert.ToInt32(GridViewSent.SelectedRow.Cells[1].Text)); // delete the item

                dbcon.MessagesTables.Remove(mess2);                                                                       //remove the message
                dbcon.SaveChanges();                                                                                      // save the changes
                GridViewSent.DataBind();                                                                                  // update the gridview
            }
        }
Exemple #9
0
        protected void Button3_Click(object sender, EventArgs e)
        {
            HA3_DataBaseV1Entities3 myDbcon4 = new HA3_DataBaseV1Entities3();

            myDbcon4.MessagesTables.Load();
            MessagesTable delMessage = (from x in myDbcon4.MessagesTables.Local
                                        where x.MessageID == Convert.ToInt32(Label3.Text)
                                        select x).First();

            myDbcon4.MessagesTables.Remove(delMessage);
            myDbcon4.SaveChanges();
            GridView1.DataBind();
            MessageBox.Show("Message successfully deleted.");
        }
Exemple #10
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            myDbcon1.DoctorsTables.Load();

            var currentDoctor = (from x in myDbcon1.DoctorsTables.Local
                                 where x.UserLoginName.Trim() == User.Identity.Name.Trim()
                                 select x).First();

            MessagesTable myMessage = new MessagesTable();

            myMessage.MessageFROM = currentDoctor.UserLoginName.Trim();
            myMessage.MessageTO   = DropDownList1.SelectedItem.Text.Trim();
            myMessage.Date        = DateTime.Now;
            myMessage.Message     = TextBox1.Text.Trim();

            myDbcon1.MessagesTables.Add(myMessage);
            myDbcon1.SaveChanges();
        }
Exemple #11
0
        //Sends the given message's info to the ViewMessageTextBox
        public void ViewMessage(int messageID)
        {
            MessagesTable mTable  = UtilitiesClass.getMessageByID(messageID);
            CustomMessage mCustom = new CustomMessage(mTable);

            ViewMessageTextBox.Visible = true;
            ViewMessageTextBox.Text    = $"From: {mCustom.From}\nTo: {mCustom.To}\nDate: {mTable.Date}\n\n{mTable.Message}";
            if (mTable.MessageTO.Trim().Equals(Session["LoginName"].ToString().Trim()) && mTable.IsRead == 0)
            {
                foreach (MessagesTable m in dbcon.MessagesTables)
                {
                    if (m.MessageID == messageID)
                    {
                        m.IsRead = 1;
                    }
                }
                dbcon.SaveChanges();
                loadMessages(Session["LoginName"].ToString());
            }
        }
        protected void deleteEmBtn_Click(object sender, EventArgs e)
        {
            int emailIdentifier;

            try
            {
                emailIdentifier = Convert.ToInt32(EmailView.SelectedRow.Cells[1].Text);
            }
            catch (Exception)
            {
                return;
            }
            NewBDcon();
            dbcon.StudentTables.Load();
            dbcon.UserTables.Load();
            dbcon.AdvisorTables.Load();
            dbcon.AppointmentTables.Load();
            dbcon.MessagesTables.Load();
            MessagesTable entry = dbcon.MessagesTables.Find(emailIdentifier);

            dbcon.MessagesTables.Remove(entry);
            dbcon.SaveChanges();
            Fill_Emails();
        }
Exemple #13
0
 public ContactController()
 {
     _contactContext = new MyWebContext();
     _modelContact   = new ModelContact();
     _messageTable   = new MessagesTable();
 }
Exemple #14
0
        protected void submitBtn_Click(object sender, EventArgs e)
        {
            DateTime dateTime;

            if (DropDownList1.Items.Count != 0)
            {
                dateTime = DateTime.ParseExact(DropDownList1.SelectedItem.Value,
                                               "hh:mm tt", CultureInfo.InvariantCulture);
            }
            else
            {
                return;
            }
            string role = check_role();

            NewBDcon();
            dbconDate.StudentTables.Load();
            dbconDate.UserTables.Load();
            dbconDate.AdvisorTables.Load();
            dbconDate.AppointmentTables.Load();
            dbconDate.MessagesTables.Load();
            TimeSpan span = dateTime.TimeOfDay;
            string   userName = User.Identity.Name;
            int      advisor, student;

            if ("advisor" == role)
            {
                advisor = (from advisors in dbconDate.AdvisorTables.Local
                           where advisors.AdvisorUserName == userName
                           select advisors.AdvisorID).First();
                student = Convert.ToInt32(StudentsView.SelectedRow.Cells[1].Text);
            }
            else
            {
                advisor = (from students in dbconDate.StudentTables.Local
                           where students.StudentUserName == userName
                           select students.StudentAdvisorID).First();
                student = (from students in dbconDate.StudentTables.Local
                           where students.StudentUserName == userName
                           select students.StudentID).First();
            }
            AppointmentTable entry = new AppointmentTable
            {
                AdvisorID         = advisor,
                AppointmentDate   = Calendar1.SelectedDate,
                AppointmentReason = TextBox1.Text,
                StudentID         = student,
                AppointmentTime   = span,
            };

            AdvisorTable advisorEntry = dbconDate.AdvisorTables.Find(advisor);
            StudentTable studentEntry = dbconDate.StudentTables.Find(student);
            string       studentEmail, advisorEmail;

            if ("advisor" == role)
            {
                advisorEmail = (from advisors in dbconDate.AdvisorTables.Local
                                where advisors.AdvisorUserName == userName
                                join user in dbconDate.UserTables.Local on advisors.AdvisorUserName equals user.UserName
                                select user.UserEmail).First();
                studentEmail = StudentsView.SelectedRow.Cells[3].Text;
            }
            else
            {
                studentEmail = (from students in dbconDate.StudentTables.Local
                                where students.StudentUserName == userName
                                join user in dbconDate.UserTables.Local on students.StudentUserName equals user.UserName
                                select user.UserEmail).First();
                advisorEmail = (from students in dbconDate.StudentTables.Local
                                where students.StudentUserName == userName
                                join advisors in dbconDate.AdvisorTables.Local on students.StudentAdvisorID equals advisors.AdvisorID
                                join user in dbconDate.UserTables.Local on advisors.AdvisorUserName equals user.UserName
                                select user.UserEmail).First();
            }
            DateTime holdTime     = DateTime.Today.Add(span);
            string   displayTime  = holdTime.ToString("hh:mm tt");
            string   emailMessage = "Appointment date and Time: " + Calendar1.SelectedDate.ToShortDateString() + " " + displayTime +
                                    " \nAppointment Reason: " + TextBox1.Text;

            MessagesTable message;

            if ("advisor" == role)
            {
                message = new MessagesTable
                {
                    EmailTime = DateTime.Now.TimeOfDay,
                    EmailDate = DateTime.Today,
                    EmailTo   = studentEmail,
                    EmailFrom = advisorEmail,
                    EmailText = emailMessage
                };
            }
            else
            {
                message = new MessagesTable
                {
                    EmailTime = DateTime.Now.TimeOfDay,
                    EmailDate = DateTime.Today,
                    EmailTo   = advisorEmail,
                    EmailFrom = studentEmail,
                    EmailText = emailMessage
                };
            }

            dbconDate.MessagesTables.Add(message);
            dbconDate.SaveChanges();
            dbconDate.AppointmentTables.Add(entry);
            dbconDate.SaveChanges();
            Response.Redirect(ResolveUrl("Student_Home.aspx"));
        }
 public ModelContact()
 {
     _messagesTable  = new MessagesTable();
     _contactContext = new MyWebContext();
 }