Ejemplo n.º 1
0
 public static string Insert(DmucThuoc objThuoc, QheCamchidinhChungphieuCollection lstQhe)
 {
     try
     {
         using (var scope = new TransactionScope())
         {
             using (var sh = new SharedDbConnectionScope())
             {
                 objThuoc.Save();
                 if (!objThuoc.IsNew)
                 {
                 }
                 new Delete().From(QheCamchidinhChungphieu.Schema)
                 .Where(QheCamchidinhChungphieu.Columns.IdDichvu).IsEqualTo(objThuoc.IdThuoc)
                 .And(QheCamchidinhChungphieu.Columns.Loai).IsEqualTo(0)
                 .Execute();
                 new Delete().From(QheCamchidinhChungphieu.Schema)
                 .Where(QheCamchidinhChungphieu.Columns.IdDichvuCamchidinhchung).IsEqualTo(objThuoc.IdThuoc)
                 .And(QheCamchidinhChungphieu.Columns.Loai).IsEqualTo(0)
                 .Execute();
                 foreach (QheCamchidinhChungphieu obj in lstQhe)
                 {
                     obj.IdDichvu = objThuoc.IdThuoc;
                 }
                 lstQhe.SaveAll();
             }
             scope.Complete();
         }
         return(string.Empty);
     }
     catch (Exception ex)
     {
         return(ex.Message);
     }
 }
Ejemplo n.º 2
0
        public static string Insert(DmucThuoc objThuoc, QheCamchidinhChungphieuCollection lstQhe)
        {
            try
               {
               using (var scope = new TransactionScope())
               {
                   using (var sh = new SharedDbConnectionScope())
                   {
                       objThuoc.Save();
                       if (!objThuoc.IsNew)
                       {

                       }
                       new Delete().From(QheCamchidinhChungphieu.Schema)
                           .Where(QheCamchidinhChungphieu.Columns.IdDichvu).IsEqualTo(objThuoc.IdThuoc)
                           .And(QheCamchidinhChungphieu.Columns.Loai).IsEqualTo(0)
                           .Execute();
                       new Delete().From(QheCamchidinhChungphieu.Schema)
                           .Where(QheCamchidinhChungphieu.Columns.IdDichvuCamchidinhchung).IsEqualTo(objThuoc.IdThuoc)
                           .And(QheCamchidinhChungphieu.Columns.Loai).IsEqualTo(0)
                           .Execute();
                       foreach (QheCamchidinhChungphieu obj in lstQhe)
                       {
                           obj.IdDichvu = objThuoc.IdThuoc;
                       }
                       lstQhe.SaveAll();
                   }
                   scope.Complete();
               }
               return string.Empty;
               }
               catch (Exception ex)
               {
               return ex.Message;
               }
        }
Ejemplo n.º 3
0
        public void Insert(string MaQD40,string MaQDTinh,string MaThuoc,short IdLoaithuoc,byte TinhChat,string TenThuoc,string TenBhyt,decimal DonGia,string MaDonvitinh,string MotaThem,string HoatChat,string HamLuong,string HangSanxuat,string SoDangky,string NuocSanxuat,byte TrangThai,string DangBaoche,short? GioihanKedon,int? DonviBut,string KieuThuocvattu,string QD31,string NoitruNgoaitru,byte? TuTuc,decimal? GiaBhyt,decimal? PhuthuDungtuyen,decimal? PhuthuTraituyen,byte? CoChiathuoc,int? SluongChia,decimal? DongiaChia,string MaDvichia,string KieuBiendong,string CachSudung,byte? SingleService,int? SluongVuottran,string NguoiTao,DateTime? NgayTao,DateTime? NgaySua,string NguoiSua,string LastActionName,decimal? GiaDv)
        {
            DmucThuoc item = new DmucThuoc();

            item.MaQD40 = MaQD40;

            item.MaQDTinh = MaQDTinh;

            item.MaThuoc = MaThuoc;

            item.IdLoaithuoc = IdLoaithuoc;

            item.TinhChat = TinhChat;

            item.TenThuoc = TenThuoc;

            item.TenBhyt = TenBhyt;

            item.DonGia = DonGia;

            item.MaDonvitinh = MaDonvitinh;

            item.MotaThem = MotaThem;

            item.HoatChat = HoatChat;

            item.HamLuong = HamLuong;

            item.HangSanxuat = HangSanxuat;

            item.SoDangky = SoDangky;

            item.NuocSanxuat = NuocSanxuat;

            item.TrangThai = TrangThai;

            item.DangBaoche = DangBaoche;

            item.GioihanKedon = GioihanKedon;

            item.DonviBut = DonviBut;

            item.KieuThuocvattu = KieuThuocvattu;

            item.QD31 = QD31;

            item.NoitruNgoaitru = NoitruNgoaitru;

            item.TuTuc = TuTuc;

            item.GiaBhyt = GiaBhyt;

            item.PhuthuDungtuyen = PhuthuDungtuyen;

            item.PhuthuTraituyen = PhuthuTraituyen;

            item.CoChiathuoc = CoChiathuoc;

            item.SluongChia = SluongChia;

            item.DongiaChia = DongiaChia;

            item.MaDvichia = MaDvichia;

            item.KieuBiendong = KieuBiendong;

            item.CachSudung = CachSudung;

            item.SingleService = SingleService;

            item.SluongVuottran = SluongVuottran;

            item.NguoiTao = NguoiTao;

            item.NgayTao = NgayTao;

            item.NgaySua = NgaySua;

            item.NguoiSua = NguoiSua;

            item.LastActionName = LastActionName;

            item.GiaDv = GiaDv;

            item.Save(UserName);
        }
