public ActionResult AppointmentDetails()
 {
     using (KIITEntities db = new KIITEntities())
     {
         int memid   = Convert.ToInt32(Session["Memberid"]);
         int doc_id  = db.Doctors.Where(a => a.MemberId == memid).Select(a => a.DoctorId).SingleOrDefault();
         var patient = db.DoctorAppointments.Where(a => a.DoctorId == doc_id);
         List <AppointmentViewModel> lst = new List <AppointmentViewModel>();
         foreach (var item in patient)
         {
             string pat_name = db.Patients.Where(a => a.PatientId == item.PatientId).Select(a => a.FirstName).SingleOrDefault();
             lst.Add(new AppointmentViewModel
             {
                 AppId       = item.AppointmentId,
                 PName       = pat_name,
                 Subject     = item.Subject,
                 Description = item.Description,
                 Date        = item.AppointmentDate,
                 AppStatus   = item.AppointmentStatus
             });
         }
         AppointmentViewModel model = new AppointmentViewModel();
         model.lst = lst;
         return(View(model));
     }
 }
        public ActionResult JS_Drugs()
        {
            int memid = Convert.ToInt32(Session["Memberid"]);

            using (KIITEntities db = new KIITEntities())
            {
                var data             = db.Drugs;
                List <DrugModel> lst = new List <DrugModel>();
                foreach (var item in data)
                {
                    lst.Add(new DrugModel
                    {
                        DrugId      = item.DrugId,
                        DrugName    = item.DrugName,
                        Man_Date    = item.ManufactureDate,
                        Exp_Date    = item.ExpiredDate,
                        UsedFor     = item.UsedFor,
                        SideEffects = item.SideEffects,
                        Quantity    = item.TotalQuantityAvailable,
                    });
                }
                DrugModel model = new DrugModel();
                model.lstDrugs = lst;
                return(View(model));
            }
        }
        public ActionResult View_Messages()
        {
            int memid = Convert.ToInt32(Session["Memberid"]);

            using (KIITEntities db = new KIITEntities())
            {
                string email                = db.MemberLogins.Where(a => a.MemberId == memid).Select(a => a.EmailId).SingleOrDefault();
                var    sent_data            = db.Inboxes.Where(a => (a.FromEmailId == email) || (a.ToEmailId == email));
                List <MessageViewModel> lst = new List <MessageViewModel>();
                foreach (var item in sent_data)
                {
                    lst.Add(new MessageViewModel
                    {
                        From_Email    = item.FromEmailId,
                        To_Email      = item.ToEmailId,
                        Subject       = item.Subject,
                        MessageDetail = item.MessageDetail,
                        Date          = item.MessageDate
                    });
                }
                MessageViewModel model = new MessageViewModel();
                model.lstMessage = lst;
                return(View(model));
            }
        }
