示例#1
0
        private void AutoFindLastExamandFetchIntoControls(string patientID, string sobhyt)
        {
            try
            {
                if (!Utility.CheckLockObject(m_strMaluotkham, "Tiếp đón", "TD"))
                    return;
                //Trả lại mã lượt khám nếu chưa được dùng đến
                new Update(KcbDmucLuotkham.Schema)
                       .Set(KcbDmucLuotkham.Columns.TrangThai).EqualTo(0)
                       .Set(KcbDmucLuotkham.Columns.UsedBy).EqualTo(DBNull.Value)
                       .Set(KcbDmucLuotkham.Columns.StartTime).EqualTo(DBNull.Value)
                       .Set(KcbDmucLuotkham.Columns.EndTime).EqualTo(null)
                       .Where(KcbDmucLuotkham.Columns.MaLuotkham).IsEqualTo(Utility.Int32Dbnull(m_strMaluotkham, "-1"))
                       .And(KcbDmucLuotkham.Columns.TrangThai).IsEqualTo(1)
                       .And(KcbDmucLuotkham.Columns.UsedBy).IsEqualTo(globalVariables.UserName)
                       .And(KcbDmucLuotkham.Columns.Nam).IsEqualTo(globalVariables.SysDate.Year).Execute();
                ;

                SqlQuery sqlQuery = new Select().From(KcbLuotkham.Schema)
                    .Where(KcbLuotkham.Columns.IdBenhnhan).IsEqualTo(patientID);
                if (!string.IsNullOrEmpty(sobhyt))
                {
                    sqlQuery.And(KcbLuotkham.Columns.MatheBhyt).IsEqualTo(sobhyt);
                }
                sqlQuery.OrderDesc(KcbLuotkham.Columns.NgayTiepdon);

                var objLuotkham = sqlQuery.ExecuteSingle<KcbLuotkham>();
                if (objLuotkham != null)
                {
                    txtMaBN.Text = patientID;
                    txtMaLankham.Text = Utility.sDbnull(objLuotkham.MaLuotkham);
                    m_strMaluotkham = objLuotkham.MaLuotkham;
                    m_enAction = action.Update;
                    AllowTextChanged = false;
                    LoadThongtinBenhnhan();
                    CanhbaoInphoi();
                    LaydanhsachdangkyKCB();
                    string ngay_kham = globalVariables.SysDate.ToString("dd/MM/yyyy");
                    if (!NotPayment(txtMaBN.Text.Trim(), ref ngay_kham))//Đã thanh toán-->Kiểm tra ngày hẹn xem có được phép khám tiếp
                    {

                        KcbChandoanKetluan _Info = new Select().From(KcbChandoanKetluan.Schema).Where(KcbChandoanKetluan.MaLuotkhamColumn).IsEqualTo(objLuotkham.MaLuotkham).ExecuteSingle<KcbChandoanKetluan>();
                        if (_Info != null && _Info.SongayDieutri != null)
                        {
                            int SoNgayDieuTri = 0;
                            if (_Info.SongayDieutri.Value.ToString() == "")
                            {
                                SoNgayDieuTri = 0;
                            }
                            else
                            {
                                SoNgayDieuTri = _Info.SongayDieutri.Value;
                            }
                            DateTime ngaykhamcu = _Info.NgayTao.Value; ;
                            DateTime ngaykhammoi = globalVariables.SysDate;
                            TimeSpan songay = ngaykhammoi - ngaykhamcu;

                            int kt = songay.Days;
                            int kt1 = SoNgayDieuTri - kt;
                            kt1 = Utility.Int32Dbnull(kt1);
                            // nếu khoảng cách từ lần khám trước đến ngày hiện tại lớn hơn ngày điều trị.
                            if (kt >= SoNgayDieuTri)
                            {
                                m_enAction = action.Add;
                                SinhMaLanKham();
                                //txtTongChiPhiKham.Text = "0";
                                m_dataDataRegExam.Rows.Clear();
                                txtKieuKham.Select();
                            }
                            else if (kt < SoNgayDieuTri)
                            {
                                DialogResult dialogResult =
                                    MessageBox.Show(
                                        "Bác Sỹ hẹn :  " + SoNgayDieuTri + "ngày" + "\nNgày khám gần nhất:  " +
                                        ngaykhamcu + "\nCòn: " + kt1 + " ngày nữa mới được tái khám" +
                                        "\nBạn có muốn tiếp tục thêm lần khám ", "Thông Báo", MessageBoxButtons.YesNo);

                                if (dialogResult == DialogResult.Yes)
                                {
                                    m_enAction = action.Add;
                                    SinhMaLanKham();
                                    //Reset dịch vụ KCB
                                    //txtTongChiPhiKham.Text = "0";
                                    m_dataDataRegExam.Rows.Clear();
                                    txtKieuKham.Select();
                                }
                                else if (dialogResult == DialogResult.No)
                                {
                                    ClearControl();
                                    return;
                                }
                            }
                        }
                        else//Chưa thăm khám-->Để nguyên trạng thái cập nhật
                        {
                        }
                    }
                    else//Còn lần khám chưa thanh toán-->Kiểm tra
                    {
                        //nếu là ngày hiện tại thì đặt về trạng thái sửa
                        if (ngay_kham == "NOREG" || ngay_kham == globalVariables.SysDate.ToString("dd/MM/yyyy"))
                        {
                            //LoadThongtinBenhnhan();
                            if (ngay_kham == "NOREG")//Bn chưa đăng ký phòng khám nào cả.
                            {
                                //Nếu ngày hệ thống=Ngày đăng ký gần nhất-->Sửa
                                if (globalVariables.SysDate.ToString("dd/MM/yyyy") == dtpInputDate.Value.ToString("dd/MM/yyyy"))
                                {
                                    m_enAction = action.Update;

                                    Utility.ShowMsg(
                                       "Bệnh nhân vừa được đăng ký ngày hôm nay nên hệ thống sẽ chuyển về chế độ Sửa thông tin. Nhấn OK để bắt đầu sửa");
                                    //LaydanhsachdangkyKCB();
                                    txtTEN_BN.Select();
                                }
                                else//Thêm lần khám cho ngày mới
                                {
                                    m_enAction = action.Add;
                                    SinhMaLanKham();
                                    //Reset dịch vụ KCB
                                    //txtTongChiPhiKham.Text = "0";
                                    m_dataDataRegExam.Rows.Clear();
                                    txtKieuKham.Select();
                                }
                            }
                            else//Quay về trạng thái sửa
                            {
                                m_enAction = action.Update;

                                Utility.ShowMsg(
                                   "Bệnh nhân vừa được đăng ký ngày hôm nay nên hệ thống sẽ chuyển về chế độ Sửa thông tin. Nhấn OK để bắt đầu sửa");
                                //LaydanhsachdangkyKCB();
                                txtTEN_BN.Select();
                            }
                        }
                        else //Không cho phép thêm lần khám khác nếu chưa thanh toán lần khám của ngày hôm trước
                        {
                            Utility.ShowMsg(
                                "Bệnh nhân đang có lần khám chưa được thanh toán. Cần thanh toán hết các lần đến khám bệnh của Bệnh nhân trước khi thêm lần khám mới. Nhấn OK để hệ thống chuyển về trạng thái thêm mới Bệnh nhân");
                            cmdThemMoiBN_Click(cmdThemMoiBN, new EventArgs());
                        }
                    }
                    StatusControl();

                    ModifyCommand();
                    txtKieuKham.SetCode("-1");
                    txtPhongkham.SetCode("-1");
                    if (PropertyLib._KCBProperties.GoMaDvu)
                    {
                        txtExamtypeCode.SelectAll();
                        txtExamtypeCode.Focus();
                    }
                    else
                    {
                        txtKieuKham.SelectAll();
                        txtKieuKham.Focus();
                    }
                }
                else
                {
                    Utility.ShowMsg(
                        "Bệnh nhân này chưa có lần khám nào-->Có thể bị lỗi dữ liệu. Đề nghị liên hệ với VNS để được giải đáp");
                }
            }
            catch (Exception ex)
            {
                Utility.ShowMsg("AutoFindLastExam().Exception-->" + ex.Message);
            }
            finally
            {
                SetActionStatus();
                AllowTextChanged = true;
            }
        }
