コード例 #1
0
 public static HisDuocProperties GetHisDuocProperties()
 {
     try
     {
         if (!System.IO.Directory.Exists(globalVariables.m_strPropertiesFolder))
         {
             Directory.CreateDirectory(globalVariables.m_strPropertiesFolder);
         }
         var    myProperty = new HisDuocProperties();
         string filePath   = string.Format(@"{0}\{1}.xml", globalVariables.m_strPropertiesFolder, myProperty.GetType().Name);
         if (!File.Exists(filePath))
         {
             return(myProperty);
         }
         var myFileStream = new FileStream(filePath, FileMode.Open);
         var mySerializer = new XmlSerializer(myProperty.GetType());
         myProperty = (HisDuocProperties)mySerializer.Deserialize(myFileStream);
         myFileStream.Close();
         return(myProperty);
     }
     catch (Exception ex)
     {
         return(new HisDuocProperties());
     }
 }
コード例 #2
0
        /// <summary>
        /// hàm thực hiện việc xác nhận thông tin
        /// </summary>
        /// <param name="objPhieuNhap"></param>
        /// <returns></returns>
        public ActionResult HuyXacNhanPhieuTraLaiKho(TPhieuNhapxuatthuoc objPhieuNhap)
        {
            HisDuocProperties objHisDuocProperties = PropertyLib._HisDuocProperties;
            string            errorMessage         = "";

            try
            {
                using (var Scope = new TransactionScope())
                {
                    using (var dbScope = new SharedDbConnectionScope())
                    {
                        SqlQuery sqlQuery = new Select().From(TPhieuNhapxuatthuocChitiet.Schema)
                                            .Where(TPhieuNhapxuatthuocChitiet.Columns.IdPhieu).IsEqualTo(objPhieuNhap.IdPhieu);
                        TPhieuNhapxuatthuocChitietCollection objPhieuNhapCtCollection =
                            sqlQuery.ExecuteAsCollection <TPhieuNhapxuatthuocChitietCollection>();

                        foreach (TPhieuNhapxuatthuocChitiet objPhieuNhapCt in objPhieuNhapCtCollection)
                        {
                            //Kiểm tra ở kho nhập xem thuốc đã sử dụng chưa
                            ActionResult _Kiemtrathuochuyxacnhan = Kiemtrathuochuyxacnhan(objPhieuNhap, objPhieuNhapCt);
                            if (_Kiemtrathuochuyxacnhan != ActionResult.Success)
                            {
                                return(_Kiemtrathuochuyxacnhan);
                            }
                            int             id_thuockho = -1;
                            StoredProcedure sp          = SPs.ThuocNhapkhoOutput(objPhieuNhapCt.NgayHethan, objPhieuNhapCt.GiaNhap, objPhieuNhapCt.GiaBan,
                                                                                 objPhieuNhapCt.SoLuong, Utility.DecimaltoDbnull(objPhieuNhapCt.Vat),
                                                                                 objPhieuNhapCt.IdThuoc, objPhieuNhap.IdKhonhap, objPhieuNhapCt.MaNhacungcap,
                                                                                 objPhieuNhapCt.SoLo, objPhieuNhapCt.SoDky, objPhieuNhapCt.SoQdinhthau, -1, id_thuockho,
                                                                                 objPhieuNhap.NgayXacnhan, objPhieuNhapCt.GiaBhyt, objPhieuNhapCt.GiaPhuthuDungtuyen, objPhieuNhapCt.GiaPhuthuTraituyen, objPhieuNhapCt.KieuThuocvattu);
                            sp.Execute();
                            sp = SPs.ThuocXuatkho(objPhieuNhap.IdKhoxuat, objPhieuNhapCt.IdThuoc,
                                                  objPhieuNhapCt.NgayHethan, objPhieuNhapCt.GiaNhap, objPhieuNhapCt.GiaBan,
                                                  Utility.DecimaltoDbnull(objPhieuNhapCt.Vat),
                                                  Utility.Int32Dbnull(objPhieuNhapCt.SoLuong), objPhieuNhapCt.IdThuockho, objPhieuNhapCt.MaNhacungcap, objPhieuNhapCt.SoLo, objHisDuocProperties.XoaDulieuKhiThuocDaHet ? 1 : 0, errorMessage);

                            sp.Execute();
                            errorMessage = Utility.sDbnull(sp.OutputValues[0]);
                        }
                        //Xóa toàn bộ chi tiết trong TBiendongThuoc
                        new Delete().From(TBiendongThuoc.Schema)
                        .Where(TBiendongThuoc.IdPhieuColumn).IsEqualTo(objPhieuNhap.IdPhieu).Execute();
                        new Update(TPhieuNhapxuatthuoc.Schema)
                        .Set(TPhieuNhapxuatthuoc.Columns.IdNhanvien).EqualTo(null)
                        .Set(TPhieuNhapxuatthuoc.Columns.NguoiXacnhan).EqualTo(null)
                        .Set(TPhieuNhapxuatthuoc.Columns.NgayXacnhan).EqualTo(null)
                        .Set(TPhieuNhapxuatthuoc.Columns.TrangThai).EqualTo(0)
                        .Where(TPhieuNhapxuatthuoc.Columns.IdPhieu).IsEqualTo(objPhieuNhap.IdPhieu).Execute();
                    }
                    Scope.Complete();
                    return(ActionResult.Success);
                }
            }
            catch (Exception exception)
            {
                log.Error("Loi ban ra tu sp :{0}", errorMessage);
                log.Error("Loi trong qua trinh xac nhan don thuoc :{0}", exception);
                return(ActionResult.Error);
            }
        }
コード例 #3
0
        private void CauHinh()
        {
            HisDuocProperties = Utility.HisDuocProperties;

            cmdHuyDonThuoc.Visible = HisDuocProperties.HuyXacNhan;
            cmdXoaChiTietThuoc.Visible = HisDuocProperties.Chophepxoachitiet;

            Janus.Windows.GridEX.GridEXColumn gridExColumn = grdPres.RootTable.Columns[TPrescription.Columns.PresId];
            Janus.Windows.GridEX.GridEXSortKey gridExSortKey = new GridEXSortKey(gridExColumn, SortOrder.Ascending);
            grdPres.RootTable.SortKeys.Add(gridExSortKey);
            if (HisDuocProperties.KieuDuyetDonThuoc == "DONTHUOC")
            {
                Utility.VisiableGridEx(grdPres, TPrescription.Columns.Status, true);
                Janus.Windows.GridEX.GridEXColumn gridExColumnFormat = grdPres.RootTable.Columns[TPrescription.Columns.Status];
                Janus.Windows.GridEX.GridEXFormatCondition gridExFormatCondition = new GridEXFormatCondition(gridExColumnFormat, ConditionOperator.Equal, 1);
                gridExFormatCondition.FormatStyle.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))));
                grdPres.RootTable.FormatConditions.Add(gridExFormatCondition);
            }
            else
            {
                Utility.VisiableGridEx(grdPres, TPrescription.Columns.Status, false);
            }
            dtNgayPhatThuoc.Enabled = HisDuocProperties.ChoPhepChinhNgayDuyet;
            chkLocNgayKhiDuyet.Checked = HisDuocProperties.LocDonThuocKhiDuyet;

            //LoadLayout();
        }
コード例 #4
0
        public ActionResult HuyXacNhanPhieuHuy_thanhly_Thuoc(TPhieuNhapxuatthuoc objPhieuNhap, ref string errMsg)
        {
            HisDuocProperties objHisDuocProperties = PropertyLib._HisDuocProperties;
            string            errorMessage         = "";

            try
            {
                using (var Scope = new TransactionScope())
                {
                    using (var dbScope = new SharedDbConnectionScope())
                    {
                        SqlQuery sqlQuery = new Select().From(TPhieuNhapxuatthuocChitiet.Schema)
                                            .Where(TPhieuNhapxuatthuocChitiet.Columns.IdPhieu).IsEqualTo(objPhieuNhap.IdPhieu);
                        TPhieuNhapxuatthuocChitietCollection objPhieuNhapCtCollection =
                            sqlQuery.ExecuteAsCollection <TPhieuNhapxuatthuocChitietCollection>();

                        foreach (TPhieuNhapxuatthuocChitiet objPhieuNhapCt in objPhieuNhapCtCollection)
                        {
                            long idthuockho = -1;
                            //Nhập lại kho thanh lý
                            StoredProcedure sp = SPs.ThuocNhapkhoOutput(objPhieuNhapCt.NgayHethan, objPhieuNhapCt.GiaNhap, objPhieuNhapCt.GiaBan,
                                                                        objPhieuNhapCt.SoLuong, Utility.DecimaltoDbnull(objPhieuNhapCt.Vat),
                                                                        objPhieuNhapCt.IdThuoc, objPhieuNhap.IdKhoxuat, objPhieuNhapCt.MaNhacungcap, objPhieuNhapCt.SoLo,
                                                                        objPhieuNhapCt.SoDky, objPhieuNhapCt.SoQdinhthau, idthuockho, idthuockho, objPhieuNhapCt.NgayNhap, objPhieuNhapCt.GiaBhyt, objPhieuNhapCt.GiaPhuthuDungtuyen, objPhieuNhapCt.GiaPhuthuTraituyen, objPhieuNhapCt.KieuThuocvattu);
                            sp.Execute();
                            idthuockho = Utility.Int64Dbnull(sp.OutputValues[0], -1);
                            if (idthuockho != objPhieuNhapCt.IdThuockho)//Nếu ai đó xóa bằng tay trong bảng thuốc kho thì cần update lại
                            {
                                new Update(TPhieuNhapxuatthuocChitiet.Schema).Set(TPhieuNhapxuatthuocChitiet.Columns.IdThuockho).EqualTo(idthuockho)
                                .Where(TPhieuNhapxuatthuocChitiet.Columns.IdPhieuchitiet).IsEqualTo(objPhieuNhapCt.IdPhieuchitiet).Execute();
                            }
                        }
                        //Xóa toàn bộ chi tiết trong TBiendongThuoc
                        new Delete().From(TBiendongThuoc.Schema)
                        .Where(TBiendongThuoc.IdPhieuColumn).IsEqualTo(objPhieuNhap.IdPhieu)
                        .And(TBiendongThuoc.MaLoaiphieuColumn).IsEqualTo(objPhieuNhap.LoaiPhieu).Execute();
                        new Update(TPhieuNhapxuatthuoc.Schema)
                        .Set(TPhieuNhapxuatthuoc.Columns.NguoiSua).EqualTo(globalVariables.UserName)
                        .Set(TPhieuNhapxuatthuoc.Columns.NgaySua).EqualTo(globalVariables.SysDate)
                        .Set(TPhieuNhapxuatthuoc.Columns.NguoiXacnhan).EqualTo(null)
                        .Set(TPhieuNhapxuatthuoc.Columns.NgayXacnhan).EqualTo(null)
                        .Set(TPhieuNhapxuatthuoc.Columns.TrangThai).EqualTo(0)
                        .Where(TPhieuNhapxuatthuoc.Columns.IdPhieu).IsEqualTo(objPhieuNhap.IdPhieu)
                        .And(TPhieuNhapxuatthuoc.LoaiPhieuColumn).IsEqualTo(objPhieuNhap.LoaiPhieu).Execute();
                    }
                    Scope.Complete();
                    return(ActionResult.Success);
                }
            }
            catch (Exception ex)
            {
                Utility.CatchException("Lỗi khi hủy xác nhận phiếu ", ex);
                return(ActionResult.Error);
            }
        }