Exemplo n.º 4
0
        public ActionResult View_Order_Details()
        {
            int memid = Convert.ToInt32(Session["Memberid"]);

            using (KIITEntities db = new KIITEntities())
            {
                int sid = db.Suppliers.Where(a => a.MemberId == memid).Select(a => a.SupplierId).SingleOrDefault();

                var data = from pod in db.PatientOrderDetails
                           join dd in db.DrugDeliveries on pod.OrderId equals dd.OrderId
                           where dd.SupplierId == sid
                           select new { pod.DrugId, pod.Quantity, pod.OrderedDate, dd.OrderId, pod.OrderStatus, pod.OrderNumber, dd.DeliveredDate, pod.PatientId };

                List <DrugViewModel> lst = new List <DrugViewModel>();
                foreach (var item in data)
                {
                    string pat_name  = db.Patients.Where(a => a.PatientId == item.PatientId).Select(a => a.FirstName).FirstOrDefault();
                    string drug_name = db.Drugs.Where(a => a.DrugId == item.DrugId).Select(a => a.DrugName).SingleOrDefault();
                    lst.Add(new DrugViewModel
                    {
                        OrderNumber  = item.OrderNumber,
                        PatientName  = pat_name,
                        DeliveryDate = Convert.ToDateTime(item.DeliveredDate),
                        DrugName     = drug_name,
                        Quantity     = item.Quantity,
                        OrderDate    = item.OrderedDate,
                        OrderId      = item.OrderId,
                        OrderStatus  = item.OrderStatus
                    });
                }
                DrugViewModel model = new DrugViewModel();
                model.lstData = lst;
                return(View(model));
            }
        }
        public ActionResult Login(LoginViewModel model)
        {
            using (KIITEntities db = new KIITEntities())
            {
                var checkuser = (from m in db.MemberLogins
                                 join r in db.RoleDetails on m.RoleId equals r.RoleId
                                 where m.EmailId == model.Username && m.Password == model.PassWord
                                 select new { m.EmailId, r.RoleName, m.MemberId }).FirstOrDefault();

                if (checkuser != null && checkuser.RoleName == "Admin")
                {
                    FormsAuthentication.SetAuthCookie(checkuser.EmailId, false);
                    var authTicket = new FormsAuthenticationTicket(2,                           // version
                                                                   checkuser.EmailId,           //username
                                                                   DateTime.Now,                // current date and time
                                                                   DateTime.Now.AddMinutes(10), // time out
                                                                   false,
                                                                   "Admin"                      //userdata , store a role
                                                                   );
                    string encryptedTicket = FormsAuthentication.Encrypt(authTicket);
                    var    authCookie      = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket);
                    Response.Cookies.Add(authCookie);
                    Session["Memberid"] = checkuser.MemberId;
                    return(RedirectToAction("DashBoard", "Admin"));
                }
                else
                {
                    ViewBag.message = "Invalid Credentials";
                }
            }
            return(View());
        }
        public ActionResult View_Order_Details()
        {
            int memid = Convert.ToInt32(Session["Memberid"]);

            using (KIITEntities db = new KIITEntities())
            {
                var data = db.PatientOrderDetails.Select(a => new { a.DrugId, a.OrderNumber, a.Quantity, a.OrderedDate, a.OrderStatus });
                List <DrugViewModel> lst = new List <DrugViewModel>();
                foreach (var item in data)
                {
                    string drug_name = db.Drugs.Where(a => a.DrugId == item.DrugId).Select(a => a.DrugName).SingleOrDefault();
                    lst.Add(new DrugViewModel
                    {
                        OrderNumber = item.OrderNumber,
                        DrugName    = drug_name,
                        Quantity    = item.Quantity,
                        OrderDate   = item.OrderedDate,
                        OrderStatus = item.OrderStatus
                    });
                }
                DrugViewModel model = new DrugViewModel();
                model.lstData = lst;
                return(View(model));
            }
        }
        public ActionResult EditProfile()
        {
            using (KIITEntities db = new KIITEntities())
            {
                int memid = Convert.ToInt32(Session["Memberid"]);

                var             getdata = db.Doctors.SingleOrDefault(a => a.MemberId == memid);
                DoctorViewModel model   = new DoctorViewModel();
                if (getdata != null)
                {
                    model.FirstName       = getdata.FirstName;
                    model.LastName        = getdata.LastName;
                    model.Gender          = getdata.Gender;
                    model.TotalExperience = getdata.TotalExperience;
                    model.SpecializedId   = getdata.SpecializedId;
                    model.lstSpec         = CommonData.GetSpecs();
                    return(View(model));
                }
                else
                {
                    model.lstSpec = CommonData.GetSpecs();
                    return(View(model));
                }
            }
        }
        public ActionResult View_App_Details()
        {
            using (KIITEntities db = new KIITEntities())
            {
                int memid = Convert.ToInt32(Session["Memberid"]);
                var p     = db.Patients.Where(a => a.MemberId == memid).Select(a => new { a.FirstName, a.PatientId }).SingleOrDefault();
                var da    = db.DoctorAppointments.Where(a => a.PatientId == p.PatientId);

                List <DoctorAppointmentViewModel> lst = new List <DoctorAppointmentViewModel>();
                foreach (var item in da)
                {
                    var d = db.Doctors.Where(a => a.DoctorId == item.DoctorId).SingleOrDefault();
                    lst.Add(new DoctorAppointmentViewModel
                    {
                        PatientName       = p.FirstName,
                        DoctorName        = d.FirstName,
                        Subject           = item.Subject,
                        Description       = item.Description,
                        AppointmentDate   = item.AppointmentDate,
                        AppointmentStatus = item.AppointmentStatus
                    });
                }
                DoctorAppointmentViewModel model = new DoctorAppointmentViewModel();
                model.lstApp = lst;
                return(View(model));
            }
        }
 public JsonResult UpdateStatus(AppointmentViewModel model)
 {
     using (KIITEntities entities = new KIITEntities())
     {
         entities.UpdateAppStatus(model.AppStatus, model.AppId);
     }
     return(Json(model));
 }
        public ActionResult UpdateDrug(DrugModel drug)
        {
            using (KIITEntities entities = new KIITEntities())
            {
                entities.UpdateDrug(drug.DrugId, drug.DrugName, drug.Man_Date, drug.Exp_Date, drug.UsedFor, drug.SideEffects, drug.Quantity);
            }

            return(new EmptyResult());
        }
        public JsonResult DeleteDrug(DrugModel drug)
        {
            using (KIITEntities entities = new KIITEntities())
            {
                entities.RemoveDrug(drug.DrugId);
            }

            return(Json(drug));
        }
        public JsonResult InsertDrug(DrugModel drug)
        {
            using (KIITEntities entities = new KIITEntities())
            {
                entities.InsertDrug(drug.DrugName, drug.Man_Date, drug.Exp_Date, drug.UsedFor, drug.SideEffects, drug.Quantity);
            }

            return(Json(drug));
        }
        public ActionResult UpdateMessage(MessageViewModel message)
        {
            using (KIITEntities entities = new KIITEntities())
            {
                entities.InsertReplyMessage(message.From_Email, message.To_Email, message.Subject, message.MessageDetail, DateTime.Now, message.MessageId);
                entities.UpdateMessageStatus(message.MessageId);
            }

            return(Json(message));
        }
