Example #1
0
        private TPhieutrathuocKholeVekhochan CreatePhieuNhapKho()
        {
            TPhieutrathuocKholeVekhochan objPhieuNhapTra = new TPhieutrathuocKholeVekhochan();

            if (em_Action == action.Update)
            {
                objPhieuNhapTra.MarkOld();
                objPhieuNhapTra.IsLoaded = true;
                objPhieuNhapTra.IdPhieu  = Utility.Int32Dbnull(txtIDPhieuNhapKho.Text, -1);
                objPhieuNhapTra.NguoiSua = globalVariables.UserName;
                objPhieuNhapTra.NgaySua  = globalVariables.SysDate;
            }
            objPhieuNhapTra.IdKhoatra    = (short)globalVariables.IdKhoaNhanvien;
            objPhieuNhapTra.IdKhonhan    = Utility.Int16Dbnull(cboKhoLinh.SelectedValue, -1);
            objPhieuNhapTra.IdKhotra     = Utility.Int16Dbnull(cboKhoTra.SelectedValue, -1);
            objPhieuNhapTra.MaNhacungcap = "-1";
            objPhieuNhapTra.TrangThai    = 0;
            objPhieuNhapTra.MotaThem     = txtLydotra.Text;
            objPhieuNhapTra.IdNhanvien   = Utility.Int16Dbnull(cboNhanVien.SelectedValue, -1);
            if (Utility.Int32Dbnull(objPhieuNhapTra.IdNhanvien, -1) <= 0)
            {
                objPhieuNhapTra.IdNhanvien = globalVariables.gv_intIDNhanvien;
            }
            objPhieuNhapTra.NgayTra        = dtNgayNhap.Value;
            objPhieuNhapTra.NgayTao        = globalVariables.SysDate;
            objPhieuNhapTra.NguoiTao       = globalVariables.UserName;
            objPhieuNhapTra.LoaiPhieu      = (byte?)LoaiPhieu.PhieuNhapTraLaiKhoLeVeKhoChan;
            objPhieuNhapTra.TenLoaiphieu   = Utility.TenLoaiPhieu(LoaiPhieu.PhieuNhapTraLaiKhoLeVeKhoChan);
            objPhieuNhapTra.KieuThuocvattu = KIEU_THUOC_VT;
            return(objPhieuNhapTra);
        }
Example #2
0
 /// <summary>
 /// hàm thực hiện việc thêm phiếu nhập kho thuốc
 /// </summary>
 /// <param name="objPhieuNhap"></param>
 /// <param name="arrPhieuNhapCts"></param>
 /// <returns></returns>
 public ActionResult ThemPhieuTraLaiKho(TPhieutrathuocKholeVekhochan objPhieuNhap, TPhieutrathuocKholeVekhochanChitiet[] arrPhieuNhapCts)
 {
     try
     {
         using (var Scope = new TransactionScope())
         {
             using (var dbScope = new SharedDbConnectionScope())
             {
                 objPhieuNhap.NgayTao  = globalVariables.SysDate;
                 objPhieuNhap.NguoiTao = globalVariables.UserName;
                 objPhieuNhap.MaPhieu  = Utility.sDbnull(THU_VIEN_CHUNG.MaTraLaiKho());
                 objPhieuNhap.IsNew    = true;
                 objPhieuNhap.Save();
                 if (objPhieuNhap != null)
                 {
                     foreach (TPhieutrathuocKholeVekhochanChitiet objPhieuNhapTraCt in arrPhieuNhapCts)
                     {
                         objPhieuNhapTraCt.ThanhTien = Utility.DecimaltoDbnull(objPhieuNhapTraCt.GiaNhap) *
                                                       Utility.Int32Dbnull(objPhieuNhapTraCt.SoLuong);
                         objPhieuNhapTraCt.IdPhieu = Utility.Int32Dbnull(objPhieuNhap.IdPhieu, -1);
                         objPhieuNhapTraCt.IsNew   = true;
                         objPhieuNhapTraCt.Save();
                     }
                 }
             }
             Scope.Complete();
             return(ActionResult.Success);
         }
     }
     catch (Exception exception)
     {
         log.Error("Loi trong qua trinh them phieu nhap kho :{0}", exception);
         return(ActionResult.Error);
     }
 }
