private void cmdHuyXacnhan_Click(object sender, EventArgs e) { try { cmdHuyXacnhan.Enabled = false; Utility.SetMsg(uiStatusBar1.Panels["MSG"], "", false); if (Utility.AcceptQuestion("Bạn có muốn hủy xác nhận phiếu nhập kho đang chọn hay không?\nSau khi hủy, thuốc sẽ được trừ ra khỏi kho nhập", "Thông báo", true)) { int ITPhieuNhapxuatthuoc = Utility.Int32Dbnull(grdList.GetValue(TPhieuNhapxuatthuoc.Columns.IdPhieu), -1); string khonhap = Utility.sDbnull(grdList.CurrentRow.Cells["ten_khonhap"].Value, ""); TPhieuNhapxuatthuoc objTPhieuNhapxuatthuoc = TPhieuNhapxuatthuoc.FetchByID(ITPhieuNhapxuatthuoc); if (objTPhieuNhapxuatthuoc != null) { if (Utility.ByteDbnull(objTPhieuNhapxuatthuoc.TrangThai, 0) == 0) { return; } string errMsg = ""; ActionResult actionResult = _NHAPKHO.HuyXacNhanPhieuNhapKho(objTPhieuNhapxuatthuoc, ref errMsg); switch (actionResult) { case ActionResult.Success: Utility.SetMsg(uiStatusBar1.Panels["MSG"], "Bạn thực hiện hủy nhập kho thành công", false); grdList.CurrentRow.BeginEdit(); grdList.CurrentRow.Cells[TPhieuNhapxuatthuoc.Columns.TrangThai].Value = 0; grdList.CurrentRow.Cells[TPhieuNhapxuatthuoc.Columns.NgayXacnhan].Value = DBNull.Value; grdList.CurrentRow.Cells[TPhieuNhapxuatthuoc.Columns.NguoiXacnhan].Value = DBNull.Value; grdList.CurrentRow.EndEdit(); THU_VIEN_CHUNG.Log(this.Name, globalVariables.UserName, string.Format( "Hủy phiếu nhập kho với số phiếu là :{0} - Tại kho {1}", ITPhieuNhapxuatthuoc, khonhap), action.Update); break; case ActionResult.Exceed: Utility.ShowMsg("Thuốc nhập đã được sử dụng hết nên bạn không thể hủy phiếu nhập", "Thông báo lỗi", MessageBoxIcon.Error); break; case ActionResult.NotEnoughDrugInStock: Utility.ShowMsg("Thuốc nhập đã được sử dụng nên bạn không thể hủy phiếu nhập", "Thông báo lỗi", MessageBoxIcon.Error); break; case ActionResult.Error: break; } } } } catch (Exception ex) { Utility.CatchException(ex); } finally { ModifyCommand(); } }
private void cmdHuyXacnhan_Click(object sender, EventArgs e) { try { cmdHuyXacnhan.Enabled = false; Utility.SetMsg(uiStatusBar1.Panels["MSG"], "", false); if (Utility.AcceptQuestion("Bạn có muốn hủy xác nhận phiếu nhập kho đang chọn hay không?\nSau khi hủy, thuốc sẽ được trừ ra khỏi kho nhập", "Thông báo", true)) { int ITPhieuNhapxuatthuoc = Utility.Int32Dbnull(grdList.GetValue(TPhieuNhapxuatthuoc.Columns.IdPhieu), -1); TPhieuNhapxuatthuoc objTPhieuNhapxuatthuoc = TPhieuNhapxuatthuoc.FetchByID(ITPhieuNhapxuatthuoc); if (objTPhieuNhapxuatthuoc != null) { string errMsg = ""; ActionResult actionResult = _NHAPKHO.HuyXacNhanPhieuNhapKho(objTPhieuNhapxuatthuoc, ref errMsg); switch (actionResult) { case ActionResult.Success: Utility.SetMsg(uiStatusBar1.Panels["MSG"], "Bạn thực hiện hủy nhập kho thành công", false); grdList.CurrentRow.BeginEdit(); grdList.CurrentRow.Cells[TPhieuNhapxuatthuoc.Columns.TrangThai].Value = 0; grdList.CurrentRow.Cells[TPhieuNhapxuatthuoc.Columns.NgayXacnhan].Value = DBNull.Value; grdList.CurrentRow.Cells[TPhieuNhapxuatthuoc.Columns.NguoiXacnhan].Value = DBNull.Value; grdList.CurrentRow.EndEdit(); break; case ActionResult.Exceed: Utility.ShowMsg("Thuốc nhập đã được sử dụng hết nên bạn không thể hủy phiếu nhập", "Thông báo lỗi", MessageBoxIcon.Error); break; case ActionResult.NotEnoughDrugInStock: Utility.ShowMsg("Thuốc nhập đã được sử dụng nên bạn không thể hủy phiếu nhập", "Thông báo lỗi", MessageBoxIcon.Error); break; case ActionResult.Error: break; } } } } catch (Exception) { ModifyCommand(); } }