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

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

            coll.LoadAndCloseReader(qry.ExecuteReader());
            return(coll);
        }
 public KcbDonthuocCollection FetchByQuery(Query qry)
 {
     KcbDonthuocCollection coll = new KcbDonthuocCollection();
     coll.LoadAndCloseReader(qry.ExecuteReader());
     return coll;
 }
 public KcbDonthuocCollection FetchByID(object IdDonthuoc)
 {
     KcbDonthuocCollection coll = new KcbDonthuocCollection().Where("id_donthuoc", IdDonthuoc).Load();
     return coll;
 }
        public ActionResult SaochepDonthuoc(int CurrentTreatID, KcbLuotkham objLuotkham,
         KcbDonthuocCollection lstPres, DateTime pres_date)
        {
            try
            {
                using (var scope = new TransactionScope())
                {
                    using (var dbscope = new SharedDbConnectionScope())
                    {
                        foreach (KcbDonthuoc pre in lstPres)
                        {
                            int oldPreID = pre.IdDonthuoc;
                            pre.IdPhieudieutri = CurrentTreatID;
                            pre.NgayKedon = pres_date;
                            pre.NguoiTao = globalVariables.UserName;
                            pre.Noitru = 1;
                            pre.IdKham = -1;
                            pre.IdGoi = -1;
                            pre.TrongGoi = 0;
                            pre.TenDonthuoc = THU_VIEN_CHUNG.TaoTenDonthuoc(objLuotkham.MaLuotkham,
                                                                                        Utility.Int32Dbnull(
                                                                                            objLuotkham.IdBenhnhan,
                                                                                            -1));
                            pre.TrangThai = 0;
                            //pre.PresStatus = null;
                            pre.IdDonthuocthaythe = -1;
                            pre.TrangthaiThanhtoan = 0;
                            pre.NgayThanhtoan = null;
                            pre.NgayCapphat = null;
                            pre.NgayXacnhan = null;
                            pre.NguoiSua = null;
                            pre.NgaySua = null;
                            pre.IsNew = true;
                            pre.Save();
                            KcbDonthuocChitietCollection lstobjChitietdonthuoc =
                                new Select().From(KcbDonthuocChitiet.Schema)
                                    .Where(KcbDonthuocChitiet.IdDonthuocColumn)
                                    .IsEqualTo(oldPreID)
                                    .ExecuteAsCollection<KcbDonthuocChitietCollection>();
                            foreach (KcbDonthuocChitiet _detail in lstobjChitietdonthuoc)
                            {

                                _detail.IdDonthuoc = pre.IdDonthuoc;
                                _detail.IdKham = -1;
                                _detail.TrangThai = 0;
                                _detail.TrangthaiTonghop = 0;
                                _detail.TrangthaiThanhtoan = 0;
                                _detail.IdGoi = 0;
                                _detail.TrongGoi = 0;
                                _detail.SoluongHuy = 0;
                                _detail.TrangthaiHuy = 0;
                                _detail.NgayThanhtoan = null;
                                _detail.NguonThanhtoan = 1;
                                _detail.IdThanhtoan = -1;
                                _detail.NguoiHuy = null;
                                _detail.NgayHuy = null;
                                _detail.SoluongHuy = 0;
                                _detail.NgayXacnhan = null;
                                _detail.SoLuong = Utility.Int32Dbnull(_detail.SluongSua, -1) <= 0
                                    ? _detail.SoLuong
                                    : _detail.SluongSua.Value;
                                _detail.SluongSua = null;
                                ;
                                _detail.SluongLinh = null;
                                _detail.IsNew = true;
                                _detail.Save();
                            }
                        }

                    }
                    scope.Complete();
                    return ActionResult.Success;
                }
            }
            catch (Exception exception)
            {
                return ActionResult.Error;
            }
        }
 public ActionResult SaochepDonthuoc(int CurrentTreatID, KcbLuotkham objLuotkham,
                                     KcbDonthuocCollection lstPres, DateTime pres_date)
 {
     try
     {
         using (var scope = new TransactionScope())
         {
             using (var dbscope = new SharedDbConnectionScope())
             {
                 foreach (KcbDonthuoc pre in lstPres)
                 {
                     long oldPreID = pre.IdDonthuoc;
                     pre.IdPhieudieutri = CurrentTreatID;
                     pre.NgayKedon      = pres_date;
                     pre.NguoiTao       = globalVariables.UserName;
                     pre.KieuDonthuoc   = 0;
                     pre.Noitru         = 1;
                     pre.IdKham         = -1;
                     pre.IdGoi          = -1;
                     pre.TrongGoi       = 0;
                     pre.TenDonthuoc    = THU_VIEN_CHUNG.TaoTenDonthuoc(objLuotkham.MaLuotkham,
                                                                        Utility.Int32Dbnull(
                                                                            objLuotkham.IdBenhnhan,
                                                                            -1));
                     pre.TrangThai = 0;
                     //pre.PresStatus = null;
                     pre.IdDonthuocthaythe  = -1;
                     pre.TrangthaiThanhtoan = 0;
                     pre.NgayThanhtoan      = null;
                     pre.NgayCapphat        = null;
                     pre.NgayXacnhan        = null;
                     pre.NguoiSua           = null;
                     pre.NgaySua            = null;
                     pre.IsNew = true;
                     pre.Save();
                     KcbDonthuocChitietCollection lstobjChitietdonthuoc =
                         new Select().From(KcbDonthuocChitiet.Schema)
                         .Where(KcbDonthuocChitiet.IdDonthuocColumn)
                         .IsEqualTo(oldPreID)
                         .ExecuteAsCollection <KcbDonthuocChitietCollection>();
                     foreach (KcbDonthuocChitiet _detail in lstobjChitietdonthuoc)
                     {
                         _detail.IdDonthuoc         = pre.IdDonthuoc;
                         _detail.IdKham             = -1;
                         _detail.TrangThai          = 0;
                         _detail.TrangthaiTonghop   = 0;
                         _detail.TrangthaiThanhtoan = 0;
                         _detail.IdGoi          = 0;
                         _detail.TrongGoi       = 0;
                         _detail.SoluongHuy     = 0;
                         _detail.TrangthaiHuy   = 0;
                         _detail.NgayThanhtoan  = null;
                         _detail.NguonThanhtoan = 1;
                         _detail.IdThanhtoan    = -1;
                         _detail.NguoiHuy       = null;
                         _detail.NgayHuy        = null;
                         _detail.SoluongHuy     = 0;
                         _detail.NgayXacnhan    = null;
                         _detail.SoLuong        = Utility.Int32Dbnull(_detail.SluongSua, -1) <= 0
                             ? _detail.SoLuong
                             : _detail.SluongSua.Value;
                         _detail.SluongSua = null;
                         ;
                         _detail.SluongLinh = null;
                         _detail.IsNew      = true;
                         _detail.Save();
                     }
                 }
             }
             scope.Complete();
             return(ActionResult.Success);
         }
     }
     catch (Exception exception)
     {
         return(ActionResult.Error);
     }
 }
        public KcbDonthuocCollection FetchByID(object IdDonthuoc)
        {
            KcbDonthuocCollection coll = new KcbDonthuocCollection().Where("id_donthuoc", IdDonthuoc).Load();

            return(coll);
        }