Example #3
0
        /// <summary>
        /// hàm thực hiện việc cập nhập thông tin nhập kho thuốc
        /// </summary>
        /// <param name="objPhieuNhap"></param>
        /// <param name="arrPhieuNhapCts"></param>
        /// <returns></returns>
        public ActionResult UpdatePhieuTraLaiKho(TPhieutrathuocKholeVekhochan objPhieuNhap, TPhieutrathuocKholeVekhochanChitiet[] arrPhieuNhapCts)
        {
            try
            {
                using (var Scope = new TransactionScope())
                {
                    using (var dbScope = new SharedDbConnectionScope())
                    {
                        objPhieuNhap.NgaySua  = globalVariables.SysDate;
                        objPhieuNhap.NguoiSua = globalVariables.UserName;
                        objPhieuNhap.MarkOld();
                        objPhieuNhap.IsNew = false;
                        objPhieuNhap.Save();
                        new Delete().From(TPhieutrathuocKholeVekhochanChitiet.Schema)
                        .Where(TPhieutrathuocKholeVekhochanChitiet.Columns.IdPhieu).IsEqualTo(objPhieuNhap.IdPhieu).Execute();

                        foreach (TPhieutrathuocKholeVekhochanChitiet objPhieuNhapTraCt in arrPhieuNhapCts)
                        {
                            objPhieuNhapTraCt.ThanhTien = Utility.DecimaltoDbnull(objPhieuNhapTraCt.GiaNhap) *
                                                          Utility.Int32Dbnull(objPhieuNhapTraCt.SoLuong);
                            objPhieuNhapTraCt.IdPhieu = Utility.Int32Dbnull(objPhieuNhap.IdPhieu, -1);
                            objPhieuNhapTraCt.IsNew   = true;
                            objPhieuNhapTraCt.Save();
                        }
                    }
                    Scope.Complete();
                    return(ActionResult.Success);
                }
            }
            catch (Exception exception)
            {
                log.Error("Loi trong qua trinh sua phieu nhap kho :{0}", exception);
                return(ActionResult.Error);
            }
        }
Example #4
0
        /// <summary>
        /// hàm thực hiện việc xác nhạn thông tin
        /// trừ vào kho khi xác nhận
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cmdXacNhan_Click(object sender, EventArgs e)
        {
            try
            {
                cmdXacNhan.Enabled = false;
                Utility.SetMsg(uiStatusBar2.Panels["MSG"], "", false);
                if (Utility.AcceptQuestion("Bạn có muốn xác nhận phieus trả thuốc từ kho lẻ về kho chẵn?\nSau khi trả, thuốc sẽ bị trừ khỏi kho lẻ(kho xuất) và cộng vào kho chẵn(kho nhập)", "Thông báo", true))
                {
                    int IDPhieuNhap = Utility.Int32Dbnull(grdList.GetValue(TPhieutrathuocKholeVekhochan.Columns.IdPhieu), -1);
                    TPhieutrathuocKholeVekhochan objDPhieuNhap = TPhieutrathuocKholeVekhochan.FetchByID(IDPhieuNhap);
                    if (objDPhieuNhap != null)
                    {
                        DateTime _ngayxacnhan = globalVariables.SysDate;
                        if (THU_VIEN_CHUNG.Laygiatrithamsohethong("THUOC_HIENTHI_NGAYXACNHAN", "0", false) == "1")
                        {
                            frm_ChonngayXacnhan _ChonngayXacnhan = new frm_ChonngayXacnhan();
                            _ChonngayXacnhan.pdt_InputDate = objDPhieuNhap.NgayTra.Value;
                            _ChonngayXacnhan.ShowDialog();
                            if (_ChonngayXacnhan.b_Cancel)
                            {
                                return;
                            }
                            else
                            {
                                _ngayxacnhan = _ChonngayXacnhan.pdt_InputDate;
                            }
                        }
                        ActionResult actionResult =
                            new PhieuTraLai().XacNhanTraLaiKhoLeVeKhoChan(objDPhieuNhap, _ngayxacnhan);
                        switch (actionResult)
                        {
                        case ActionResult.Success:
                            Utility.SetMsg(uiStatusBar2.Panels["MSG"], "Trả thuốc từ kho lẻ về kho chẵn thành công", false);
                            grdList.CurrentRow.BeginEdit();
                            grdList.CurrentRow.Cells[TPhieutrathuocKholeVekhochan.Columns.TrangThai].Value    = 1;
                            grdList.CurrentRow.Cells[TPhieutrathuocKholeVekhochan.Columns.NgayXacnhan].Value  = _ngayxacnhan;
                            grdList.CurrentRow.Cells[TPhieutrathuocKholeVekhochan.Columns.NguoiXacnhan].Value = globalVariables.UserName;
                            grdList.CurrentRow.EndEdit();
                            break;

                        case ActionResult.Error:
                            break;
                        }
                    }
                }
            }
            catch (Exception)
            {
            }
            finally
            {
                ModifyCommand();
            }
        }