コード例 #5
0
        /// <summary>
        /// hàm thực hiện việc xác nhận thông tin
        /// </summary>
        /// <param name="objPhieuNhap"></param>
        /// <returns></returns>
        public ActionResult XacNhanPhieuTraThuocVeKho(TPhieuNhapxuatthuoc objPhieuNhap, DateTime _ngayxacnhan)
        {
            string errorMessage = "";

            try
            {
                using (var Scope = new TransactionScope())
                {
                    using (var dbScope = new SharedDbConnectionScope())
                    {
                        HisDuocProperties objHisDuocProperties = PropertyLib._HisDuocProperties;
                        SqlQuery          sqlQuery             = new Select().From(TPhieuNhapxuatthuocChitiet.Schema)
                                                                 .Where(TPhieuNhapxuatthuocChitiet.Columns.IdPhieu).IsEqualTo(objPhieuNhap.IdPhieu);
                        TPhieuNhapxuatthuocChitietCollection objPhieuNhapCtCollection =
                            sqlQuery.ExecuteAsCollection <TPhieuNhapxuatthuocChitietCollection>();
                        foreach (TPhieuNhapxuatthuocChitiet objPhieuNhapCt in objPhieuNhapCtCollection)
                        {
                            //Insert dòng kho nhập
                            TBiendongThuoc objXuatNhap = new TBiendongThuoc();
                            objXuatNhap.IdPhieu        = Utility.Int32Dbnull(objPhieuNhapCt.IdPhieu);
                            objXuatNhap.IdPhieuChitiet = Utility.Int32Dbnull(objPhieuNhapCt.IdPhieuchitiet);
                            objXuatNhap.MaPhieu        = Utility.sDbnull(objPhieuNhap.MaPhieu);
                            objXuatNhap.DonGia         = Utility.DecimaltoDbnull(objPhieuNhapCt.GiaNhap);
                            objXuatNhap.GiaBan         = Utility.DecimaltoDbnull(objPhieuNhapCt.GiaBan);
                            objXuatNhap.SoHoadon       = Utility.sDbnull(objPhieuNhap.SoHoadon);
                            objXuatNhap.PhuThu         = 0;
                            objXuatNhap.SoLuong        = Utility.Int32Dbnull(objPhieuNhapCt.SoLuong);
                            objXuatNhap.NgayTao        = globalVariables.SysDate;
                            objXuatNhap.NguoiTao       = globalVariables.UserName;
                            objXuatNhap.ThanhTien      = Utility.DecimaltoDbnull(objPhieuNhapCt.ThanhTien);
                            objXuatNhap.IdThuoc        = Utility.Int32Dbnull(objPhieuNhapCt.IdThuoc);
                            objXuatNhap.Vat            = Utility.Int32Dbnull(objPhieuNhap.Vat);
                            objXuatNhap.IdNhanvien     = Utility.Int16Dbnull(objPhieuNhap.IdNhanvien);
                            objXuatNhap.IdKho          = Utility.Int16Dbnull(objPhieuNhap.IdKhonhap);
                            objXuatNhap.NgayHethan     = objPhieuNhapCt.NgayHethan.Date;
                            //objXuatNhap.IdNhaCcap = Utility.Int32Dbnull(objPhieuNhap.IdNhaCcap);
                            objXuatNhap.MaNhacungcap = objPhieuNhap.MaNhacungcap;
                            objXuatNhap.MaLoaiphieu  = (byte)LoaiPhieu.PhieuNhapTraKhoLe;
                            objXuatNhap.TenLoaiphieu = Utility.TenLoaiPhieu(LoaiPhieu.PhieuNhapTraKhoLe);
                            objXuatNhap.IdKhoaLinh   = objPhieuNhap.IdKhoalinh;
                            objXuatNhap.NgayBiendong = _ngayxacnhan;
                            objXuatNhap.IsNew        = true;
                            objXuatNhap.Save();
                            //Insert dòng của kho xuất
                            objXuatNhap                = new TBiendongThuoc();
                            objXuatNhap.IdPhieu        = Utility.Int32Dbnull(objPhieuNhapCt.IdPhieu);
                            objXuatNhap.IdPhieuChitiet = Utility.Int32Dbnull(objPhieuNhapCt.IdPhieuchitiet);
                            objXuatNhap.MaPhieu        = Utility.sDbnull(objPhieuNhap.MaPhieu);
                            objXuatNhap.DonGia         = Utility.DecimaltoDbnull(objPhieuNhapCt.GiaNhap);
                            objXuatNhap.GiaBan         = Utility.DecimaltoDbnull(objPhieuNhapCt.GiaBan);
                            objXuatNhap.SoHoadon       = Utility.sDbnull(objPhieuNhap.SoHoadon);
                            objXuatNhap.PhuThu         = 0;
                            objXuatNhap.SoLuong        = Utility.Int32Dbnull(objPhieuNhapCt.SoLuong);
                            objXuatNhap.NgayTao        = globalVariables.SysDate;
                            objXuatNhap.NguoiTao       = globalVariables.UserName;
                            objXuatNhap.ThanhTien      = Utility.DecimaltoDbnull(objPhieuNhapCt.ThanhTien);
                            objXuatNhap.IdThuoc        = Utility.Int32Dbnull(objPhieuNhapCt.IdThuoc);
                            objXuatNhap.Vat            = Utility.Int32Dbnull(objPhieuNhap.Vat);
                            objXuatNhap.IdNhanvien     = Utility.Int16Dbnull(objPhieuNhap.IdNhanvien);
                            objXuatNhap.IdKho          = Utility.Int16Dbnull(objPhieuNhap.IdKhoxuat);
                            objXuatNhap.NgayHethan     = objPhieuNhapCt.NgayHethan.Date;
                            //objXuatNhap.IdNhaCcap = Utility.Int32Dbnull(objPhieuNhap.IdNhaCcap);
                            objXuatNhap.MaNhacungcap = objPhieuNhap.MaNhacungcap;
                            objXuatNhap.MaLoaiphieu  = (byte)LoaiPhieu.PhieuXuatKho;
                            objXuatNhap.TenLoaiphieu = Utility.TenLoaiPhieu(LoaiPhieu.PhieuXuatKho);
                            objXuatNhap.IdKhoaLinh   = objPhieuNhap.IdKhoalinh;
                            objXuatNhap.NgayBiendong = _ngayxacnhan;
                            objXuatNhap.IsNew        = true;
                            objXuatNhap.Save();
                            StoredProcedure sp = SPs.ThuocNhapkho(objPhieuNhapCt.NgayHethan, objPhieuNhapCt.GiaNhap, objPhieuNhapCt.GiaBan,
                                                                  objPhieuNhapCt.SoLuong, Utility.DecimaltoDbnull(objPhieuNhapCt.Vat),
                                                                  objPhieuNhapCt.IdThuoc, objPhieuNhap.IdKhonhap, objPhieuNhapCt.MaNhacungcap, objPhieuNhapCt.SoLo, _ngayxacnhan, objPhieuNhapCt.GiaBhyt);
                            sp.Execute();

                            sp = SPs.ThuocXuatkho(objPhieuNhap.IdKhoxuat, objPhieuNhapCt.IdThuoc,
                                                  objPhieuNhapCt.NgayHethan, objPhieuNhapCt.GiaNhap, objPhieuNhapCt.GiaBan,
                                                  Utility.DecimaltoDbnull(objPhieuNhapCt.Vat),
                                                  Utility.Int32Dbnull(objXuatNhap.SoLuong), objPhieuNhapCt.IdThuockho,
                                                  objPhieuNhapCt.MaNhacungcap, objPhieuNhapCt.SoLo, objHisDuocProperties.XoaDulieuKhiThuocDaHet ? 1 : 0, errorMessage);

                            sp.Execute();
                            errorMessage = Utility.sDbnull(sp.OutputValues[0]);
                        }
                        new Update(TPhieuNhapxuatthuoc.Schema)
                        .Set(TPhieuNhapxuatthuoc.Columns.IdNhanvien).EqualTo(globalVariables.gv_intIDNhanvien)
                        .Set(TPhieuNhapxuatthuoc.Columns.NguoiXacnhan).EqualTo(globalVariables.UserName)
                        .Set(TPhieuNhapxuatthuoc.Columns.NgayXacnhan).EqualTo(globalVariables.SysDate)
                        .Set(TPhieuNhapxuatthuoc.Columns.TrangThai).EqualTo(1)
                        .Where(TPhieuNhapxuatthuoc.Columns.IdPhieu).IsEqualTo(objPhieuNhap.IdPhieu).Execute();
                    }
                    Scope.Complete();
                    return(ActionResult.Success);
                }
            }
            catch (Exception exception)
            {
                log.Error("Loi trong qua trinh xac nhan don thuoc :{0}", exception);
                log.Error("Loi ban ra tu sp :{0}", errorMessage);
                return(ActionResult.Error);
            }
        }
コード例 #6
0
 private void CauHinh()
 {
     HisDuocProperties = PropertyLib._HisDuocProperties;
 }
コード例 #7
0
        /// <summary>
        /// hàm thực hiện việc xác nhận thông tin
        /// </summary>
        /// <param name="objPhieuNhap"></param>
        /// <returns></returns>
        public ActionResult HuyXacNhanPhieuXuatKho(TPhieuNhapxuatthuoc objPhieuNhap, ref string errMsg)
        {
            HisDuocProperties objHisDuocProperties = PropertyLib._HisDuocProperties;
            string            errorMessage         = "";

            try
            {
                using (var Scope = new TransactionScope())
                {
                    using (var dbScope = new SharedDbConnectionScope())
                    {
                        SqlQuery sqlQuery = new Select().From(TPhieuNhapxuatthuocChitiet.Schema)
                                            .Where(TPhieuNhapxuatthuocChitiet.Columns.IdPhieu).IsEqualTo(objPhieuNhap.IdPhieu);
                        TPhieuNhapxuatthuocChitietCollection objPhieuNhapCtCollection =
                            sqlQuery.ExecuteAsCollection <TPhieuNhapxuatthuocChitietCollection>();

                        foreach (TPhieuNhapxuatthuocChitiet objPhieuNhapCt in objPhieuNhapCtCollection)
                        {
                            //Kiểm tra ở kho nhập xem thuốc đã sử dụng chưa
                            ActionResult _Kiemtrathuochuyxacnhan = Kiemtrathuochuyxacnhan(objPhieuNhap, objPhieuNhapCt, ref errMsg);
                            if (_Kiemtrathuochuyxacnhan != ActionResult.Success)
                            {
                                return(_Kiemtrathuochuyxacnhan);
                            }
                            //Xóa biến động kho nhập
                            new Delete().From(TBiendongThuoc.Schema)
                            .Where(TBiendongThuoc.IdPhieuColumn).IsEqualTo(objPhieuNhap.IdPhieu)
                            .And(TBiendongThuoc.IdPhieuChitietColumn).IsEqualTo(objPhieuNhapCt.IdPhieuchitiet)
                            .And(TBiendongThuoc.MaLoaiphieuColumn).IsEqualTo((byte)LoaiPhieu.PhieuNhapKho).Execute();
                            //Xóa biến động kho xuất
                            new Delete().From(TBiendongThuoc.Schema)
                            .Where(TBiendongThuoc.IdPhieuColumn).IsEqualTo(objPhieuNhap.IdPhieu)
                            .And(TBiendongThuoc.IdPhieuChitietColumn).IsEqualTo(objPhieuNhapCt.IdPhieuchitiet)
                            .And(TBiendongThuoc.MaLoaiphieuColumn).IsEqualTo((byte)LoaiPhieu.PhieuXuatKhoBenhNhan).Execute();
                            long id_Thuockho_new = -1;
                            new Update(TPhieuNhapxuatthuocChitiet.Schema).Set(TPhieuNhapxuatthuocChitiet.Columns.IdThuockho).EqualTo(-1)
                            .Where(TPhieuNhapxuatthuocChitiet.Columns.IdPhieuchitiet).IsEqualTo(objPhieuNhapCt.IdPhieuchitiet).Execute();
                            StoredProcedure sp = SPs.ThuocNhapkhoOutput(objPhieuNhapCt.NgayHethan, objPhieuNhapCt.GiaNhap, objPhieuNhapCt.GiaBan,
                                                                        objPhieuNhapCt.SoLuong, Utility.DecimaltoDbnull(objPhieuNhapCt.Vat),
                                                                        objPhieuNhapCt.IdThuoc, objPhieuNhap.IdKhoxuat, objPhieuNhapCt.MaNhacungcap, objPhieuNhapCt.SoLo,
                                                                        objPhieuNhapCt.SoDky, objPhieuNhapCt.SoQdinhthau, objPhieuNhapCt.IdThuockho.Value, id_Thuockho_new, objPhieuNhapCt.NgayNhap,
                                                                        objPhieuNhapCt.GiaBhyt, objPhieuNhapCt.GiaPhuthuDungtuyen, objPhieuNhapCt.GiaPhuthuTraituyen, objPhieuNhapCt.KieuThuocvattu);
                            sp.Execute();
                            sp = SPs.ThuocXuatkho(objPhieuNhap.IdKhonhap, objPhieuNhapCt.IdThuoc,
                                                  objPhieuNhapCt.NgayHethan, objPhieuNhapCt.GiaNhap, objPhieuNhapCt.GiaBan,
                                                  Utility.DecimaltoDbnull(objPhieuNhapCt.Vat),
                                                  Utility.Int32Dbnull(objPhieuNhapCt.SoLuong), objPhieuNhapCt.IdThuockho, objPhieuNhapCt.MaNhacungcap, objPhieuNhapCt.SoLo, objHisDuocProperties.XoaDulieuKhiThuocDaHet ? 1 : 0, errorMessage);
                            sp.Execute();
                        }


                        new Update(TPhieuNhapxuatthuoc.Schema)
                        .Set(TPhieuNhapxuatthuoc.Columns.IdNhanvien).EqualTo(null)
                        .Set(TPhieuNhapxuatthuoc.Columns.NguoiXacnhan).EqualTo(null)
                        .Set(TPhieuNhapxuatthuoc.Columns.NgayXacnhan).EqualTo(null)
                        .Set(TPhieuNhapxuatthuoc.Columns.TrangThai).EqualTo(0)
                        .Where(TPhieuNhapxuatthuoc.Columns.IdPhieu).IsEqualTo(objPhieuNhap.IdPhieu)
                        .And(TPhieuNhapxuatthuoc.LoaiPhieuColumn).IsEqualTo(objPhieuNhap.LoaiPhieu).Execute();
                    }
                    Scope.Complete();
                    return(ActionResult.Success);
                }
            }
            catch (Exception ex)
            {
                Utility.CatchException("Lỗi khi hủy xác nhận phiếu chuyển kho", ex);
                return(ActionResult.Error);
            }
        }