Ejemplo n.º 4
0
        public void Insert(string MaThuoc,short IdLoaithuoc,byte TinhChat,string TenThuoc,string TenBhyt,decimal DonGia,string MaDonvitinh,string MotaThem,string HoatChat,string HamLuong,string HangSanxuat,string SoDangky,string NuocSanxuat,byte TrangThai,string DangBaoche,string NguoiTao,DateTime? NgayTao,DateTime? NgaySua,string NguoiSua,string KieuThuocvattu,string QD31,string NoitruNgoaitru,byte? TuTuc,decimal? GiaBhyt,decimal? PhuthuDungtuyen,decimal? PhuthuTraituyen)
        {
            DmucThuoc item = new DmucThuoc();

            item.MaThuoc = MaThuoc;

            item.IdLoaithuoc = IdLoaithuoc;

            item.TinhChat = TinhChat;

            item.TenThuoc = TenThuoc;

            item.TenBhyt = TenBhyt;

            item.DonGia = DonGia;

            item.MaDonvitinh = MaDonvitinh;

            item.MotaThem = MotaThem;

            item.HoatChat = HoatChat;

            item.HamLuong = HamLuong;

            item.HangSanxuat = HangSanxuat;

            item.SoDangky = SoDangky;

            item.NuocSanxuat = NuocSanxuat;

            item.TrangThai = TrangThai;

            item.DangBaoche = DangBaoche;

            item.NguoiTao = NguoiTao;

            item.NgayTao = NgayTao;

            item.NgaySua = NgaySua;

            item.NguoiSua = NguoiSua;

            item.KieuThuocvattu = KieuThuocvattu;

            item.QD31 = QD31;

            item.NoitruNgoaitru = NoitruNgoaitru;

            item.TuTuc = TuTuc;

            item.GiaBhyt = GiaBhyt;

            item.PhuthuDungtuyen = PhuthuDungtuyen;

            item.PhuthuTraituyen = PhuthuTraituyen;

            item.Save(UserName);
        }
Ejemplo n.º 5
0
        public void Insert(string MaQD40, string MaQDTinh, string MaThuoc, short IdLoaithuoc, byte TinhChat, string TenThuoc, string TenBhyt, decimal DonGia, string MaDonvitinh, string MotaThem, string HoatChat, string HamLuong, string HangSanxuat, string SoDangky, string NuocSanxuat, byte TrangThai, string DangBaoche, short?GioihanKedon, int?DonviBut, string KieuThuocvattu, string QD31, string NoitruNgoaitru, byte?TuTuc, decimal?GiaBhyt, decimal?PhuthuDungtuyen, decimal?PhuthuTraituyen, byte?CoChiathuoc, int?SluongChia, decimal?DongiaChia, string MaDvichia, string KieuBiendong, string CachSudung, byte?SingleService, int?SluongVuottran, decimal?GiaDv, byte?NguonGoc, string NguoiTao, DateTime?NgayTao, DateTime?NgaySua, string NguoiSua, string LastActionName)
        {
            DmucThuoc item = new DmucThuoc();

            item.MaQD40 = MaQD40;

            item.MaQDTinh = MaQDTinh;

            item.MaThuoc = MaThuoc;

            item.IdLoaithuoc = IdLoaithuoc;

            item.TinhChat = TinhChat;

            item.TenThuoc = TenThuoc;

            item.TenBhyt = TenBhyt;

            item.DonGia = DonGia;

            item.MaDonvitinh = MaDonvitinh;

            item.MotaThem = MotaThem;

            item.HoatChat = HoatChat;

            item.HamLuong = HamLuong;

            item.HangSanxuat = HangSanxuat;

            item.SoDangky = SoDangky;

            item.NuocSanxuat = NuocSanxuat;

            item.TrangThai = TrangThai;

            item.DangBaoche = DangBaoche;

            item.GioihanKedon = GioihanKedon;

            item.DonviBut = DonviBut;

            item.KieuThuocvattu = KieuThuocvattu;

            item.QD31 = QD31;

            item.NoitruNgoaitru = NoitruNgoaitru;

            item.TuTuc = TuTuc;

            item.GiaBhyt = GiaBhyt;

            item.PhuthuDungtuyen = PhuthuDungtuyen;

            item.PhuthuTraituyen = PhuthuTraituyen;

            item.CoChiathuoc = CoChiathuoc;

            item.SluongChia = SluongChia;

            item.DongiaChia = DongiaChia;

            item.MaDvichia = MaDvichia;

            item.KieuBiendong = KieuBiendong;

            item.CachSudung = CachSudung;

            item.SingleService = SingleService;

            item.SluongVuottran = SluongVuottran;

            item.GiaDv = GiaDv;

            item.NguonGoc = NguonGoc;

            item.NguoiTao = NguoiTao;

            item.NgayTao = NgayTao;

            item.NgaySua = NgaySua;

            item.NguoiSua = NguoiSua;

            item.LastActionName = LastActionName;


            item.Save(UserName);
        }