Example #5
0
        private void cmdInDonThuoc_Click(object sender, EventArgs e)
        {
            //IdPhieu = Utility.Int32Dbnull(grdList.GetValue(TPrescription.Columns.PresId));
            int IDPhieuNhap = Utility.Int32Dbnull(grdList.GetValue(TPhieutrathuocKholeVekhochan.Columns.IdPhieu), -1);
            TPhieutrathuocKholeVekhochan objPhieuNhap = TPhieutrathuocKholeVekhochan.FetchByID(IDPhieuNhap);

            if (objPhieuNhap != null)
            {
                VNS.HIS.UI.Baocao.thuoc_phieuin_nhapxuat.InphieuTraKholeVeKhochan(IDPhieuNhap, "PHIẾU NHẬP TRẢ", globalVariables.SysDate);
            }
        }
Example #6
0
        private void cmdHuyTralai_Click(object sender, EventArgs e)
        {
            try
            {
                cmdHuyTralai.Enabled = false;
                Utility.SetMsg(uiStatusBar2.Panels["MSG"], "", false);
                if (Utility.AcceptQuestion("Bạn có muốn hủy trả thuốc từ kho lẻ về kho chẵn?\nSau khi hủy, thuốc được cộng lại kho lẻ(kho xuất) và trừ khỏi kho chẵn(kho nhập)?", "Thông báo", true))
                {
                    int IDPhieuNhaptra = Utility.Int32Dbnull(grdList.GetValue(TPhieutrathuocKholeVekhochan.Columns.IdPhieu), -1);
                    TPhieutrathuocKholeVekhochan objTPhieutrathuocKholeVekhochan = TPhieutrathuocKholeVekhochan.FetchByID(IDPhieuNhaptra);
                    if (objTPhieutrathuocKholeVekhochan != null)
                    {
                        ActionResult actionResult =
                            new PhieuTraLai().HuyXacNhanPhieuTralaiKho(objTPhieutrathuocKholeVekhochan);
                        switch (actionResult)
                        {
                        case ActionResult.Success:
                            Utility.SetMsg(uiStatusBar2.Panels["MSG"], "Hủy trả thuốc từ kho lẻ về kho chẵn thành công", false);
                            grdList.CurrentRow.BeginEdit();
                            grdList.CurrentRow.Cells[TPhieutrathuocKholeVekhochan.Columns.TrangThai].Value    = 0;
                            grdList.CurrentRow.Cells[TPhieutrathuocKholeVekhochan.Columns.NgayXacnhan].Value  = DBNull.Value;
                            grdList.CurrentRow.Cells[TPhieutrathuocKholeVekhochan.Columns.NguoiXacnhan].Value = DBNull.Value;
                            grdList.CurrentRow.EndEdit();
                            break;

                        case ActionResult.Exceed:
                            Utility.ShowMsg("Thuốc trong kho nhận đã được sử dụng hết nên bạn không thể hủy phiếu trả", "Thông báo lỗi", MessageBoxIcon.Error);
                            break;

                        case ActionResult.NotEnoughDrugInStock:
                            Utility.ShowMsg("Thuốc trong kho nhận(chẵn) đã được sử dụng nên không đủ số lượng để hoàn trả lại kho xuất(lẻ)", "Thông báo lỗi", MessageBoxIcon.Error);
                            break;

                        case ActionResult.Error:
                            break;
                        }
                    }
                }
            }
            catch (Exception)
            {
            }
            finally
            {
                ModifyCommand();
            }
        }