示例#2
0
        /// <summary>
        /// Loads the grid.
        /// </summary>
        private void LoadGrid()
        {
            if(String.IsNullOrEmpty(tableName))
                throw new ArgumentException("No tableName property set - please be sure to set the name of the table or view you'd like to see", tableName);

            DecideSortDirection();

            //load the data
            DataProvider provider = DataService.GetInstance(ProviderName);
            SqlQuery q = new Select(provider).From(tableName);

            //set the select list
            StringBuilder selectList = new StringBuilder("*");
            if(!String.IsNullOrEmpty(columnList))
            {
                selectList = new StringBuilder();
                for(int i = 0; i < colList.Count; i++)
                {
                    selectList.Append(colList[i].ToString().Trim());
                    if(i + 1 < colList.Count)
                        selectList.Append(",");
                }
            }

            q.SelectColumnList = selectList.ToString().Split(new[] {','}, StringSplitOptions.RemoveEmptyEntries);

            //sorting
            if(!String.IsNullOrEmpty(sortBy))
            {
                TableSchema.TableColumn col = provider.GetTableSchema(tableName, TableType.Table).GetColumn(sortBy);
                if(col != null && col.MaxLength < 2048 && col.DataType != DbType.Binary && col.DataType != DbType.Byte)
                {
                    if(String.IsNullOrEmpty(sortDirection) || sortDirection.Trim() == SqlFragment.ASC.Trim())
                        q.OrderAsc(sortBy);
                    else
                        q.OrderDesc(sortBy);
                }
            }

            //paging
            if(pageSize > 0)
            {
                q.Paged(pageIndex, pageSize);
                ddlPages.SelectedValue = pageIndex.ToString();
            }

            //honor logical deletes
            q.CheckLogicalDelete();

            //where
            if(!String.IsNullOrEmpty(whereExpression))
                q.WhereExpression(whereExpression);

            SqlQueryBridge.AddLegacyWhereCollection(q, whereCollection);

            DataSet ds = q.ExecuteDataSet();

            if(ds.Tables.Count > 0)
                dataSource = ds.Tables[0];
            else
                throw new Exception("Bad query - no data returned. Did you set the correct provider?");

            EnsureTotals(q);
            //set the buttons
            SetPagingButtonState();
            //create a table
            BuildRows();
        }
        private void AutoFindLastExamandFetchIntoControls(string patientID, string sobhyt)
        {
            try
            {
                if (!Utility.CheckLockObject(m_strMaluotkham, "Tiếp đón", "TD"))
                    return;
                //Trả lại mã lượt khám nếu chưa được dùng đến
                new Update(KcbDmucLuotkham.Schema)
                       .Set(KcbDmucLuotkham.Columns.TrangThai).EqualTo(0)
                       .Set(KcbDmucLuotkham.Columns.UsedBy).EqualTo(DBNull.Value)
                       .Set(KcbDmucLuotkham.Columns.StartTime).EqualTo(DBNull.Value)
                       .Set(KcbDmucLuotkham.Columns.EndTime).EqualTo(null)
                       .Where(KcbDmucLuotkham.Columns.MaLuotkham).IsEqualTo(Utility.Int32Dbnull(m_strMaluotkham, "-1"))
                       .And(KcbDmucLuotkham.Columns.TrangThai).IsEqualTo(1)
                       .And(KcbDmucLuotkham.Columns.UsedBy).IsEqualTo(globalVariables.UserName)
                       .And(KcbDmucLuotkham.Columns.Nam).IsEqualTo(globalVariables.SysDate.Year).Execute();
                ;

                SqlQuery sqlQuery = new Select().From(KcbLuotkham.Schema)
                    .Where(KcbLuotkham.Columns.IdBenhnhan).IsEqualTo(patientID);
                if (!string.IsNullOrEmpty(sobhyt))
                {
                    sqlQuery.And(KcbLuotkham.Columns.MatheBhyt).IsEqualTo(sobhyt);
                }
                sqlQuery.OrderDesc(KcbLuotkham.Columns.NgayTiepdon);

                var objLuotkham = sqlQuery.ExecuteSingle<KcbLuotkham>();
                if (objLuotkham != null)
                {
                    txtMaBN.Text = patientID;
                    txtMaLankham.Text = Utility.sDbnull(objLuotkham.MaLuotkham);
                    m_strMaluotkham = objLuotkham.MaLuotkham;
                    m_enAction = action.Update;
                    AllowTextChanged = false;
                    LoadThongtinBenhnhan();
                    CanhbaoInphoi();
                    string ngay_kham = globalVariables.SysDate.ToString("dd/MM/yyyy");
                    //Nếu ngày hệ thống=Ngày đăng ký gần nhất-->Sửa
                    if (globalVariables.SysDate.ToString("dd/MM/yyyy") == dtpInputDate.Value.ToString("dd/MM/yyyy"))
                    {
                        m_enAction = action.Update;
                        Utility.ShowMsg(
                           "Bệnh nhân vừa được đăng ký ngày hôm nay nên hệ thống sẽ chuyển về chế độ Sửa thông tin. Nhấn OK để bắt đầu sửa");
                        //LaydanhsachdangkyKCB();
                        txtTEN_BN.Select();
                    }
                    else//Thêm lần khám cho ngày mới
                    {
                        m_enAction = action.Add;
                        SinhMaLanKham();
                        //Reset dịch vụ KCB
                        //txtTongChiPhiKham.Text = "0";
                        m_dataDataRegExam.Rows.Clear();

                    }
                    StatusControl();
                    ModifyCommand();
                }
                else
                {
                    Utility.ShowMsg(
                        "Bệnh nhân này chưa có lần khám nào-->Có thể bị lỗi dữ liệu. Đề nghị liên hệ với VMS để được giải đáp");
                }
            }
            catch (Exception ex)
            {
                Utility.ShowMsg("AutoFindLastExam().Exception-->" + ex.Message);
            }
            finally
            {
                SetActionStatus();
                AllowTextChanged = true;
            }
        }