コード例 #8
0
        public ActionResult XacnhanPhieuTrathuocNhacungcap(TPhieuNhapxuatthuoc objPhieuNhap)
        {
            HisDuocProperties objHisDuocProperties = PropertyLib._HisDuocProperties;
            string            errorMessage         = "";

            try
            {
                using (var Scope = new TransactionScope())
                {
                    using (var dbScope = new SharedDbConnectionScope())
                    {
                        SqlQuery sqlQuery = new Select().From(TPhieuNhapxuatthuocChitiet.Schema)
                                            .Where(TPhieuNhapxuatthuocChitiet.Columns.IdPhieu).IsEqualTo(objPhieuNhap.IdPhieu);
                        TPhieuNhapxuatthuocChitietCollection objPhieuNhapCtCollection =
                            sqlQuery.ExecuteAsCollection <TPhieuNhapxuatthuocChitietCollection>();
                        foreach (TPhieuNhapxuatthuocChitiet objPhieuNhapCt in objPhieuNhapCtCollection)
                        {
                            //Insert dòng hủy vào TBiendongThuoc
                            TBiendongThuoc objXuatNhap = new TBiendongThuoc();
                            objXuatNhap.IdPhieu        = Utility.Int32Dbnull(objPhieuNhapCt.IdPhieu);
                            objXuatNhap.IdPhieuChitiet = Utility.Int32Dbnull(objPhieuNhapCt.IdPhieuchitiet);
                            objXuatNhap.MaPhieu        = Utility.sDbnull(objPhieuNhap.MaPhieu);
                            objXuatNhap.DonGia         = Utility.DecimaltoDbnull(objPhieuNhapCt.DonGia);
                            objXuatNhap.NgayHoadon     = objPhieuNhap.NgayHoadon;
                            objXuatNhap.GiaBan         = Utility.DecimaltoDbnull(objPhieuNhapCt.GiaBan);
                            objXuatNhap.GiaNhap        = Utility.DecimaltoDbnull(objPhieuNhapCt.GiaNhap);
                            objXuatNhap.SoDky          = objPhieuNhapCt.SoDky;
                            objXuatNhap.SoQdinhthau    = objPhieuNhapCt.SoQdinhthau;
                            objXuatNhap.SoLo           = objPhieuNhapCt.SoLo;
                            objXuatNhap.IdThuockho     = Utility.Int32Dbnull(objPhieuNhapCt.IdThuockho);
                            objXuatNhap.KieuThuocvattu = Utility.sDbnull(objPhieuNhapCt.KieuThuocvattu);

                            objXuatNhap.SoChungtuKemtheo   = "";
                            objXuatNhap.Noitru             = 0;
                            objXuatNhap.QuayThuoc          = 0;
                            objXuatNhap.GiaBhyt            = 0;
                            objXuatNhap.GiaBhytCu          = 0;
                            objXuatNhap.GiaPhuthuDungtuyen = 0;
                            objXuatNhap.GiaPhuthuTraituyen = 0;
                            objXuatNhap.DuTru = 0;

                            objXuatNhap.SoHoadon     = Utility.sDbnull(objPhieuNhap.SoHoadon);
                            objXuatNhap.PhuThu       = 0;
                            objXuatNhap.SoLuong      = Utility.Int32Dbnull(objPhieuNhapCt.SoLuong);
                            objXuatNhap.NgayTao      = globalVariables.SysDate;
                            objXuatNhap.NguoiTao     = globalVariables.UserName;
                            objXuatNhap.ThanhTien    = Utility.DecimaltoDbnull(objPhieuNhapCt.ThanhTien);
                            objXuatNhap.IdThuoc      = Utility.Int32Dbnull(objPhieuNhapCt.IdThuoc);
                            objXuatNhap.Vat          = Utility.Int32Dbnull(objPhieuNhap.Vat);
                            objXuatNhap.IdNhanvien   = Utility.Int16Dbnull(objPhieuNhap.IdNhanvien);
                            objXuatNhap.IdKho        = Utility.Int16Dbnull(objPhieuNhap.IdKhoxuat);
                            objXuatNhap.NgayHethan   = objPhieuNhapCt.NgayHethan.Date;
                            objXuatNhap.MaNhacungcap = objPhieuNhap.MaNhacungcap;
                            objXuatNhap.MaLoaiphieu  = objPhieuNhap.LoaiPhieu;
                            objXuatNhap.TenLoaiphieu = objPhieuNhap.TenLoaiphieu;
                            objXuatNhap.NgayBiendong = objPhieuNhap.NgayHoadon;
                            objXuatNhap.IsNew        = true;
                            objXuatNhap.Save();
                            StoredProcedure sp = SPs.ThuocXuatkho(objPhieuNhap.IdKhoxuat, objPhieuNhapCt.IdThuoc,
                                                                  objPhieuNhapCt.NgayHethan, objPhieuNhapCt.GiaNhap, objPhieuNhapCt.GiaBan,
                                                                  Utility.DecimaltoDbnull(objPhieuNhapCt.Vat),
                                                                  Utility.Int32Dbnull(objXuatNhap.SoLuong), objPhieuNhapCt.IdThuockho, objPhieuNhapCt.MaNhacungcap, objPhieuNhapCt.SoLo, objHisDuocProperties.XoaDulieuKhiThuocDaHet ? 1 : 0, errorMessage);

                            sp.Execute();
                        }
                        new Update(TPhieuNhapxuatthuoc.Schema)
                        .Set(TPhieuNhapxuatthuoc.Columns.IdNhanvien).EqualTo(globalVariables.gv_intIDNhanvien)
                        .Set(TPhieuNhapxuatthuoc.Columns.NguoiXacnhan).EqualTo(globalVariables.UserName)
                        .Set(TPhieuNhapxuatthuoc.Columns.NgayXacnhan).EqualTo(globalVariables.SysDate)
                        .Set(TPhieuNhapxuatthuoc.Columns.TrangThai).EqualTo(1)
                        .Where(TPhieuNhapxuatthuoc.Columns.IdPhieu).IsEqualTo(objPhieuNhap.IdPhieu).Execute();
                    }
                    Scope.Complete();
                    return(ActionResult.Success);
                }
            }
            catch (Exception exception)
            {
                log.Error("Loi ban ra tu sp :{0}", errorMessage);
                log.Error("Loi trong qua trinh xac nhan don thuoc :{0}", exception);
                return(ActionResult.Error);
            }
        }