Example #7
0
        /// <summary>
        /// hàm thực hiện việc thêm phiếu nhập kho thuốc
        /// </summary>
        private void ThemPhieuXuatKho()
        {
            TPhieutrathuocKholeVekhochan objPhieuNhap = CreatePhieuNhapKho();

            ActionResult actionResult = new PhieuTraLai().ThemPhieuTraLaiKho
                                            (objPhieuNhap, CreateArrPhieuChiTiet());

            switch (actionResult)
            {
            case ActionResult.Success:
                txtIDPhieuNhapKho.Text = Utility.sDbnull(objPhieuNhap.IdPhieu);
                txtMaPhieu.Text        = Utility.sDbnull(objPhieuNhap.MaPhieu);
                TPhieutrathuocKholeVekhochan objDPhieuNhap = TPhieutrathuocKholeVekhochan.FetchByID(Utility.Int32Dbnull(txtIDPhieuNhapKho.Text));
                DataRow newDr = p_dtPhieuNhapTra.NewRow();
                Utility.FromObjectToDatarow(objDPhieuNhap, ref newDr);
                TDmucKho objKho = TDmucKho.FetchByID(Utility.Int32Dbnull(cboKhoLinh.SelectedValue, -1));
                if (objKho != null)
                {
                    newDr["ten_khonhap"] = Utility.sDbnull(objKho.TenKho);
                }
                objKho = TDmucKho.FetchByID(Utility.Int32Dbnull(cboKhoTra.SelectedValue, -1));
                if (objKho != null)
                {
                    newDr["ten_khoxuat"] = Utility.sDbnull(objKho.TenKho);
                }
                DmucNhanvien objStaff = DmucNhanvien.FetchByID(Utility.Int32Dbnull(cboNhanVien.SelectedValue));
                if (objStaff != null)
                {
                    newDr["ten_nhanvien"] = Utility.sDbnull(objStaff.TenNhanvien);
                }
                p_dtPhieuNhapTra.Rows.Add(newDr);
                grdList.UpdateData();
                //Utility.ShowMsg("Bạn thêm mới phiếu thành công", "Thông báo");
                Utility.GonewRowJanus(grdList, TPhieutrathuocKholeVekhochan.Columns.IdPhieu, Utility.sDbnull(txtIDPhieuNhapKho.Text));
                em_Action = action.Insert;
                b_Cancel  = true;
                this.Close();
                break;

            case ActionResult.Error:
                Utility.ShowMsg("Lỗi trong quá trình thêm phiếu", "Thông báo lỗi", MessageBoxIcon.Error);
                break;
            }
        }
Example #8
0
        private void UpdatePhieuXuatKho()
        {
            TPhieutrathuocKholeVekhochan objPhieuNhap = CreatePhieuNhapKho();

            ActionResult actionResult = new PhieuTraLai().UpdatePhieuTraLaiKho(objPhieuNhap, CreateArrPhieuChiTiet());

            switch (actionResult)
            {
            case ActionResult.Success:
                TPhieutrathuocKholeVekhochan objDPhieuNhap = TPhieutrathuocKholeVekhochan.FetchByID(Utility.Int32Dbnull(txtIDPhieuNhapKho.Text));
                DataRow[] arrDr =
                    p_dtPhieuNhapTra.Select(string.Format("{0}={1}", TPhieutrathuocKholeVekhochan.Columns.IdPhieu,
                                                          Utility.Int32Dbnull(txtIDPhieuNhapKho.Text)));
                if (arrDr.GetLength(0) > 0)
                {
                    arrDr[0].Delete();
                }
                DataRow newDr = p_dtPhieuNhapTra.NewRow();
                Utility.FromObjectToDatarow(objDPhieuNhap, ref newDr);
                TDmucKho objKho = TDmucKho.FetchByID(Utility.Int32Dbnull(cboKhoLinh.SelectedValue, -1));
                if (objKho != null)
                {
                    newDr["ten_khonhap"] = Utility.sDbnull(objKho.TenKho);
                }
                objKho = TDmucKho.FetchByID(Utility.Int32Dbnull(cboKhoTra.SelectedValue, -1));
                if (objKho != null)
                {
                    newDr["ten_khoxuat"] = Utility.sDbnull(objKho.TenKho);
                }
                p_dtPhieuNhapTra.Rows.Add(newDr);
                Utility.GonewRowJanus(grdList, TPhieutrathuocKholeVekhochan.Columns.IdPhieu, Utility.sDbnull(txtIDPhieuNhapKho.Text));
                Utility.ShowMsg("Bạn sửa  phiếu thành công", "Thông báo");
                em_Action = action.Insert;
                this.Close();
                b_Cancel = true;
                break;

            case ActionResult.Error:
                Utility.ShowMsg("Lỗi trong quá trình sửa phiếu", "Thông báo lỗi", MessageBoxIcon.Error);
                break;
            }
        }