Exemplo n.º 14
0
 // GET: Supplier
 public ActionResult DashBoard()
 {
     using (KIITEntities db = new KIITEntities())
     {
         DashView model = new DashView();
         model.TotOrd = db.PatientOrderDetails.Count();
         model.DelOrd = db.PatientOrderDetails.Where(a => a.OrderStatus == "Delivered").Count();
         model.DisOrd = db.PatientOrderDetails.Where(a => a.OrderStatus == "Dispatched").Count();
         model.ReqOrd = db.PatientOrderDetails.Where(a => a.OrderStatus == "Requested").Count();
         return(View(model));
     }
 }
        public ActionResult Send_Message(MessageViewModel model)
        {
            int memid = Convert.ToInt32(Session["Memberid"]);
            MessageViewModel p_model = new MessageViewModel();

            p_model.lstDocId = CommonData.GetDocsId();
            using (KIITEntities db = new KIITEntities())
            {
                string email = db.MemberLogins.Where(a => a.MemberId == memid).Select(a => a.EmailId).SingleOrDefault();
                db.InsertMessage(email, model.To_Email, model.Subject, model.MessageDetail, DateTime.Now, model.ReplyId, 0);
            }
            return(View(p_model));
        }
Exemplo n.º 16
0
 public ActionResult UpdateStatus(DrugViewModel drug)
 {
     using (KIITEntities db = new KIITEntities())
     {
         db.UpdateOrderStatus(drug.OrderStatus, drug.OrderId);
         if (drug.OrderStatus == "Delivered")
         {
             int did = db.DrugDeliveries.Where(a => a.OrderId == drug.OrderId).Select(a => a.DeliveryId).SingleOrDefault();
             db.UpdateDeliveryDate(did, DateTime.Now);
         }
     }
     return(Json(drug));
 }