コード例 #9
0
        public ActionResult XacNhanPhieuHuy_thanhly_thuoc(TPhieuNhapxuatthuoc objPhieuNhap, DateTime ngayxacnhan, ref string errMsg)
        {
            HisDuocProperties objHisDuocProperties = PropertyLib._HisDuocProperties;
            string            errorMessage         = "";

            try
            {
                using (var Scope = new TransactionScope())
                {
                    using (var dbScope = new SharedDbConnectionScope())
                    {
                        SqlQuery sqlQuery = new Select().From(TPhieuNhapxuatthuocChitiet.Schema)
                                            .Where(TPhieuNhapxuatthuocChitiet.Columns.IdPhieu).IsEqualTo(objPhieuNhap.IdPhieu);
                        TPhieuNhapxuatthuocChitietCollection objPhieuNhapCtCollection =
                            sqlQuery.ExecuteAsCollection <TPhieuNhapxuatthuocChitietCollection>();
                        objPhieuNhap.NgayXacnhan = ngayxacnhan;
                        foreach (TPhieuNhapxuatthuocChitiet objPhieuNhapCt in objPhieuNhapCtCollection)
                        {
                            //Kiểm tra đề phòng Kho A-->Xuất kho B. Kho B xác nhận-->Xuất kho C. Kho B hủy xác nhận. Kho C xác nhận dẫn tới việc kho B chưa có thuốc để trừ kho

                            ActionResult _Kiemtrathuocxacnhan = Kiemtrathuocxacnhan(objPhieuNhap, objPhieuNhapCt, ref errMsg);
                            if (_Kiemtrathuocxacnhan != ActionResult.Success)
                            {
                                return(_Kiemtrathuocxacnhan);
                            }

                            long            idthuockho = -1;
                            StoredProcedure sp         = SPs.ThuocXuatkho(objPhieuNhap.IdKhoxuat, objPhieuNhapCt.IdThuoc,
                                                                          objPhieuNhapCt.NgayHethan, objPhieuNhapCt.GiaNhap, objPhieuNhapCt.GiaBan,
                                                                          Utility.DecimaltoDbnull(objPhieuNhapCt.Vat),
                                                                          Utility.Int32Dbnull(objPhieuNhapCt.SoLuong), objPhieuNhapCt.IdChuyen,
                                                                          objPhieuNhapCt.MaNhacungcap, objPhieuNhapCt.SoLo,
                                                                          objHisDuocProperties.XoaDulieuKhiThuocDaHet ? 1 : 0, errorMessage);

                            sp.Execute();
                            //Insert dòng kho xuất
                            TBiendongThuoc objXuatNhap = new TBiendongThuoc();
                            objXuatNhap.IdPhieu        = Utility.Int32Dbnull(objPhieuNhapCt.IdPhieu);
                            objXuatNhap.IdPhieuChitiet = Utility.Int32Dbnull(objPhieuNhapCt.IdPhieuchitiet);
                            objXuatNhap.MaPhieu        = Utility.sDbnull(objPhieuNhap.MaPhieu);
                            objXuatNhap.DonGia         = Utility.DecimaltoDbnull(objPhieuNhapCt.DonGia);
                            objXuatNhap.GiaBan         = Utility.DecimaltoDbnull(objPhieuNhapCt.GiaBan);
                            objXuatNhap.GiaNhap        = Utility.DecimaltoDbnull(objPhieuNhapCt.GiaNhap);
                            objXuatNhap.SoHoadon       = Utility.sDbnull(objPhieuNhap.SoHoadon);

                            objXuatNhap.GiaBhyt            = objPhieuNhapCt.GiaBhyt;
                            objXuatNhap.GiaBhytCu          = objPhieuNhapCt.GiaBhytCu;
                            objXuatNhap.GiaPhuthuDungtuyen = objPhieuNhapCt.GiaPhuthuDungtuyen;
                            objXuatNhap.GiaPhuthuTraituyen = objPhieuNhapCt.GiaPhuthuTraituyen;

                            objXuatNhap.NgayNhap   = objPhieuNhapCt.NgayNhap;
                            objXuatNhap.Noitru     = 0;
                            objXuatNhap.QuayThuoc  = 0;
                            objXuatNhap.PhuThu     = 0;
                            objXuatNhap.DuTru      = objPhieuNhap.DuTru;
                            objXuatNhap.SoLuong    = Utility.Int32Dbnull(objPhieuNhapCt.SoLuong);
                            objXuatNhap.NgayTao    = globalVariables.SysDate;
                            objXuatNhap.NguoiTao   = globalVariables.UserName;
                            objXuatNhap.IdThuockho = Utility.Int32Dbnull(objPhieuNhapCt.IdChuyen);

                            objXuatNhap.ThanhTien        = Utility.DecimaltoDbnull(objPhieuNhapCt.ThanhTien);
                            objXuatNhap.IdThuoc          = Utility.Int32Dbnull(objPhieuNhapCt.IdThuoc);
                            objXuatNhap.Vat              = Utility.Int32Dbnull(objPhieuNhap.Vat);
                            objXuatNhap.IdNhanvien       = Utility.Int16Dbnull(objPhieuNhap.IdNhanvien);
                            objXuatNhap.IdKho            = Utility.Int16Dbnull(objPhieuNhap.IdKhoxuat);
                            objXuatNhap.NgayHethan       = objPhieuNhapCt.NgayHethan.Date;
                            objXuatNhap.MaNhacungcap     = objPhieuNhapCt.MaNhacungcap;
                            objXuatNhap.SoChungtuKemtheo = objPhieuNhap.SoChungtuKemtheo;
                            objXuatNhap.SoDky            = objPhieuNhapCt.SoDky;
                            objXuatNhap.SoQdinhthau      = objPhieuNhapCt.SoQdinhthau;
                            objXuatNhap.SoLo             = objPhieuNhapCt.SoLo;
                            objXuatNhap.MaLoaiphieu      = objPhieuNhap.LoaiPhieu;
                            objXuatNhap.TenLoaiphieu     = objPhieuNhap.TenLoaiphieu;
                            objXuatNhap.NgayBiendong     = objPhieuNhap.NgayXacnhan;
                            objXuatNhap.NgayHoadon       = objPhieuNhap.NgayHoadon;
                            objXuatNhap.KieuThuocvattu   = objPhieuNhapCt.KieuThuocvattu;
                            objXuatNhap.IsNew            = true;
                            objXuatNhap.Save();
                        }
                        new Update(TPhieuNhapxuatthuoc.Schema)
                        .Set(TPhieuNhapxuatthuoc.Columns.NguoiSua).EqualTo(globalVariables.UserName)
                        .Set(TPhieuNhapxuatthuoc.Columns.NgaySua).EqualTo(globalVariables.SysDate)
                        .Set(TPhieuNhapxuatthuoc.Columns.NguoiXacnhan).EqualTo(globalVariables.UserName)
                        .Set(TPhieuNhapxuatthuoc.Columns.NgayXacnhan).EqualTo(ngayxacnhan)
                        .Set(TPhieuNhapxuatthuoc.Columns.TrangThai).EqualTo(1)
                        .Where(TPhieuNhapxuatthuoc.Columns.IdPhieu).IsEqualTo(objPhieuNhap.IdPhieu)
                        .And(TPhieuNhapxuatthuoc.LoaiPhieuColumn).IsEqualTo(objPhieuNhap.LoaiPhieu).Execute();
                    }
                    Scope.Complete();
                    return(ActionResult.Success);
                }
            }
            catch (Exception ex)
            {
                Utility.CatchException("Lỗi khi xác nhận phiếu ", ex);
                return(ActionResult.Error);
            }
        }
コード例 #10
0
        /// <summary>
        /// hàm thực hiện việc xác nhận phiếu nhập
        /// </summary>
        /// <param name="objPhieuNhap"></param>
        /// <returns></returns>
        public ActionResult XacNhanPhieuNhapTraNhaCungCap(TPhieutrathuocKholeVekhochan objPhieuNhap)
        {
            HisDuocProperties objHisDuocProperties = PropertyLib._HisDuocProperties;
            string            errorMessage         = "";

            try
            {
                using (var Scope = new TransactionScope())
                {
                    using (var dbScope = new SharedDbConnectionScope())
                    {
                        SqlQuery sqlQuery = new Select().From(TPhieutrathuocKholeVekhochanChitiet.Schema)
                                            .Where(TPhieutrathuocKholeVekhochanChitiet.Columns.IdPhieu).IsEqualTo(objPhieuNhap.IdPhieu);
                        TPhieutrathuocKholeVekhochanChitietCollection objPhieuNhapCtCollection =
                            sqlQuery.ExecuteAsCollection <TPhieutrathuocKholeVekhochanChitietCollection>();
                        foreach (TPhieutrathuocKholeVekhochanChitiet objPhieuNhapCt in objPhieuNhapCtCollection)
                        {
                            ///phiếu nhập trả từ kho lẻ về kho chẵn
                            TBiendongThuoc objXuatNhap = new TBiendongThuoc();
                            objXuatNhap.IdPhieu        = Utility.Int32Dbnull(objPhieuNhapCt.IdPhieu);
                            objXuatNhap.IdPhieuChitiet = Utility.Int32Dbnull(objPhieuNhapCt.IdPhieuChitiet);
                            objXuatNhap.MaPhieu        = Utility.sDbnull(objPhieuNhap.MaPhieu);
                            objXuatNhap.GiaNhap        = Utility.DecimaltoDbnull(objPhieuNhapCt.GiaNhap);
                            objXuatNhap.SoHoadon       = string.Empty;
                            objXuatNhap.PhuThu         = 0;
                            objXuatNhap.SoLuong        = Utility.Int32Dbnull(objPhieuNhapCt.SoLuong);
                            objXuatNhap.NgayTao        = globalVariables.SysDate;
                            objXuatNhap.NguoiTao       = globalVariables.UserName;
                            objXuatNhap.ThanhTien      = Utility.DecimaltoDbnull(objPhieuNhapCt.ThanhTien);
                            objXuatNhap.IdThuoc        = Utility.Int32Dbnull(objPhieuNhapCt.IdThuoc);
                            objXuatNhap.Vat            = Utility.Int32Dbnull(objPhieuNhapCt.Vat);
                            objXuatNhap.IdNhanvien     = Utility.Int16Dbnull(objPhieuNhap.IdNhanvien);
                            objXuatNhap.IdKhoaLinh     = Utility.Int16Dbnull(objPhieuNhap.IdKhonhan);
                            objXuatNhap.IdKho          = Utility.Int16Dbnull(objPhieuNhap.IdKhonhan);
                            objXuatNhap.NgayHethan     = objPhieuNhapCt.NgayHethan;
                            objXuatNhap.MaNhacungcap   = objPhieuNhap.MaNhacungcap;
                            objXuatNhap.MaLoaiphieu    = Utility.ByteDbnull(LoaiPhieu.PhieuNhapTraLaiKhoLeVeKhoChan);
                            objXuatNhap.TenLoaiphieu   = Utility.sDbnull(objPhieuNhap.TenLoaiphieu);
                            objXuatNhap.NgayBiendong   = objPhieuNhap.NgayXacnhan;
                            objXuatNhap.IsNew          = true;
                            objXuatNhap.Save();
                            StoredProcedure sp = SPs.ThuocNhapkho(objPhieuNhapCt.NgayHethan, objPhieuNhapCt.GiaNhap, objPhieuNhapCt.GiaBan,
                                                                  objPhieuNhapCt.SoLuong, Utility.DecimaltoDbnull(objPhieuNhapCt.Vat),
                                                                  objPhieuNhapCt.IdThuoc, objPhieuNhap.IdKhonhan, objPhieuNhapCt.MaNhacungcap, objPhieuNhapCt.SoLo, objPhieuNhap.NgayXacnhan, objPhieuNhapCt.GiaBhyt);
                            sp.Execute();
                            log.Info(string.Format("Nhạp tra lai kho {0} voi so phieu {1}", objPhieuNhap.IdKhonhan, objPhieuNhapCt.IdPhieuChitiet));
                            ///phiếu xuất về kho từ kho lẻ
                            objXuatNhap                = new TBiendongThuoc();
                            objXuatNhap.IdPhieu        = Utility.Int32Dbnull(objPhieuNhapCt.IdPhieu);
                            objXuatNhap.IdPhieuChitiet = Utility.Int32Dbnull(objPhieuNhapCt.IdPhieuChitiet);
                            objXuatNhap.MaPhieu        = Utility.sDbnull(objPhieuNhap.MaPhieu);
                            objXuatNhap.GiaNhap        = Utility.DecimaltoDbnull(objPhieuNhapCt.GiaNhap);
                            objXuatNhap.SoHoadon       = string.Empty;
                            objXuatNhap.PhuThu         = 0;
                            objXuatNhap.SoLuong        = Utility.Int32Dbnull(objPhieuNhapCt.SoLuong);
                            objXuatNhap.NgayTao        = globalVariables.SysDate;
                            objXuatNhap.NguoiTao       = globalVariables.UserName;
                            objXuatNhap.ThanhTien      = Utility.DecimaltoDbnull(objPhieuNhapCt.ThanhTien);
                            objXuatNhap.IdThuoc        = Utility.Int32Dbnull(objPhieuNhapCt.IdThuoc);
                            objXuatNhap.Vat            = Utility.Int32Dbnull(objPhieuNhapCt.Vat);
                            objXuatNhap.IdNhanvien     = Utility.Int16Dbnull(objPhieuNhap.IdNhanvien);
                            objXuatNhap.IdKhoaLinh     = Utility.Int16Dbnull(objPhieuNhap.IdKhonhan);
                            objXuatNhap.IdKho          = Utility.Int16Dbnull(objPhieuNhap.IdKhonhan);
                            objXuatNhap.NgayHethan     = objPhieuNhapCt.NgayHethan;
                            objXuatNhap.MaNhacungcap   = objPhieuNhap.MaNhacungcap;
                            objXuatNhap.MaLoaiphieu    = Utility.ByteDbnull(LoaiPhieu.PhieuXuatKho);
                            objXuatNhap.TenLoaiphieu   = Utility.sDbnull(objPhieuNhap.TenLoaiphieu);
                            objXuatNhap.NgayBiendong   = objPhieuNhap.NgayXacnhan;
                            objXuatNhap.IsNew          = true;
                            objXuatNhap.Save();
                            sp = SPs.ThuocXuatkho(objPhieuNhap.IdKhotra, objPhieuNhapCt.IdThuoc,
                                                  objPhieuNhapCt.NgayHethan, objPhieuNhapCt.GiaNhap, objPhieuNhapCt.GiaBan,
                                                  Utility.DecimaltoDbnull(objPhieuNhapCt.Vat),
                                                  Utility.Int32Dbnull(objXuatNhap.SoLuong), objPhieuNhapCt.IdThuockho, objPhieuNhapCt.MaNhacungcap, objPhieuNhapCt.SoLo, objHisDuocProperties.XoaDulieuKhiThuocDaHet ? 1 : 0, errorMessage);

                            sp.Execute();
                            log.Info(string.Format("xuat tra lai kho {0} voi so phieu {1}", objPhieuNhap.IdKhotra, objPhieuNhapCt.IdPhieuChitiet));
                        }
                        new Update(TPhieutrathuocKholeVekhochan.Schema)
                        .Set(TPhieutrathuocKholeVekhochan.Columns.NgaySua).EqualTo(globalVariables.SysDate)
                        .Set(TPhieutrathuocKholeVekhochan.Columns.NguoiSua).EqualTo(globalVariables.UserName)
                        .Set(TPhieutrathuocKholeVekhochan.Columns.IdNhanvien).EqualTo(globalVariables.gv_intIDNhanvien)
                        .Set(TPhieutrathuocKholeVekhochan.Columns.NguoiXacnhan).EqualTo(globalVariables.UserName)
                        .Set(TPhieutrathuocKholeVekhochan.Columns.NgayXacnhan).EqualTo(globalVariables.SysDate)
                        .Set(TPhieutrathuocKholeVekhochan.Columns.TrangThai).EqualTo(1)
                        .Where(TPhieutrathuocKholeVekhochan.Columns.IdPhieu).IsEqualTo(objPhieuNhap.IdPhieu)
                        .And(TPhieutrathuocKholeVekhochan.LoaiPhieuColumn).IsEqualTo(objPhieuNhap.LoaiPhieu).Execute();
                    }
                    Scope.Complete();
                    return(ActionResult.Success);
                }
            }
            catch (Exception exception)
            {
                log.Error("Loi ban ra tu sp :{0}", errorMessage);
                log.Error("Loi trong qua trinh xac nhan don thuoc :{0}", exception);
                return(ActionResult.Error);
            }
        }