Example #9
0
 /// <summary>
 /// hàm thực hiện việc in phiếu
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void cmdInPhieuNhap_Click(object sender, EventArgs e)
 {
     try
     {
         int IDPhieuNhap = Utility.Int32Dbnull(grdList.GetValue(TPhieutrathuocKholeVekhochan.Columns.IdPhieu), -1);
         TPhieutrathuocKholeVekhochan objPhieuNhap = TPhieutrathuocKholeVekhochan.FetchByID(IDPhieuNhap);
         if (objPhieuNhap != null)
         {
             VNS.HIS.UI.Baocao.thuoc_phieuin_nhapxuat.InphieuTraKholeVeKhochan(IDPhieuNhap, "PHIẾU NHẬP TRẢ", globalVariables.SysDate);
         }
     }
     catch (Exception exception)
     {
         if (globalVariables.IsAdmin)
         {
             Utility.ShowMsg(exception.ToString());
         }
         //throw;
     }
 }
Example #10
0
        private void getData()
        {
            if (em_Action == action.Update)
            {
                TPhieutrathuocKholeVekhochan objPhieuNhap = TPhieutrathuocKholeVekhochan.FetchByID(Utility.Int32Dbnull(txtIDPhieuNhapKho.Text));
                if (objPhieuNhap != null)
                {
                    dtNgayNhap.Value = Convert.ToDateTime(objPhieuNhap.NgayTra);
                    txtMaPhieu.Text  = Utility.sDbnull(objPhieuNhap.MaPhieu);

                    // cboKhoLinh.SelectedValue = Utility.sDbnull(objPhieuNhap.IdKhonhan);
                    if (Utility.Int32Dbnull(objPhieuNhap.IdKhonhan) > 0)
                    {
                        cboKhoTra.SelectedValue = Utility.sDbnull(objPhieuNhap.IdKhotra);
                    }
                    if (Utility.Int32Dbnull(objPhieuNhap.IdKhotra) > 0)
                    {
                        cboKhoLinh.SelectedValue = Utility.sDbnull(objPhieuNhap.IdKhonhan);
                    }
                    if (Utility.Int32Dbnull(objPhieuNhap.IdNhanvien) > 0)
                    {
                        cboNhanVien.SelectedValue = Utility.sDbnull(objPhieuNhap.IdNhanvien);
                    }
                    txtLydotra._Text     = objPhieuNhap.MotaThem;
                    m_dtDataPhieuChiTiet = SPs.ThuocLaychitietphieunhaptrakholevekhochan(Utility.Int32Dbnull(txtIDPhieuNhapKho.Text)).GetDataSet().Tables[0];
                    Utility.SetDataSourceForDataGridEx(grdPhieuXuatChiTiet, m_dtDataPhieuChiTiet, false, true, "1=1", "");
                }
            }
            if (em_Action == action.Insert)
            {
                m_dtDataPhieuChiTiet =
                    SPs.ThuocLaychitietphieunhaptrakholevekhochan(-100).GetDataSet()
                    .Tables[0];
                Utility.SetDataSourceForDataGridEx(grdPhieuXuatChiTiet, m_dtDataPhieuChiTiet, false, true, "SO_LUONG>0", "");
            }
            UpdateWhenChanged();
        }