示例#4
0
        /// <summary>
        /// Binds the grid.
        /// </summary>
        /// <param name="orderBy">The order by.</param>
        protected void BindGrid(string orderBy)
        {
            if(TableSchema != null && TableSchema.PrimaryKey != null)
            {
                SqlQuery query = new Select(TableSchema.Provider).From(TableSchema);

                if(!String.IsNullOrEmpty(_whereExpression))
                    query.WhereExpression(_whereExpression);

                if(_whereCollection != null)
                    SqlQueryBridge.AddLegacyWhereCollection(query, _whereCollection);

                string sortColumn = null;
                if(!String.IsNullOrEmpty(orderBy))
                    sortColumn = orderBy;
                else if(ViewState[ORDER_BY] != null)
                    sortColumn = (string)ViewState[ORDER_BY];

                int colIndex = -1;

                if(!String.IsNullOrEmpty(sortColumn))
                {
                    ViewState.Add(ORDER_BY, sortColumn);
                    TableSchema.TableColumn col = TableSchema.GetColumn(sortColumn);
                    if(col == null)
                    {
                        for(int i = 0; i < TableSchema.Columns.Count; i++)
                        {
                            TableSchema.TableColumn fkCol = TableSchema.Columns[i];
                            if(fkCol.IsForeignKey && !String.IsNullOrEmpty(fkCol.ForeignKeyTableName))
                            {
                                TableSchema.Table fkTbl = DataService.GetSchema(fkCol.ForeignKeyTableName, ProviderName, TableType.Table);
                                if(fkTbl != null)
                                {
                                    col = Utility.GetDisplayTableColumn(fkTbl);
                                    colIndex = i;
                                    break;
                                }
                            }
                        }
                    }
                    if(col != null && col.MaxLength < 2048)
                    {
                        string sortAlias = colIndex > -1 ? SqlFragment.JOIN_PREFIX + colIndex : col.ColumnName;
                        if(ViewState[SORT_DIRECTION] == null || ((string)ViewState[SORT_DIRECTION]) == SqlFragment.ASC)
                        {
                            query.OrderAsc(sortAlias);
                            //query.OrderBy = colIndex > -1 ? OrderBy.Asc(col, SqlFragment.JOIN_PREFIX + colIndex) : OrderBy.Asc(col);
                            ViewState[SORT_DIRECTION] = SqlFragment.ASC;
                        }
                        else
                        {
                            query.OrderDesc(sortAlias);
                            //query.OrderBy = colIndex > -1 ? OrderBy.Desc(col, SqlFragment.JOIN_PREFIX + colIndex) : OrderBy.Desc(col);
                            ViewState[SORT_DIRECTION] = SqlFragment.DESC;
                        }
                    }
                }

                DataTable dt = query.ExecuteJoinedDataSet().Tables[0];
                grid.DataSource = dt;
                grid.AutoGenerateColumns = false;
                grid.Columns.Clear();

                int columnOffset = 0;
                string dataKey = TableSchema.PrimaryKey.ColumnName;
                if(Utility.IsMappingTable(TableSchema) && dt.Columns.Count > TableSchema.Columns.Count)
                {
                    columnOffset = 1;
                    dataKey = dt.Columns[0].ColumnName;
                }

                grid.DataKeyNames = new[] {dataKey};

                CommandField link = new CommandField
                                        {
                                            ShowEditButton = true,
                                            EditText = "Edit"
                                        };

                grid.Columns.Insert(0, link);

                for(int i = 0; i < TableSchema.Columns.Count; i++)
                {
                    int dtColIndex = i + columnOffset;

                    BoundField field = new BoundField
                                           {
                                               DataField = dt.Columns[dtColIndex].ColumnName,
                                               SortExpression = dt.Columns[dtColIndex].ColumnName, HtmlEncode = false
                                           };
                    //field.SortExpression = Utility.QualifyColumnName(schema.Name, dt.Columns[i].ColumnName, schema.Provider);
                    TableSchema.TableColumn col = TableSchema.Columns[i];
                    if(col.IsForeignKey)
                    {
                        TableSchema.Table fkSchema = col.ForeignKeyTableName == null
                                                         ? DataService.GetForeignKeyTable(col, TableSchema)
                                                         : DataService.GetSchema(col.ForeignKeyTableName, ProviderName, TableType.Table);

                        if(fkSchema != null)
                            field.HeaderText = fkSchema.DisplayName;
                    }
                    else
                        field.HeaderText = col.DisplayName;

                    if(!Utility.IsAuditField(dt.Columns[dtColIndex].ColumnName) && !listHiddenGridColumns.Contains(dt.Columns[dtColIndex].ColumnName.ToLower()))
                        grid.Columns.Add(field);
                }

                grid.DataBind();
            }
        }
        private void AutoFindLastExamandFetchIntoControls(string patientID, string sobhyt)
        {
            try
            {
                if (!Utility.CheckLockObject(m_strMaluotkham, "Tiếp đón", "TD"))
                    return;
                //Trả lại mã lượt khám nếu chưa được dùng đến
                new Update(KcbDmucLuotkham.Schema)
                       .Set(KcbDmucLuotkham.Columns.TrangThai).EqualTo(0)
                       .Set(KcbDmucLuotkham.Columns.UsedBy).EqualTo(DBNull.Value)
                       .Set(KcbDmucLuotkham.Columns.StartTime).EqualTo(DBNull.Value)
                       .Set(KcbDmucLuotkham.Columns.EndTime).EqualTo(null)
                       .Where(KcbDmucLuotkham.Columns.MaLuotkham).IsEqualTo(Utility.Int32Dbnull(m_strMaluotkham, "-1"))
                       .And(KcbDmucLuotkham.Columns.TrangThai).IsEqualTo(1)
                       .And(KcbDmucLuotkham.Columns.UsedBy).IsEqualTo(globalVariables.UserName)
                       .And(KcbDmucLuotkham.Columns.Nam).IsEqualTo(globalVariables.SysDate.Year).Execute();
                ;

                SqlQuery sqlQuery = new Select().From(KcbLuotkham.Schema)
                    .Where(KcbLuotkham.Columns.IdBenhnhan).IsEqualTo(patientID);
                if (!string.IsNullOrEmpty(sobhyt))
                {
                    sqlQuery.And(KcbLuotkham.Columns.MatheBhyt).IsEqualTo(sobhyt);
                }
                sqlQuery.OrderDesc(KcbLuotkham.Columns.NgayTiepdon);

                var objLuotkham = sqlQuery.ExecuteSingle<KcbLuotkham>();
                if (objLuotkham != null)
                {
                    txtMaBN.Text = patientID;
                    txtMaLankham.Text = Utility.sDbnull(objLuotkham.MaLuotkham);
                    m_strMaluotkham = objLuotkham.MaLuotkham;
                    m_enAct = action.FirstOrFinished;
                    AllowTextChanged = false;
                    LoadThongtinBenhnhan();
                    ModifyCommand();
                }
                else
                {
                    Utility.ShowMsg("Không tìm thấy thông tin bệnh nhân. Đề nghị liên hệ với VMS để được giải đáp");
                }
            }
            catch (Exception ex)
            {
                Utility.ShowMsg("AutoFindLastExam().Exception-->" + ex.Message);
            }
            finally
            {
                AllowTextChanged = true;
            }
        }