コード例 #11
0
        /// <summary>
        /// hàm thực hiện việc xác nhận thông tin
        /// </summary>
        /// <param name="objPhieuNhap"></param>
        /// <returns></returns>
        public ActionResult HuyXacNhanPhieuTralaiKho(TPhieutrathuocKholeVekhochan objPhieuNhapTra)
        {
            HisDuocProperties objHisDuocProperties = PropertyLib._HisDuocProperties;
            string            errorMessage         = "";

            try
            {
                using (var Scope = new TransactionScope())
                {
                    using (var dbScope = new SharedDbConnectionScope())
                    {
                        SqlQuery sqlQuery = new Select().From(TPhieutrathuocKholeVekhochanChitiet.Schema)
                                            .Where(TPhieutrathuocKholeVekhochanChitiet.Columns.IdPhieu).IsEqualTo(objPhieuNhapTra.IdPhieu);
                        TPhieutrathuocKholeVekhochanChitietCollection objPhieuNhaptraCtCollection =
                            sqlQuery.ExecuteAsCollection <TPhieutrathuocKholeVekhochanChitietCollection>();

                        foreach (TPhieutrathuocKholeVekhochanChitiet objPhieuNhapTraCt in objPhieuNhaptraCtCollection)
                        {
                            //Kiểm tra ở kho lĩnh xem thuốc đã sử dụng chưa
                            ActionResult _Kiemtrathuochuyxacnhan = Kiemtrathuochuyxacnhan(objPhieuNhapTra, objPhieuNhapTraCt);
                            if (_Kiemtrathuochuyxacnhan != ActionResult.Success)
                            {
                                return(_Kiemtrathuochuyxacnhan);
                            }

                            //Xóa toàn bộ chi tiết trong TBiendongThuoc
                            new Delete().From(TBiendongThuoc.Schema)
                            .Where(TBiendongThuoc.IdPhieuColumn).IsEqualTo(objPhieuNhapTra.IdPhieu)
                            .And(TBiendongThuoc.IdPhieuChitietColumn).IsEqualTo(objPhieuNhapTraCt.IdPhieuChitiet)
                            .And(TBiendongThuoc.MaLoaiphieuColumn).IsEqualTo(LoaiPhieu.PhieuNhapTraLaiKhoLeVeKhoChan).Execute();

                            //Xóa toàn bộ chi tiết trong TBiendongThuoc
                            new Delete().From(TBiendongThuoc.Schema)
                            .Where(TBiendongThuoc.IdPhieuColumn).IsEqualTo(objPhieuNhapTra.IdPhieu)
                            .And(TBiendongThuoc.IdPhieuChitietColumn).IsEqualTo(objPhieuNhapTraCt.IdPhieuChitiet)
                            .And(TBiendongThuoc.MaLoaiphieuColumn).IsEqualTo(LoaiPhieu.PhieuXuatKhoLeTraKhoChan).Execute();

                            new Update(TPhieutrathuocKholeVekhochanChitiet.Schema).Set(TPhieutrathuocKholeVekhochanChitiet.Columns.IdChuyen).EqualTo(-1)
                            .Where(TPhieutrathuocKholeVekhochanChitiet.Columns.IdPhieuChitiet).IsEqualTo(objPhieuNhapTraCt.IdPhieuChitiet).Execute();

                            StoredProcedure sp = SPs.ThuocNhapkho(objPhieuNhapTraCt.NgayHethan, objPhieuNhapTraCt.GiaNhap, objPhieuNhapTraCt.GiaBan,
                                                                  objPhieuNhapTraCt.SoLuong, Utility.DecimaltoDbnull(objPhieuNhapTraCt.Vat),
                                                                  objPhieuNhapTraCt.IdThuoc, objPhieuNhapTra.IdKhotra, objPhieuNhapTraCt.MaNhacungcap, objPhieuNhapTraCt.SoLo, objPhieuNhapTraCt.NgayNhap, objPhieuNhapTraCt.GiaBhyt);
                            sp.Execute();
                            sp = SPs.ThuocXuatkho(objPhieuNhapTra.IdKhonhan, objPhieuNhapTraCt.IdThuoc,
                                                  objPhieuNhapTraCt.NgayHethan, objPhieuNhapTraCt.GiaNhap, objPhieuNhapTraCt.GiaBan,
                                                  Utility.DecimaltoDbnull(objPhieuNhapTraCt.Vat),
                                                  Utility.Int32Dbnull(objPhieuNhapTraCt.SoLuong), objPhieuNhapTraCt.IdChuyen, objPhieuNhapTraCt.MaNhacungcap, objPhieuNhapTraCt.SoLo, objHisDuocProperties.XoaDulieuKhiThuocDaHet ? 1 : 0, errorMessage);

                            sp.Execute();
                        }


                        new Update(TPhieutrathuocKholeVekhochan.Schema)
                        .Set(TPhieutrathuocKholeVekhochan.Columns.IdNhanvien).EqualTo(null)
                        .Set(TPhieutrathuocKholeVekhochan.Columns.NguoiXacnhan).EqualTo(null)
                        .Set(TPhieutrathuocKholeVekhochan.Columns.NgayXacnhan).EqualTo(null)
                        .Set(TPhieutrathuocKholeVekhochan.Columns.TrangThai).EqualTo(0)
                        .Where(TPhieutrathuocKholeVekhochan.Columns.IdPhieu).IsEqualTo(objPhieuNhapTra.IdPhieu)
                        .And(TPhieutrathuocKholeVekhochan.LoaiPhieuColumn).IsEqualTo(objPhieuNhapTra.LoaiPhieu).Execute();
                    }
                    Scope.Complete();
                    return(ActionResult.Success);
                }
            }
            catch (Exception exception)
            {
                log.Error("Loi ban ra tu sp :{0}", errorMessage);
                log.Error("Loi trong qua trinh xac nhan don thuoc :{0}", exception);
                return(ActionResult.Error);
            }
        }
