public KcbDanhsachBenhnhanCollection FetchAll()
 {
     KcbDanhsachBenhnhanCollection coll = new KcbDanhsachBenhnhanCollection();
     Query qry = new Query(KcbDanhsachBenhnhan.Schema);
     coll.LoadAndCloseReader(qry.ExecuteReader());
     return coll;
 }
        public KcbDanhsachBenhnhanCollection FetchByQuery(Query qry)
        {
            KcbDanhsachBenhnhanCollection coll = new KcbDanhsachBenhnhanCollection();

            coll.LoadAndCloseReader(qry.ExecuteReader());
            return(coll);
        }
        public KcbDanhsachBenhnhanCollection FetchAll()
        {
            KcbDanhsachBenhnhanCollection coll = new KcbDanhsachBenhnhanCollection();
            Query qry = new Query(KcbDanhsachBenhnhan.Schema);

            coll.LoadAndCloseReader(qry.ExecuteReader());
            return(coll);
        }
 public KcbDanhsachBenhnhanCollection FetchByQuery(Query qry)
 {
     KcbDanhsachBenhnhanCollection coll = new KcbDanhsachBenhnhanCollection();
     coll.LoadAndCloseReader(qry.ExecuteReader());
     return coll;
 }
 public KcbDanhsachBenhnhanCollection FetchByID(object IdBenhnhan)
 {
     KcbDanhsachBenhnhanCollection coll = new KcbDanhsachBenhnhanCollection().Where("id_benhnhan", IdBenhnhan).Load();
     return coll;
 }
        public KcbDanhsachBenhnhanCollection FetchByID(object IdBenhnhan)
        {
            KcbDanhsachBenhnhanCollection coll = new KcbDanhsachBenhnhanCollection().Where("id_benhnhan", IdBenhnhan).Load();

            return(coll);
        }
        private void UpdatePres(KcbDonthuocChitiet[] arrPresDetail)
        {
            Dictionary<long, long> lstChitietDonthuoc = new Dictionary<long, long>();
            if (arrPresDetail != null)
            {

                this._actionResult = this._KEDONTHUOC.CapnhatDonthuoc(this.objBenhnhan, this.CreateNewPres(), arrPresDetail, ref this.IdDonthuoc, ref lstChitietDonthuoc);
                switch (this._actionResult)
                {
                    case ActionResult.Error:
                        this.setMsg(this.lblMsg, "Lỗi trong quá trình lưu đơn thuốc", true);
                        break;

                    case ActionResult.Success:
                        this.UpdateChiDanThem();
                         DataRow[] arrDr = m_dtPatients.Select(KcbDanhsachBenhnhan.Columns.IdBenhnhan+ "="+objBenhnhan.IdBenhnhan.ToString());
                        if (arrDr!=null && arrDr.Length > 0)
                        {
                            KcbDanhsachBenhnhanCollection lstBN = new KcbDanhsachBenhnhanCollection();
                            lstBN.Add(objBenhnhan);
                            DataTable _temp = new DataTable();
                            _temp = lstBN.ToDataTable();
                            Utility.CopyData(_temp.Rows[0], ref arrDr[0]);
                            m_dtPatients.AcceptChanges();
                        }
                        this.setMsg(this.lblMsg, "Bạn thực hiện lưu đơn thuốc thành công", false);
                        this.UpdateDetailID(lstChitietDonthuoc);
                        this.m_blnCancel = false;
                           // this.Close();
                        break;
                }
            }
        }
        private void InsertPres(KcbDonthuocChitiet[] arrPresDetail)
        {
            try
            {

                Dictionary<long, long> lstChitietDonthuoc = new Dictionary<long, long>();
                if (arrPresDetail != null && arrPresDetail.Count()>0)
                {
                    CreatePatientInfo();
                    this._actionResult = this._KEDONTHUOC.ThemDonThuoc(this.objBenhnhan, this.CreateNewPres(), arrPresDetail, ref this.IdDonthuoc, ref lstChitietDonthuoc);
                    switch (this._actionResult)
                    {
                        case ActionResult.Error:
                            this.setMsg(this.lblMsg, "Lỗi trong quá trình lưu đơn thuốc", true);
                            break;
                        case ActionResult.Success:
                            this.UpdateChiDanThem();
                            DataRow dr = m_dtPatients.NewRow();
                            KcbDanhsachBenhnhanCollection lstBN = new KcbDanhsachBenhnhanCollection();
                            lstBN.Add(objBenhnhan);
                            DataTable _temp = new DataTable();
                            _temp = lstBN.ToDataTable();
                            Utility.CopyData(_temp.Rows[0], ref dr);
                            dr[KcbDonthuoc.Columns.IdDonthuoc] = IdDonthuoc;
                            m_dtPatients.Rows.Add(dr);

                            this.txtPres_ID.Text = this.IdDonthuoc.ToString();
                            this.m_enAct = action.Update;
                            this.setMsg(this.lblMsg, "Bạn thực hiện lưu đơn thuốc thành công", false);
                            this.UpdateDetailID(lstChitietDonthuoc);
                            this.m_blnCancel = false;
                            break;
                    }
                }
            }
            catch (Exception exception)
            {
                if (globalVariables.IsAdmin)
                {
                    Utility.ShowMsg(exception.ToString());
                }
            }
            finally
            {
                if (this.Manual)
                {
                    this.m_enAct = action.Update;
                }
            }
        }