Exemplo n.º 17
0
        public ActionResult Register(MemberViewModel model)
        {
            MemberViewModel model_post = new MemberViewModel();

            model_post.lstRoles = CommonData.GetRoles();
            if (model.EmailId != null && model.Password != null && model.RoleId != 0)
            {
                KIITEntities db = new KIITEntities();
                db.InsertMember(model.EmailId, model.Password, model.RoleId);
                return(View(model_post));
            }
            else
            {
                return(View(model_post));
            }
        }
        public ActionResult Doctor_Appointment(DoctorAppointmentViewModel model)
        {
            int memid = Convert.ToInt32(Session["Memberid"]);
            DoctorAppointmentViewModel model_post = new DoctorAppointmentViewModel();

            model_post.lstDocs = CommonData.GetDocs();
            if (model.PatientName != null && model.Subject != null && model.DoctorId != 0)
            {
                KIITEntities db   = new KIITEntities();
                int          p_id = db.Patients.Where(a => a.MemberId == memid).Select(a => a.PatientId).SingleOrDefault();
                db.InsertAppointment(p_id, model.DoctorId, model.Subject, model.Description, model.AppointmentDate);
                return(View(model_post));
            }
            else
            {
                return(View(model_post));
            }
        }
        public ActionResult InsertSupplier(DrugViewModel drug)
        {
            using (KIITEntities entities = new KIITEntities())
            {
                var quan = (from d in entities.Drugs where d.DrugId == drug.DrugId select d.TotalQuantityAvailable).FirstOrDefault();
                if (drug.Quantity < quan)
                {
                    entities.InsertDelivery(drug.OrderId, drug.SupplierId);
                    entities.UpdateDQuan(quan - drug.Quantity, drug.DrugId);
                }
                else
                {
                    throw new Exception("abc");
                }
            }

            return(Json(drug));
        }
        // GET: Patient
        public ActionResult DashBoard()
        {
            int memid = Convert.ToInt32(Session["Memberid"]);

            using (KIITEntities db = new KIITEntities())
            {
                DashView model = new DashView();
                int      pid   = db.Patients.Where(a => a.MemberId == memid).Select(a => a.PatientId).SingleOrDefault();
                model.App     = db.DoctorAppointments.Where(a => a.PatientId == pid).Count();
                model.AprApp  = db.DoctorAppointments.Where(a => (a.PatientId == pid) && (a.AppointmentStatus == "Accept")).Count();
                model.RejApp  = db.DoctorAppointments.Where(a => (a.PatientId == pid) && (a.AppointmentStatus == "Reject")).Count();
                model.ProcApp = db.DoctorAppointments.Where(a => (a.PatientId == pid) && (a.AppointmentStatus == "Requested")).Count();
                model.TotOrd  = db.PatientOrderDetails.Where(a => a.PatientId == pid).Count();
                model.DelOrd  = db.PatientOrderDetails.Where(a => (a.PatientId == pid) && (a.OrderStatus == "Delivered")).Count();
                model.ReqOrd  = db.PatientOrderDetails.Where(a => (a.PatientId == pid) && (a.OrderStatus == "Requested") || (a.OrderStatus == "Dispatched")).Count();
                return(View(model));
            }
        }
        public ActionResult Raise_Drug_Request(DrugViewModel model)
        {
            int           memid      = Convert.ToInt32(Session["Memberid"]);
            DrugViewModel model_post = new DrugViewModel();

            model_post.lstDrugs = CommonData.GetDrugs();
            int    day   = DateTime.Now.Day;
            int    hrs   = DateTime.Now.Hour;
            int    min   = DateTime.Now.Minute;
            int    sec   = DateTime.Now.Second;
            string odrno = string.Format("{0}{1}{2}{3}", day, hrs, min, sec);

            using (KIITEntities db = new KIITEntities())
            {
                int p_id = db.Patients.Where(a => a.MemberId == memid).Select(a => a.PatientId).SingleOrDefault();
                db.OrderDrug(p_id, model.DrugId, Convert.ToInt32(odrno), model.Quantity, DateTime.Now);
            }
            return(View(model_post));
        }
        // GET: Doctor
        public ActionResult DashBoard()
        {
            int memid = Convert.ToInt32(Session["Memberid"]);

            using (KIITEntities db = new KIITEntities())
            {
                DashView model  = new DashView();
                string   doceid = db.MemberLogins.Where(a => a.MemberId == memid).Select(a => a.EmailId).SingleOrDefault();
                int      docid  = db.Doctors.Where(a => a.MemberId == memid).Select(a => a.DoctorId).SingleOrDefault();
                model.App     = db.DoctorAppointments.Where(a => a.DoctorId == docid).Count();
                model.AprApp  = db.DoctorAppointments.Where(a => (a.AppointmentStatus == "Accept") && (a.DoctorId == docid)).Count();
                model.RejApp  = db.DoctorAppointments.Where(a => (a.AppointmentStatus == "Reject") && (a.DoctorId == docid)).Count();
                model.ProcApp = db.DoctorAppointments.Where(a => (a.AppointmentStatus == "Requested") && (a.DoctorId == docid)).Count();
                model.Inbox   = db.Inboxes.Where(a => a.ToEmailId == doceid).Count();
                model.RInbox  = db.Inboxes.Where(a => (a.ToEmailId == doceid) && (a.IsRead == true)).Count();;
                model.URInbox = db.Inboxes.Where(a => (a.ToEmailId == doceid) && (a.IsRead == false)).Count();;
                return(View(model));
            }
        }
        public ActionResult Change_Password(LoginViewModel model)
        {
            int memid = Convert.ToInt32(Session["Memberid"]);

            using (KIITEntities db = new KIITEntities())
            {
                var getdata = db.MemberLogins.FirstOrDefault(a => a.MemberId == memid);

                if (model.Old_Password == getdata.Password)
                {
                    db.UpdatePassword(model.PassWord, memid);
                    ViewBag.message = "Password Updated";
                }
                else
                {
                    ViewBag.message = "Wrong Password Entered";
                }
            }

            return(View());
        }
        public ActionResult View_Order_Details()
        {
            string sname;
            int    memid = Convert.ToInt32(Session["Memberid"]);

            using (KIITEntities db = new KIITEntities())
            {
                var data = db.PatientOrderDetails;
                List <DrugViewModel> lst = new List <DrugViewModel>();
                foreach (var item in data)
                {
                    string drug_Name = db.Drugs.Where(a => a.DrugId == item.DrugId).Select(a => a.DrugName).SingleOrDefault();
                    int    sid       = db.DrugDeliveries.Where(a => a.OrderId == item.OrderId).Select(a => a.SupplierId).SingleOrDefault();
                    if (sid > 0)
                    {
                        sname = db.Suppliers.Where(a => a.SupplierId == sid).Select(a => a.FirstName).SingleOrDefault();
                    }
                    else
                    {
                        sname = null;
                    }

                    lst.Add(new DrugViewModel
                    {
                        OrderId      = item.OrderId,
                        DrugId       = item.DrugId,
                        OrderNumber  = item.OrderNumber,
                        DrugName     = drug_Name,
                        Quantity     = item.Quantity,
                        OrderDate    = item.OrderedDate,
                        SupplierName = sname
                    });
                }

                DrugViewModel model = new DrugViewModel();
                model.lstShowDrugs = lst;
                model.lstSupplier  = CommonData.GetSuppliers();
                return(View(model));
            }
        }