コード例 #12
0
        /// <summary>
        /// hàm thực hiện việc xác nhận thông tin
        /// </summary>
        /// <param name="objPhieuNhap"></param>
        /// <returns></returns>
        public ActionResult XacNhanTraLaiKhoLeVeKhoChan(TPhieutrathuocKholeVekhochan objPhieuNhap, DateTime _ngayxacnhan)
        {
            HisDuocProperties objHisDuocProperties = PropertyLib._HisDuocProperties;
            string            errorMessage         = "";

            try
            {
                using (var Scope = new TransactionScope())
                {
                    using (var dbScope = new SharedDbConnectionScope())
                    {
                        SqlQuery sqlQuery = new Select().From(TPhieutrathuocKholeVekhochanChitiet.Schema)
                                            .Where(TPhieutrathuocKholeVekhochanChitiet.Columns.IdPhieu).IsEqualTo(objPhieuNhap.IdPhieu);
                        TPhieutrathuocKholeVekhochanChitietCollection objPhieuNhapCtCollection =
                            sqlQuery.ExecuteAsCollection <TPhieutrathuocKholeVekhochanChitietCollection>();
                        foreach (TPhieutrathuocKholeVekhochanChitiet objPhieuNhapCt in objPhieuNhapCtCollection)
                        {
                            long            idthuockho = -1;
                            StoredProcedure sp         = SPs.ThuocNhapkhoOutput(objPhieuNhapCt.NgayHethan, objPhieuNhapCt.GiaNhap, objPhieuNhapCt.GiaBan,
                                                                                objPhieuNhapCt.SoLuong, Utility.DecimaltoDbnull(objPhieuNhapCt.Vat),
                                                                                objPhieuNhapCt.IdThuoc, objPhieuNhap.IdKhonhan, objPhieuNhapCt.MaNhacungcap,
                                                                                objPhieuNhapCt.SoLo, objPhieuNhapCt.SoDky, objPhieuNhapCt.SoQdinhthau, objPhieuNhapCt.IdThuockho, idthuockho, objPhieuNhapCt.NgayNhap, objPhieuNhapCt.GiaBhyt, objPhieuNhapCt.PhuthuDungtuyen, objPhieuNhapCt.PhuthuTraituyen, objPhieuNhapCt.KieuThuocvattu);
                            sp.Execute();
                            idthuockho = Utility.Int64Dbnull(sp.OutputValues[0], -1);
                            //log.Info(string.Format("Nhạp tra lai kho {0} voi so phieu {1}", objPhieuNhap.IdKhonhan, objPhieuNhapCt.IdPhieuChitiet));

                            sp = SPs.ThuocXuatkho(objPhieuNhap.IdKhotra, objPhieuNhapCt.IdThuoc,
                                                  objPhieuNhapCt.NgayHethan, objPhieuNhapCt.GiaNhap, objPhieuNhapCt.GiaBan,
                                                  Utility.DecimaltoDbnull(objPhieuNhapCt.Vat),
                                                  Utility.Int32Dbnull(objPhieuNhapCt.SoLuong), objPhieuNhapCt.IdThuockho,
                                                  objPhieuNhapCt.MaNhacungcap, objPhieuNhapCt.SoLo, objHisDuocProperties.XoaDulieuKhiThuocDaHet ? 1 : 0, errorMessage);

                            sp.Execute();
                            new Update(TPhieutrathuocKholeVekhochanChitiet.Schema).Set(TPhieutrathuocKholeVekhochanChitiet.Columns.IdChuyen).EqualTo(idthuockho)
                            .Where(TPhieutrathuocKholeVekhochanChitiet.Columns.IdPhieuChitiet).IsEqualTo(objPhieuNhapCt.IdPhieuChitiet).Execute();
                            objPhieuNhapCt.IdThuockho = idthuockho;
                            ///phiếu nhập trả từ kho lẻ về kho chẵn
                            TBiendongThuoc objXuatNhap = new TBiendongThuoc();
                            objXuatNhap.IdPhieu        = Utility.Int32Dbnull(objPhieuNhapCt.IdPhieu);
                            objXuatNhap.IdPhieuChitiet = Utility.Int32Dbnull(objPhieuNhapCt.IdPhieuChitiet);
                            objXuatNhap.MaPhieu        = Utility.sDbnull(objPhieuNhap.MaPhieu);
                            objXuatNhap.GiaNhap        = Utility.DecimaltoDbnull(objPhieuNhapCt.GiaNhap);
                            objXuatNhap.GiaBan         = Utility.DecimaltoDbnull(objPhieuNhapCt.GiaBan);
                            objXuatNhap.NgayNhap       = objPhieuNhapCt.NgayNhap;
                            objXuatNhap.DonGia         = Utility.DecimaltoDbnull(objPhieuNhapCt.DonGia);
                            objXuatNhap.NgayHoadon     = objPhieuNhap.NgayTra;
                            objXuatNhap.KieuThuocvattu = Utility.sDbnull(objPhieuNhapCt.KieuThuocvattu);

                            objXuatNhap.SoChungtuKemtheo   = "";
                            objXuatNhap.Noitru             = 0;
                            objXuatNhap.QuayThuoc          = 0;
                            objXuatNhap.GiaBhyt            = objPhieuNhapCt.GiaBhyt;
                            objXuatNhap.GiaBhytCu          = 0;
                            objXuatNhap.ThuocVay           = 0;
                            objXuatNhap.GiaPhuthuDungtuyen = objPhieuNhapCt.PhuthuDungtuyen;
                            objXuatNhap.GiaPhuthuTraituyen = objPhieuNhapCt.PhuthuTraituyen;
                            objXuatNhap.DuTru = 0;


                            objXuatNhap.MaNhacungcap   = objPhieuNhapCt.MaNhacungcap;
                            objXuatNhap.SoLo           = objPhieuNhapCt.SoLo;
                            objXuatNhap.SoDky          = objPhieuNhapCt.SoDky;
                            objXuatNhap.SoQdinhthau    = objPhieuNhapCt.SoQdinhthau;
                            objXuatNhap.IdThuockho     = objPhieuNhapCt.IdThuockho;
                            objXuatNhap.SoHoadon       = string.Empty;
                            objXuatNhap.PhuThu         = 0;
                            objXuatNhap.SoLuong        = Utility.Int32Dbnull(objPhieuNhapCt.SoLuong);
                            objXuatNhap.NgayTao        = globalVariables.SysDate;
                            objXuatNhap.NguoiTao       = globalVariables.UserName;
                            objXuatNhap.ThanhTien      = Utility.DecimaltoDbnull(objPhieuNhapCt.ThanhTien);
                            objXuatNhap.IdThuoc        = Utility.Int32Dbnull(objPhieuNhapCt.IdThuoc);
                            objXuatNhap.Vat            = Utility.Int32Dbnull(objPhieuNhapCt.Vat);
                            objXuatNhap.IdNhanvien     = Utility.Int16Dbnull(objPhieuNhap.IdNhanvien);
                            objXuatNhap.IdKhoaLinh     = Utility.Int16Dbnull(objPhieuNhap.IdKhonhan);
                            objXuatNhap.IdKho          = Utility.Int16Dbnull(objPhieuNhap.IdKhonhan);
                            objXuatNhap.NgayHethan     = objPhieuNhapCt.NgayHethan;
                            objXuatNhap.MaLoaiphieu    = Utility.ByteDbnull(LoaiPhieu.PhieuNhapTraLaiKhoLeVeKhoChan);
                            objXuatNhap.TenLoaiphieu   = Utility.TenLoaiPhieu(LoaiPhieu.PhieuNhapTraLaiKhoLeVeKhoChan);
                            objXuatNhap.NgayBiendong   = _ngayxacnhan;
                            objXuatNhap.KieuThuocvattu = objPhieuNhapCt.KieuThuocvattu;
                            objXuatNhap.IsNew          = true;
                            objXuatNhap.Save();

                            ///phiếu xuất về kho từ kho lẻ
                            objXuatNhap                = new TBiendongThuoc();
                            objXuatNhap.IdPhieu        = Utility.Int32Dbnull(objPhieuNhapCt.IdPhieu);
                            objXuatNhap.IdPhieuChitiet = Utility.Int32Dbnull(objPhieuNhapCt.IdPhieuChitiet);
                            objXuatNhap.MaPhieu        = Utility.sDbnull(objPhieuNhap.MaPhieu);
                            objXuatNhap.GiaNhap        = Utility.DecimaltoDbnull(objPhieuNhapCt.GiaNhap);
                            objXuatNhap.GiaBan         = Utility.DecimaltoDbnull(objPhieuNhapCt.GiaBan);
                            objXuatNhap.MaNhacungcap   = objPhieuNhapCt.MaNhacungcap;
                            objXuatNhap.NgayNhap       = objPhieuNhapCt.NgayNhap;
                            objXuatNhap.DonGia         = Utility.DecimaltoDbnull(objPhieuNhapCt.DonGia);
                            objXuatNhap.NgayHoadon     = objPhieuNhap.NgayTra;
                            objXuatNhap.KieuThuocvattu = Utility.sDbnull(objPhieuNhapCt.KieuThuocvattu);

                            objXuatNhap.SoChungtuKemtheo   = "";
                            objXuatNhap.Noitru             = 0;
                            objXuatNhap.QuayThuoc          = 0;
                            objXuatNhap.GiaBhyt            = objPhieuNhapCt.GiaBhyt;
                            objXuatNhap.GiaBhytCu          = 0;
                            objXuatNhap.GiaPhuthuDungtuyen = objPhieuNhapCt.PhuthuDungtuyen;
                            objXuatNhap.GiaPhuthuTraituyen = objPhieuNhapCt.PhuthuTraituyen;
                            objXuatNhap.DuTru    = 0;
                            objXuatNhap.ThuocVay = 0;

                            objXuatNhap.SoLo        = objPhieuNhapCt.SoLo;
                            objXuatNhap.SoDky       = objPhieuNhapCt.SoDky;
                            objXuatNhap.SoQdinhthau = objPhieuNhapCt.SoQdinhthau;
                            objXuatNhap.IdThuockho  = objPhieuNhapCt.IdThuockho;
                            objXuatNhap.SoHoadon    = string.Empty;
                            objXuatNhap.PhuThu      = 0;
                            objXuatNhap.SoLuong     = Utility.Int32Dbnull(objPhieuNhapCt.SoLuong);
                            objXuatNhap.NgayTao     = globalVariables.SysDate;
                            objXuatNhap.NguoiTao    = globalVariables.UserName;
                            objXuatNhap.ThanhTien   = Utility.DecimaltoDbnull(objPhieuNhapCt.ThanhTien);
                            objXuatNhap.IdThuoc     = Utility.Int32Dbnull(objPhieuNhapCt.IdThuoc);
                            objXuatNhap.Vat         = Utility.Int32Dbnull(objPhieuNhapCt.Vat);
                            objXuatNhap.IdNhanvien  = Utility.Int16Dbnull(objPhieuNhap.IdNhanvien);
                            objXuatNhap.IdKhoaLinh  = Utility.Int16Dbnull(objPhieuNhap.IdKhotra);
                            objXuatNhap.IdKho       = Utility.Int16Dbnull(objPhieuNhap.IdKhotra);
                            objXuatNhap.NgayHethan  = objPhieuNhapCt.NgayHethan;

                            objXuatNhap.MaLoaiphieu    = Utility.ByteDbnull(LoaiPhieu.PhieuXuatKhoLeTraKhoChan);
                            objXuatNhap.TenLoaiphieu   = Utility.TenLoaiPhieu(LoaiPhieu.PhieuXuatKhoLeTraKhoChan);
                            objXuatNhap.NgayBiendong   = _ngayxacnhan;
                            objXuatNhap.KieuThuocvattu = objPhieuNhapCt.KieuThuocvattu;
                            objXuatNhap.IsNew          = true;
                            objXuatNhap.Save();
                        }
                        new Update(TPhieutrathuocKholeVekhochan.Schema)
                        .Set(TPhieutrathuocKholeVekhochan.Columns.NgaySua).EqualTo(globalVariables.SysDate)
                        .Set(TPhieutrathuocKholeVekhochan.Columns.NguoiSua).EqualTo(globalVariables.UserName)
                        .Set(TPhieutrathuocKholeVekhochan.Columns.IdNhanvien).EqualTo(globalVariables.gv_intIDNhanvien)
                        .Set(TPhieutrathuocKholeVekhochan.Columns.NguoiXacnhan).EqualTo(globalVariables.UserName)
                        .Set(TPhieutrathuocKholeVekhochan.Columns.NgayXacnhan).EqualTo(globalVariables.SysDate)
                        .Set(TPhieutrathuocKholeVekhochan.Columns.TrangThai).EqualTo(1)
                        .Where(TPhieutrathuocKholeVekhochan.Columns.IdPhieu).IsEqualTo(objPhieuNhap.IdPhieu)
                        .And(TPhieutrathuocKholeVekhochan.LoaiPhieuColumn).IsEqualTo(objPhieuNhap.LoaiPhieu).Execute();
                    }
                    Scope.Complete();
                    return(ActionResult.Success);
                }
            }
            catch (Exception ex)
            {
                Utility.CatchException("Lỗi khi xác nhận phiếu trả thuốc từ kho lẻ về kho chẵn", ex);
                return(ActionResult.Error);
            }
        }
コード例 #13
0
        /// <summary>
        /// hàm thực hiện việc xác nhận thông tin 
        /// </summary>
        /// <param name="objPhieuNhap"></param>
        /// <returns></returns>
        public ActionResult HuyXacNhanPhieuTralaiKho(TPhieuNhapxuatthuoc objPhieuNhapTra,ref string ErrMsg)
        {
            HisDuocProperties objHisDuocProperties = PropertyLib._HisDuocProperties;
            string errorMessage = "";
            try
            {
                using (var Scope = new TransactionScope())
                {
                    using (var dbScope = new SharedDbConnectionScope())
                    {
                        SqlQuery sqlQuery = new Select().From(TPhieuNhapxuatthuocChitiet.Schema)
                            .Where(TPhieuNhapxuatthuocChitiet.Columns.IdPhieu).IsEqualTo(objPhieuNhapTra.IdPhieu);
                        var objPhieuNhaptraCtCollection =
                            sqlQuery.ExecuteAsCollection<TPhieuNhapxuatthuocChitietCollection>();

                        foreach (TPhieuNhapxuatthuocChitiet objPhieuNhapTraCt in objPhieuNhaptraCtCollection)
                        {
                            //Kiểm tra ở kho lĩnh xem thuốc đã sử dụng chưa
                            ActionResult kiemtrathuochuyxacnhan = Kiemtrathuochuyxacnhan_tralai(objPhieuNhapTra, objPhieuNhapTraCt);
                            if (kiemtrathuochuyxacnhan != ActionResult.Success) return kiemtrathuochuyxacnhan;

                            //Xóa toàn bộ chi tiết trong TBiendongThuoc
                            new Delete().From(TBiendongThuoc.Schema)
                                .Where(TBiendongThuoc.IdPhieuColumn).IsEqualTo(objPhieuNhapTra.IdPhieu)
                                .And(TBiendongThuoc.IdPhieuChitietColumn).IsEqualTo(objPhieuNhapTraCt.IdPhieuchitiet)
                                .And(TBiendongThuoc.MaLoaiphieuColumn).IsEqualTo(LoaiPhieu.PhieuNhapTraLaiKhoLeVeKhoChan).Execute();

                            //Xóa toàn bộ chi tiết trong TBiendongThuoc
                            new Delete().From(TBiendongThuoc.Schema)
                                .Where(TBiendongThuoc.IdPhieuColumn).IsEqualTo(objPhieuNhapTra.IdPhieu)
                                .And(TBiendongThuoc.IdPhieuChitietColumn).IsEqualTo(objPhieuNhapTraCt.IdPhieuchitiet)
                                .And(TBiendongThuoc.MaLoaiphieuColumn).IsEqualTo(LoaiPhieu.PhieuXuatKhoLeTraKhoChan).Execute();

                            new Update(TPhieuNhapxuatthuocChitiet.Schema).Set(TPhieuNhapxuatthuocChitiet.Columns.IdThuockho).EqualTo(-1)
                             .Where(TPhieuNhapxuatthuocChitiet.Columns.IdPhieuchitiet).IsEqualTo(objPhieuNhapTraCt.IdPhieuchitiet).Execute();
                            int id_thuockho = -1;
                            StoredProcedure sp = SPs.ThuocNhapkhoOutput(objPhieuNhapTraCt.NgayHethan,
                                objPhieuNhapTraCt.GiaNhap, objPhieuNhapTraCt.GiaBan,
                                objPhieuNhapTraCt.SoLuong, Utility.DecimaltoDbnull(objPhieuNhapTraCt.Vat),
                                objPhieuNhapTraCt.IdThuoc, objPhieuNhapTra.IdKhoxuat,
                                objPhieuNhapTraCt.MaNhacungcap, objPhieuNhapTraCt.SoLo, objPhieuNhapTraCt.SoDky,
                                objPhieuNhapTraCt.SoQdinhthau, objPhieuNhapTraCt.IdChuyen, id_thuockho,
                                objPhieuNhapTraCt.NgayNhap, objPhieuNhapTraCt.GiaBhyt,
                                objPhieuNhapTraCt.GiaPhuthuDungtuyen, objPhieuNhapTraCt.GiaPhuthuTraituyen,
                                objPhieuNhapTraCt.KieuThuocvattu);
                            sp.Execute();
                            sp = SPs.ThuocXuatkho(objPhieuNhapTra.IdKhonhap, objPhieuNhapTraCt.IdThuoc,
                                objPhieuNhapTraCt.NgayHethan, objPhieuNhapTraCt.GiaNhap, objPhieuNhapTraCt.GiaBan,
                                Utility.DecimaltoDbnull(objPhieuNhapTraCt.Vat),
                                Utility.Int32Dbnull(objPhieuNhapTraCt.SoLuong), objPhieuNhapTraCt.IdThuockho,
                                objPhieuNhapTraCt.MaNhacungcap, objPhieuNhapTraCt.SoLo,
                                objHisDuocProperties.XoaDulieuKhiThuocDaHet ? 1 : 0, errorMessage);

                            sp.Execute();
                        }
                        new Update(TPhieuNhapxuatthuoc.Schema)
                            .Set(TPhieuNhapxuatthuoc.Columns.IdNhanvien).EqualTo(null)
                            .Set(TPhieuNhapxuatthuoc.Columns.NguoiXacnhan).EqualTo(null)
                            .Set(TPhieuNhapxuatthuoc.Columns.NgayXacnhan).EqualTo(null)
                            .Set(TPhieuNhapxuatthuoc.Columns.TrangThai).EqualTo(0)
                            .Where(TPhieuNhapxuatthuoc.Columns.IdPhieu).IsEqualTo(objPhieuNhapTra.IdPhieu)
                            .And(TPhieuNhapxuatthuoc.LoaiPhieuColumn).IsEqualTo(objPhieuNhapTra.LoaiPhieu).Execute();
                    }
                    Scope.Complete();
                    return ActionResult.Success;
                }
            }
            catch (Exception ex)
            {
               ErrMsg="Lỗi khi hủy xác nhận phiếu trả thuốc từ kho lẻ về kho chẵn-->"+ex.Message;
                return ActionResult.Error;
            }
        }