Example #11
0
        /// <summary>
        /// Kiểm tra xem thuốc trong kho xuất đã được sử dụng hay chưa?
        /// </summary>
        /// <param name="objPhieuNhap"></param>
        /// <param name="objPhieuNhapCt"></param>
        /// <returns></returns>
        public ActionResult Kiemtrathuochuyxacnhan(TPhieutrathuocKholeVekhochan objPhieuNhap, TPhieutrathuocKholeVekhochanChitiet objPhieuNhapCt)
        {
            TThuockhoCollection vCollection = new TThuockhoController().FetchByQuery(
                TThuockho.CreateQuery()
                .WHERE(TThuockho.IdKhoColumn.ColumnName, Comparison.Equals, objPhieuNhap.IdKhonhan)
                .AND(TThuockho.IdThuocColumn.ColumnName, Comparison.Equals, objPhieuNhapCt.IdThuoc)
                .AND(TThuockho.NgayHethanColumn.ColumnName, Comparison.Equals, objPhieuNhapCt.NgayHethan.Date)
                .AND(TThuockho.GiaNhapColumn.ColumnName, Comparison.Equals, objPhieuNhapCt.GiaNhap)
                .AND(TThuockho.GiaBanColumn.ColumnName, Comparison.Equals, objPhieuNhapCt.GiaBan)
                );

            if (vCollection.Count <= 0)
            {
                return(ActionResult.Exceed);                       //Lỗi không có dòng dữ liệu trong bảng kho-thuốc
            }
            int SoLuong = vCollection[0].SoLuong;

            SoLuong = SoLuong - objPhieuNhapCt.SoLuong;
            if (SoLuong < 0)
            {
                return(ActionResult.NotEnoughDrugInStock);            //Thuốc đã sử dụng nhiều nên không thể hủy
            }
            return(ActionResult.Success);
        }
Example #12
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);
            }
        }
Example #13
0
        /// <summary>
        /// hàm thực hiện việc thêm phiếu nhập kho thuốc
        /// </summary>
        /// <param name="objPhieuNhap"></param>
        /// <param name="arrPhieuNhapCts"></param>
        /// <returns></returns>
        public ActionResult ThemPhieuTraLaiKho(TPhieutrathuocKholeVekhochan objPhieuNhap, TPhieutrathuocKholeVekhochanChitiet[] arrPhieuNhapCts)
        {
            try
            {
                using (var Scope = new TransactionScope())
                {
                    using (var dbScope = new SharedDbConnectionScope())
                    {
                        objPhieuNhap.NgayTao = globalVariables.SysDate;
                        objPhieuNhap.NguoiTao = globalVariables.UserName;
                        objPhieuNhap.MaPhieu = Utility.sDbnull(THU_VIEN_CHUNG.MaTraLaiKho());
                        objPhieuNhap.IsNew = true;
                        objPhieuNhap.Save();
                        if (objPhieuNhap != null)
                        {

                            foreach (TPhieutrathuocKholeVekhochanChitiet objPhieuNhapTraCt in arrPhieuNhapCts)
                            {
                                objPhieuNhapTraCt.ThanhTien = Utility.DecimaltoDbnull(objPhieuNhapTraCt.GiaNhap) *
                                                          Utility.Int32Dbnull(objPhieuNhapTraCt.SoLuong);
                                objPhieuNhapTraCt.IdPhieu = Utility.Int32Dbnull(objPhieuNhap.IdPhieu, -1);
                                objPhieuNhapTraCt.IsNew = true;
                                objPhieuNhapTraCt.Save();
                            }
                        }

                    }
                    Scope.Complete();
                    return ActionResult.Success;
                }
            }
            catch (Exception exception)
            {
                log.Error("Loi trong qua trinh them phieu nhap kho :{0}", exception);
                return ActionResult.Error;

            }
        }
Example #14
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);
            }
        }
Example #15
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);
            }
        }
