public IEnumerable <CPhieuDKKhamModel> getDSPhieuDKKhamByDS(string maNV)
        {
            NhanVien           nv               = (NhanVien)tc.getDSNhanVien().Where(x => x.MaNhanVien == maNV);
            LichKham           lk_nv_p          = (LichKham)tc.getDSLichKham().Where(x => x.NhanVienID == nv.IDNhanVien);
            List <PhieuDKKham> ds_pdkk_nv_phong = new List <PhieuDKKham>();

            foreach (PhieuDKKham a in tc.getDSPhieuDKKham())
            {
                List <CTDKPhongKham> dsDKPK = a.CTDKPhongKham.ToList();
                foreach (CTDKPhongKham b in dsDKPK)
                {
                    if (b.PhongKhamID == lk_nv_p.PhongKhamID)
                    {
                        ds_pdkk_nv_phong.Add(a);
                    }
                }
            }
            return(ds_pdkk_nv_phong.Select(x => new CPhieuDKKhamModel
            {
                IDPhieuDKKham = x.IDPhieuDKK,
                MaPhieuDKKham = x.MaPhieuDKK,
                NgayLap = x.NgayLap.Value.ToShortDateString(),

                MaBenhNhan = x.BenhNhan.MaBenhNhan.ToString(),
                TenBenhNhan = x.BenhNhan.HoTen.ToString(),
                NgaySinh = x.BenhNhan.NgaySinh.Value.ToShortDateString(),
                CMND = x.BenhNhan.CMND == null ? string.Empty : x.BenhNhan.CMND.ToString(),
                MaNhanVien = x.NhanVien.MaNhanVien.ToString(),
            }));
        }
Exemple #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            LichKham lichKham = db.LichKhams.Find(id);

            db.LichKhams.Remove(lichKham);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemple #3
0
        public void Xoa(string maLk)
        {
            LichKham a = Tim(maLk);

            if (a != null)
            {
                Xoa(a);
            }
        }
 public ActionResult Xacnhanlichhen([Bind(Include = "IDLichKham,ChuDe,MoTa,BatDau,KetThuc,TrangThai,ZoomInfo,KetQuaKham,IDNguoiDung,IDQuanTri")] LichKham lichKham)
 {
     if (ModelState.IsValid)
     {
         db.Entry(lichKham).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Kiemtralichhen", "Bacsi"));
     }
     ViewBag.IDNguoiDung = new SelectList(db.NguoiDungs, "IDNguoiDung", "HoTen", lichKham.IDNguoiDung);
     ViewBag.IDQuanTri   = new SelectList(db.QuanTris, "IDQuanTri", "TaiKhoan", lichKham.IDQuanTri);
     return(View(lichKham));
 }
Exemple #5
0
        public ActionResult Create([Bind(Include = "IDLichKham,ChuDe,MoTa,BatDau,KetThuc,TrangThai,ZoomInfo,KetQuaKham,IDNguoiDung,IDQuanTri")] LichKham lichKham)
        {
            if (ModelState.IsValid)
            {
                db.LichKhams.Add(lichKham);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.IDNguoiDung = new SelectList(db.NguoiDungs, "IDNguoiDung", "HoTen", lichKham.IDNguoiDung);
            ViewBag.IDQuanTri   = new SelectList(db.QuanTris, "IDQuanTri", "TaiKhoan", lichKham.IDQuanTri);
            return(View(lichKham));
        }
        private void CommandBinding_Executed_SuaLich(object sender, ExecutedRoutedEventArgs e)
        {
            LichKham a = new LichKham();

            a.MaLichKham  = txtMaLK.Text;
            a.NhanVienID  = cboNhanVien.SelectedValue == null ? 0 : int.Parse(cboNhanVien.SelectedValue.ToString());
            a.PhongKhamID = cboPhongKham.SelectedValue == null ? 0 : int.Parse(cboPhongKham.SelectedValue.ToString());
            a.CaTrucID    = cboCaTruc.SelectedValue == null ? 0 : int.Parse(cboCaTruc.SelectedValue.ToString());
            a.Ngay        = DateTime.Parse(dpNgay.Text.ToString());
            xl.Sua(a);

            getDS();
        }
Exemple #7
0
        public void Sua(LichKham a)
        {
            LichKham b = Tim(a.MaLichKham);

            if (b != null)
            {
                b.MaLichKham = a.MaLichKham;
                b.NhanVienID = a.NhanVienID;
                //b.PhongKhamID = a.PhongKhamID;
                b.CaTrucID = a.CaTrucID;
                b.Ngay     = a.Ngay;
                tc.capnhat();
            }
        }
Exemple #8
0
        // GET: Admin/LichKhams/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            LichKham lichKham = db.LichKhams.Find(id);

            if (lichKham == null)
            {
                return(HttpNotFound());
            }
            return(View(lichKham));
        }