示例#6
0
        public List<TThuockho> GetObjThuocKhoCollection(int id_kho, int id_thuoc, int id_thuockho, int so_luong)
        {
            string _value = THU_VIEN_CHUNG.Laygiatrithamsohethong("KIEU_XUATTHUOC", "STT", false);

            SqlQuery sqlQuery;

            SqlQuery myquery = new Select().From(TThuockho.Schema)
             .Where(TThuockho.Columns.IdKho).IsEqualTo(id_kho)
             .And(TThuockho.Columns.NgayHethan).IsGreaterThanOrEqualTo(globalVariables.SysDate.Date)
             .And(TThuockho.Columns.IdThuoc).IsEqualTo(id_thuoc)
             .And(TThuockho.Columns.SoLuong).IsGreaterThan(0);
            if (id_thuockho > 0)
                myquery.And(TThuockho.Columns.IdThuockho).IsEqualTo(id_thuockho);
            switch (_value)
            {
                case "FIFO":
                    myquery.OrderAsc(TThuockho.Columns.NgayNhap);
                    myquery.OrderAsc(TThuockho.Columns.NgayHethan);
                    break;
                case "LIFO":
                    myquery.OrderDesc(TThuockho.Columns.NgayNhap);
                    myquery.OrderAsc(TThuockho.Columns.NgayHethan);
                    break;
                case "EXP":
                    myquery.OrderAsc(TThuockho.Columns.NgayHethan);
                    myquery.OrderAsc(TThuockho.Columns.NgayNhap);
                    break;
                case "STT":
                    myquery.OrderAsc(TThuockho.Columns.SttBan);
                    myquery.OrderAsc(TThuockho.Columns.NgayHethan);
                    break;
                default:
                    break;

            }
            //Khi chưa có phần cấu hình thì theo điều kiện phía dưới
            //myquery.OrderAsc(TThuockho.Columns.SttBan);
            //myquery.OrderAsc(TThuockho.Columns.NgayHethan);
            TThuockhoCollection lstAll = myquery.ExecuteAsCollection<TThuockhoCollection>();
            //Lấy số lượng ảo của các đơn thuốc có thuốc chưa được xác nhận
            DataTable dtPresDetail = SPs.TLaythuocTrongkhoKedon(id_kho, id_thuoc, so_luong).GetDataSet().Tables[0];
            List<TThuockho> lstItems = new List<TThuockho>();
            int iSoLuongConLai = 0;
            int iSoLuongDonThuoc = so_luong;
            int iSoLuongTru = 0;
            int soluongAo = 0;
            foreach (TThuockho item in lstAll)
            {
                DataRow[] arrDR = dtPresDetail.Select(TThuockho.Columns.IdThuockho + "=" + item.IdThuockho.ToString());
                if (arrDR.Length > 0)
                    soluongAo = Utility.Int32Dbnull(arrDR.CopyToDataTable().Compute("SUM(" + KcbDonthuocChitiet.Columns.SoLuong + ")", "1=1"), 0);
                else
                    soluongAo = 0;
                //Tính số lượng kho còn lại
                iSoLuongConLai = item.SoLuong - soluongAo;
                if (iSoLuongConLai >= iSoLuongDonThuoc)
                {
                    iSoLuongTru = iSoLuongConLai - iSoLuongDonThuoc;
                    item.SoLuong = iSoLuongDonThuoc;
                    if (item.SoLuong > 0)
                        lstItems.Add(item);
                    break;
                }
                else//Số lượng kho < số lượng thuốc
                {
                    //Lượng nhỏ hơn
                    iSoLuongTru = iSoLuongDonThuoc - iSoLuongConLai;
                    iSoLuongDonThuoc = iSoLuongTru;
                    item.SoLuong = iSoLuongConLai;
                    if (item.SoLuong > 0)
                        lstItems.Add(item);
                }
            }
            return lstItems;
        }