Example #16
0
        /// <summary>
        /// hàm thực hiện việc cập nhập thông tin nhập kho thuốc
        /// </summary>
        /// <param name="objPhieuNhap"></param>
        /// <param name="arrPhieuNhapCts"></param>
        /// <returns></returns>
        public ActionResult UpdatePhieuTraLaiKho(TPhieutrathuocKholeVekhochan objPhieuNhap, TPhieutrathuocKholeVekhochanChitiet[] arrPhieuNhapCts)
        {
            try
            {
                using (var Scope = new TransactionScope())
                {
                    using (var dbScope = new SharedDbConnectionScope())
                    {
                        objPhieuNhap.NgaySua =  globalVariables.SysDate;
                        objPhieuNhap.NguoiSua = globalVariables.UserName;
                        objPhieuNhap.MarkOld();
                        objPhieuNhap.IsNew = false;
                        objPhieuNhap.Save();
                        new Delete().From(TPhieutrathuocKholeVekhochanChitiet.Schema)
                            .Where(TPhieutrathuocKholeVekhochanChitiet.Columns.IdPhieu).IsEqualTo(objPhieuNhap.IdPhieu).Execute();

                        foreach (TPhieutrathuocKholeVekhochanChitiet objPhieuNhapTraCt in arrPhieuNhapCts)
                        {
                            objPhieuNhapTraCt.ThanhTien = Utility.DecimaltoDbnull(objPhieuNhapTraCt.GiaNhap)*
                                                          Utility.Int32Dbnull(objPhieuNhapTraCt.SoLuong);
                            objPhieuNhapTraCt.IdPhieu = Utility.Int32Dbnull(objPhieuNhap.IdPhieu, -1);
                            objPhieuNhapTraCt.IsNew = true;
                            objPhieuNhapTraCt.Save();
                        }
                    }
                    Scope.Complete();
                    return ActionResult.Success;
                }
            }
            catch (Exception exception)
            {
                log.Error("Loi trong qua trinh sua phieu nhap kho :{0}", exception);
                return ActionResult.Error;

            }
        }
Example #17
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, -1, idthuockho, objPhieuNhapCt.NgayNhap, objPhieuNhapCt.GiaBhyt);
                            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.GiaNhap);
                            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 = 0;
                            objXuatNhap.GiaPhuthuTraituyen = 0;
                            objXuatNhap.DuTru = 0;

                            objXuatNhap.MaNhacungcap = objPhieuNhapCt.MaNhacungcap;
                            objXuatNhap.SoLo = objPhieuNhapCt.SoLo;
                            objXuatNhap.IdThuockho = objPhieuNhapCt.IdThuockho;
                            objXuatNhap.DonGia = 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.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.GiaNhap);
                            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 = 0;
                            objXuatNhap.GiaPhuthuTraituyen = 0;
                            objXuatNhap.DuTru = 0;

                            objXuatNhap.SoLo = objPhieuNhapCt.SoLo;
                            objXuatNhap.IdThuockho = objPhieuNhapCt.IdThuockho;
                            objXuatNhap.DonGia = 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.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 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;

            }
        }
Example #18
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;
            }
        }