Exemple #9
0
        // GET: Admin/LichKhams/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            LichKham lichKham = db.LichKhams.Find(id);

            if (lichKham == null)
            {
                return(HttpNotFound());
            }
            ViewBag.IDNguoiDung = new SelectList(db.NguoiDungs, "IDNguoiDung", "HoTen", lichKham.IDNguoiDung);
            ViewBag.IDQuanTri   = new SelectList(db.QuanTris, "IDQuanTri", "TaiKhoan", lichKham.IDQuanTri);
            return(View(lichKham));
        }
        // GET: Lichkham/Edit/5
        public ActionResult Xacnhanlichhen(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            LichKham lichKham = db.LichKhams.Find(id);

            if (lichKham == null)
            {
                return(HttpNotFound());
            }
            // NguoiDung n = new NguoiDung();
            ViewBag.IDNguoiDung = new SelectList(db.NguoiDungs.Where(x => x.IDNguoiDung == lichKham.IDNguoiDung), "IDNguoiDung", "HoTen", lichKham.IDNguoiDung);
            ViewBag.IDQuanTri   = new SelectList(db.QuanTris.Where(x => x.IDQuanTri == lichKham.IDQuanTri), "IDQuanTri", "HoTen", lichKham.IDQuanTri);
            return(View(lichKham));
        }
Exemple #11
0
        private void dgLichKham_CellLostFocus(object sender, SourceGrid2.PositionCancelEventArgs e)
        {
            if (e.Position.Column < 3 || e.Position.Row < 2)
            {
                return;
            }
            SourceGrid2.Cells.Real.Cell cell = e.Cell as SourceGrid2.Cells.Real.Cell;
            object value    = cell.Value;
            string strValue = value == null ? string.Empty : value.ToString().Trim();

            if (_currentValue == strValue)
            {
                return;
            }

            LichKham lichKham = cell.Tag as LichKham;

            if (lichKham == null)
            {
                lichKham             = new LichKham();
                lichKham.Ngay        = Convert.ToDateTime(dgLichKham[e.Position.Row, 0].Tag);
                lichKham.Type        = (int)GetLoaiLichKham(e.Position.Column - 1);
                lichKham.Value       = strValue;
                lichKham.CreatedDate = DateTime.Now;
                lichKham.CreatedBy   = Guid.Parse(Global.UserGUID);
            }
            else
            {
                lichKham.Value       = strValue;
                lichKham.UpdatedDate = DateTime.Now;
                lichKham.UpdatedBy   = Guid.Parse(Global.UserGUID);
            }

            Result result = LichKhamBus.InsertLichKham(lichKham);

            if (result.IsOK)
            {
                cell.Tag = lichKham;
            }
            else
            {
                MsgBox.Show(Application.ProductName, result.GetErrorAsString("LichKhamBus.InsertLichKham"), IconType.Error);
                Utility.WriteToTraceLog(result.GetErrorAsString("LichKhamBus.InsertLichKham"));
            }
        }
Exemple #12
0
        private void OnView()
        {
            SourceGrid2.Cells.Real.Cell cell = dgLichKham.FocusCell as SourceGrid2.Cells.Real.Cell;
            if (cell != null)
            {
                if (cell.Column < 3 || cell.Row < 2)
                {
                    return;
                }
                object value = cell.Value;
                _currentValue = value == null ? string.Empty : value.ToString().Trim();

                LichKham lichKham = cell.Tag as LichKham;
                if (lichKham == null)
                {
                    lichKham             = new LichKham();
                    lichKham.Ngay        = Convert.ToDateTime(dgLichKham[cell.Row, 0].Tag);
                    lichKham.Type        = (int)GetLoaiLichKham(cell.Column - 1);
                    lichKham.Value       = _currentValue;
                    lichKham.CreatedDate = DateTime.Now;
                    lichKham.CreatedBy   = Guid.Parse(Global.UserGUID);
                }
                else
                {
                    lichKham.Value       = _currentValue;
                    lichKham.UpdatedDate = DateTime.Now;
                    lichKham.UpdatedBy   = Guid.Parse(Global.UserGUID);
                }

                Result result = LichKhamBus.InsertLichKham(lichKham);
                if (result.IsOK)
                {
                    cell.Tag = lichKham;
                }
                else
                {
                    MsgBox.Show(Application.ProductName, result.GetErrorAsString("LichKhamBus.InsertLichKham"), IconType.Error);
                    Utility.WriteToTraceLog(result.GetErrorAsString("LichKhamBus.InsertLichKham"));
                }
            }

            DisplayAsThread();
        }