コード例 #14
0
        public ActionResult XacNhanPhieuTrathuocTutrucKhoaveKho(TPhieuNhapxuatthuoc objPhieuNhap, DateTime ngayxacnhan, ref string errMsg)
        {
            HisDuocProperties objHisDuocProperties = PropertyLib._HisDuocProperties;
            string            errorMessage         = "";

            try
            {
                using (var Scope = new TransactionScope())
                {
                    using (var dbScope = new SharedDbConnectionScope())
                    {
                        SqlQuery sqlQuery = new Select().From(TPhieuNhapxuatthuocChitiet.Schema)
                                            .Where(TPhieuNhapxuatthuocChitiet.Columns.IdPhieu).IsEqualTo(objPhieuNhap.IdPhieu);
                        TPhieuNhapxuatthuocChitietCollection objPhieuNhapCtCollection =
                            sqlQuery.ExecuteAsCollection <TPhieuNhapxuatthuocChitietCollection>();
                        objPhieuNhap.NgayXacnhan = ngayxacnhan;
                        foreach (TPhieuNhapxuatthuocChitiet objPhieuNhapCt in objPhieuNhapCtCollection)
                        {
                            //Kiểm tra đề phòng Kho A-->Xuất kho B. Kho B xác nhận-->Xuất kho C. Kho B hủy xác nhận. Kho C xác nhận dẫn tới việc kho B chưa có thuốc để trừ kho

                            ActionResult _Kiemtrathuocxacnhan = Kiemtrathuocxacnhan(objPhieuNhap, objPhieuNhapCt, ref errMsg);
                            if (_Kiemtrathuocxacnhan != ActionResult.Success)
                            {
                                return(_Kiemtrathuocxacnhan);
                            }
                            long idthuockho = -1;
                            //Nhập vào tủ trực
                            StoredProcedure sp = SPs.ThuocNhapkhoOutput(objPhieuNhapCt.NgayHethan, objPhieuNhapCt.GiaNhap, objPhieuNhapCt.GiaBan,
                                                                        objPhieuNhapCt.SoLuong, Utility.DecimaltoDbnull(objPhieuNhapCt.Vat),
                                                                        objPhieuNhapCt.IdThuoc, objPhieuNhap.IdKhonhap,
                                                                        objPhieuNhapCt.MaNhacungcap, objPhieuNhapCt.SoLo, objPhieuNhapCt.SoDky, objPhieuNhapCt.SoQdinhthau,
                                                                        -1, idthuockho, ngayxacnhan, objPhieuNhapCt.GiaBhyt, objPhieuNhapCt.GiaPhuthuDungtuyen, objPhieuNhapCt.GiaPhuthuTraituyen, objPhieuNhapCt.KieuThuocvattu);
                            sp.Execute();
                            //Lấy về Id_thuockho tương ứng trong tủ trực
                            idthuockho = Utility.Int64Dbnull(sp.OutputValues[0], -1);

                            //Trừ tủ trực theo đơn vị chia
                            int SluongChia = Utility.Int32Dbnull(objPhieuNhapCt.SluongChia, 1);
                            if (SluongChia <= 0)
                            {
                                SluongChia = 1;                 //Nếu lỗi do người dùng sửa tay thì tự động đặt=1
                            }
                            //Chú ý khi lập phiếu xuất thuốc tủ trực thì
                            //objPhieuNhapCt.SoLuong= số lượng đã chia-->Cần trừ số lượng trong kho xuất theo số lượng nguyên gốc. Tức là phải lấy số lượng này / số lượng chia
                            int _SoLuong = objPhieuNhapCt.SoLuong * SluongChia;//Số lượng thực sự bị mất khỏi kho xuất(khi xuất thuốc sang tủ trực)
                            sp = SPs.ThuocXuatkho(objPhieuNhap.IdKhoxuat, objPhieuNhapCt.IdThuoc,
                                                  objPhieuNhapCt.NgayHethan, objPhieuNhapCt.GiaNhap, objPhieuNhapCt.GiaBan,
                                                  Utility.DecimaltoDbnull(objPhieuNhapCt.Vat),
                                                  _SoLuong, objPhieuNhapCt.IdChuyen,
                                                  objPhieuNhapCt.MaNhacungcap, objPhieuNhapCt.SoLo,
                                                  objHisDuocProperties.XoaDulieuKhiThuocDaHet ? 1 : 0, errorMessage);

                            sp.Execute();
                            if (idthuockho > 0)
                            {
                                new Update(TPhieuNhapxuatthuocChitiet.Schema).Set(TPhieuNhapxuatthuocChitiet.Columns.IdThuockho).EqualTo(idthuockho)
                                .Where(TPhieuNhapxuatthuocChitiet.Columns.IdPhieuchitiet).IsEqualTo(objPhieuNhapCt.IdPhieuchitiet).Execute();
                            }
                            else
                            {
                                idthuockho = Utility.Int64Dbnull(objPhieuNhapCt.IdThuockho, -1);
                            }
                            objPhieuNhapCt.IdThuockho = idthuockho;
                            //Insert dòng kho nhập
                            TBiendongThuoc objXuatNhap = new TBiendongThuoc();
                            objXuatNhap.IdPhieu        = Utility.Int32Dbnull(objPhieuNhapCt.IdPhieu);
                            objXuatNhap.IdPhieuChitiet = Utility.Int32Dbnull(objPhieuNhapCt.IdPhieuchitiet);
                            objXuatNhap.MaPhieu        = Utility.sDbnull(objPhieuNhap.MaPhieu);
                            objXuatNhap.DonGia         = Utility.DecimaltoDbnull(objPhieuNhapCt.DonGia);
                            objXuatNhap.GiaBan         = Utility.DecimaltoDbnull(objPhieuNhapCt.GiaBan);

                            objXuatNhap.GiaPhuthuDungtuyen = Utility.DecimaltoDbnull(objPhieuNhapCt.GiaPhuthuDungtuyen);
                            objXuatNhap.GiaPhuthuTraituyen = Utility.DecimaltoDbnull(objPhieuNhapCt.GiaPhuthuTraituyen);
                            objXuatNhap.GiaBhyt            = Utility.DecimaltoDbnull(objPhieuNhapCt.GiaBhyt);
                            objXuatNhap.GiaBhytCu          = Utility.DecimaltoDbnull(objPhieuNhapCt.GiaBhytCu);

                            objXuatNhap.IdChuyen         = objPhieuNhapCt.IdChuyen;
                            objXuatNhap.NgayNhap         = objPhieuNhapCt.NgayNhap;
                            objXuatNhap.GiaNhap          = Utility.DecimaltoDbnull(objPhieuNhapCt.GiaNhap);
                            objXuatNhap.SoHoadon         = Utility.sDbnull(objPhieuNhap.SoHoadon);
                            objXuatNhap.SoChungtuKemtheo = objPhieuNhap.SoChungtuKemtheo;
                            objXuatNhap.PhuThu           = 0;
                            objXuatNhap.DuTru            = objPhieuNhap.DuTru;
                            objXuatNhap.Noitru           = 1;
                            objXuatNhap.QuayThuoc        = 0;
                            objXuatNhap.SoLuong          = Utility.Int32Dbnull(objPhieuNhapCt.SoLuong);
                            objXuatNhap.SluongChia       = Utility.Int32Dbnull(objPhieuNhapCt.SluongChia, 1);
                            objXuatNhap.NgayTao          = globalVariables.SysDate;
                            objXuatNhap.NguoiTao         = globalVariables.UserName;
                            objXuatNhap.ThanhTien        = Utility.DecimaltoDbnull(objPhieuNhapCt.ThanhTien);
                            objXuatNhap.IdThuoc          = Utility.Int32Dbnull(objPhieuNhapCt.IdThuoc);
                            objXuatNhap.IdThuockho       = Utility.Int32Dbnull(objPhieuNhapCt.IdThuockho);
                            objXuatNhap.Vat          = Utility.Int32Dbnull(objPhieuNhap.Vat);
                            objXuatNhap.IdNhanvien   = Utility.Int16Dbnull(objPhieuNhap.IdNhanvien);
                            objXuatNhap.IdKho        = Utility.Int16Dbnull(objPhieuNhap.IdKhonhap);
                            objXuatNhap.NgayHethan   = objPhieuNhapCt.NgayHethan.Date;
                            objXuatNhap.MaNhacungcap = objPhieuNhapCt.MaNhacungcap;
                            objXuatNhap.SoLo         = objPhieuNhapCt.SoLo;
                            objXuatNhap.SoDky        = objPhieuNhapCt.SoDky;
                            objXuatNhap.SoQdinhthau  = objPhieuNhapCt.SoQdinhthau;
                            objXuatNhap.IdKhoaLinh   = objPhieuNhap.IdKhoalinh;//Chính là khoa trả

                            objXuatNhap.MaLoaiphieu    = (byte)LoaiPhieu.PhieuNhapKhoTututruc;
                            objXuatNhap.TenLoaiphieu   = Utility.TenLoaiPhieu(LoaiPhieu.PhieuNhapKhoTututruc);
                            objXuatNhap.NgayBiendong   = objPhieuNhap.NgayXacnhan;
                            objXuatNhap.NgayHoadon     = objPhieuNhap.NgayHoadon;
                            objXuatNhap.KieuThuocvattu = objPhieuNhapCt.KieuThuocvattu;
                            objXuatNhap.IsNew          = true;
                            objXuatNhap.Save();
                            //Insert dòng của kho xuất
                            objXuatNhap                = new TBiendongThuoc();
                            objXuatNhap.IdPhieu        = Utility.Int32Dbnull(objPhieuNhapCt.IdPhieu);
                            objXuatNhap.IdPhieuChitiet = Utility.Int32Dbnull(objPhieuNhapCt.IdPhieuchitiet);
                            objXuatNhap.MaPhieu        = Utility.sDbnull(objPhieuNhap.MaPhieu);
                            objXuatNhap.DonGia         = Utility.DecimaltoDbnull(objPhieuNhapCt.DonGia);
                            objXuatNhap.NgayNhap       = objPhieuNhapCt.NgayNhap;
                            objXuatNhap.GiaBan         = Utility.DecimaltoDbnull(objPhieuNhapCt.GiaBan);
                            objXuatNhap.GiaNhap        = Utility.DecimaltoDbnull(objPhieuNhapCt.GiaNhap);

                            objXuatNhap.GiaPhuthuDungtuyen = Utility.DecimaltoDbnull(objPhieuNhapCt.GiaPhuthuDungtuyen);
                            objXuatNhap.GiaPhuthuTraituyen = Utility.DecimaltoDbnull(objPhieuNhapCt.GiaPhuthuTraituyen);
                            objXuatNhap.GiaBhyt            = Utility.DecimaltoDbnull(objPhieuNhapCt.GiaBhyt);
                            objXuatNhap.GiaBhytCu          = Utility.DecimaltoDbnull(objPhieuNhapCt.GiaBhytCu);

                            objXuatNhap.SoHoadon         = Utility.sDbnull(objPhieuNhap.SoHoadon);
                            objXuatNhap.PhuThu           = 0;
                            objXuatNhap.IdChuyen         = objPhieuNhapCt.IdChuyen;
                            objXuatNhap.DuTru            = objPhieuNhap.DuTru;
                            objXuatNhap.Noitru           = 1;
                            objXuatNhap.QuayThuoc        = 0;
                            objXuatNhap.SoLuong          = Utility.Int32Dbnull(objPhieuNhapCt.SoLuong);
                            objXuatNhap.SluongChia       = Utility.Int32Dbnull(objPhieuNhapCt.SluongChia, 1);
                            objXuatNhap.NgayTao          = globalVariables.SysDate;
                            objXuatNhap.NguoiTao         = globalVariables.UserName;
                            objXuatNhap.IdThuockho       = Utility.Int32Dbnull(objPhieuNhapCt.IdChuyen);
                            objXuatNhap.ThanhTien        = Utility.DecimaltoDbnull(objPhieuNhapCt.ThanhTien);
                            objXuatNhap.IdThuoc          = Utility.Int32Dbnull(objPhieuNhapCt.IdThuoc);
                            objXuatNhap.Vat              = Utility.Int32Dbnull(objPhieuNhap.Vat);
                            objXuatNhap.IdNhanvien       = Utility.Int16Dbnull(objPhieuNhap.IdNhanvien);
                            objXuatNhap.IdKho            = Utility.Int16Dbnull(objPhieuNhap.IdKhoxuat);
                            objXuatNhap.NgayHethan       = objPhieuNhapCt.NgayHethan.Date;
                            objXuatNhap.MaNhacungcap     = objPhieuNhapCt.MaNhacungcap;
                            objXuatNhap.SoChungtuKemtheo = objPhieuNhap.SoChungtuKemtheo;
                            objXuatNhap.SoLo             = objPhieuNhapCt.SoLo;
                            objXuatNhap.SoDky            = objPhieuNhapCt.SoDky;
                            objXuatNhap.SoQdinhthau      = objPhieuNhapCt.SoQdinhthau;
                            objXuatNhap.MaLoaiphieu      = (byte)LoaiPhieu.PhieuXuatKhoBenhNhanTuTutruc;
                            objXuatNhap.TenLoaiphieu     = Utility.TenLoaiPhieu(LoaiPhieu.PhieuXuatKhoBenhNhanTuTutruc);
                            objXuatNhap.NgayBiendong     = objPhieuNhap.NgayXacnhan;
                            objXuatNhap.NgayHoadon       = objPhieuNhap.NgayHoadon;
                            objXuatNhap.KieuThuocvattu   = objPhieuNhapCt.KieuThuocvattu;
                            objXuatNhap.IdKhoaLinh       = objPhieuNhap.IdKhoalinh;
                            objXuatNhap.IsNew            = true;
                            objXuatNhap.Save();
                        }
                        new Update(TPhieuNhapxuatthuoc.Schema)
                        .Set(TPhieuNhapxuatthuoc.Columns.IdNhanvien).EqualTo(globalVariables.gv_intIDNhanvien)
                        .Set(TPhieuNhapxuatthuoc.Columns.NguoiXacnhan).EqualTo(globalVariables.UserName)
                        .Set(TPhieuNhapxuatthuoc.Columns.NgayXacnhan).EqualTo(ngayxacnhan)
                        .Set(TPhieuNhapxuatthuoc.Columns.TrangThai).EqualTo(1)
                        .Where(TPhieuNhapxuatthuoc.Columns.IdPhieu).IsEqualTo(objPhieuNhap.IdPhieu)
                        .And(TPhieuNhapxuatthuoc.LoaiPhieuColumn).IsEqualTo(objPhieuNhap.LoaiPhieu).Execute();
                    }
                    Scope.Complete();
                    return(ActionResult.Success);
                }
            }
            catch (Exception ex)
            {
                Utility.CatchException("Lỗi khi xác nhận phiếu trả thuốc từ tủ trực khoa nội trú về kho lẻ", ex);
                return(ActionResult.Error);
            }
        }