Example #19
0
        /// <summary>
        /// Kiểm tra xem thuốc trong kho xuất đã được sử dụng hay chưa?
        /// </summary>
        /// <param name="objPhieuNhap"></param>
        /// <param name="objPhieuNhapCt"></param>
        /// <returns></returns>
        public ActionResult Kiemtrathuochuyxacnhan(TPhieutrathuocKholeVekhochan objPhieuNhap, TPhieutrathuocKholeVekhochanChitiet objPhieuNhapCt)
        {
            TThuockhoCollection vCollection = new TThuockhoController().FetchByQuery(
              TThuockho.CreateQuery()
              .WHERE(TThuockho.IdKhoColumn.ColumnName, Comparison.Equals, objPhieuNhap.IdKhonhan)
              .AND(TThuockho.IdThuocColumn.ColumnName, Comparison.Equals, objPhieuNhapCt.IdThuoc)
              .AND(TThuockho.NgayHethanColumn.ColumnName, Comparison.Equals, objPhieuNhapCt.NgayHethan.Date)
              .AND(TThuockho.GiaNhapColumn.ColumnName, Comparison.Equals, objPhieuNhapCt.GiaNhap)
              .AND(TThuockho.GiaBanColumn.ColumnName, Comparison.Equals, objPhieuNhapCt.GiaBan)
              );

            if (vCollection.Count <= 0) return ActionResult.Exceed;//Lỗi không có dòng dữ liệu trong bảng kho-thuốc
            int SoLuong = vCollection[0].SoLuong;
            SoLuong = SoLuong - objPhieuNhapCt.SoLuong;
            if (SoLuong < 0) return ActionResult.NotEnoughDrugInStock;//Thuốc đã sử dụng nhiều nên không thể hủy
            return ActionResult.Success;
        }
 private TPhieutrathuocKholeVekhochan CreatePhieuNhapKho()
 {
     TPhieutrathuocKholeVekhochan objPhieuNhapTra = new TPhieutrathuocKholeVekhochan();
     if (em_Action == action.Update)
     {
         objPhieuNhapTra.MarkOld();
         objPhieuNhapTra.IsLoaded = true;
         objPhieuNhapTra.IdPhieu = Utility.Int32Dbnull(txtIDPhieuNhapKho.Text, -1);
         objPhieuNhapTra.NguoiSua = globalVariables.UserName;
         objPhieuNhapTra.NgaySua = globalVariables.SysDate;
     }
     objPhieuNhapTra.IdKhoatra = (short)globalVariables.IdKhoaNhanvien;
     objPhieuNhapTra.IdKhonhan = Utility.Int16Dbnull(cboKhoLinh.SelectedValue, -1);
     objPhieuNhapTra.IdKhotra = Utility.Int16Dbnull(cboKhoTra.SelectedValue, -1);
     objPhieuNhapTra.MaNhacungcap = "-1";
     objPhieuNhapTra.TrangThai = 0;
     objPhieuNhapTra.MotaThem = txtLydotra.Text;
     objPhieuNhapTra.IdNhanvien = Utility.Int16Dbnull(cboNhanVien.SelectedValue, -1);
     if (Utility.Int32Dbnull(objPhieuNhapTra.IdNhanvien, -1) <= 0)
         objPhieuNhapTra.IdNhanvien = globalVariables.gv_intIDNhanvien;
     objPhieuNhapTra.NgayTra = dtNgayNhap.Value;
     objPhieuNhapTra.NgayTao = globalVariables.SysDate;
     objPhieuNhapTra.NguoiTao = globalVariables.UserName;
     objPhieuNhapTra.LoaiPhieu = (byte?)LoaiPhieu.PhieuNhapTraLaiKhoLeVeKhoChan;
     objPhieuNhapTra.TenLoaiphieu = Utility.TenLoaiPhieu(LoaiPhieu.PhieuNhapTraLaiKhoLeVeKhoChan);
     objPhieuNhapTra.KieuThuocvattu = KIEU_THUOC_VT;
     return objPhieuNhapTra;
 }
        public void Insert(string MaPhieu,DateTime? NgayTra,short? IdNhanvien,short? IdKhotra,short? IdKhoatra,short? IdKhonhan,short? IdKhoaThuchien,string NguoiTao,DateTime? NgayTao,string MaNhacungcap,byte? LoaiPhieu,string TenLoaiphieu,byte? TrangThai,DateTime? NgaySua,string NguoiSua,string NguoiXacnhan,DateTime? NgayXacnhan,string KieuThuocvattu,string MotaThem)
        {
            TPhieutrathuocKholeVekhochan item = new TPhieutrathuocKholeVekhochan();

            item.MaPhieu = MaPhieu;

            item.NgayTra = NgayTra;

            item.IdNhanvien = IdNhanvien;

            item.IdKhotra = IdKhotra;

            item.IdKhoatra = IdKhoatra;

            item.IdKhonhan = IdKhonhan;

            item.IdKhoaThuchien = IdKhoaThuchien;

            item.NguoiTao = NguoiTao;

            item.NgayTao = NgayTao;

            item.MaNhacungcap = MaNhacungcap;

            item.LoaiPhieu = LoaiPhieu;

            item.TenLoaiphieu = TenLoaiphieu;

            item.TrangThai = TrangThai;

            item.NgaySua = NgaySua;

            item.NguoiSua = NguoiSua;

            item.NguoiXacnhan = NguoiXacnhan;

            item.NgayXacnhan = NgayXacnhan;

            item.KieuThuocvattu = KieuThuocvattu;

            item.MotaThem = MotaThem;

            item.Save(UserName);
        }