Exemple #13
0
        private void dgLichKham_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Delete && AllowEdit && dgLichKham.Selection != null)
            {
                List <SourceGrid2.Cells.Real.Cell> deletedCells = new List <SourceGrid2.Cells.Real.Cell>();
                foreach (SourceGrid2.Cells.Real.Cell cell in dgLichKham.Selection.GetCells())
                {
                    if (cell.Column < 3 || cell.Row < 2 || cell.Value == null ||
                        cell.Value.ToString().Trim() == string.Empty)
                    {
                        continue;
                    }

                    deletedCells.Add(cell);
                }

                foreach (SourceGrid2.Cells.Real.Cell cell in deletedCells)
                {
                    LichKham lichKham = cell.Tag as LichKham;
                    if (lichKham == null)
                    {
                        continue;
                    }
                    lichKham.UpdatedDate = DateTime.Now;
                    lichKham.UpdatedBy   = Guid.Parse(Global.UserGUID);
                    lichKham.Value       = string.Empty;

                    Result result = LichKhamBus.InsertLichKham(lichKham);
                    if (result.IsOK)
                    {
                        cell.Value = null;
                    }
                    else
                    {
                        MsgBox.Show(Application.ProductName, result.GetErrorAsString("LichKhamBus.InsertLichKham"), IconType.Error);
                        Utility.WriteToTraceLog(result.GetErrorAsString("LichKhamBus.InsertLichKham"));
                        return;
                    }
                }
            }

            dgLichKham.AutoSizeView(false);
        }
        private void CommandBinding_Executed_LapLich(object sender, ExecutedRoutedEventArgs e)
        {
            LichKham t = xl.Tim(txtMaLK.Text);

            if (t != null)
            {
                MessageBox.Show("Đã có lịch này trong CSDL!");
                return;
            }

            LichKham a = new LichKham();

            a.MaLichKham  = txtMaLK.Text;
            a.NhanVienID  = cboNhanVien.SelectedValue == null ? 0 : int.Parse(cboNhanVien.SelectedValue.ToString());
            a.PhongKhamID = cboPhongKham.SelectedValue == null ? 0 : int.Parse(cboPhongKham.SelectedValue.ToString());
            a.CaTrucID    = cboCaTruc.SelectedValue == null ? 0 : int.Parse(cboCaTruc.SelectedValue.ToString());
            a.Ngay        = DateTime.Parse(dpNgay.Text.ToString());
            xl.Them(a);

            getDS();
        }