コード例 #15
0
        public ActionResult HuyXacNhanPhieuTrathuocTutrucKhoaVeKho(TPhieuNhapxuatthuoc objPhieuNhap, ref string errMsg)
        {
            HisDuocProperties objHisDuocProperties = PropertyLib._HisDuocProperties;
            string            errorMessage         = "";

            try
            {
                using (var Scope = new TransactionScope())
                {
                    using (var dbScope = new SharedDbConnectionScope())
                    {
                        SqlQuery sqlQuery = new Select().From(TPhieuNhapxuatthuocChitiet.Schema)
                                            .Where(TPhieuNhapxuatthuocChitiet.Columns.IdPhieu).IsEqualTo(objPhieuNhap.IdPhieu);
                        TPhieuNhapxuatthuocChitietCollection objPhieuNhapCtCollection =
                            sqlQuery.ExecuteAsCollection <TPhieuNhapxuatthuocChitietCollection>();

                        foreach (TPhieuNhapxuatthuocChitiet objPhieuNhapCt in objPhieuNhapCtCollection)
                        {
                            //Kiểm tra ở kho nhập xem thuốc đã sử dụng chưa
                            ActionResult _Kiemtrathuochuyxacnhan = Kiemtrathuochuyxacnhan(objPhieuNhap, objPhieuNhapCt, ref errMsg);
                            if (_Kiemtrathuochuyxacnhan != ActionResult.Success)
                            {
                                return(_Kiemtrathuochuyxacnhan);
                            }
                            //Xóa biến động kho nhập
                            new Delete().From(TBiendongThuoc.Schema)
                            .Where(TBiendongThuoc.IdPhieuColumn).IsEqualTo(objPhieuNhap.IdPhieu)
                            .And(TBiendongThuoc.IdPhieuChitietColumn).IsEqualTo(objPhieuNhapCt.IdPhieuchitiet)
                            .And(TBiendongThuoc.MaLoaiphieuColumn).IsEqualTo((byte)LoaiPhieu.PhieuNhapKhoTututruc).Execute();
                            //Xóa biến động kho xuất
                            new Delete().From(TBiendongThuoc.Schema)
                            .Where(TBiendongThuoc.IdPhieuColumn).IsEqualTo(objPhieuNhap.IdPhieu)
                            .And(TBiendongThuoc.IdPhieuChitietColumn).IsEqualTo(objPhieuNhapCt.IdPhieuchitiet)
                            .And(TBiendongThuoc.MaLoaiphieuColumn).IsEqualTo((byte)LoaiPhieu.PhieuXuatKhoBenhNhanTuTutruc).Execute();

                            //Cộng trả lại kho xuất
                            long idthuockho = -1;
                            //Nhập theo tủ trực theo số lượng chia
                            int SluongChia = Utility.Int32Dbnull(objPhieuNhapCt.SluongChia, 1);
                            if (SluongChia <= 0)
                            {
                                SluongChia = 1;                 //Nếu lỗi do người dùng sửa tay thì tự động đặt=1
                            }
                            //Chú ý khi lập phiếu xuất thuốc tủ trực thì
                            //objPhieuNhapCt.SoLuong= số lượng đã chia-->Cần trừ số lượng trong kho xuất theo số lượng nguyên gốc. Tức là phải lấy số lượng này / số lượng chia
                            int             Sluong = objPhieuNhapCt.SoLuong * SluongChia;//Số lượng thực sự bị mất khỏi kho xuất(khi xuất thuốc sang tủ trực)
                            StoredProcedure sp     = SPs.ThuocNhapkhoOutput(objPhieuNhapCt.NgayHethan, objPhieuNhapCt.GiaNhap, objPhieuNhapCt.GiaBan,
                                                                            Sluong, Utility.DecimaltoDbnull(objPhieuNhapCt.Vat),
                                                                            objPhieuNhapCt.IdThuoc, objPhieuNhap.IdKhoxuat, objPhieuNhapCt.MaNhacungcap,
                                                                            objPhieuNhapCt.SoLo, objPhieuNhapCt.SoDky, objPhieuNhapCt.SoQdinhthau, -1, idthuockho, objPhieuNhapCt.NgayNhap, objPhieuNhapCt.GiaBhyt,
                                                                            objPhieuNhapCt.GiaPhuthuDungtuyen, objPhieuNhapCt.GiaPhuthuTraituyen, objPhieuNhapCt.KieuThuocvattu);
                            sp.Execute();
                            idthuockho = Utility.Int64Dbnull(sp.OutputValues[0], -1);
                            //Xuất thứ nguyên từ kho nhận
                            sp = SPs.ThuocXuatkho(objPhieuNhap.IdKhonhap, objPhieuNhapCt.IdThuoc,
                                                  objPhieuNhapCt.NgayHethan, objPhieuNhapCt.GiaNhap, objPhieuNhapCt.GiaBan,
                                                  Utility.DecimaltoDbnull(objPhieuNhapCt.Vat),
                                                  objPhieuNhapCt.SoLuong, objPhieuNhapCt.IdThuockho, objPhieuNhapCt.MaNhacungcap, objPhieuNhapCt.SoLo, objHisDuocProperties.XoaDulieuKhiThuocDaHet ? 1 : 0, errorMessage);
                            sp.Execute();
                            //Cạp nhật lại id_thuockho =-1(giá trị này được update khi xác nhận phiếu). Giá trị id_chuyen cho biết chuyển từ id_thuockho của kho nội trú.
                            new Update(TPhieuNhapxuatthuocChitiet.Schema).Set(TPhieuNhapxuatthuocChitiet.Columns.IdThuockho).EqualTo(-1)
                            .Where(TPhieuNhapxuatthuocChitiet.Columns.IdPhieuchitiet).IsEqualTo(objPhieuNhapCt.IdPhieuchitiet).Execute();
                        }
                        new Update(TPhieuNhapxuatthuoc.Schema)
                        .Set(TPhieuNhapxuatthuoc.Columns.IdNhanvien).EqualTo(null)
                        .Set(TPhieuNhapxuatthuoc.Columns.NguoiXacnhan).EqualTo(null)
                        .Set(TPhieuNhapxuatthuoc.Columns.NgayXacnhan).EqualTo(null)
                        .Set(TPhieuNhapxuatthuoc.Columns.TrangThai).EqualTo(0)
                        .Where(TPhieuNhapxuatthuoc.Columns.IdPhieu).IsEqualTo(objPhieuNhap.IdPhieu)
                        .And(TPhieuNhapxuatthuoc.LoaiPhieuColumn).IsEqualTo(objPhieuNhap.LoaiPhieu).Execute();
                    }
                    Scope.Complete();
                    return(ActionResult.Success);
                }
            }
            catch (Exception ex)
            {
                Utility.CatchException("Lỗi khi hủy xác nhận phiếu trả thuốc từ tủ trực về kho lẻ nội trú", ex);
                return(ActionResult.Error);
            }
        }