Exemplo n.º 25
0
        public ActionResult EditProfile(SupplierViewModel model)
        {
            int memid = Convert.ToInt32(Session["Memberid"]);

            using (KIITEntities db = new KIITEntities())
            {
                var getdata = db.Suppliers.FirstOrDefault(a => a.MemberId == memid);
                if (getdata != null)
                {
                    db.UpdateSupplier(model.FirstName, model.LastName, model.CompanyName, model.CompanyAddress, memid);
                    ViewBag.message = "Updated";
                }

                else
                {
                    db.InsertSupplier(model.FirstName, model.LastName, model.CompanyName, model.CompanyAddress, memid);
                    ViewBag.message = "Inserted";
                }
            }

            return(View());
        }
        public ActionResult EditProfile()
        {
            using (KIITEntities db = new KIITEntities())
            {
                int memid = Convert.ToInt32(Session["Memberid"]);
                ProfileViewModel model = new ProfileViewModel();
                var getdata            = db.Admins.SingleOrDefault(a => a.MemberId == memid);

                if (getdata != null)
                {
                    model.FirstName = getdata.FirstName;
                    model.LastName  = getdata.LastName;
                    model.Gender    = getdata.Gender;
                    model.Address   = getdata.Address;
                    return(View(model));
                }
                else
                {
                    return(View());
                }
            }
        }
        public ActionResult EditProfile(ProfileViewModel model)
        {
            int memid = Convert.ToInt32(Session["Memberid"]);

            using (KIITEntities db = new KIITEntities())
            {
                var getdata = db.Patients.FirstOrDefault(a => a.MemberId == memid);
                if (getdata != null)
                {
                    db.UpdatePatient(model.FirstName, model.LastName, model.DateOfBirth, model.Gender, model.Address, memid);
                    ViewBag.message = "Updated";
                }

                else
                {
                    db.InsertPatient(model.FirstName, model.LastName, model.DateOfBirth, model.Gender, model.Address, memid);
                    ViewBag.message = "Inserted";
                }
            }

            return(View());
        }
        public ActionResult EditProfile(DoctorViewModel model)
        {
            int             memid      = Convert.ToInt32(Session["Memberid"]);
            DoctorViewModel model_post = new DoctorViewModel();

            model_post.lstSpec = CommonData.GetSpecs();
            using (KIITEntities db = new KIITEntities())
            {
                var getdata = db.Patients.FirstOrDefault(a => a.MemberId == memid);
                if (getdata != null)
                {
                    db.UpdateDoctor(model.FirstName, model.LastName, model.TotalExperience, model.SpecializedId, model.Gender, memid);
                    ViewBag.message = "Updated";
                }

                else
                {
                    db.InsertDoctor(model.FirstName, model.LastName, model.TotalExperience, model.SpecializedId, model.Gender, memid);
                    ViewBag.message = "Inserted";
                }
            }

            return(View(model_post));
        }