Example #1
0
 public bool create(bacsy doctor)
 {
     dbContext.bacsies.Add(doctor);
     try
     {
         dbContext.SaveChanges();
     }
     catch
     {
         return(false);
     }
     return(true);
 }
Example #2
0
        public bool saveImg(string id, byte[] img)
        {
            bacsy u = dbContext.bacsies.Find(id);

            //  u.image = new byte[img.Length];
            u.image = img;
            try
            {
                dbContext.SaveChanges();
                return(true);
            }
            catch
            {
                return(false);
            }
        }
Example #3
0
        public int update(bacsy doctor)
        {
            var d = dbContext.bacsies.Find(doctor.idbsy);

            if (d == null)
            {
                return(0);
            }
            if (String.IsNullOrEmpty(doctor.idbv))
            {
                doctor.idbv = d.idbv;
            }
            if (String.IsNullOrEmpty(doctor.tenbs))
            {
                doctor.tenbs = d.tenbs;
            }
            if (!String.IsNullOrEmpty(doctor.pass))
            {
                d.pass = doctor.pass;
            }
            d.tenbs      = doctor.tenbs;
            d.dienthoai  = doctor.dienthoai;
            d.email      = doctor.email;
            d.ngaysinh   = doctor.ngaysinh;
            d.idbv       = doctor.idbv;
            d.chucvu     = doctor.chucvu;
            d.idxa       = doctor.idxa;
            d.idtinh     = doctor.idtinh;
            d.idhuyen    = doctor.idhuyen;
            d.updatetime = doctor.updatetime;
            try
            {
                dbContext.SaveChanges();
                return(1);
            }
            catch (Exception)
            {
                return(0);
            }
        }
Example #4
0
        public ActionResult Create(bacsy doctor)
        {
            doctor.updatetime        = DateTime.Today;
            doctor.trangthai         = true;
            ViewBag.getListHospitals = new HospitalModels().getListHospitals();
            ViewBag.getListTinhs     = new TinhModels().getListTinhs();
            ViewBag.getListXas       = new XaModels().getListXas();
            ViewBag.getListHuyens    = new HuyenModels().getListHuyens();
            ViewBag.id = new DoctorModels().createDoctorId();

            if (ModelState.IsValid)
            {
                if (new DoctorModels().insert(doctor))
                {
                    ViewBag.Susscess = "Thêm người dùng thành công";
                    return(View());
                }
                ModelState.AddModelError("", "Không thể thêm bản ghi");
                return(View());
            }

            return(View());
        }
Example #5
0
        public ActionResult Edit(bacsy doctor)
        {
            ViewBag.getListHospitals = new HospitalModels().getListHospitals();
            ViewBag.getListTinhs     = new TinhModels().getListTinhs();
            ViewBag.getListXas       = new XaModels().getListXas();
            ViewBag.getListHuyens    = new HuyenModels().getListHuyens();

            if ((Session[Constants.SESSION_GROUPID] as string) == Constants.G_MANAGER &&
                doctor.idbv.Trim() != (Session[Constants.SESSION_HOSPITAL_ID] as string).Trim())
            {
                return(RedirectToAction(actionName: "NotAuthorize", controllerName: "Login"));
            }
            doctor.updatetime = DateTime.Now;
            if (new DoctorModels().update(doctor) == 1)
            {
                return(RedirectToAction("Details", new { @id = doctor.idbsy.Trim() }));
            }
            else
            {
                ViewBag.getListHospitals = new HospitalModels().getListHospitals();
                return(View());
            }
        }
Example #6
0
        public ActionResult Login(string username, string pass, string group)
        {
            if (ModelState.IsValid)
            {
                var account = new LoginModels().CheckAccount(username, pass, group);

                if (account != null)
                {
                    if (group == Constants.G_ADMIN)
                    {
                        user user = account as user;
                        Session[Constants.SESSION_ID]            = user.idnd;
                        Session[Constants.SESSION_GROUPID]       = Constants.G_ADMIN;
                        Session[Constants.SESSION_NAME]          = user.tennd;
                        Session[Constants.SESSION_HOSPITAL_ID]   = user.idbv;
                        Session[Constants.SESSION_HOSPITAL_NAME] = user.benhvien.tenbv;
                        return(RedirectToAction("Index", "Admin"));
                    }
                    if (group == Constants.G_MANAGER)
                    {
                        user user = account as user;
                        if (user.trangthai == false || user.trangthai == null)
                        {
                            ViewBag.Err1 = "Tài Khoản đang bị khóa";
                            return(View("Index"));
                        }
                        Session[Constants.SESSION_ID]            = user.idnd;
                        Session[Constants.SESSION_GROUPID]       = Constants.G_MANAGER;
                        Session[Constants.SESSION_NAME]          = user.tennd;
                        Session[Constants.SESSION_HOSPITAL_ID]   = user.idbv;
                        Session[Constants.SESSION_HOSPITAL_NAME] = user.benhvien.tenbv;
                        return(RedirectToAction("Index", "Manager"));
                    }
                    if (group == Constants.G_STAFF)
                    {
                        user user = account as user;
                        if (user.trangthai == false || user.trangthai == null)
                        {
                            ViewBag.Err1 = "Tài Khoản đang bị khóa";
                            return(View("Index"));
                        }
                        Session[Constants.SESSION_ID]            = user.idnd;
                        Session[Constants.SESSION_GROUPID]       = Constants.G_STAFF;
                        Session[Constants.SESSION_NAME]          = user.tennd;
                        Session[Constants.SESSION_HOSPITAL_ID]   = user.idbv;
                        Session[Constants.SESSION_HOSPITAL_NAME] = user.benhvien.tenbv;
                        return(RedirectToAction("Index", "Staff"));
                    }
                    if (group == Constants.G_PATIENT)
                    {
                        benhnhan patient = account as benhnhan;
                        if (patient.trangthai == false || patient.trangthai == null)
                        {
                            ViewBag.Err1 = "Tài Khoản đang bị khóa";
                            return(View("Index"));
                        }
                        Session[Constants.SESSION_ID]            = patient.idbn;
                        Session[Constants.SESSION_GROUPID]       = Constants.G_PATIENT;
                        Session[Constants.SESSION_NAME]          = patient.tenbn;
                        Session[Constants.SESSION_HOSPITAL_NAME] = patient.benhvien.tenbv;
                        return(RedirectToAction("Index", "Patient"));
                    }
                    if (group == Constants.G_DOCTOR)
                    {
                        bacsy doctor = account as bacsy;
                        if (doctor.trangthai == false || doctor.trangthai == null)
                        {
                            ViewBag.Err1 = "Tài Khoản đang bị khóa";
                            return(View("Index"));
                        }
                        Session[Constants.SESSION_ID]            = doctor.idbsy;
                        Session[Constants.SESSION_GROUPID]       = Constants.G_DOCTOR;
                        Session[Constants.SESSION_NAME]          = doctor.tenbs;
                        Session[Constants.SESSION_HOSPITAL_ID]   = doctor.idbv;
                        Session[Constants.SESSION_HOSPITAL_NAME] = doctor.benhvien.tenbv;
                        return(RedirectToAction("Index", "Doctor"));
                    }
                }
            }
            ViewBag.Err1 = "Sai mật khẩu hoặc tài khoản";
            ViewBag.Err2 = "Kiểm tra quyền người dùng";
            return(View("Index"));
        }