Exemple #15
0
        private void CommandBinding_Executed_DangNhap(object sender, ExecutedRoutedEventArgs e)
        {
            NhanVien nv = xlNV.TimMa(txtTenDangNhap.Text);

            if (nv == null)
            {
                MessageBox.Show("Tên đăng nhập hoặc Mật khẩu không đúng!",
                                "Thông báo", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }
            else
            {
                Byte[] passwordDB = new Byte[16];
                passwordDB = nv.MatKhau.ToArray();
                Byte[] passwordInput = (Byte[])Common.HashPassword(this.txtMatKhau.Password);
                if (passwordDB.SequenceEqual(passwordInput))
                {
                    if (nv.TrangThai == true && nv.HieuLuc == false)
                    {
                        MessageBox.Show("Tài khoản không còn hiệu lực!",
                                        "Thông báo", MessageBoxButton.OK, MessageBoxImage.Warning);
                        return;
                    }
                    else if (nv.TrangThai == false && nv.HieuLuc == true)
                    {
                        MessageBox.Show("Nhân viên đã nghỉ việc!",
                                        "Thông báo", MessageBoxButton.OK, MessageBoxImage.Warning);
                        return;
                    }
                    else if (nv.TrangThai == false && nv.HieuLuc == false)
                    {
                        MessageBox.Show("Nhân viên đã nghỉ việc!",
                                        "Thông báo", MessageBoxButton.OK, MessageBoxImage.Warning);
                        return;
                    }
                    else
                    {
                        // MessageBox.Show("Đăng nhập thành công.",
                        //"Thông báo", MessageBoxButton.OK, MessageBoxImage.Information);
                        Common.maNhanVien     = nv.MaNhanVien;
                        Common.nhanVienID     = nv.IDNhanVien;
                        Common.vaiTroNhanVien = nv.VaiTroID.Value;
                        if (nv.VaiTroID == Common.BacSi)
                        {
                            LichKham lk = xlLK.TimLichKhamCuaNV(nv, DateTime.Now);
                            if (lk != null)
                            {
                                Common.maPhongBacSi = lk.PhongKham.MaPhongKham.ToString();
                            }
                            else
                            {
                                MessageBox.Show("Hệ thống phát hiện bạn không có lịch khám hôm nay ! Vui lòng liên hệ người quản trị để cập nhật lịch làm việc !");
                                //return;   //ko cho login luôn
                            }
                        }
                        //LichKham lk = xlLK.TimLichKhamCuaNV(nv);
                        //if (lk != null)
                        //    Common.maPhongBacSi = lk.PhongKham.MaPhongKham.ToString();
                        //else
                        //    MessageBox.Show("null");

                        this.Close();
                    }
                }
                else
                {
                    MessageBox.Show("Nhập sai mật khẩu.",
                                    "Thông báo", MessageBoxButton.OK, MessageBoxImage.Warning);
                    return;
                }
            }
        }
Exemple #16
0
 public void Xoa(LichKham a)
 {
     tc.getDSLichKham().DeleteOnSubmit(a);
     tc.capnhat();
 }
Exemple #17
0
        private void FillData(List <LichKham> lichKhams)
        {
            DateTime dt          = new DateTime(_nam, _thang, 1);
            int      daysInMonth = DateTime.DaysInMonth(_nam, _thang);
            int      rowIndex    = 2;
            Color    foreColor   = Color.Black;
            Font     fontBold    = new Font("Tahoma", 9, FontStyle.Bold);
            Font     fontNormal  = new Font("Tahoma", 9);

            SourceGrid2.RectangleBorder borderRB  = new SourceGrid2.RectangleBorder(new SourceGrid2.Border(Color.Black), new SourceGrid2.Border(Color.Black));
            SourceGrid2.RectangleBorder borderRTB = new SourceGrid2.RectangleBorder(new SourceGrid2.Border(Color.Black), new SourceGrid2.Border(Color.Black));
            borderRTB.Top = new SourceGrid2.Border(Color.Black);

            bool isBorderTop = true;

            for (int i = 0; i < daysInMonth; i++)
            {
                string dateStr = string.Format("{0} {1}", dt.ToString("dd/MM"), Utility.GetDayOfWeek(dt));
                SourceGrid2.Cells.Real.Cell cell = NewCell(dateStr, Color.White, foreColor, ContentAlignment.MiddleCenter, fontBold, false, string.Empty);
                cell.Tag                = dt;
                cell.Border             = isBorderTop ? borderRTB : borderRB;
                dgLichKham[rowIndex, 0] = cell;

                Result result = BookingBus.GetBooking(dt);
                if (!result.IsOK)
                {
                    MsgBox.Show(Application.ProductName, result.GetErrorAsString("BookingBus.GetBooking"), IconType.Error);
                    Utility.WriteToTraceLog(result.GetErrorAsString("BookingBus.GetBooking"));
                }

                for (int col = 0; col < 14; col++)
                {
                    if (col < 2)
                    {
                        object value = null;
                        if (result.QueryResult != null)
                        {
                            List <Booking> bookingList = result.QueryResult as List <Booking>;
                            int            count       = GetPersonCount(bookingList, col);
                            if (count > 0)
                            {
                                value = count;
                            }
                        }

                        cell = NewNumericCell(value, Color.White, foreColor, ContentAlignment.MiddleCenter, fontNormal, false, string.Empty);
                    }
                    else
                    {
                        LichKham lichKham = GetLichKham(lichKhams, dt, GetLoaiLichKham(col));
                        bool     isEnable = AllowEdit;
                        object   value    = lichKham != null ? lichKham.Value : null;
                        cell     = NewCell(value, Color.White, foreColor, ContentAlignment.MiddleCenter, fontNormal, isEnable, string.Empty);
                        cell.Tag = lichKham;
                    }

                    cell.Border = isBorderTop ? borderRTB : borderRB;;
                    dgLichKham[rowIndex, col + 1] = cell;
                }

                isBorderTop = false;
                rowIndex++;

                if (dt.DayOfWeek == DayOfWeek.Sunday)
                {
                    isBorderTop = true;
                    if (i != 0 && i != daysInMonth - 1)
                    {
                        rowIndex++;
                    }
                }

                dt = dt.AddDays(1);
            }
        }
Exemple #18
0
        public static Result InsertLichKham(LichKham lichKham)
        {
            Result     result = new Result();
            MMOverride db     = null;

            try
            {
                db = new MMOverride();
                string desc = string.Empty;
                using (TransactionScope t = new TransactionScope(TransactionScopeOption.RequiresNew))
                {
                    //Insert
                    if (lichKham.LichKhamGUID == null || lichKham.LichKhamGUID == Guid.Empty)
                    {
                        lichKham.LichKhamGUID = Guid.NewGuid();
                        db.LichKhams.InsertOnSubmit(lichKham);
                        db.SubmitChanges();

                        //Tracking
                        desc += string.Format("- GUID: '{0}', Ngay: '{1}', Type: '{2}', Value: '{3}'",
                                              lichKham.LichKhamGUID.ToString(), lichKham.Ngay.ToString("dd/MM/yyyy"), lichKham.Type, lichKham.Value);

                        Tracking tk = new Tracking();
                        tk.TrackingGUID = Guid.NewGuid();
                        tk.TrackingDate = DateTime.Now;
                        tk.DocStaffGUID = Guid.Parse(Global.UserGUID);
                        tk.ActionType   = (byte)ActionType.Add;
                        tk.Action       = "Thêm thông tin lịch khám";
                        tk.Description  = desc;
                        tk.TrackingType = (byte)TrackingType.None;
                        tk.ComputerName = Utility.GetDNSHostName();
                        db.Trackings.InsertOnSubmit(tk);

                        db.SubmitChanges();
                    }
                    else //Update
                    {
                        LichKham lk = db.LichKhams.SingleOrDefault <LichKham>(l => l.LichKhamGUID == lichKham.LichKhamGUID);
                        if (lk != null)
                        {
                            lk.Value       = lichKham.Value;
                            lk.CreatedBy   = lichKham.CreatedBy;
                            lk.CreatedDate = lichKham.CreatedDate;
                            lk.DeletedBy   = lichKham.DeletedBy;
                            lk.DeletedDate = lichKham.DeletedDate;
                            lk.UpdatedBy   = lichKham.UpdatedBy;
                            lk.UpdatedDate = lichKham.UpdatedDate;
                            db.SubmitChanges();

                            //Tracking
                            desc += string.Format("- GUID: '{0}', Ngay: '{1}', Type: '{2}', Value: '{3}'",
                                                  lk.LichKhamGUID.ToString(), lk.Ngay.ToString("dd/MM/yyyy"), lk.Type, lk.Value);

                            Tracking tk = new Tracking();
                            tk.TrackingGUID = Guid.NewGuid();
                            tk.TrackingDate = DateTime.Now;
                            tk.DocStaffGUID = Guid.Parse(Global.UserGUID);
                            tk.ActionType   = (byte)ActionType.Edit;
                            tk.Action       = "Sửa thông tin lịch khám";
                            tk.Description  = desc;
                            tk.TrackingType = (byte)TrackingType.None;
                            tk.ComputerName = Utility.GetDNSHostName();
                            db.Trackings.InsertOnSubmit(tk);

                            db.SubmitChanges();
                        }
                    }

                    t.Complete();
                }
            }
            catch (System.Data.SqlClient.SqlException se)
            {
                result.Error.Code        = (se.Message.IndexOf("Timeout expired") >= 0) ? ErrorCode.SQL_QUERY_TIMEOUT : ErrorCode.INVALID_SQL_STATEMENT;
                result.Error.Description = se.ToString();
            }
            catch (Exception e)
            {
                result.Error.Code        = ErrorCode.UNKNOWN_ERROR;
                result.Error.Description = e.ToString();
            }
            finally
            {
                if (db != null)
                {
                    db.Dispose();
                    db = null;
                }
            }

            return(result);
        }
 public void Insert(LichKham o)
 {
     throw new NotImplementedException();
 }
Exemple #20
0
 public void Them(LichKham lk)
 {
     tc.getDSLichKham().InsertOnSubmit(lk);
     tc.capnhat();
 }