Ejemplo n.º 6
0
        void ImportFromExcel(bool taoquanhe)
        {
            bool hasError = false;
            try
            {
                using (var Scope = new TransactionScope())
                {
                    using (var dbScope = new SharedDbConnectionScope())
                    {

                        //new Delete().From(DmucThuoc.Schema).Execute();
                        //if (taoquanhe)
                        //{
                        //    List<int> lstIdDoituongKCB = (from p in grdObjectTypeList.GetCheckedRows()
                        //                                  select Utility.Int32Dbnull(p.Cells[DmucDoituongkcb.Columns.IdDoituongKcb].Value, 0)
                        //                                     ).ToList<int>();
                        //    new Delete().From(QheDoituongThuoc.Schema).Where(QheDoituongThuoc.Columns.IdDoituongKcb).In(lstIdDoituongKCB).Execute();
                        //}
                        SPs.ResetDuocAll().Execute();
                        int idx = 0;
                        List<string> lstNoitruNgoaitru = new List<string>() { "ALL", "NOI", "NGOAI" };
                        List<string> lstThuoc_VT = new List<string>() { "THUOC", "VT" };
                        progressBar1.Visible = true;
                        lblCount.Visible = true;
                        progressBar1.Minimum = 0;
                        progressBar1.Maximum = grdList.GetCheckedRows().Length;
                        progressBar1.Value = 0;
                        foreach (GridEXRow row in grdList.GetCheckedRows())
                        {
                            idx++;
                            if (progressBar1.Value + 1 <= progressBar1.Maximum) progressBar1.Value += 1;
                            lblCount.Text = progressBar1.Value.ToString() + " / " + progressBar1.Maximum.ToString();

                            try
                            {
                                DmucThuoc _newDmucThuoc = new DmucThuoc();
                                _newDmucThuoc.DangBaoche = Utility.sDbnull(row.Cells[DmucThuoc.Columns.DangBaoche].Value, "");
                                _newDmucThuoc.DonGia = Utility.DecimaltoDbnull(row.Cells[DmucThuoc.Columns.DonGia].Value, 0);
                                _newDmucThuoc.GiaBhyt = Utility.DecimaltoDbnull(row.Cells[DmucThuoc.Columns.GiaBhyt].Value, 0);
                                _newDmucThuoc.HamLuong = Utility.sDbnull(row.Cells[DmucThuoc.Columns.HamLuong].Value, "");
                                _newDmucThuoc.HangSanxuat = Utility.sDbnull(row.Cells[DmucThuoc.Columns.HangSanxuat].Value, "");
                                _newDmucThuoc.HoatChat = Utility.sDbnull(row.Cells[DmucThuoc.Columns.HoatChat].Value, "");
                                _newDmucThuoc.IdLoaithuoc = Utility.Int16Dbnull(row.Cells[DmucThuoc.Columns.IdLoaithuoc].Value, -1);
                                _newDmucThuoc.IdThuoc = -1;
                                string KieuThuocvattu = Utility.DoTrim(Utility.sDbnull(row.Cells[DmucThuoc.Columns.KieuThuocvattu].Value, "THUOC"));
                                _newDmucThuoc.KieuThuocvattu = KieuThuocvattu == "" || !lstThuoc_VT.Contains(KieuThuocvattu) ? "THUOC" : KieuThuocvattu;
                                _newDmucThuoc.MaDonvitinh = Utility.sDbnull(row.Cells[DmucThuoc.Columns.MaDonvitinh].Value, "");
                                string ma_thuoc = Utility.DoTrim(Utility.sDbnull(row.Cells[DmucThuoc.Columns.MaThuoc].Value, ""));
                                _newDmucThuoc.MaThuoc = ma_thuoc == "" ? "T" + idx.ToString() : ma_thuoc;
                                _newDmucThuoc.MotaThem = Utility.sDbnull(row.Cells[DmucThuoc.Columns.MotaThem].Value, "");
                                string NoitruNgoaitru = Utility.DoTrim(Utility.sDbnull(row.Cells[DmucThuoc.Columns.NoitruNgoaitru].Value, ""));
                                _newDmucThuoc.NoitruNgoaitru = NoitruNgoaitru == "" || !lstNoitruNgoaitru.Contains(NoitruNgoaitru) ? "ALL" : NoitruNgoaitru;
                                _newDmucThuoc.NuocSanxuat = Utility.sDbnull(row.Cells[DmucThuoc.Columns.NuocSanxuat].Value, "");
                                _newDmucThuoc.PhuthuDungtuyen = Utility.DecimaltoDbnull(row.Cells[DmucThuoc.Columns.PhuthuDungtuyen].Value, 0);
                                _newDmucThuoc.PhuthuTraituyen = Utility.DecimaltoDbnull(row.Cells[DmucThuoc.Columns.PhuthuTraituyen].Value, 0);
                                _newDmucThuoc.QD31 = Utility.sDbnull(row.Cells[DmucThuoc.Columns.QD31].Value, "");
                                _newDmucThuoc.SoDangky = Utility.sDbnull(row.Cells[DmucThuoc.Columns.SoDangky].Value, "");
                                _newDmucThuoc.TenBhyt = Utility.sDbnull(row.Cells[DmucThuoc.Columns.TenBhyt].Value, "");
                                _newDmucThuoc.TenThuoc = Utility.sDbnull(row.Cells[DmucThuoc.Columns.TenThuoc].Value, "");
                                _newDmucThuoc.TinhChat = Utility.ByteDbnull(row.Cells[DmucThuoc.Columns.TinhChat].Value, 0);
                                _newDmucThuoc.TrangThai = 1;
                                _newDmucThuoc.TuTuc = Utility.ByteDbnull(row.Cells[DmucThuoc.Columns.TuTuc].Value, 0);

                                _newDmucThuoc.IsNew = true;
                                _newDmucThuoc.Save();
                                if (taoquanhe)
                                {
                                    foreach (GridEXRow rowdoituong in grdObjectTypeList.GetCheckedRows())
                                    {
                                        DmucDoituongkcb _DmucDoituongkcb = DmucDoituongkcb.FetchByID(Utility.Int32Dbnull(rowdoituong.Cells[DmucDoituongkcb.Columns.IdDoituongKcb].Value, -1));
                                        QheDoituongThuoc _QheDoituongThuoc = new QheDoituongThuoc();

                                        _QheDoituongThuoc.IdDoituongKcb = _DmucDoituongkcb.IdDoituongKcb;
                                        _QheDoituongThuoc.IdLoaithuoc = _newDmucThuoc.IdLoaithuoc;
                                        _QheDoituongThuoc.IdThuoc = _newDmucThuoc.IdThuoc;
                                        _QheDoituongThuoc.TyleGiamgia = 0;
                                        _QheDoituongThuoc.KieuGiamgia = "%";
                                        _QheDoituongThuoc.DonGia = (THU_VIEN_CHUNG.IsBaoHiem(_DmucDoituongkcb.IdLoaidoituongKcb) ? Utility.DecimaltoDbnull(_newDmucThuoc.GiaBhyt, 0) : Utility.DecimaltoDbnull(_newDmucThuoc.DonGia, 0));
                                        _QheDoituongThuoc.PhuthuDungtuyen = (THU_VIEN_CHUNG.IsBaoHiem(_DmucDoituongkcb.IdLoaidoituongKcb) ? Utility.DecimaltoDbnull(_newDmucThuoc.PhuthuDungtuyen, 0) : 0m);
                                        _QheDoituongThuoc.PhuthuTraituyen = (THU_VIEN_CHUNG.IsBaoHiem(_DmucDoituongkcb.IdLoaidoituongKcb) ? Utility.DecimaltoDbnull(_newDmucThuoc.PhuthuTraituyen, 0) : 0m);
                                        _QheDoituongThuoc.IdLoaidoituongKcb = _DmucDoituongkcb.IdLoaidoituongKcb;

                                        _QheDoituongThuoc.MaDoituongKcb = _DmucDoituongkcb.MaDoituongKcb;
                                        _QheDoituongThuoc.MaKhoaThuchien = globalVariables.MA_KHOA_THIEN;
                                        _QheDoituongThuoc.NgayTao = globalVariables.SysDate;
                                        _QheDoituongThuoc.NguoiTao = globalVariables.UserName;
                                        _QheDoituongThuoc.IsNew = true;
                                        _QheDoituongThuoc.Save();
                                    }
                                }

                            }
                            catch
                            {
                                hasError = true;
                                row.BeginEdit();
                                row.Cells["Error"].Value = 1;
                                row.Cells["Success"].Value = 0;
                                row.EndEdit();
                            }
                            finally
                            {
                                Application.DoEvents();
                            }
                        }

                    }
                    if (hasError)
                    {
                        if (Utility.AcceptQuestion("Có lỗi trong quá trình đẩy dữ liệu thuốc từ file excel vào hệ thống. Bạn có muốn chấp nhận các dữ liệu đã đẩy thành công hay không?\nChú ý: Với các dữ liệu lỗi bạn có thể liên hệ để được trợ giúp để khắc phục"))
                        {
                            Scope.Complete();
                            m_blnCancel = false;
                        }
                    }
                    else
                    {
                        Scope.Complete();
                        Utility.ShowMsg("Đã nhập liệu thành công. Nhấn OK để kết thúc");
                        m_blnCancel = false;
                    }

                }
            }
            catch (Exception ex)
            {
                Utility.CatchException("Lỗi khi xuất thuốc ra file Excel", ex);

            }
            finally
            {
                progressBar1.Visible = false;
                lblCount.Visible = false;
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Thực hiện nghiệp vụ Insert dữ liệu
        /// </summary>
        private void PerformInsertAction()
        {
            try
            {
                Utility.SetMsg(lblMsg, "", false);
                SqlQuery sqlQuery = new Select().From(DmucThuoc.Schema)
                    .Where(DmucThuoc.Columns.MaThuoc).IsEqualTo(txtCode.Text);
                if (sqlQuery.GetRecordCount() > 0)
                {
                    Utility.SetMsg(lblMsg, "Đã tồn tại thuốc có mã(Drug Code)=" + txtCode.Text.Trim() + ".Đề nghị bạn nhập mã khác",true);
                    m_Query = DmucThuoc.CreateQuery();
                    return;
                }
                //Bước 0: Thêm mới thuốc
                DmucThuoc objnewItems = new DmucThuoc();
                objnewItems.TenThuoc = Utility.sDbnull(txtName.Text);
                objnewItems.TenBhyt = Utility.sDbnull(txtTEN_BHYT.Text);
                objnewItems.MaThuoc = Utility.sDbnull(txtCode.Text);
                objnewItems.IdLoaithuoc = Utility.Int16Dbnull(txtLoaithuoc.MyID);
                objnewItems.DonGia = Utility.DecimaltoDbnull( txtDongia.Text, 0);
                objnewItems.GiaBhyt = Utility.DecimaltoDbnull(txtGiaBHYT.Text, 0);
                objnewItems.PhuthuDungtuyen = Utility.DecimaltoDbnull(txtPTDT.Text, 0);
                objnewItems.PhuthuTraituyen = Utility.DecimaltoDbnull(txtPTTT.Text, 0);
                objnewItems.MotaThem = Utility.sDbnull(txtDesc.Text);
                objnewItems.DangBaoche = Utility.DoTrim(txtDangBaoChe.Text);
                objnewItems.HamLuong = Utility.sDbnull(txtContent.Text);
                objnewItems.HangSanxuat = Utility.sDbnull(txtHangSX.Text);
                objnewItems.TrangThai = chkHieuLuc.Checked ? (byte)1 : (byte)0;
                objnewItems.TuTuc =Utility.Bool2byte( chkTutuc.Checked );
                objnewItems.NgayTao = DateTime.Now;
                objnewItems.QD31 = Utility.DoTrim(txtQD31.Text);
                objnewItems.NguoiTao = globalVariables.UserName;
                objnewItems.NuocSanxuat = Utility.sDbnull(txtNuocSX.Text);
                objnewItems.GioihanKedon = (Int16)Utility.DecimaltoDbnull(txtSoluong.Text,-1);
                objnewItems.DonviBut = (int)Utility.DecimaltoDbnull(txtBut.Text, -1);
                objnewItems.MaDonvitinh = txtDonvitinh.myCode;

                objnewItems.CoChiathuoc = Utility.Bool2byte(chkChiathuoc.Checked);
                objnewItems.MaDvichia = txtDonvichia.myCode;
                objnewItems.SluongChia =(int) Utility.DecimaltoDbnull(txtSoluongchia.Text, 0);
                objnewItems.DongiaChia = Utility.DecimaltoDbnull(txtDongiachia.Text, 0);

                objnewItems.TinhChat = Convert.ToByte(cboDrugNature.SelectedIndex);
                objnewItems.HoatChat = Utility.sDbnull(txtActice.Text);
                objnewItems.KieuThuocvattu = Utility.sDbnull(cboKIEU_THUOC_VT.SelectedValue);
                objnewItems.NoitruNgoaitru = optAll.Checked ? "ALL" : (optNoitru.Checked ? "NOI" : "NGOAI");
                objnewItems.IsNew = true;
                objnewItems.Save();
                int v_intNewDrugID = objnewItems.IdThuoc;
                txtID.Text = Utility.sDbnull(objnewItems.IdThuoc);
                DataRow dr = m_dtDrugDataSource.NewRow();
                Utility.FromObjectToDatarow(objnewItems, ref dr);
                dr[DmucThuoc.Columns.TinhChat] = Convert.ToByte(cboDrugNature.SelectedIndex);
                dr["ten_loaithuoc"] = txtLoaithuoc.Text;
                dr["ten_donvitinh"] = txtDonvitinh.Text;
                dr["ten_donvichia"] = txtDonvichia.Text;
                dr[DmucThuoc.Columns.NguoiTao] = globalVariables.UserName;
                dr[DmucThuoc.Columns.NgayTao] = DateTime.Now;
                m_dtDrugDataSource.Rows.Add(dr);
                m_dtDrugDataSource.AcceptChanges();
                m_enAction = action.Insert;
                //Nhảy đến bản ghi vừa thêm mới trên lưới. Do txtID chưa bị reset nên dùng luôn
                try
                {
                    Utility.GotoNewRowJanus(grdList, "id_thuoc", v_intNewDrugID.ToString().Trim());
                    if (chkThemlientuc.Checked)
                        SetControlStatus();
                    else
                        this.Close();
                }
                catch (Exception exception)
                {
                }
                Utility.SetMsg(lblMsg, "Thêm mới dữ liệu thành công!",false);
                SetControlStatus();
                txtCode.Focus();
            }
            catch
            {
            }
        }
Ejemplo n.º 8
0
        public void Update(int IdThuoc,string MaThuoc,short IdLoaithuoc,byte TinhChat,string TenThuoc,string TenBhyt,decimal DonGia,string MaDonvitinh,string MotaThem,string HoatChat,string HamLuong,string HangSanxuat,string SoDangky,string NuocSanxuat,byte TrangThai,string DangBaoche,short? GioihanKedon,int? DonviBut,string KieuThuocvattu,string QD31,string NoitruNgoaitru,byte? TuTuc,decimal? GiaBhyt,decimal? PhuthuDungtuyen,decimal? PhuthuTraituyen,byte? CoChiathuoc,int? SluongChia,decimal? DongiaChia,string MaDvichia,string NguoiTao,DateTime? NgayTao,DateTime? NgaySua,string NguoiSua)
        {
            DmucThuoc item = new DmucThuoc();
            item.MarkOld();
            item.IsLoaded = true;

            item.IdThuoc = IdThuoc;

            item.MaThuoc = MaThuoc;

            item.IdLoaithuoc = IdLoaithuoc;

            item.TinhChat = TinhChat;

            item.TenThuoc = TenThuoc;

            item.TenBhyt = TenBhyt;

            item.DonGia = DonGia;

            item.MaDonvitinh = MaDonvitinh;

            item.MotaThem = MotaThem;

            item.HoatChat = HoatChat;

            item.HamLuong = HamLuong;

            item.HangSanxuat = HangSanxuat;

            item.SoDangky = SoDangky;

            item.NuocSanxuat = NuocSanxuat;

            item.TrangThai = TrangThai;

            item.DangBaoche = DangBaoche;

            item.GioihanKedon = GioihanKedon;

            item.DonviBut = DonviBut;

            item.KieuThuocvattu = KieuThuocvattu;

            item.QD31 = QD31;

            item.NoitruNgoaitru = NoitruNgoaitru;

            item.TuTuc = TuTuc;

            item.GiaBhyt = GiaBhyt;

            item.PhuthuDungtuyen = PhuthuDungtuyen;

            item.PhuthuTraituyen = PhuthuTraituyen;

            item.CoChiathuoc = CoChiathuoc;

            item.SluongChia = SluongChia;

            item.DongiaChia = DongiaChia;

            item.MaDvichia = MaDvichia;

            item.NguoiTao = NguoiTao;

            item.NgayTao = NgayTao;

            item.NgaySua = NgaySua;

            item.NguoiSua = NguoiSua;

            item.Save(UserName);
        }
Ejemplo n.º 9
0
        void ImportFromExcel(bool taoquanhe)
        {
            bool hasError = false;

            try
            {
                using (var Scope = new TransactionScope())
                {
                    using (var dbScope = new SharedDbConnectionScope())
                    {
                        //new Delete().From(DmucThuoc.Schema).Execute();
                        //if (taoquanhe)
                        //{
                        //    List<int> lstIdDoituongKCB = (from p in grdObjectTypeList.GetCheckedRows()
                        //                                  select Utility.Int32Dbnull(p.Cells[DmucDoituongkcb.Columns.IdDoituongKcb].Value, 0)
                        //                                     ).ToList<int>();
                        //    new Delete().From(QheDoituongThuoc.Schema).Where(QheDoituongThuoc.Columns.IdDoituongKcb).In(lstIdDoituongKCB).Execute();
                        //}
                        SPs.ResetDuocAll().Execute();
                        int           idx = 0;
                        List <string> lstNoitruNgoaitru = new List <string>()
                        {
                            "ALL", "NOI", "NGOAI"
                        };
                        List <string> lstThuoc_VT = new List <string>()
                        {
                            "THUOC", "VT"
                        };
                        progressBar1.Visible = true;
                        lblCount.Visible     = true;
                        progressBar1.Minimum = 0;
                        progressBar1.Maximum = grdList.GetCheckedRows().Length;
                        progressBar1.Value   = 0;
                        foreach (GridEXRow row in grdList.GetCheckedRows())
                        {
                            idx++;
                            if (progressBar1.Value + 1 <= progressBar1.Maximum)
                            {
                                progressBar1.Value += 1;
                            }
                            lblCount.Text = progressBar1.Value.ToString() + " / " + progressBar1.Maximum.ToString();

                            try
                            {
                                DmucThuoc _newDmucThuoc = new DmucThuoc();
                                _newDmucThuoc.DangBaoche  = Utility.sDbnull(row.Cells[DmucThuoc.Columns.DangBaoche].Value, "");
                                _newDmucThuoc.DonGia      = Utility.DecimaltoDbnull(row.Cells[DmucThuoc.Columns.DonGia].Value, 0);
                                _newDmucThuoc.GiaBhyt     = Utility.DecimaltoDbnull(row.Cells[DmucThuoc.Columns.GiaBhyt].Value, 0);
                                _newDmucThuoc.HamLuong    = Utility.sDbnull(row.Cells[DmucThuoc.Columns.HamLuong].Value, "");
                                _newDmucThuoc.HangSanxuat = Utility.sDbnull(row.Cells[DmucThuoc.Columns.HangSanxuat].Value, "");
                                _newDmucThuoc.HoatChat    = Utility.sDbnull(row.Cells[DmucThuoc.Columns.HoatChat].Value, "");
                                _newDmucThuoc.IdLoaithuoc = Utility.Int16Dbnull(row.Cells[DmucThuoc.Columns.IdLoaithuoc].Value, -1);
                                _newDmucThuoc.IdThuoc     = -1;
                                string KieuThuocvattu = Utility.DoTrim(Utility.sDbnull(row.Cells[DmucThuoc.Columns.KieuThuocvattu].Value, "THUOC"));
                                _newDmucThuoc.KieuThuocvattu = KieuThuocvattu == "" || !lstThuoc_VT.Contains(KieuThuocvattu) ? "THUOC" : KieuThuocvattu;
                                _newDmucThuoc.MaDonvitinh    = Utility.sDbnull(row.Cells[DmucThuoc.Columns.MaDonvitinh].Value, "");
                                string ma_thuoc = Utility.DoTrim(Utility.sDbnull(row.Cells[DmucThuoc.Columns.MaThuoc].Value, ""));
                                _newDmucThuoc.MaThuoc  = ma_thuoc == "" ? "T" + idx.ToString() : ma_thuoc;
                                _newDmucThuoc.MotaThem = Utility.sDbnull(row.Cells[DmucThuoc.Columns.MotaThem].Value, "");
                                string NoitruNgoaitru = Utility.DoTrim(Utility.sDbnull(row.Cells[DmucThuoc.Columns.NoitruNgoaitru].Value, ""));
                                _newDmucThuoc.NoitruNgoaitru  = NoitruNgoaitru == "" || !lstNoitruNgoaitru.Contains(NoitruNgoaitru) ? "ALL" : NoitruNgoaitru;
                                _newDmucThuoc.NuocSanxuat     = Utility.sDbnull(row.Cells[DmucThuoc.Columns.NuocSanxuat].Value, "");
                                _newDmucThuoc.PhuthuDungtuyen = Utility.DecimaltoDbnull(row.Cells[DmucThuoc.Columns.PhuthuDungtuyen].Value, 0);
                                _newDmucThuoc.PhuthuTraituyen = Utility.DecimaltoDbnull(row.Cells[DmucThuoc.Columns.PhuthuTraituyen].Value, 0);
                                _newDmucThuoc.QD31            = Utility.sDbnull(row.Cells[DmucThuoc.Columns.QD31].Value, "");
                                _newDmucThuoc.SoDangky        = Utility.sDbnull(row.Cells[DmucThuoc.Columns.SoDangky].Value, "");
                                _newDmucThuoc.TenBhyt         = Utility.sDbnull(row.Cells[DmucThuoc.Columns.TenBhyt].Value, "");
                                _newDmucThuoc.TenThuoc        = Utility.sDbnull(row.Cells[DmucThuoc.Columns.TenThuoc].Value, "");
                                _newDmucThuoc.TinhChat        = Utility.ByteDbnull(row.Cells[DmucThuoc.Columns.TinhChat].Value, 0);
                                _newDmucThuoc.TrangThai       = 1;
                                _newDmucThuoc.TuTuc           = Utility.ByteDbnull(row.Cells[DmucThuoc.Columns.TuTuc].Value, 0);

                                _newDmucThuoc.IsNew = true;
                                _newDmucThuoc.Save();
                                if (taoquanhe)
                                {
                                    foreach (GridEXRow rowdoituong in grdObjectTypeList.GetCheckedRows())
                                    {
                                        DmucDoituongkcb  _DmucDoituongkcb  = DmucDoituongkcb.FetchByID(Utility.Int32Dbnull(rowdoituong.Cells[DmucDoituongkcb.Columns.IdDoituongKcb].Value, -1));
                                        QheDoituongThuoc _QheDoituongThuoc = new QheDoituongThuoc();

                                        _QheDoituongThuoc.IdDoituongKcb     = _DmucDoituongkcb.IdDoituongKcb;
                                        _QheDoituongThuoc.IdLoaithuoc       = _newDmucThuoc.IdLoaithuoc;
                                        _QheDoituongThuoc.IdThuoc           = _newDmucThuoc.IdThuoc;
                                        _QheDoituongThuoc.TyleGiamgia       = 0;
                                        _QheDoituongThuoc.KieuGiamgia       = "%";
                                        _QheDoituongThuoc.DonGia            = (THU_VIEN_CHUNG.IsBaoHiem(_DmucDoituongkcb.IdLoaidoituongKcb) ? Utility.DecimaltoDbnull(_newDmucThuoc.GiaBhyt, 0) : Utility.DecimaltoDbnull(_newDmucThuoc.DonGia, 0));
                                        _QheDoituongThuoc.PhuthuDungtuyen   = (THU_VIEN_CHUNG.IsBaoHiem(_DmucDoituongkcb.IdLoaidoituongKcb) ? Utility.DecimaltoDbnull(_newDmucThuoc.PhuthuDungtuyen, 0) : 0m);
                                        _QheDoituongThuoc.PhuthuTraituyen   = (THU_VIEN_CHUNG.IsBaoHiem(_DmucDoituongkcb.IdLoaidoituongKcb) ? Utility.DecimaltoDbnull(_newDmucThuoc.PhuthuTraituyen, 0) : 0m);
                                        _QheDoituongThuoc.IdLoaidoituongKcb = _DmucDoituongkcb.IdLoaidoituongKcb;

                                        _QheDoituongThuoc.MaDoituongKcb  = _DmucDoituongkcb.MaDoituongKcb;
                                        _QheDoituongThuoc.MaKhoaThuchien = globalVariables.MA_KHOA_THIEN;
                                        _QheDoituongThuoc.NgayTao        = globalVariables.SysDate;
                                        _QheDoituongThuoc.NguoiTao       = globalVariables.UserName;
                                        _QheDoituongThuoc.IsNew          = true;
                                        _QheDoituongThuoc.Save();
                                    }
                                }
                            }
                            catch
                            {
                                hasError = true;
                                row.BeginEdit();
                                row.Cells["Error"].Value   = 1;
                                row.Cells["Success"].Value = 0;
                                row.EndEdit();
                            }
                            finally
                            {
                                Application.DoEvents();
                            }
                        }
                    }
                    if (hasError)
                    {
                        if (Utility.AcceptQuestion("Có lỗi trong quá trình đẩy dữ liệu thuốc từ file excel vào hệ thống. Bạn có muốn chấp nhận các dữ liệu đã đẩy thành công hay không?\nChú ý: Với các dữ liệu lỗi bạn có thể liên hệ để được trợ giúp để khắc phục"))
                        {
                            Scope.Complete();
                            m_blnCancel = false;
                        }
                    }
                    else
                    {
                        Scope.Complete();
                        Utility.ShowMsg("Đã nhập liệu thành công. Nhấn OK để kết thúc");
                        m_blnCancel = false;
                    }
                }
            }
            catch (Exception ex)
            {
                Utility.CatchException("Lỗi khi xuất thuốc ra file Excel", ex);
            }
            finally
            {
                progressBar1.Visible = false;
                lblCount.Visible     = false;
            }
        }